blob: 38b1b69fd19fd16cf1a89b5227874a7bd2645a92 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Jaeden Ameroa258ccd2019-07-03 13:51:04 +010024# Limit the size of each log to 10 GiB, in case of failures with this script
25# where it may output seemingly unlimited length error logs.
26ulimit -f 20971520
27
Angus Grattonc4dd0732018-04-11 16:28:39 +100028if cd $( dirname $0 ); then :; else
29 echo "cd $( dirname $0 ) failed" >&2
30 exit 1
31fi
32
Antonin Décimod5f47592019-01-23 15:24:37 +010033# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010034: ${P_SRV:=../programs/ssl/ssl_server2}
35: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020036: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010037: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020038: ${GNUTLS_CLI:=gnutls-cli}
39: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020040: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010041
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020042O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010043O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020044G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010045G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020046TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010047
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020048# alternative versions of OpenSSL and GnuTLS (no default path)
49
50if [ -n "${OPENSSL_LEGACY:-}" ]; then
51 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
52 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
53else
54 O_LEGACY_SRV=false
55 O_LEGACY_CLI=false
56fi
57
Hanno Becker58e9dc32018-08-17 15:53:21 +010058if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020059 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
60else
61 G_NEXT_SRV=false
62fi
63
Hanno Becker58e9dc32018-08-17 15:53:21 +010064if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020065 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
66else
67 G_NEXT_CLI=false
68fi
69
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010070TESTS=0
71FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020072SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010073
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010074MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010075FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020076EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010077
Paul Bakkere20310a2016-05-10 11:18:17 +010078SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010079RUN_TEST_NUMBER=''
80
Paul Bakkeracaac852016-05-10 11:47:13 +010081PRESERVE_LOGS=0
82
Gilles Peskinef93c7d32017-04-14 17:55:28 +020083# Pick a "unique" server port in the range 10000-19999, and a proxy
84# port which is this plus 10000. Each port number may be independently
85# overridden by a command line option.
86SRV_PORT=$(($$ % 10000 + 10000))
87PXY_PORT=$((SRV_PORT + 10000))
88
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010089print_usage() {
90 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010091 printf " -h|--help\tPrint this help.\n"
92 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020093 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
94 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010095 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010096 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010097 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020098 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
99 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100100 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100101}
102
103get_options() {
104 while [ $# -gt 0 ]; do
105 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100106 -f|--filter)
107 shift; FILTER=$1
108 ;;
109 -e|--exclude)
110 shift; EXCLUDE=$1
111 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100112 -m|--memcheck)
113 MEMCHECK=1
114 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100115 -n|--number)
116 shift; RUN_TEST_NUMBER=$1
117 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100118 -s|--show-numbers)
119 SHOW_TEST_NUMBER=1
120 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100121 -p|--preserve-logs)
122 PRESERVE_LOGS=1
123 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200124 --port)
125 shift; SRV_PORT=$1
126 ;;
127 --proxy-port)
128 shift; PXY_PORT=$1
129 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100130 --seed)
131 shift; SEED="$1"
132 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100133 -h|--help)
134 print_usage
135 exit 0
136 ;;
137 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200138 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100139 print_usage
140 exit 1
141 ;;
142 esac
143 shift
144 done
145}
146
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100147# Skip next test; use this macro to skip tests which are legitimate
148# in theory and expected to be re-introduced at some point, but
149# aren't expected to succeed at the moment due to problems outside
150# our control (such as bugs in other TLS implementations).
151skip_next_test() {
152 SKIP_NEXT="YES"
153}
154
Hanno Becker91900362019-07-03 13:22:59 +0100155requires_ciphersuite_enabled() {
156 if [ -z "$($P_CLI --help | grep "$1")" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Hanno Becker7c48dd12018-08-28 16:09:22 +0100161get_config_value_or_default() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100162 # This function uses the query_config command line option to query the
163 # required Mbed TLS compile time configuration from the ssl_server2
164 # program. The command will always return a success value if the
165 # configuration is defined and the value will be printed to stdout.
166 #
167 # Note that if the configuration is not defined or is defined to nothing,
168 # the output of this function will be an empty string.
169 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100170}
171
Hanno Beckerab9a29b2019-09-24 16:14:39 +0100172# skip next test if the flag is enabled in config.h
173requires_config_disabled() {
174 if get_config_value_or_default $1; then
175 SKIP_NEXT="YES"
176 fi
177}
178
179requires_config_enabled() {
180 if ! get_config_value_or_default $1; then
181 SKIP_NEXT="YES"
182 fi
183}
184
Hanno Becker7c48dd12018-08-28 16:09:22 +0100185requires_config_value_at_least() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100186 VAL="$( get_config_value_or_default "$1" )"
187 if [ -z "$VAL" ]; then
188 # Should never happen
189 echo "Mbed TLS configuration $1 is not defined"
190 exit 1
191 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100192 SKIP_NEXT="YES"
193 fi
194}
195
196requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100197 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100198 if [ -z "$VAL" ]; then
199 # Should never happen
200 echo "Mbed TLS configuration $1 is not defined"
201 exit 1
202 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100203 SKIP_NEXT="YES"
204 fi
205}
206
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200207# skip next test if OpenSSL doesn't support FALLBACK_SCSV
208requires_openssl_with_fallback_scsv() {
209 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
210 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
211 then
212 OPENSSL_HAS_FBSCSV="YES"
213 else
214 OPENSSL_HAS_FBSCSV="NO"
215 fi
216 fi
217 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
218 SKIP_NEXT="YES"
219 fi
220}
221
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200222# skip next test if GnuTLS isn't available
223requires_gnutls() {
224 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200225 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200226 GNUTLS_AVAILABLE="YES"
227 else
228 GNUTLS_AVAILABLE="NO"
229 fi
230 fi
231 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
232 SKIP_NEXT="YES"
233 fi
234}
235
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200236# skip next test if GnuTLS-next isn't available
237requires_gnutls_next() {
238 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
239 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
240 GNUTLS_NEXT_AVAILABLE="YES"
241 else
242 GNUTLS_NEXT_AVAILABLE="NO"
243 fi
244 fi
245 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
246 SKIP_NEXT="YES"
247 fi
248}
249
250# skip next test if OpenSSL-legacy isn't available
251requires_openssl_legacy() {
252 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
253 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
254 OPENSSL_LEGACY_AVAILABLE="YES"
255 else
256 OPENSSL_LEGACY_AVAILABLE="NO"
257 fi
258 fi
259 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
260 SKIP_NEXT="YES"
261 fi
262}
263
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200264# skip next test if IPv6 isn't available on this host
265requires_ipv6() {
266 if [ -z "${HAS_IPV6:-}" ]; then
267 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
268 SRV_PID=$!
269 sleep 1
270 kill $SRV_PID >/dev/null 2>&1
271 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
272 HAS_IPV6="NO"
273 else
274 HAS_IPV6="YES"
275 fi
276 rm -r $SRV_OUT
277 fi
278
279 if [ "$HAS_IPV6" = "NO" ]; then
280 SKIP_NEXT="YES"
281 fi
282}
283
Andrzej Kurekb4593462018-10-11 08:43:30 -0400284# skip next test if it's i686 or uname is not available
285requires_not_i686() {
286 if [ -z "${IS_I686:-}" ]; then
287 IS_I686="YES"
288 if which "uname" >/dev/null 2>&1; then
289 if [ -z "$(uname -a | grep i686)" ]; then
290 IS_I686="NO"
291 fi
292 fi
293 fi
294 if [ "$IS_I686" = "YES" ]; then
295 SKIP_NEXT="YES"
296 fi
297}
298
Angus Grattonc4dd0732018-04-11 16:28:39 +1000299# Calculate the input & output maximum content lengths set in the config
300MAX_CONTENT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
301MAX_IN_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
302MAX_OUT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
303
304if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
305 MAX_CONTENT_LEN="$MAX_IN_LEN"
306fi
307if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
308 MAX_CONTENT_LEN="$MAX_OUT_LEN"
309fi
310
311# skip the next test if the SSL output buffer is less than 16KB
312requires_full_size_output_buffer() {
313 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
314 SKIP_NEXT="YES"
315 fi
316}
317
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200318# skip the next test if valgrind is in use
319not_with_valgrind() {
320 if [ "$MEMCHECK" -gt 0 ]; then
321 SKIP_NEXT="YES"
322 fi
323}
324
Paul Bakker362689d2016-05-13 10:33:25 +0100325# skip the next test if valgrind is NOT in use
326only_with_valgrind() {
327 if [ "$MEMCHECK" -eq 0 ]; then
328 SKIP_NEXT="YES"
329 fi
330}
331
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200332# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100333client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200334 CLI_DELAY_FACTOR=$1
335}
336
Janos Follath74537a62016-09-02 13:45:28 +0100337# wait for the given seconds after the client finished in the next test
338server_needs_more_time() {
339 SRV_DELAY_SECONDS=$1
340}
341
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100342# print_name <name>
343print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100344 TESTS=$(( $TESTS + 1 ))
345 LINE=""
346
347 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
348 LINE="$TESTS "
349 fi
350
351 LINE="$LINE$1"
352 printf "$LINE "
353 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100354 for i in `seq 1 $LEN`; do printf '.'; done
355 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100356
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100357}
358
359# fail <message>
360fail() {
361 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100362 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100363
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200364 mv $SRV_OUT o-srv-${TESTS}.log
365 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200366 if [ -n "$PXY_CMD" ]; then
367 mv $PXY_OUT o-pxy-${TESTS}.log
368 fi
369 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100370
Azim Khan19d13732018-03-29 11:04:20 +0100371 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 +0200372 echo " ! server output:"
373 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200374 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200375 echo " ! client output:"
376 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200377 if [ -n "$PXY_CMD" ]; then
378 echo " ! ========================================================"
379 echo " ! proxy output:"
380 cat o-pxy-${TESTS}.log
381 fi
382 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200383 fi
384
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200385 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100386}
387
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100388# is_polar <cmd_line>
389is_polar() {
390 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
391}
392
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200393# openssl s_server doesn't have -www with DTLS
394check_osrv_dtls() {
395 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
396 NEEDS_INPUT=1
397 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
398 else
399 NEEDS_INPUT=0
400 fi
401}
402
403# provide input to commands that need it
404provide_input() {
405 if [ $NEEDS_INPUT -eq 0 ]; then
406 return
407 fi
408
409 while true; do
410 echo "HTTP/1.0 200 OK"
411 sleep 1
412 done
413}
414
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100415# has_mem_err <log_file_name>
416has_mem_err() {
417 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
418 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
419 then
420 return 1 # false: does not have errors
421 else
422 return 0 # true: has errors
423 fi
424}
425
Unknown43dc0d62019-09-02 10:42:57 -0400426# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100427if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400428 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100429 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200430 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100431 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200432 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100433 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200434 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100435 # Make a tight loop, server normally takes less than 1s to start.
436 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
437 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400438 echo "$3 START TIMEOUT"
439 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100440 break
441 fi
442 # Linux and *BSD support decimal arguments to sleep. On other
443 # OSes this may be a tight loop.
444 sleep 0.1 2>/dev/null || true
445 done
446 }
447else
Unknown43dc0d62019-09-02 10:42:57 -0400448 echo "Warning: lsof not available, wait_app_start = sleep"
449 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200450 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100451 }
452fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200453
Unknown43dc0d62019-09-02 10:42:57 -0400454# Wait for server process $2 to be listening on port $1.
455wait_server_start() {
456 wait_app_start $1 $2 "SERVER" $SRV_OUT
457}
458
459# Wait for proxy process $2 to be listening on port $1.
460wait_proxy_start() {
461 wait_app_start $1 $2 "PROXY" $PXY_OUT
462}
463
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100464# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100465# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100466# acceptable bounds
467check_server_hello_time() {
468 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100469 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100470 # Get the Unix timestamp for now
471 CUR_TIME=$(date +'%s')
472 THRESHOLD_IN_SECS=300
473
474 # Check if the ServerHello time was printed
475 if [ -z "$SERVER_HELLO_TIME" ]; then
476 return 1
477 fi
478
479 # Check the time in ServerHello is within acceptable bounds
480 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
481 # The time in ServerHello is at least 5 minutes before now
482 return 1
483 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100484 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100485 return 1
486 else
487 return 0
488 fi
489}
490
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200491# wait for client to terminate and set CLI_EXIT
492# must be called right after starting the client
493wait_client_done() {
494 CLI_PID=$!
495
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200496 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
497 CLI_DELAY_FACTOR=1
498
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200499 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200500 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200501
502 wait $CLI_PID
503 CLI_EXIT=$?
504
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200505 kill $DOG_PID >/dev/null 2>&1
506 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200507
508 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100509
510 sleep $SRV_DELAY_SECONDS
511 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200512}
513
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200514# check if the given command uses dtls and sets global variable DTLS
515detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200516 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200517 DTLS=1
518 else
519 DTLS=0
520 fi
521}
522
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100523# Strip off a particular parameter from the command line
524# and return its value.
525# Parameter 1: Command line parameter to strip off
526# ENV I/O: CMD command line to search and modify
527extract_cmdline_argument() {
528 __ARG=$(echo "$CMD" | sed -n "s/^.* $1=\([^ ]*\).*$/\1/p")
529 CMD=$(echo "$CMD" | sed "s/$1=\([^ ]*\)//")
530}
531
532# Check compatibility of the ssl_client2/ssl_server2 command-line
533# with a particular compile-time configurable option.
534# Parameter 1: Command-line argument (e.g. extended_ms)
535# Parameter 2: Corresponding compile-time configuration
536# (e.g. MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET)
537# ENV I/O: CMD command line to search and modify
538# SKIP_NEXT set to "YES" on a mismatch
539check_cmdline_param_compat() {
540 __VAL="$( get_config_value_or_default "$2" )"
541 if [ ! -z "$__VAL" ]; then
542 extract_cmdline_argument "$1"
543 if [ ! -z "$__ARG" ] && [ "$__ARG" != "$__VAL" ]; then
544 SKIP_NEXT="YES"
545 fi
546 fi
547}
548
Hanno Beckera43f85c2019-09-05 14:51:20 +0100549check_cmdline_check_tls_dtls() {
Hanno Becker73b72d12019-07-26 12:00:38 +0100550 detect_dtls "$CMD"
551 if [ "$DTLS" = "0" ]; then
552 requires_config_disabled MBEDTLS_SSL_PROTO_NO_TLS
Hanno Beckera43f85c2019-09-05 14:51:20 +0100553 elif [ "$DTLS" = "1" ]; then
554 requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Hanno Becker73b72d12019-07-26 12:00:38 +0100555 fi
556}
557
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100558check_cmdline_authmode_compat() {
559 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_AUTHMODE" )"
560 if [ ! -z "$__VAL" ]; then
561 extract_cmdline_argument "auth_mode"
562 if [ "$__ARG" = "none" ] && [ "$__VAL" != "0" ]; then
563 SKIP_NEXT="YES";
564 elif [ "$__ARG" = "optional" ] && [ "$__VAL" != "1" ]; then
565 SKIP_NEXT="YES"
566 elif [ "$__ARG" = "required" ] && [ "$__VAL" != "2" ]; then
567 SKIP_NEXT="YES"
568 fi
569 fi
570}
571
Hanno Beckerb0b2b672019-06-12 16:58:10 +0100572check_cmdline_legacy_renego_compat() {
573 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_ALLOW_LEGACY_RENEGOTIATION" )"
574 if [ ! -z "$__VAL" ]; then
575 extract_cmdline_argument "allow_legacy"
576 if [ "$__ARG" = "-1" ] && [ "$__VAL" != "2" ]; then
577 SKIP_NEXT="YES";
578 elif [ "$__ARG" = "0" ] && [ "$__VAL" != "0" ]; then
579 SKIP_NEXT="YES"
580 elif [ "$__ARG" = "1" ] && [ "$__VAL" != "1" ]; then
581 SKIP_NEXT="YES"
582 fi
583 fi
584}
585
Hanno Beckerd82a0302019-07-05 11:40:52 +0100586check_cmdline_min_minor_version_compat() {
587 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MIN_MINOR_VER" )"
588 if [ ! -z "$__VAL" ]; then
589 extract_cmdline_argument "min_version"
590 if [ "$__ARG" = "ssl3" ] && [ "$__VAL" != "0" ]; then
591 SKIP_NEXT="YES";
592 elif [ "$__ARG" = "tls1" ] && [ "$__VAL" != "1" ]; then
593 SKIP_NEXT="YES"
594 elif [ "$__ARG" = "tls1_1" ] && [ "$__VAL" != "2" ]; then
595 SKIP_NEXT="YES"
596 elif [ "$__ARG" = "tls1_2" ] && [ "$__VAL" != "3" ]; then
597 SKIP_NEXT="YES"
598 fi
599 fi
600}
601
602check_cmdline_max_minor_version_compat() {
603 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MAX_MINOR_VER" )"
604 if [ ! -z "$__VAL" ]; then
605 extract_cmdline_argument "max_version"
606 if [ "$__ARG" = "ssl3" ] && [ "$__VAL" != "0" ]; then
607 SKIP_NEXT="YES";
608 elif [ "$__ARG" = "tls1" ] && [ "$__VAL" != "1" ]; then
609 SKIP_NEXT="YES"
610 elif [ "$__ARG" = "tls1_1" ] && [ "$__VAL" != "2" ]; then
611 SKIP_NEXT="YES"
612 elif [ "$__ARG" = "tls1_2" ] && [ "$__VAL" != "3" ]; then
613 SKIP_NEXT="YES"
614 fi
615 fi
616}
617
618check_cmdline_force_version_compat() {
619 __VAL_MAX="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MAX_MINOR_VER" )"
620 __VAL_MIN="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MIN_MINOR_VER" )"
621 if [ ! -z "$__VAL_MIN" ]; then
622
623 # SSL cli/srv cmd line
624
625 extract_cmdline_argument "force_version"
626 if [ "$__ARG" = "ssl3" ] && \
627 ( [ "$__VAL_MIN" != "0" ] || [ "$__VAL_MAX" != "0" ] ); then
628 SKIP_NEXT="YES";
629 elif [ "$__ARG" = "tls1" ] && \
630 ( [ "$__VAL_MIN" != "1" ] || [ "$__VAL_MAX" != "1" ] ); then
631 SKIP_NEXT="YES"
632 elif ( [ "$__ARG" = "tls1_1" ] || [ "$__ARG" = "dtls1" ] ) && \
633 ( [ "$__VAL_MIN" != "2" ] || [ "$__VAL_MAX" != "2" ] ); then
634 SKIP_NEXT="YES"
635 elif ( [ "$__ARG" = "tls1_2" ] || [ "$__ARG" = "dtls1_2" ] ) && \
636 ( [ "$__VAL_MIN" != "3" ] || [ "$__VAL_MAX" != "3" ] ); then
637 echo "FORCE SKIP"
638 SKIP_NEXT="YES"
639 fi
640
641 # OpenSSL cmd line
642
643 if echo "$CMD" | grep -e "-tls1\($\|[^_]\)" > /dev/null; then
644 if [ "$__VAL_MIN" != "1" ] || [ "$__VAL_MAX" != "1" ]; then
645 SKIP_NEXT="YES"
646 fi
647 fi
648
649 if echo "$CMD" | grep -e "-\(dtls1\($\|[^_]\)\|tls1_1\)" > /dev/null; then
650 if [ "$__VAL_MIN" != "2" ] || [ "$__VAL_MAX" != "2" ]; then
651 SKIP_NEXT="YES"
652 fi
653 fi
654
655 if echo "$CMD" | grep -e "-\(dtls1_2\($\|[^_]\)\|tls1_2\)" > /dev/null; then
656 if [ "$__VAL_MIN" != "3" ] || [ "$__VAL_MAX" != "3" ]; then
657 SKIP_NEXT="YES"
658 fi
659 fi
660
661 fi
662}
663
Hanno Becker69c6cde2019-09-02 14:34:23 +0100664check_cmdline_crt_key_files_compat() {
665
666 # test-ca2.crt
667 if echo "$CMD" | grep -e "test-ca2" > /dev/null; then
668 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
669 fi
670
671 # Variants of server5.key and server5.crt
672 if echo "$CMD" | grep -e "server5" > /dev/null; then
673 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
674 fi
675
676 # Variants of server6.key and server6.crt
677 if echo "$CMD" | grep -e "server6" > /dev/null; then
678 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
679 fi
680
681}
682
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100683# Go through all options that can be hardcoded at compile-time and
684# detect whether the command line configures them in a conflicting
685# way. If so, skip the test. Otherwise, remove the corresponding
686# entry.
687# Parameter 1: Command line to inspect
688# Output: Modified command line
689# ENV I/O: SKIP_TEST set to 1 on mismatch.
690check_cmdline_compat() {
691 CMD="$1"
692
Hanno Becker69c6cde2019-09-02 14:34:23 +0100693 # Check that if we're specifying particular certificate and/or
694 # ECC key files, the corresponding curve is enabled.
695 check_cmdline_crt_key_files_compat
696
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100697 # ExtendedMasterSecret configuration
698 check_cmdline_param_compat "extended_ms" \
699 "MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET"
700 check_cmdline_param_compat "enforce_extended_master_secret" \
701 "MBEDTLS_SSL_CONF_ENFORCE_EXTENDED_MASTER_SECRET"
Hanno Becker7f376f42019-06-12 16:20:48 +0100702
703 # DTLS anti replay protection configuration
704 check_cmdline_param_compat "anti_replay" \
705 "MBEDTLS_SSL_CONF_ANTI_REPLAY"
706
Hanno Beckerde671542019-06-12 16:30:46 +0100707 # DTLS bad MAC limit
708 check_cmdline_param_compat "badmac_limit" \
709 "MBEDTLS_SSL_CONF_BADMAC_LIMIT"
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100710
Hanno Beckera43f85c2019-09-05 14:51:20 +0100711 # Skip tests relying on TLS/DTLS in configs that disable it.
712 check_cmdline_check_tls_dtls
Hanno Becker73b72d12019-07-26 12:00:38 +0100713
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100714 # Authentication mode
715 check_cmdline_authmode_compat
Hanno Beckerb0b2b672019-06-12 16:58:10 +0100716
717 # Legacy renegotiation
718 check_cmdline_legacy_renego_compat
Hanno Beckerd82a0302019-07-05 11:40:52 +0100719
720 # Version configuration
721 check_cmdline_min_minor_version_compat
722 check_cmdline_max_minor_version_compat
723 check_cmdline_force_version_compat
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100724}
725
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200726# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100727# Options: -s pattern pattern that must be present in server output
728# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100729# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100730# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100731# -S pattern pattern that must be absent in server output
732# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100733# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100734# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100735run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100736 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200737 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100738
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100739 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
740 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200741 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100742 return
743 fi
744
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100745 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100746
Paul Bakkerb7584a52016-05-10 10:50:43 +0100747 # Do we only run numbered tests?
748 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
749 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
750 else
751 SKIP_NEXT="YES"
752 fi
753
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200754 # does this test use a proxy?
755 if [ "X$1" = "X-p" ]; then
756 PXY_CMD="$2"
757 shift 2
758 else
759 PXY_CMD=""
760 fi
761
762 # get commands and client output
763 SRV_CMD="$1"
764 CLI_CMD="$2"
765 CLI_EXPECT="$3"
766 shift 3
767
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100768 check_cmdline_compat "$SRV_CMD"
769 SRV_CMD="$CMD"
770
771 check_cmdline_compat "$CLI_CMD"
772 CLI_CMD="$CMD"
773
Hanno Becker7a11e722019-05-10 14:38:42 +0100774 # Check if test uses files
775 TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
776 if [ ! -z "$TEST_USES_FILES" ]; then
777 requires_config_enabled MBEDTLS_FS_IO
778 fi
779
780 # should we skip?
781 if [ "X$SKIP_NEXT" = "XYES" ]; then
782 SKIP_NEXT="NO"
783 echo "SKIP"
784 SKIPS=$(( $SKIPS + 1 ))
785 return
786 fi
787
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200788 # fix client port
789 if [ -n "$PXY_CMD" ]; then
790 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
791 else
792 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
793 fi
794
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200795 # update DTLS variable
796 detect_dtls "$SRV_CMD"
797
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100798 # prepend valgrind to our commands if active
799 if [ "$MEMCHECK" -gt 0 ]; then
800 if is_polar "$SRV_CMD"; then
801 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
802 fi
803 if is_polar "$CLI_CMD"; then
804 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
805 fi
806 fi
807
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200808 TIMES_LEFT=2
809 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200810 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200811
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200812 # run the commands
813 if [ -n "$PXY_CMD" ]; then
814 echo "$PXY_CMD" > $PXY_OUT
815 $PXY_CMD >> $PXY_OUT 2>&1 &
816 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400817 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200818 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200819
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200820 check_osrv_dtls
821 echo "$SRV_CMD" > $SRV_OUT
822 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
823 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100824 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200825
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200826 echo "$CLI_CMD" > $CLI_OUT
827 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
828 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100829
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100830 sleep 0.05
831
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200832 # terminate the server (and the proxy)
833 kill $SRV_PID
834 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100835
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200836 if [ -n "$PXY_CMD" ]; then
837 kill $PXY_PID >/dev/null 2>&1
838 wait $PXY_PID
839 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100840
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200841 # retry only on timeouts
842 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
843 printf "RETRY "
844 else
845 TIMES_LEFT=0
846 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200847 done
848
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100849 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200850 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100851 # expected client exit to incorrectly succeed in case of catastrophic
852 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100853 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200854 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100855 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100856 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100857 return
858 fi
859 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100860 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200861 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100862 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100863 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100864 return
865 fi
866 fi
867
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100868 # check server exit code
869 if [ $? != 0 ]; then
870 fail "server fail"
871 return
872 fi
873
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100874 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100875 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
876 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100877 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200878 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100879 return
880 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100881
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100882 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200883 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100884 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100885 while [ $# -gt 0 ]
886 do
887 case $1 in
888 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100889 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 +0100890 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100891 return
892 fi
893 ;;
894
895 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100896 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 +0100897 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100898 return
899 fi
900 ;;
901
902 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100903 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 +0100904 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100905 return
906 fi
907 ;;
908
909 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100910 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 +0100911 fail "pattern '$2' MUST NOT be present in the Client output"
912 return
913 fi
914 ;;
915
916 # The filtering in the following two options (-u and -U) do the following
917 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100918 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100919 # - keep one of each non-unique line
920 # - count how many lines remain
921 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
922 # if there were no duplicates.
923 "-U")
924 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
925 fail "lines following pattern '$2' must be unique in Server output"
926 return
927 fi
928 ;;
929
930 "-u")
931 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
932 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100933 return
934 fi
935 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100936 "-F")
937 if ! $2 "$SRV_OUT"; then
938 fail "function call to '$2' failed on Server output"
939 return
940 fi
941 ;;
942 "-f")
943 if ! $2 "$CLI_OUT"; then
944 fail "function call to '$2' failed on Client output"
945 return
946 fi
947 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100948
949 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200950 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100951 exit 1
952 esac
953 shift 2
954 done
955
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100956 # check valgrind's results
957 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200958 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100959 fail "Server has memory errors"
960 return
961 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200962 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100963 fail "Client has memory errors"
964 return
965 fi
966 fi
967
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100968 # if we're here, everything is ok
969 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100970 if [ "$PRESERVE_LOGS" -gt 0 ]; then
971 mv $SRV_OUT o-srv-${TESTS}.log
972 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100973 if [ -n "$PXY_CMD" ]; then
974 mv $PXY_OUT o-pxy-${TESTS}.log
975 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100976 fi
977
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200978 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100979}
980
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100981cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200982 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200983 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
984 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
985 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
986 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100987 exit 1
988}
989
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100990#
991# MAIN
992#
993
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100994get_options "$@"
995
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100996# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100997P_SRV_BIN="${P_SRV%%[ ]*}"
998P_CLI_BIN="${P_CLI%%[ ]*}"
999P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +01001000if [ ! -x "$P_SRV_BIN" ]; then
1001 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001002 exit 1
1003fi
Hanno Becker17c04932017-10-10 14:44:53 +01001004if [ ! -x "$P_CLI_BIN" ]; then
1005 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001006 exit 1
1007fi
Hanno Becker17c04932017-10-10 14:44:53 +01001008if [ ! -x "$P_PXY_BIN" ]; then
1009 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001010 exit 1
1011fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +01001012if [ "$MEMCHECK" -gt 0 ]; then
1013 if which valgrind >/dev/null 2>&1; then :; else
1014 echo "Memcheck not possible. Valgrind not found"
1015 exit 1
1016 fi
1017fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +01001018if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
1019 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001020 exit 1
1021fi
1022
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +02001023# used by watchdog
1024MAIN_PID="$$"
1025
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001026# We use somewhat arbitrary delays for tests:
1027# - how long do we wait for the server to start (when lsof not available)?
1028# - how long do we allow for the client to finish?
1029# (not to check performance, just to avoid waiting indefinitely)
1030# Things are slower with valgrind, so give extra time here.
1031#
1032# Note: without lsof, there is a trade-off between the running time of this
1033# script and the risk of spurious errors because we didn't wait long enough.
1034# The watchdog delay on the other hand doesn't affect normal running time of
1035# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001036if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001037 START_DELAY=6
1038 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001039else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001040 START_DELAY=2
1041 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001042fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001043
1044# some particular tests need more time:
1045# - for the client, we multiply the usual watchdog limit by a factor
1046# - for the server, we sleep for a number of seconds after the client exits
1047# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001048CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001049SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001050
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001051# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001052# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001053P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1054P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001055P_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 +02001056O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001057O_CLI="$O_CLI -connect localhost:+SRV_PORT"
1058G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001059G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001060
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001061if [ -n "${OPENSSL_LEGACY:-}" ]; then
1062 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1063 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1064fi
1065
Hanno Becker58e9dc32018-08-17 15:53:21 +01001066if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001067 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1068fi
1069
Hanno Becker58e9dc32018-08-17 15:53:21 +01001070if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001071 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001072fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001073
Gilles Peskine62469d92017-05-10 10:13:59 +02001074# Allow SHA-1, because many of our test certificates use it
1075P_SRV="$P_SRV allow_sha1=1"
1076P_CLI="$P_CLI allow_sha1=1"
1077
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001078# Also pick a unique name for intermediate files
1079SRV_OUT="srv_out.$$"
1080CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001081PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001082SESSION="session.$$"
1083
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001084SKIP_NEXT="NO"
1085
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001086trap cleanup INT TERM HUP
1087
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001088# Basic test
1089
Hanno Becker91900362019-07-03 13:22:59 +01001090run_test "Default" \
1091 "$P_SRV debug_level=3" \
1092 "$P_CLI" \
1093 0
1094
1095run_test "Default, DTLS" \
1096 "$P_SRV dtls=1" \
1097 "$P_CLI dtls=1" \
1098 0
1099
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001100# Checks that:
1101# - things work with all ciphersuites active (used with config-full in all.sh)
1102# - the expected (highest security) parameters are selected
1103# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Hanno Becker91900362019-07-03 13:22:59 +01001104requires_ciphersuite_enabled "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
1105requires_config_enabled MBEDTLS_SHA512_C
1106requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
1107requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1108run_test "Default, choose highest security suite and hash" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001109 "$P_SRV debug_level=3" \
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03001110 "$P_CLI" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001111 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001112 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001113 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001114 -s "client hello v3, signature_algorithm ext: 6" \
1115 -s "ECDHE curve: secp521r1" \
1116 -S "error" \
1117 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001118
Hanno Becker91900362019-07-03 13:22:59 +01001119requires_ciphersuite_enabled "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
1120requires_config_enabled MBEDTLS_SHA512_C
1121requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
1122requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1123run_test "Default, choose highest security suite and hash, DTLS" \
1124 "$P_SRV debug_level=3 dtls=1" \
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001125 "$P_CLI dtls=1" \
1126 0 \
1127 -s "Protocol is DTLSv1.2" \
Hanno Becker91900362019-07-03 13:22:59 +01001128 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
1129 -s "client hello v3, signature_algorithm ext: 6" \
1130 -s "ECDHE curve: secp521r1"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001131
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001132# Test current time in ServerHello
1133requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001134run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001135 "$P_SRV debug_level=3" \
1136 "$P_CLI debug_level=3" \
1137 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001138 -f "check_server_hello_time" \
1139 -F "check_server_hello_time"
1140
Simon Butcher8e004102016-10-14 00:48:33 +01001141# Test for uniqueness of IVs in AEAD ciphersuites
1142run_test "Unique IV in GCM" \
1143 "$P_SRV exchanges=20 debug_level=4" \
1144 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1145 0 \
1146 -u "IV used" \
1147 -U "IV used"
1148
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001149# Tests for rc4 option
1150
Simon Butchera410af52016-05-19 22:12:18 +01001151requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001152run_test "RC4: server disabled, client enabled" \
1153 "$P_SRV" \
1154 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1155 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001156 -s "SSL - The server has no ciphersuites in common"
1157
Simon Butchera410af52016-05-19 22:12:18 +01001158requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001159run_test "RC4: server half, client enabled" \
1160 "$P_SRV arc4=1" \
1161 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1162 1 \
1163 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001164
1165run_test "RC4: server enabled, client disabled" \
1166 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1167 "$P_CLI" \
1168 1 \
1169 -s "SSL - The server has no ciphersuites in common"
1170
1171run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001172 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001173 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1174 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001175 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001176 -S "SSL - The server has no ciphersuites in common"
1177
Hanno Beckerd26bb202018-08-17 09:54:10 +01001178# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1179
1180requires_gnutls
1181requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1182run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1183 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001184 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001185 0
1186
1187requires_gnutls
1188requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1189run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1190 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001191 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001192 0
1193
Gilles Peskinebc70a182017-05-09 15:59:24 +02001194# Tests for SHA-1 support
1195
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001196requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001197requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001198requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001199run_test "SHA-1 forbidden by default in server certificate" \
1200 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1201 "$P_CLI debug_level=2 allow_sha1=0" \
1202 1 \
1203 -c "The certificate is signed with an unacceptable hash"
1204
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001205requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1206run_test "SHA-1 forbidden by default in server certificate" \
1207 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1208 "$P_CLI debug_level=2 allow_sha1=0" \
1209 0
1210
Gilles Peskinebc70a182017-05-09 15:59:24 +02001211run_test "SHA-1 explicitly allowed in server certificate" \
1212 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1213 "$P_CLI allow_sha1=1" \
1214 0
1215
1216run_test "SHA-256 allowed by default in server certificate" \
1217 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1218 "$P_CLI allow_sha1=0" \
1219 0
1220
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001221requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001222requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001223requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001224run_test "SHA-1 forbidden by default in client certificate" \
1225 "$P_SRV auth_mode=required allow_sha1=0" \
1226 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1227 1 \
1228 -s "The certificate is signed with an unacceptable hash"
1229
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001230requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1231run_test "SHA-1 forbidden by default in client certificate" \
1232 "$P_SRV auth_mode=required allow_sha1=0" \
1233 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1234 0
1235
Gilles Peskinebc70a182017-05-09 15:59:24 +02001236run_test "SHA-1 explicitly allowed in client certificate" \
1237 "$P_SRV auth_mode=required allow_sha1=1" \
1238 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1239 0
1240
1241run_test "SHA-256 allowed by default in client certificate" \
1242 "$P_SRV auth_mode=required allow_sha1=0" \
1243 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1244 0
1245
Hanno Becker7ae8a762018-08-14 15:43:35 +01001246# Tests for datagram packing
1247run_test "DTLS: multiple records in same datagram, client and server" \
1248 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1249 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1250 0 \
1251 -c "next record in same datagram" \
1252 -s "next record in same datagram"
1253
1254run_test "DTLS: multiple records in same datagram, client only" \
1255 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1256 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1257 0 \
1258 -s "next record in same datagram" \
1259 -C "next record in same datagram"
1260
1261run_test "DTLS: multiple records in same datagram, server only" \
1262 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1263 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1264 0 \
1265 -S "next record in same datagram" \
1266 -c "next record in same datagram"
1267
1268run_test "DTLS: multiple records in same datagram, neither client nor server" \
1269 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1270 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1271 0 \
1272 -S "next record in same datagram" \
1273 -C "next record in same datagram"
1274
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001275# Tests for Truncated HMAC extension
1276
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001277run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001278 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001279 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001280 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001281 -s "dumping 'expected mac' (20 bytes)" \
1282 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001283
Hanno Becker32c55012017-11-10 08:42:54 +00001284requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001285run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001286 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001287 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001288 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001289 -s "dumping 'expected mac' (20 bytes)" \
1290 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001291
Hanno Becker32c55012017-11-10 08:42:54 +00001292requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001293run_test "Truncated HMAC: client enabled, server default" \
1294 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001295 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001296 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001297 -s "dumping 'expected mac' (20 bytes)" \
1298 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001299
Hanno Becker32c55012017-11-10 08:42:54 +00001300requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001301run_test "Truncated HMAC: client enabled, server disabled" \
1302 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001303 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001304 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001305 -s "dumping 'expected mac' (20 bytes)" \
1306 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001307
Hanno Becker32c55012017-11-10 08:42:54 +00001308requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001309run_test "Truncated HMAC: client disabled, server enabled" \
1310 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001311 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001312 0 \
1313 -s "dumping 'expected mac' (20 bytes)" \
1314 -S "dumping 'expected mac' (10 bytes)"
1315
1316requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001317run_test "Truncated HMAC: client enabled, server enabled" \
1318 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001319 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001320 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001321 -S "dumping 'expected mac' (20 bytes)" \
1322 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001323
Hanno Becker4c4f4102017-11-10 09:16:05 +00001324run_test "Truncated HMAC, DTLS: client default, server default" \
1325 "$P_SRV dtls=1 debug_level=4" \
1326 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1327 0 \
1328 -s "dumping 'expected mac' (20 bytes)" \
1329 -S "dumping 'expected mac' (10 bytes)"
1330
1331requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1332run_test "Truncated HMAC, DTLS: client disabled, server default" \
1333 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001334 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001335 0 \
1336 -s "dumping 'expected mac' (20 bytes)" \
1337 -S "dumping 'expected mac' (10 bytes)"
1338
1339requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1340run_test "Truncated HMAC, DTLS: client enabled, server default" \
1341 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001342 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001343 0 \
1344 -s "dumping 'expected mac' (20 bytes)" \
1345 -S "dumping 'expected mac' (10 bytes)"
1346
1347requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1348run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1349 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001350 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001351 0 \
1352 -s "dumping 'expected mac' (20 bytes)" \
1353 -S "dumping 'expected mac' (10 bytes)"
1354
1355requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1356run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1357 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001358 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001359 0 \
1360 -s "dumping 'expected mac' (20 bytes)" \
1361 -S "dumping 'expected mac' (10 bytes)"
1362
1363requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1364run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1365 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001366 "$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 +01001367 0 \
1368 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001369 -s "dumping 'expected mac' (10 bytes)"
1370
Jarno Lamsafa45e602019-06-04 11:33:23 +03001371# Tests for Context serialization
1372
1373requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001374run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001375 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001376 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001377 0 \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001378 -c "Deserializing connection..." \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001379 -S "Deserializing connection..."
1380
1381requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001382run_test "Context serialization, client serializes, ChaChaPoly" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001383 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001384 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001385 0 \
1386 -c "Deserializing connection..." \
1387 -S "Deserializing connection..."
1388
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001389requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001390run_test "Context serialization, client serializes, GCM" \
1391 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1392 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001393 0 \
1394 -c "Deserializing connection..." \
1395 -S "Deserializing connection..."
Jarno Lamsacc281b82019-06-04 15:21:13 +03001396
Jarno Lamsafa45e602019-06-04 11:33:23 +03001397requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001398requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1399run_test "Context serialization, client serializes, with CID" \
1400 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1401 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1402 0 \
1403 -c "Deserializing connection..." \
1404 -S "Deserializing connection..."
1405
1406requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001407run_test "Context serialization, server serializes, CCM" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001408 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001409 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001410 0 \
1411 -C "Deserializing connection..." \
1412 -s "Deserializing connection..."
1413
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001414requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001415run_test "Context serialization, server serializes, ChaChaPoly" \
1416 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1417 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1418 0 \
1419 -C "Deserializing connection..." \
1420 -s "Deserializing connection..."
1421
1422requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1423run_test "Context serialization, server serializes, GCM" \
1424 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1425 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001426 0 \
1427 -C "Deserializing connection..." \
Jarno Lamsacc281b82019-06-04 15:21:13 +03001428 -s "Deserializing connection..."
Jarno Lamsafa45e602019-06-04 11:33:23 +03001429
1430requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001431requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1432run_test "Context serialization, server serializes, with CID" \
1433 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1434 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1435 0 \
1436 -C "Deserializing connection..." \
1437 -s "Deserializing connection..."
1438
1439requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001440run_test "Context serialization, both serialize, CCM" \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001441 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001442 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1443 0 \
1444 -c "Deserializing connection..." \
1445 -s "Deserializing connection..."
1446
1447requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1448run_test "Context serialization, both serialize, ChaChaPoly" \
1449 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1450 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1451 0 \
1452 -c "Deserializing connection..." \
1453 -s "Deserializing connection..."
1454
1455requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1456run_test "Context serialization, both serialize, GCM" \
1457 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1458 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001459 0 \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001460 -c "Deserializing connection..." \
1461 -s "Deserializing connection..."
1462
1463requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001464requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1465run_test "Context serialization, both serialize, with CID" \
1466 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1467 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1468 0 \
1469 -c "Deserializing connection..." \
1470 -s "Deserializing connection..."
1471
1472requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001473run_test "Context serialization, re-init, client serializes, CCM" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001474 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001475 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1476 0 \
1477 -c "Deserializing connection..." \
1478 -S "Deserializing connection..."
1479
1480requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1481run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1482 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1483 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1484 0 \
1485 -c "Deserializing connection..." \
1486 -S "Deserializing connection..."
1487
1488requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1489run_test "Context serialization, re-init, client serializes, GCM" \
1490 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1491 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001492 0 \
1493 -c "Deserializing connection..." \
1494 -S "Deserializing connection..."
1495
1496requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001497requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1498run_test "Context serialization, re-init, client serializes, with CID" \
1499 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1500 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1501 0 \
1502 -c "Deserializing connection..." \
1503 -S "Deserializing connection..."
1504
1505requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001506run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001507 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001508 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1509 0 \
1510 -C "Deserializing connection..." \
1511 -s "Deserializing connection..."
1512
1513requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1514run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1515 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1516 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1517 0 \
1518 -C "Deserializing connection..." \
1519 -s "Deserializing connection..."
1520
1521requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1522run_test "Context serialization, re-init, server serializes, GCM" \
1523 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1524 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001525 0 \
1526 -C "Deserializing connection..." \
1527 -s "Deserializing connection..."
1528
1529requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001530requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1531run_test "Context serialization, re-init, server serializes, with CID" \
1532 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1533 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1534 0 \
1535 -C "Deserializing connection..." \
1536 -s "Deserializing connection..."
1537
1538requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001539run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001540 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001541 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1542 0 \
1543 -c "Deserializing connection..." \
1544 -s "Deserializing connection..."
1545
1546requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1547run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1548 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1549 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1550 0 \
1551 -c "Deserializing connection..." \
1552 -s "Deserializing connection..."
1553
1554requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1555run_test "Context serialization, re-init, both serialize, GCM" \
1556 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1557 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001558 0 \
1559 -c "Deserializing connection..." \
1560 -s "Deserializing connection..."
1561
Hanno Beckere80c1b02019-08-30 11:18:59 +01001562requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1563requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1564run_test "Context serialization, re-init, both serialize, with CID" \
1565 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1566 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001567 0 \
1568 -c "Deserializing connection..." \
Hanno Becker73455992019-04-25 17:01:43 +01001569 -s "Deserializing connection..."
Hanno Beckerc008cb52019-04-26 14:17:56 +01001570
Hanno Becker4eb05872019-04-26 16:00:29 +01001571# Tests for DTLS Connection ID extension
Hanno Beckercf2a5652019-04-26 16:13:31 +01001572
Hanno Becker5e2cd142019-04-26 16:23:52 +01001573# So far, the CID API isn't implemented, so we can't
1574# grep for output witnessing its use. This needs to be
Hanno Becker6a3ff282019-04-26 17:19:46 +01001575# changed once the CID extension is implemented.
Hanno Beckerad8e2c92019-05-08 13:19:53 +01001576
Hanno Becker2dcdc922019-04-09 18:08:47 +01001577requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckera5a2b082019-05-15 14:03:01 +01001578run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001579 "$P_SRV debug_level=3 dtls=1 cid=0" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001580 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1581 0 \
1582 -s "Disable use of CID extension." \
1583 -s "found CID extension" \
Hanno Becker73455992019-04-25 17:01:43 +01001584 -s "Client sent CID extension, but CID disabled" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001585 -c "Enable use of CID extension." \
1586 -c "client hello, adding CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001587 -S "server hello, adding CID extension" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001588 -C "found CID extension" \
1589 -S "Copy CIDs into SSL transform" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001590 -C "Copy CIDs into SSL transform" \
1591 -c "Use of Connection ID was rejected by the server"
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001592
1593requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1594run_test "Connection ID: Cli disabled, Srv enabled" \
1595 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1596 "$P_CLI debug_level=3 dtls=1 cid=0" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001597 0 \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001598 -c "Disable use of CID extension." \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001599 -C "client hello, adding CID extension" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001600 -S "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001601 -s "Enable use of CID extension." \
1602 -S "server hello, adding CID extension" \
1603 -C "found CID extension" \
1604 -S "Copy CIDs into SSL transform" \
1605 -C "Copy CIDs into SSL transform" \
1606 -s "Use of Connection ID was not offered by client"
1607
1608requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1609run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
1610 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1611 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1612 0 \
1613 -c "Enable use of CID extension." \
1614 -s "Enable use of CID extension." \
1615 -c "client hello, adding CID extension" \
1616 -s "found CID extension" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001617 -s "Use of CID extension negotiated" \
1618 -s "server hello, adding CID extension" \
1619 -c "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001620 -c "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001621 -s "Copy CIDs into SSL transform" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001622 -c "Copy CIDs into SSL transform" \
1623 -c "Peer CID (length 2 Bytes): de ad" \
1624 -s "Peer CID (length 2 Bytes): be ef" \
1625 -s "Use of Connection ID has been negotiated" \
1626 -c "Use of Connection ID has been negotiated"
1627
1628requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1629run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
1630 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
1631 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1632 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1633 0 \
1634 -c "Enable use of CID extension." \
1635 -s "Enable use of CID extension." \
1636 -c "client hello, adding CID extension" \
1637 -s "found CID extension" \
1638 -s "Use of CID extension negotiated" \
1639 -s "server hello, adding CID extension" \
1640 -c "found CID extension" \
1641 -c "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001642 -s "Copy CIDs into SSL transform" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001643 -c "Copy CIDs into SSL transform" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001644 -c "Peer CID (length 2 Bytes): de ad" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001645 -s "Peer CID (length 2 Bytes): be ef" \
1646 -s "Use of Connection ID has been negotiated" \
1647 -c "Use of Connection ID has been negotiated" \
1648 -c "ignoring unexpected CID" \
1649 -s "ignoring unexpected CID"
1650
1651requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1652run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1653 -p "$P_PXY mtu=800" \
1654 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1655 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1656 0 \
1657 -c "Enable use of CID extension." \
1658 -s "Enable use of CID extension." \
1659 -c "client hello, adding CID extension" \
1660 -s "found CID extension" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001661 -s "Use of CID extension negotiated" \
1662 -s "server hello, adding CID extension" \
1663 -c "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001664 -c "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001665 -s "Copy CIDs into SSL transform" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001666 -c "Copy CIDs into SSL transform" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001667 -c "Peer CID (length 2 Bytes): de ad" \
1668 -s "Peer CID (length 2 Bytes): be ef" \
1669 -s "Use of Connection ID has been negotiated" \
1670 -c "Use of Connection ID has been negotiated"
Hanno Becker73455992019-04-25 17:01:43 +01001671
Hanno Beckerc008cb52019-04-26 14:17:56 +01001672requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1673run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001674 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001675 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1676 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001677 0 \
1678 -c "Enable use of CID extension." \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001679 -s "Enable use of CID extension." \
1680 -c "client hello, adding CID extension" \
1681 -s "found CID extension" \
1682 -s "Use of CID extension negotiated" \
1683 -s "server hello, adding CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001684 -c "found CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001685 -c "Use of CID extension negotiated" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001686 -s "Copy CIDs into SSL transform" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001687 -c "Copy CIDs into SSL transform" \
1688 -c "Peer CID (length 2 Bytes): de ad" \
1689 -s "Peer CID (length 2 Bytes): be ef" \
1690 -s "Use of Connection ID has been negotiated" \
Hanno Becker73455992019-04-25 17:01:43 +01001691 -c "Use of Connection ID has been negotiated" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001692 -c "ignoring unexpected CID" \
1693 -s "ignoring unexpected CID"
Hanno Becker4eb05872019-04-26 16:00:29 +01001694
Hanno Beckercf2a5652019-04-26 16:13:31 +01001695requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1696run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001697 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1698 "$P_CLI debug_level=3 dtls=1 cid=1" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001699 0 \
1700 -c "Enable use of CID extension." \
1701 -s "Enable use of CID extension." \
1702 -c "client hello, adding CID extension" \
1703 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001704 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001705 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001706 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001707 -c "Use of CID extension negotiated" \
1708 -s "Copy CIDs into SSL transform" \
1709 -c "Copy CIDs into SSL transform" \
1710 -c "Peer CID (length 4 Bytes): de ad be ef" \
Hanno Becker73455992019-04-25 17:01:43 +01001711 -s "Peer CID (length 0 Bytes):" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001712 -s "Use of Connection ID has been negotiated" \
1713 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001714
Hanno Beckercf2a5652019-04-26 16:13:31 +01001715requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1716run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001717 "$P_SRV debug_level=3 dtls=1 cid=1" \
1718 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001719 0 \
1720 -c "Enable use of CID extension." \
1721 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001722 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001723 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001724 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001725 -s "server hello, adding CID extension" \
1726 -c "found CID extension" \
1727 -c "Use of CID extension negotiated" \
1728 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001729 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001730 -s "Peer CID (length 4 Bytes): de ad be ef" \
1731 -c "Peer CID (length 0 Bytes):" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001732 -s "Use of Connection ID has been negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001733 -c "Use of Connection ID has been negotiated"
1734
Hanno Becker5e2cd142019-04-26 16:23:52 +01001735requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1736run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001737 "$P_SRV debug_level=3 dtls=1 cid=1" \
1738 "$P_CLI debug_level=3 dtls=1 cid=1" \
1739 0 \
1740 -c "Enable use of CID extension." \
1741 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001742 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001743 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001744 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001745 -s "server hello, adding CID extension" \
1746 -c "found CID extension" \
1747 -c "Use of CID extension negotiated" \
1748 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001749 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001750 -S "Use of Connection ID has been negotiated" \
1751 -C "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001752
Hanno Beckercf2a5652019-04-26 16:13:31 +01001753requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1754run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001755 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1756 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001757 0 \
1758 -c "Enable use of CID extension." \
1759 -s "Enable use of CID extension." \
1760 -c "client hello, adding CID extension" \
1761 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001762 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001763 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001764 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001765 -c "Use of CID extension negotiated" \
1766 -s "Copy CIDs into SSL transform" \
1767 -c "Copy CIDs into SSL transform" \
1768 -c "Peer CID (length 2 Bytes): de ad" \
Hanno Becker73455992019-04-25 17:01:43 +01001769 -s "Peer CID (length 2 Bytes): be ef" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001770 -s "Use of Connection ID has been negotiated" \
1771 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001772
Hanno Beckercf2a5652019-04-26 16:13:31 +01001773requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1774run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001775 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1776 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001777 0 \
1778 -c "Enable use of CID extension." \
1779 -s "Enable use of CID extension." \
1780 -c "client hello, adding CID extension" \
1781 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001782 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001783 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001784 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001785 -c "Use of CID extension negotiated" \
1786 -s "Copy CIDs into SSL transform" \
1787 -c "Copy CIDs into SSL transform" \
1788 -c "Peer CID (length 4 Bytes): de ad be ef" \
Hanno Becker73455992019-04-25 17:01:43 +01001789 -s "Peer CID (length 0 Bytes):" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001790 -s "Use of Connection ID has been negotiated" \
1791 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001792
Hanno Beckercf2a5652019-04-26 16:13:31 +01001793requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1794run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001795 "$P_SRV debug_level=3 dtls=1 cid=1" \
1796 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001797 0 \
1798 -c "Enable use of CID extension." \
1799 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001800 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001801 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001802 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001803 -s "server hello, adding CID extension" \
1804 -c "found CID extension" \
1805 -c "Use of CID extension negotiated" \
1806 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001807 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001808 -s "Peer CID (length 4 Bytes): de ad be ef" \
1809 -c "Peer CID (length 0 Bytes):" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001810 -s "Use of Connection ID has been negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001811 -c "Use of Connection ID has been negotiated"
1812
Hanno Becker5e2cd142019-04-26 16:23:52 +01001813requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1814run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001815 "$P_SRV debug_level=3 dtls=1 cid=1" \
1816 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1817 0 \
1818 -c "Enable use of CID extension." \
1819 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001820 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001821 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001822 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001823 -s "server hello, adding CID extension" \
1824 -c "found CID extension" \
1825 -c "Use of CID extension negotiated" \
1826 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001827 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001828 -S "Use of Connection ID has been negotiated" \
1829 -C "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001830
Hanno Beckercf2a5652019-04-26 16:13:31 +01001831requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1832run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001833 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1834 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001835 0 \
1836 -c "Enable use of CID extension." \
1837 -s "Enable use of CID extension." \
1838 -c "client hello, adding CID extension" \
1839 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001840 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001841 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001842 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001843 -c "Use of CID extension negotiated" \
1844 -s "Copy CIDs into SSL transform" \
1845 -c "Copy CIDs into SSL transform" \
1846 -c "Peer CID (length 2 Bytes): de ad" \
Hanno Becker73455992019-04-25 17:01:43 +01001847 -s "Peer CID (length 2 Bytes): be ef" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001848 -s "Use of Connection ID has been negotiated" \
1849 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001850
Hanno Beckercf2a5652019-04-26 16:13:31 +01001851requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1852run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001853 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1854 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001855 0 \
1856 -c "Enable use of CID extension." \
1857 -s "Enable use of CID extension." \
1858 -c "client hello, adding CID extension" \
1859 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001860 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001861 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001862 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001863 -c "Use of CID extension negotiated" \
1864 -s "Copy CIDs into SSL transform" \
1865 -c "Copy CIDs into SSL transform" \
1866 -c "Peer CID (length 4 Bytes): de ad be ef" \
Hanno Becker73455992019-04-25 17:01:43 +01001867 -s "Peer CID (length 0 Bytes):" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001868 -s "Use of Connection ID has been negotiated" \
1869 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001870
Hanno Beckercf2a5652019-04-26 16:13:31 +01001871requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1872run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001873 "$P_SRV debug_level=3 dtls=1 cid=1" \
1874 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001875 0 \
1876 -c "Enable use of CID extension." \
1877 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001878 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001879 -s "found CID extension" \
Hanno Becker963cb352019-04-23 11:52:44 +01001880 -s "Use of CID extension negotiated" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001881 -s "server hello, adding CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001882 -c "found CID extension" \
1883 -c "Use of CID extension negotiated" \
1884 -s "Copy CIDs into SSL transform" \
Hanno Becker96870292019-05-03 17:30:59 +01001885 -c "Copy CIDs into SSL transform" \
1886 -s "Peer CID (length 4 Bytes): de ad be ef" \
1887 -c "Peer CID (length 0 Bytes):" \
1888 -s "Use of Connection ID has been negotiated" \
1889 -c "Use of Connection ID has been negotiated"
1890
1891requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1892run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
1893 "$P_SRV debug_level=3 dtls=1 cid=1" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001894 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
Hanno Becker96870292019-05-03 17:30:59 +01001895 0 \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001896 -c "Enable use of CID extension." \
Hanno Becker96870292019-05-03 17:30:59 +01001897 -s "Enable use of CID extension." \
1898 -c "client hello, adding CID extension" \
1899 -s "found CID extension" \
1900 -s "Use of CID extension negotiated" \
1901 -s "server hello, adding CID extension" \
1902 -c "found CID extension" \
1903 -c "Use of CID extension negotiated" \
1904 -s "Copy CIDs into SSL transform" \
1905 -c "Copy CIDs into SSL transform" \
1906 -S "Use of Connection ID has been negotiated" \
1907 -C "Use of Connection ID has been negotiated"
1908
Hanno Beckera5a2b082019-05-15 14:03:01 +01001909requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01001910requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01001911run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
1912 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
1913 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
1914 0 \
1915 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1916 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1917 -s "(initial handshake) Use of Connection ID has been negotiated" \
1918 -c "(initial handshake) Use of Connection ID has been negotiated" \
1919 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1920 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1921 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1922 -c "(after renegotiation) Use of Connection ID has been negotiated"
1923
Hanno Beckera5a2b082019-05-15 14:03:01 +01001924requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01001925requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001926run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001927 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001928 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1929 0 \
1930 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1931 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1932 -s "(initial handshake) Use of Connection ID has been negotiated" \
1933 -c "(initial handshake) Use of Connection ID has been negotiated" \
1934 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1935 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1936 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1937 -c "(after renegotiation) Use of Connection ID has been negotiated"
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001938
1939requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1940requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001941run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001942 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001943 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1944 0 \
Hanno Becker96870292019-05-03 17:30:59 +01001945 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1946 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1947 -s "(initial handshake) Use of Connection ID has been negotiated" \
1948 -c "(initial handshake) Use of Connection ID has been negotiated" \
1949 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1950 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1951 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1952 -c "(after renegotiation) Use of Connection ID has been negotiated"
1953
1954requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1955requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
1956run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001957 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker96870292019-05-03 17:30:59 +01001958 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
Hanno Becker84bbc512019-05-08 16:20:46 +01001959 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1960 0 \
1961 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1962 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1963 -s "(initial handshake) Use of Connection ID has been negotiated" \
1964 -c "(initial handshake) Use of Connection ID has been negotiated" \
1965 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1966 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1967 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1968 -c "(after renegotiation) Use of Connection ID has been negotiated" \
1969 -c "ignoring unexpected CID" \
1970 -s "ignoring unexpected CID"
1971
Hanno Beckera5a2b082019-05-15 14:03:01 +01001972requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01001973requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001974run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001975 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001976 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
1977 0 \
1978 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1979 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1980 -s "(initial handshake) Use of Connection ID has been negotiated" \
1981 -c "(initial handshake) Use of Connection ID has been negotiated" \
1982 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1983 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1984 -C "(after renegotiation) Use of Connection ID has been negotiated" \
1985 -S "(after renegotiation) Use of Connection ID has been negotiated"
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001986
1987requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1988requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001989run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001990 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001991 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
1992 0 \
Hanno Becker96870292019-05-03 17:30:59 +01001993 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1994 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1995 -s "(initial handshake) Use of Connection ID has been negotiated" \
1996 -c "(initial handshake) Use of Connection ID has been negotiated" \
1997 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1998 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1999 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2000 -S "(after renegotiation) Use of Connection ID has been negotiated"
2001
2002requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckera5a2b082019-05-15 14:03:01 +01002003requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker96870292019-05-03 17:30:59 +01002004run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Becker84bbc512019-05-08 16:20:46 +01002005 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
2006 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2007 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2008 0 \
2009 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2010 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2011 -s "(initial handshake) Use of Connection ID has been negotiated" \
2012 -c "(initial handshake) Use of Connection ID has been negotiated" \
2013 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2014 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2015 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01002016 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Becker84bbc512019-05-08 16:20:46 +01002017 -c "ignoring unexpected CID" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002018 -s "ignoring unexpected CID"
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002019
Hanno Becker04ca04c2019-05-08 13:31:15 +01002020requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2021requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2022run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
2023 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2024 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2025 0 \
2026 -S "(initial handshake) Use of Connection ID has been negotiated" \
2027 -C "(initial handshake) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002028 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2029 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2030 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002031 -s "(after renegotiation) Use of Connection ID has been negotiated"
Hanno Beckera5a2b082019-05-15 14:03:01 +01002032
Hanno Becker04ca04c2019-05-08 13:31:15 +01002033requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2034requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker96870292019-05-03 17:30:59 +01002035run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2036 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2037 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2038 0 \
2039 -S "(initial handshake) Use of Connection ID has been negotiated" \
2040 -C "(initial handshake) Use of Connection ID has been negotiated" \
2041 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2042 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2043 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2044 -s "(after renegotiation) Use of Connection ID has been negotiated"
2045
2046requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2047requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckera5a2b082019-05-15 14:03:01 +01002048run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Becker96870292019-05-03 17:30:59 +01002049 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002050 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002051 "$P_CLI debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002052 0 \
2053 -S "(initial handshake) Use of Connection ID has been negotiated" \
2054 -C "(initial handshake) Use of Connection ID has been negotiated" \
2055 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2056 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2057 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2058 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2059 -c "ignoring unexpected CID" \
2060 -s "ignoring unexpected CID"
2061
2062requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002063requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2064run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
2065 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002066 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01002067 0 \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002068 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2069 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2070 -s "(initial handshake) Use of Connection ID has been negotiated" \
2071 -c "(initial handshake) Use of Connection ID has been negotiated" \
2072 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2073 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2074 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2075 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2076 -s "(after renegotiation) Use of Connection ID was not offered by client"
2077
2078requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2079requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2080run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
2081 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
2082 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01002083 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002084 0 \
2085 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002086 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
Hanno Becker96870292019-05-03 17:30:59 +01002087 -s "(initial handshake) Use of Connection ID has been negotiated" \
2088 -c "(initial handshake) Use of Connection ID has been negotiated" \
2089 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2090 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2091 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2092 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2093 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2094 -c "ignoring unexpected CID" \
2095 -s "ignoring unexpected CID"
2096
2097requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002098requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2099run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2100 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01002101 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002102 0 \
2103 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2104 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002105 -s "(initial handshake) Use of Connection ID has been negotiated" \
2106 -c "(initial handshake) Use of Connection ID has been negotiated" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002107 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2108 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2109 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2110 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2111 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2112
2113requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2114requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2115run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
2116 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002117 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2118 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002119 0 \
2120 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2121 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2122 -s "(initial handshake) Use of Connection ID has been negotiated" \
2123 -c "(initial handshake) Use of Connection ID has been negotiated" \
2124 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2125 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2126 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2127 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002128 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2129 -c "ignoring unexpected CID" \
2130 -s "ignoring unexpected CID"
2131
2132# Tests for Encrypt-then-MAC extension
2133
2134run_test "Encrypt then MAC: default" \
2135 "$P_SRV debug_level=3 \
2136 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2137 "$P_CLI debug_level=3" \
2138 0 \
2139 -c "client hello, adding encrypt_then_mac extension" \
2140 -s "found encrypt then mac extension" \
2141 -s "server hello, adding encrypt then mac extension" \
2142 -c "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002143 -c "using encrypt then mac" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002144 -s "using encrypt then mac"
2145
2146run_test "Encrypt then MAC: client enabled, server disabled" \
2147 "$P_SRV debug_level=3 etm=0 \
2148 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2149 "$P_CLI debug_level=3 etm=1" \
2150 0 \
2151 -c "client hello, adding encrypt_then_mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002152 -s "found encrypt then mac extension" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002153 -S "server hello, adding encrypt then mac extension" \
2154 -C "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002155 -C "using encrypt then mac" \
2156 -S "using encrypt then mac"
2157
2158run_test "Encrypt then MAC: client enabled, aead cipher" \
2159 "$P_SRV debug_level=3 etm=1 \
2160 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2161 "$P_CLI debug_level=3 etm=1" \
2162 0 \
2163 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathe2681a42016-03-07 15:57:05 +00002164 -s "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002165 -S "server hello, adding encrypt then mac extension" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002166 -C "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002167 -C "using encrypt then mac" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002168 -S "using encrypt then mac"
2169
2170run_test "Encrypt then MAC: client enabled, stream cipher" \
2171 "$P_SRV debug_level=3 etm=1 \
2172 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2173 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2174 0 \
2175 -c "client hello, adding encrypt_then_mac extension" \
2176 -s "found encrypt then mac extension" \
Janos Follathe2681a42016-03-07 15:57:05 +00002177 -S "server hello, adding encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002178 -C "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002179 -C "using encrypt then mac" \
2180 -S "using encrypt then mac"
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002181
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002182run_test "Encrypt then MAC: client disabled, server enabled" \
2183 "$P_SRV debug_level=3 etm=1 \
Janos Follath00efff72016-05-06 13:48:23 +01002184 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002185 "$P_CLI debug_level=3 etm=0" \
2186 0 \
2187 -C "client hello, adding encrypt_then_mac extension" \
2188 -S "found encrypt then mac extension" \
2189 -S "server hello, adding encrypt then mac extension" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002190 -C "found encrypt_then_mac extension" \
2191 -C "using encrypt then mac" \
Jarno Lamsa31d940b2019-06-12 10:21:33 +03002192 -S "using encrypt then mac"
2193
2194requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2195run_test "Encrypt then MAC: client SSLv3, server enabled" \
2196 "$P_SRV debug_level=3 min_version=ssl3 \
2197 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2198 "$P_CLI debug_level=3 force_version=ssl3" \
2199 0 \
2200 -C "client hello, adding encrypt_then_mac extension" \
2201 -S "found encrypt then mac extension" \
2202 -S "server hello, adding encrypt then mac extension" \
2203 -C "found encrypt_then_mac extension" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002204 -C "using encrypt then mac" \
2205 -S "using encrypt then mac"
2206
2207requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2208run_test "Encrypt then MAC: client enabled, server SSLv3" \
2209 "$P_SRV debug_level=3 force_version=ssl3 \
2210 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2211 "$P_CLI debug_level=3 min_version=ssl3" \
2212 0 \
2213 -c "client hello, adding encrypt_then_mac extension" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002214 -S "found encrypt then mac extension" \
2215 -S "server hello, adding encrypt then mac extension" \
2216 -C "found encrypt_then_mac extension" \
2217 -C "using encrypt then mac" \
2218 -S "using encrypt then mac"
2219
2220# Tests for Extended Master Secret extension
2221
2222run_test "Extended Master Secret: default (not enforcing)" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002223 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0 " \
2224 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01002225 0 \
2226 -c "client hello, adding extended_master_secret extension" \
2227 -s "found extended master secret extension" \
2228 -s "server hello, adding extended master secret extension" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002229 -c "found extended_master_secret extension" \
2230 -c "session hash for extended master secret" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002231 -s "session hash for extended master secret"
2232
Jarno Lamsa41b35912019-06-10 15:51:11 +03002233run_test "Extended Master Secret: both enabled, both enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002234 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2235 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002236 0 \
2237 -c "client hello, adding extended_master_secret extension" \
2238 -s "found extended master secret extension" \
2239 -s "server hello, adding extended master secret extension" \
2240 -c "found extended_master_secret extension" \
2241 -c "session hash for extended master secret" \
2242 -s "session hash for extended master secret"
2243
Jarno Lamsa20095af2019-06-11 17:16:58 +03002244run_test "Extended Master Secret: both enabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002245 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2246 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002247 0 \
2248 -c "client hello, adding extended_master_secret extension" \
2249 -s "found extended master secret extension" \
2250 -s "server hello, adding extended master secret extension" \
2251 -c "found extended_master_secret extension" \
2252 -c "session hash for extended master secret" \
2253 -s "session hash for extended master secret"
2254
2255run_test "Extended Master Secret: both enabled, server enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002256 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2257 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002258 0 \
2259 -c "client hello, adding extended_master_secret extension" \
2260 -s "found extended master secret extension" \
2261 -s "server hello, adding extended master secret extension" \
2262 -c "found extended_master_secret extension" \
2263 -c "session hash for extended master secret" \
2264 -s "session hash for extended master secret"
2265
2266run_test "Extended Master Secret: client enabled, server disabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002267 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002268 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2269 1 \
2270 -c "client hello, adding extended_master_secret extension" \
2271 -s "found extended master secret extension" \
2272 -S "server hello, adding extended master secret extension" \
2273 -C "found extended_master_secret extension" \
2274 -c "Peer not offering extended master secret, while it is enforced"
2275
Jarno Lamsa20095af2019-06-11 17:16:58 +03002276run_test "Extended Master Secret enforced: client disabled, server enabled, server enforcing" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002277 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002278 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002279 1 \
2280 -C "client hello, adding extended_master_secret extension" \
2281 -S "found extended master secret extension" \
2282 -S "server hello, adding extended master secret extension" \
2283 -C "found extended_master_secret extension" \
2284 -s "Peer not offering extended master secret, while it is enforced"
2285
Jarno Lamsa20095af2019-06-11 17:16:58 +03002286run_test "Extended Master Secret: client enabled, server disabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002287 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2288 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002289 0 \
2290 -c "client hello, adding extended_master_secret extension" \
2291 -s "found extended master secret extension" \
2292 -S "server hello, adding extended master secret extension" \
2293 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002294 -C "session hash for extended master secret" \
2295 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002296
Jarno Lamsa20095af2019-06-11 17:16:58 +03002297run_test "Extended Master Secret: client disabled, server enabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002298 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2299 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002300 0 \
2301 -C "client hello, adding extended_master_secret extension" \
2302 -S "found extended master secret extension" \
2303 -S "server hello, adding extended master secret extension" \
2304 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002305 -C "session hash for extended master secret" \
2306 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002307
Jarno Lamsa20095af2019-06-11 17:16:58 +03002308run_test "Extended Master Secret: client disabled, server disabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002309 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2310 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002311 0 \
2312 -C "client hello, adding extended_master_secret extension" \
2313 -S "found extended master secret extension" \
2314 -S "server hello, adding extended master secret extension" \
2315 -C "found extended_master_secret extension" \
2316 -C "session hash for extended master secret" \
2317 -S "session hash for extended master secret"
2318
Janos Follathe2681a42016-03-07 15:57:05 +00002319requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002320run_test "Extended Master Secret: client SSLv3, server enabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002321 "$P_SRV debug_level=3 min_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2322 "$P_CLI debug_level=3 force_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002323 0 \
2324 -C "client hello, adding extended_master_secret extension" \
2325 -S "found extended master secret extension" \
2326 -S "server hello, adding extended master secret extension" \
2327 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002328 -C "session hash for extended master secret" \
2329 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002330
Janos Follathe2681a42016-03-07 15:57:05 +00002331requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002332run_test "Extended Master Secret: client enabled, server SSLv3" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002333 "$P_SRV debug_level=3 force_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2334 "$P_CLI debug_level=3 min_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002335 0 \
2336 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002337 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002338 -S "server hello, adding extended master secret extension" \
2339 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002340 -C "session hash for extended master secret" \
2341 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002342
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002343# Tests for FALLBACK_SCSV
2344
2345run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002346 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002347 "$P_CLI debug_level=3 force_version=tls1_1" \
2348 0 \
2349 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002350 -S "received FALLBACK_SCSV" \
2351 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002352 -C "is a fatal alert message (msg 86)"
2353
2354run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002355 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002356 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2357 0 \
2358 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002359 -S "received FALLBACK_SCSV" \
2360 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002361 -C "is a fatal alert message (msg 86)"
2362
2363run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002364 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002365 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002366 1 \
2367 -c "adding FALLBACK_SCSV" \
2368 -s "received FALLBACK_SCSV" \
2369 -s "inapropriate fallback" \
2370 -c "is a fatal alert message (msg 86)"
2371
2372run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002373 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002374 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002375 0 \
2376 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002377 -s "received FALLBACK_SCSV" \
2378 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002379 -C "is a fatal alert message (msg 86)"
2380
2381requires_openssl_with_fallback_scsv
2382run_test "Fallback SCSV: default, openssl server" \
2383 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002384 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002385 0 \
2386 -C "adding FALLBACK_SCSV" \
2387 -C "is a fatal alert message (msg 86)"
2388
2389requires_openssl_with_fallback_scsv
2390run_test "Fallback SCSV: enabled, openssl server" \
2391 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002392 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002393 1 \
2394 -c "adding FALLBACK_SCSV" \
2395 -c "is a fatal alert message (msg 86)"
2396
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002397requires_openssl_with_fallback_scsv
2398run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002399 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002400 "$O_CLI -tls1_1" \
2401 0 \
2402 -S "received FALLBACK_SCSV" \
2403 -S "inapropriate fallback"
2404
2405requires_openssl_with_fallback_scsv
2406run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002407 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002408 "$O_CLI -tls1_1 -fallback_scsv" \
2409 1 \
2410 -s "received FALLBACK_SCSV" \
2411 -s "inapropriate fallback"
2412
2413requires_openssl_with_fallback_scsv
2414run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002415 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002416 "$O_CLI -fallback_scsv" \
2417 0 \
2418 -s "received FALLBACK_SCSV" \
2419 -S "inapropriate fallback"
2420
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002421# Test sending and receiving empty application data records
2422
2423run_test "Encrypt then MAC: empty application data record" \
2424 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2425 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2426 0 \
2427 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2428 -s "dumping 'input payload after decrypt' (0 bytes)" \
2429 -c "0 bytes written in 1 fragments"
2430
2431run_test "Default, no Encrypt then MAC: empty application data record" \
2432 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2433 "$P_CLI auth_mode=none etm=0 request_size=0" \
2434 0 \
2435 -s "dumping 'input payload after decrypt' (0 bytes)" \
2436 -c "0 bytes written in 1 fragments"
2437
2438run_test "Encrypt then MAC, DTLS: empty application data record" \
2439 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2440 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2441 0 \
2442 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2443 -s "dumping 'input payload after decrypt' (0 bytes)" \
2444 -c "0 bytes written in 1 fragments"
2445
2446run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
2447 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2448 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2449 0 \
2450 -s "dumping 'input payload after decrypt' (0 bytes)" \
2451 -c "0 bytes written in 1 fragments"
2452
Gilles Peskined50177f2017-05-16 17:53:03 +02002453## ClientHello generated with
2454## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2455## then manually twiddling the ciphersuite list.
2456## The ClientHello content is spelled out below as a hex string as
2457## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2458## The expected response is an inappropriate_fallback alert.
2459requires_openssl_with_fallback_scsv
2460run_test "Fallback SCSV: beginning of list" \
2461 "$P_SRV debug_level=2" \
2462 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2463 0 \
2464 -s "received FALLBACK_SCSV" \
2465 -s "inapropriate fallback"
2466
2467requires_openssl_with_fallback_scsv
2468run_test "Fallback SCSV: end of list" \
2469 "$P_SRV debug_level=2" \
2470 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2471 0 \
2472 -s "received FALLBACK_SCSV" \
2473 -s "inapropriate fallback"
2474
2475## Here the expected response is a valid ServerHello prefix, up to the random.
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02002476## Due to the way the clienthello was generated, this currently needs the
2477## server to have support for session tickets.
2478requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Gilles Peskined50177f2017-05-16 17:53:03 +02002479requires_openssl_with_fallback_scsv
2480run_test "Fallback SCSV: not in list" \
2481 "$P_SRV debug_level=2" \
2482 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2483 0 \
2484 -S "received FALLBACK_SCSV" \
2485 -S "inapropriate fallback"
2486
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002487# Tests for CBC 1/n-1 record splitting
2488
2489run_test "CBC Record splitting: TLS 1.2, no splitting" \
2490 "$P_SRV" \
2491 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2492 request_size=123 force_version=tls1_2" \
2493 0 \
2494 -s "Read from client: 123 bytes read" \
2495 -S "Read from client: 1 bytes read" \
2496 -S "122 bytes read"
2497
2498run_test "CBC Record splitting: TLS 1.1, no splitting" \
2499 "$P_SRV" \
2500 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2501 request_size=123 force_version=tls1_1" \
2502 0 \
2503 -s "Read from client: 123 bytes read" \
2504 -S "Read from client: 1 bytes read" \
2505 -S "122 bytes read"
2506
2507run_test "CBC Record splitting: TLS 1.0, splitting" \
2508 "$P_SRV" \
2509 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2510 request_size=123 force_version=tls1" \
2511 0 \
2512 -S "Read from client: 123 bytes read" \
2513 -s "Read from client: 1 bytes read" \
2514 -s "122 bytes read"
2515
Janos Follathe2681a42016-03-07 15:57:05 +00002516requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002517run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002518 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002519 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2520 request_size=123 force_version=ssl3" \
2521 0 \
2522 -S "Read from client: 123 bytes read" \
2523 -s "Read from client: 1 bytes read" \
2524 -s "122 bytes read"
2525
2526run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002527 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002528 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2529 request_size=123 force_version=tls1" \
2530 0 \
2531 -s "Read from client: 123 bytes read" \
2532 -S "Read from client: 1 bytes read" \
2533 -S "122 bytes read"
2534
2535run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2536 "$P_SRV" \
2537 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2538 request_size=123 force_version=tls1 recsplit=0" \
2539 0 \
2540 -s "Read from client: 123 bytes read" \
2541 -S "Read from client: 1 bytes read" \
2542 -S "122 bytes read"
2543
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002544run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2545 "$P_SRV nbio=2" \
2546 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2547 request_size=123 force_version=tls1" \
2548 0 \
2549 -S "Read from client: 123 bytes read" \
2550 -s "Read from client: 1 bytes read" \
2551 -s "122 bytes read"
2552
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002553# Tests for Session Tickets
2554
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002555requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002556requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002557run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002558 "$P_SRV debug_level=3 tickets=1" \
2559 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002560 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002561 -c "client hello, adding session ticket extension" \
2562 -s "found session ticket extension" \
2563 -s "server hello, adding session ticket extension" \
2564 -c "found session_ticket extension" \
2565 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002566 -S "session successfully restored from cache" \
2567 -s "session successfully restored from ticket" \
2568 -s "a session has been resumed" \
2569 -c "a session has been resumed"
2570
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002571requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002572requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002573run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002574 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2575 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002576 0 \
2577 -c "client hello, adding session ticket extension" \
2578 -s "found session ticket extension" \
2579 -s "server hello, adding session ticket extension" \
2580 -c "found session_ticket extension" \
2581 -c "parse new session ticket" \
2582 -S "session successfully restored from cache" \
2583 -s "session successfully restored from ticket" \
2584 -s "a session has been resumed" \
2585 -c "a session has been resumed"
2586
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002587requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002588requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002589run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002590 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2591 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002592 0 \
2593 -c "client hello, adding session ticket extension" \
2594 -s "found session ticket extension" \
2595 -s "server hello, adding session ticket extension" \
2596 -c "found session_ticket extension" \
2597 -c "parse new session ticket" \
2598 -S "session successfully restored from cache" \
2599 -S "session successfully restored from ticket" \
2600 -S "a session has been resumed" \
2601 -C "a session has been resumed"
2602
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002603requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002604requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002605run_test "Session resume using tickets: session copy" \
2606 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2607 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2608 0 \
2609 -c "client hello, adding session ticket extension" \
2610 -s "found session ticket extension" \
2611 -s "server hello, adding session ticket extension" \
2612 -c "found session_ticket extension" \
2613 -c "parse new session ticket" \
2614 -S "session successfully restored from cache" \
2615 -s "session successfully restored from ticket" \
2616 -s "a session has been resumed" \
2617 -c "a session has been resumed"
2618
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002619requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002620requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002621run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002622 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002623 "$P_CLI debug_level=3 tickets=1 reconnect=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002624 0 \
2625 -c "client hello, adding session ticket extension" \
2626 -c "found session_ticket extension" \
2627 -c "parse new session ticket" \
2628 -c "a session has been resumed"
2629
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002630requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002631requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002632run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002633 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002634 "( $O_CLI -sess_out $SESSION; \
2635 $O_CLI -sess_in $SESSION; \
2636 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002637 0 \
2638 -s "found session ticket extension" \
2639 -s "server hello, adding session ticket extension" \
2640 -S "session successfully restored from cache" \
2641 -s "session successfully restored from ticket" \
2642 -s "a session has been resumed"
2643
Hanno Becker1d739932018-08-21 13:55:22 +01002644# Tests for Session Tickets with DTLS
2645
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002646requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002647requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002648run_test "Session resume using tickets, DTLS: basic" \
2649 "$P_SRV debug_level=3 dtls=1 tickets=1" \
2650 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2651 0 \
2652 -c "client hello, adding session ticket extension" \
2653 -s "found session ticket extension" \
2654 -s "server hello, adding session ticket extension" \
2655 -c "found session_ticket extension" \
2656 -c "parse new session ticket" \
2657 -S "session successfully restored from cache" \
2658 -s "session successfully restored from ticket" \
2659 -s "a session has been resumed" \
2660 -c "a session has been resumed"
2661
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002662requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002663requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002664run_test "Session resume using tickets, DTLS: cache disabled" \
2665 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2666 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2667 0 \
2668 -c "client hello, adding session ticket extension" \
2669 -s "found session ticket extension" \
2670 -s "server hello, adding session ticket extension" \
2671 -c "found session_ticket extension" \
2672 -c "parse new session ticket" \
2673 -S "session successfully restored from cache" \
2674 -s "session successfully restored from ticket" \
2675 -s "a session has been resumed" \
2676 -c "a session has been resumed"
2677
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002678requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002679requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002680run_test "Session resume using tickets, DTLS: timeout" \
2681 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
2682 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_delay=2" \
2683 0 \
2684 -c "client hello, adding session ticket extension" \
2685 -s "found session ticket extension" \
2686 -s "server hello, adding session ticket extension" \
2687 -c "found session_ticket extension" \
2688 -c "parse new session ticket" \
2689 -S "session successfully restored from cache" \
2690 -S "session successfully restored from ticket" \
2691 -S "a session has been resumed" \
2692 -C "a session has been resumed"
2693
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002694requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002695requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002696run_test "Session resume using tickets, DTLS: session copy" \
2697 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2698 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_mode=0" \
2699 0 \
2700 -c "client hello, adding session ticket extension" \
2701 -s "found session ticket extension" \
2702 -s "server hello, adding session ticket extension" \
2703 -c "found session_ticket extension" \
2704 -c "parse new session ticket" \
2705 -S "session successfully restored from cache" \
2706 -s "session successfully restored from ticket" \
2707 -s "a session has been resumed" \
2708 -c "a session has been resumed"
2709
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002710requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002711requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002712run_test "Session resume using tickets, DTLS: openssl server" \
2713 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002714 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 ca_file=data_files/test-ca2.crt" \
Hanno Becker1d739932018-08-21 13:55:22 +01002715 0 \
2716 -c "client hello, adding session ticket extension" \
2717 -c "found session_ticket extension" \
2718 -c "parse new session ticket" \
2719 -c "a session has been resumed"
2720
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002721requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002722requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002723run_test "Session resume using tickets, DTLS: openssl client" \
2724 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2725 "( $O_CLI -dtls1 -sess_out $SESSION; \
2726 $O_CLI -dtls1 -sess_in $SESSION; \
2727 rm -f $SESSION )" \
2728 0 \
2729 -s "found session ticket extension" \
2730 -s "server hello, adding session ticket extension" \
2731 -S "session successfully restored from cache" \
2732 -s "session successfully restored from ticket" \
2733 -s "a session has been resumed"
2734
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002735# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002736
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002737requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002738requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002739requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002740run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002741 "$P_SRV debug_level=3 tickets=0" \
2742 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002743 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002744 -c "client hello, adding session ticket extension" \
2745 -s "found session ticket extension" \
2746 -S "server hello, adding session ticket extension" \
2747 -C "found session_ticket extension" \
2748 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002749 -s "session successfully restored from cache" \
2750 -S "session successfully restored from ticket" \
2751 -s "a session has been resumed" \
2752 -c "a session has been resumed"
2753
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002754requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002755requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002756requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002757run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002758 "$P_SRV debug_level=3 tickets=1" \
2759 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002760 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002761 -C "client hello, adding session ticket extension" \
2762 -S "found session ticket extension" \
2763 -S "server hello, adding session ticket extension" \
2764 -C "found session_ticket extension" \
2765 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002766 -s "session successfully restored from cache" \
2767 -S "session successfully restored from ticket" \
2768 -s "a session has been resumed" \
2769 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002770
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002771requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2772requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002773run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002774 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2775 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002776 0 \
2777 -S "session successfully restored from cache" \
2778 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002779 -S "a session has been resumed" \
2780 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002781
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002782requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2783requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002784run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002785 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2786 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002787 0 \
2788 -s "session successfully restored from cache" \
2789 -S "session successfully restored from ticket" \
2790 -s "a session has been resumed" \
2791 -c "a session has been resumed"
2792
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002793requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2794requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002795run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002796 "$P_SRV debug_level=3 tickets=0" \
2797 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002798 0 \
2799 -s "session successfully restored from cache" \
2800 -S "session successfully restored from ticket" \
2801 -s "a session has been resumed" \
2802 -c "a session has been resumed"
2803
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002804requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2805requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002806run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002807 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2808 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002809 0 \
2810 -S "session successfully restored from cache" \
2811 -S "session successfully restored from ticket" \
2812 -S "a session has been resumed" \
2813 -C "a session has been resumed"
2814
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002815requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2816requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002817run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002818 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2819 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002820 0 \
2821 -s "session successfully restored from cache" \
2822 -S "session successfully restored from ticket" \
2823 -s "a session has been resumed" \
2824 -c "a session has been resumed"
2825
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002826requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2827requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002828run_test "Session resume using cache: session copy" \
2829 "$P_SRV debug_level=3 tickets=0" \
2830 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2831 0 \
2832 -s "session successfully restored from cache" \
2833 -S "session successfully restored from ticket" \
2834 -s "a session has been resumed" \
2835 -c "a session has been resumed"
2836
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002837requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2838requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002839run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002840 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002841 "( $O_CLI -sess_out $SESSION; \
2842 $O_CLI -sess_in $SESSION; \
2843 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002844 0 \
2845 -s "found session ticket extension" \
2846 -S "server hello, adding session ticket extension" \
2847 -s "session successfully restored from cache" \
2848 -S "session successfully restored from ticket" \
2849 -s "a session has been resumed"
2850
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002851requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2852requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002853run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002854 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002855 "$P_CLI debug_level=3 tickets=0 reconnect=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002856 0 \
2857 -C "found session_ticket extension" \
2858 -C "parse new session ticket" \
2859 -c "a session has been resumed"
2860
Hanno Becker1d739932018-08-21 13:55:22 +01002861# Tests for Session Resume based on session-ID and cache, DTLS
2862
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002863requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002864requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002865requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002866run_test "Session resume using cache, DTLS: tickets enabled on client" \
2867 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2868 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2869 0 \
2870 -c "client hello, adding session ticket extension" \
2871 -s "found session ticket extension" \
2872 -S "server hello, adding session ticket extension" \
2873 -C "found session_ticket extension" \
2874 -C "parse new session ticket" \
2875 -s "session successfully restored from cache" \
2876 -S "session successfully restored from ticket" \
2877 -s "a session has been resumed" \
2878 -c "a session has been resumed"
2879
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002880requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002881requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002882requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002883run_test "Session resume using cache, DTLS: tickets enabled on server" \
2884 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2885 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2886 0 \
2887 -C "client hello, adding session ticket extension" \
2888 -S "found session ticket extension" \
2889 -S "server hello, adding session ticket extension" \
2890 -C "found session_ticket extension" \
2891 -C "parse new session ticket" \
2892 -s "session successfully restored from cache" \
2893 -S "session successfully restored from ticket" \
2894 -s "a session has been resumed" \
2895 -c "a session has been resumed"
2896
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002897requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2898requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002899run_test "Session resume using cache, DTLS: cache_max=0" \
2900 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
2901 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2902 0 \
2903 -S "session successfully restored from cache" \
2904 -S "session successfully restored from ticket" \
2905 -S "a session has been resumed" \
2906 -C "a session has been resumed"
2907
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002908requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2909requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002910run_test "Session resume using cache, DTLS: cache_max=1" \
2911 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
2912 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2913 0 \
2914 -s "session successfully restored from cache" \
2915 -S "session successfully restored from ticket" \
2916 -s "a session has been resumed" \
2917 -c "a session has been resumed"
2918
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002919requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2920requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002921run_test "Session resume using cache, DTLS: timeout > delay" \
2922 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2923 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
2924 0 \
2925 -s "session successfully restored from cache" \
2926 -S "session successfully restored from ticket" \
2927 -s "a session has been resumed" \
2928 -c "a session has been resumed"
2929
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002930requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2931requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002932run_test "Session resume using cache, DTLS: timeout < delay" \
2933 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
2934 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2935 0 \
2936 -S "session successfully restored from cache" \
2937 -S "session successfully restored from ticket" \
2938 -S "a session has been resumed" \
2939 -C "a session has been resumed"
2940
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002941requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2942requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002943run_test "Session resume using cache, DTLS: no timeout" \
2944 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
2945 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2946 0 \
2947 -s "session successfully restored from cache" \
2948 -S "session successfully restored from ticket" \
2949 -s "a session has been resumed" \
2950 -c "a session has been resumed"
2951
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002952requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2953requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002954run_test "Session resume using cache, DTLS: session copy" \
2955 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2956 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2957 0 \
2958 -s "session successfully restored from cache" \
2959 -S "session successfully restored from ticket" \
2960 -s "a session has been resumed" \
2961 -c "a session has been resumed"
2962
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002963requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2964requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002965run_test "Session resume using cache, DTLS: openssl client" \
2966 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2967 "( $O_CLI -dtls1 -sess_out $SESSION; \
2968 $O_CLI -dtls1 -sess_in $SESSION; \
2969 rm -f $SESSION )" \
2970 0 \
2971 -s "found session ticket extension" \
2972 -S "server hello, adding session ticket extension" \
2973 -s "session successfully restored from cache" \
2974 -S "session successfully restored from ticket" \
2975 -s "a session has been resumed"
2976
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002977requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2978requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002979run_test "Session resume using cache, DTLS: openssl server" \
2980 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002981 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 ca_file=data_files/test-ca2.crt" \
Hanno Becker1d739932018-08-21 13:55:22 +01002982 0 \
2983 -C "found session_ticket extension" \
2984 -C "parse new session ticket" \
2985 -c "a session has been resumed"
2986
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002987# Tests for Max Fragment Length extension
2988
Angus Grattonc4dd0732018-04-11 16:28:39 +10002989if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
Hanno Beckerab9a29b2019-09-24 16:14:39 +01002990 printf "The configuration defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n"
Hanno Becker6428f8d2017-09-22 16:58:50 +01002991 exit 1
2992fi
2993
Angus Grattonc4dd0732018-04-11 16:28:39 +10002994if [ $MAX_CONTENT_LEN -ne 16384 ]; then
2995 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
2996fi
2997
Hanno Becker4aed27e2017-09-18 15:00:34 +01002998requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002999run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003000 "$P_SRV debug_level=3" \
3001 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003002 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003003 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3004 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003005 -C "client hello, adding max_fragment_length extension" \
3006 -S "found max fragment length extension" \
3007 -S "server hello, max_fragment_length extension" \
3008 -C "found max_fragment_length extension"
3009
Hanno Becker4aed27e2017-09-18 15:00:34 +01003010requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003011run_test "Max fragment length: enabled, default, larger message" \
3012 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003013 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003014 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003015 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3016 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003017 -C "client hello, adding max_fragment_length extension" \
3018 -S "found max fragment length extension" \
3019 -S "server hello, max_fragment_length extension" \
3020 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003021 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3022 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003023 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003024
3025requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3026run_test "Max fragment length, DTLS: enabled, default, larger message" \
3027 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003028 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003029 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003030 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3031 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003032 -C "client hello, adding max_fragment_length extension" \
3033 -S "found max fragment length extension" \
3034 -S "server hello, max_fragment_length extension" \
3035 -C "found max_fragment_length extension" \
3036 -c "fragment larger than.*maximum "
3037
Angus Grattonc4dd0732018-04-11 16:28:39 +10003038# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
3039# (session fragment length will be 16384 regardless of mbedtls
3040# content length configuration.)
3041
Hanno Beckerc5266962017-09-18 15:01:50 +01003042requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3043run_test "Max fragment length: disabled, larger message" \
3044 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003045 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003046 0 \
3047 -C "Maximum fragment length is 16384" \
3048 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003049 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3050 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003051 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003052
3053requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3054run_test "Max fragment length DTLS: disabled, larger message" \
3055 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003056 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003057 1 \
3058 -C "Maximum fragment length is 16384" \
3059 -S "Maximum fragment length is 16384" \
3060 -c "fragment larger than.*maximum "
3061
3062requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003063run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003064 "$P_SRV debug_level=3" \
3065 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003066 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003067 -c "Maximum fragment length is 4096" \
3068 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003069 -c "client hello, adding max_fragment_length extension" \
3070 -s "found max fragment length extension" \
3071 -s "server hello, max_fragment_length extension" \
3072 -c "found max_fragment_length extension"
3073
Hanno Becker4aed27e2017-09-18 15:00:34 +01003074requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003075run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003076 "$P_SRV debug_level=3 max_frag_len=4096" \
3077 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003078 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003079 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003080 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003081 -C "client hello, adding max_fragment_length extension" \
3082 -S "found max fragment length extension" \
3083 -S "server hello, max_fragment_length extension" \
3084 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003085
Hanno Becker4aed27e2017-09-18 15:00:34 +01003086requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003087requires_gnutls
3088run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003089 "$G_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003090 "$P_CLI debug_level=3 max_frag_len=4096 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003091 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003092 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003093 -c "client hello, adding max_fragment_length extension" \
3094 -c "found max_fragment_length extension"
3095
Hanno Becker4aed27e2017-09-18 15:00:34 +01003096requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003097run_test "Max fragment length: client, message just fits" \
3098 "$P_SRV debug_level=3" \
3099 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3100 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003101 -c "Maximum fragment length is 2048" \
3102 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003103 -c "client hello, adding max_fragment_length extension" \
3104 -s "found max fragment length extension" \
3105 -s "server hello, max_fragment_length extension" \
3106 -c "found max_fragment_length extension" \
3107 -c "2048 bytes written in 1 fragments" \
3108 -s "2048 bytes read"
3109
Hanno Becker4aed27e2017-09-18 15:00:34 +01003110requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003111run_test "Max fragment length: client, larger message" \
3112 "$P_SRV debug_level=3" \
3113 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3114 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003115 -c "Maximum fragment length is 2048" \
3116 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003117 -c "client hello, adding max_fragment_length extension" \
3118 -s "found max fragment length extension" \
3119 -s "server hello, max_fragment_length extension" \
3120 -c "found max_fragment_length extension" \
3121 -c "2345 bytes written in 2 fragments" \
3122 -s "2048 bytes read" \
3123 -s "297 bytes read"
3124
Hanno Becker4aed27e2017-09-18 15:00:34 +01003125requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003126run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003127 "$P_SRV debug_level=3 dtls=1" \
3128 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3129 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003130 -c "Maximum fragment length is 2048" \
3131 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003132 -c "client hello, adding max_fragment_length extension" \
3133 -s "found max fragment length extension" \
3134 -s "server hello, max_fragment_length extension" \
3135 -c "found max_fragment_length extension" \
3136 -c "fragment larger than.*maximum"
3137
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003138# Tests for renegotiation
3139
Hanno Becker6a243642017-10-12 15:18:45 +01003140# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003141run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003142 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003143 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003144 0 \
3145 -C "client hello, adding renegotiation extension" \
3146 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3147 -S "found renegotiation extension" \
3148 -s "server hello, secure renegotiation extension" \
3149 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003150 -C "=> renegotiate" \
3151 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003152 -S "write hello request"
3153
Hanno Becker6a243642017-10-12 15:18:45 +01003154requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003155run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003156 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003157 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003158 0 \
3159 -c "client hello, adding renegotiation extension" \
3160 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3161 -s "found renegotiation extension" \
3162 -s "server hello, secure renegotiation extension" \
3163 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003164 -c "=> renegotiate" \
3165 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003166 -S "write hello request"
3167
Hanno Becker6a243642017-10-12 15:18:45 +01003168requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003169run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003170 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003171 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003172 0 \
3173 -c "client hello, adding renegotiation extension" \
3174 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3175 -s "found renegotiation extension" \
3176 -s "server hello, secure renegotiation extension" \
3177 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003178 -c "=> renegotiate" \
3179 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003180 -s "write hello request"
3181
Janos Follathb0f148c2017-10-05 12:29:42 +01003182# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3183# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3184# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003185requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003186run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3187 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3188 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3189 0 \
3190 -c "client hello, adding renegotiation extension" \
3191 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3192 -s "found renegotiation extension" \
3193 -s "server hello, secure renegotiation extension" \
3194 -c "found renegotiation extension" \
3195 -c "=> renegotiate" \
3196 -s "=> renegotiate" \
3197 -S "write hello request" \
3198 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3199
3200# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3201# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3202# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003203requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003204run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3205 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3206 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3207 0 \
3208 -c "client hello, adding renegotiation extension" \
3209 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3210 -s "found renegotiation extension" \
3211 -s "server hello, secure renegotiation extension" \
3212 -c "found renegotiation extension" \
3213 -c "=> renegotiate" \
3214 -s "=> renegotiate" \
3215 -s "write hello request" \
3216 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3217
Hanno Becker6a243642017-10-12 15:18:45 +01003218requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003219run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003220 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003221 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003222 0 \
3223 -c "client hello, adding renegotiation extension" \
3224 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3225 -s "found renegotiation extension" \
3226 -s "server hello, secure renegotiation extension" \
3227 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003228 -c "=> renegotiate" \
3229 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003230 -s "write hello request"
3231
Hanno Becker6a243642017-10-12 15:18:45 +01003232requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003233run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003234 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003235 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003236 1 \
3237 -c "client hello, adding renegotiation extension" \
3238 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3239 -S "found renegotiation extension" \
3240 -s "server hello, secure renegotiation extension" \
3241 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003242 -c "=> renegotiate" \
3243 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003244 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003245 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003246 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003247
Hanno Becker6a243642017-10-12 15:18:45 +01003248requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003249run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003250 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003251 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003252 0 \
3253 -C "client hello, adding renegotiation extension" \
3254 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3255 -S "found renegotiation extension" \
3256 -s "server hello, secure renegotiation extension" \
3257 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003258 -C "=> renegotiate" \
3259 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003260 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003261 -S "SSL - An unexpected message was received from our peer" \
3262 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003263
Hanno Becker6a243642017-10-12 15:18:45 +01003264requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003265run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003266 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003267 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003268 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003269 0 \
3270 -C "client hello, adding renegotiation extension" \
3271 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3272 -S "found renegotiation extension" \
3273 -s "server hello, secure renegotiation extension" \
3274 -c "found renegotiation extension" \
3275 -C "=> renegotiate" \
3276 -S "=> renegotiate" \
3277 -s "write hello request" \
3278 -S "SSL - An unexpected message was received from our peer" \
3279 -S "failed"
3280
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003281# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003282requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003283run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003284 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003285 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003286 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003287 0 \
3288 -C "client hello, adding renegotiation extension" \
3289 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3290 -S "found renegotiation extension" \
3291 -s "server hello, secure renegotiation extension" \
3292 -c "found renegotiation extension" \
3293 -C "=> renegotiate" \
3294 -S "=> renegotiate" \
3295 -s "write hello request" \
3296 -S "SSL - An unexpected message was received from our peer" \
3297 -S "failed"
3298
Hanno Becker6a243642017-10-12 15:18:45 +01003299requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003300run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003301 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003302 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003303 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003304 0 \
3305 -C "client hello, adding renegotiation extension" \
3306 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3307 -S "found renegotiation extension" \
3308 -s "server hello, secure renegotiation extension" \
3309 -c "found renegotiation extension" \
3310 -C "=> renegotiate" \
3311 -S "=> renegotiate" \
3312 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003313 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003314
Hanno Becker6a243642017-10-12 15:18:45 +01003315requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003316run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003317 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003318 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003319 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003320 0 \
3321 -c "client hello, adding renegotiation extension" \
3322 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3323 -s "found renegotiation extension" \
3324 -s "server hello, secure renegotiation extension" \
3325 -c "found renegotiation extension" \
3326 -c "=> renegotiate" \
3327 -s "=> renegotiate" \
3328 -s "write hello request" \
3329 -S "SSL - An unexpected message was received from our peer" \
3330 -S "failed"
3331
Hanno Becker6a243642017-10-12 15:18:45 +01003332requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003333run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003334 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003335 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3336 0 \
3337 -C "client hello, adding renegotiation extension" \
3338 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3339 -S "found renegotiation extension" \
3340 -s "server hello, secure renegotiation extension" \
3341 -c "found renegotiation extension" \
3342 -S "record counter limit reached: renegotiate" \
3343 -C "=> renegotiate" \
3344 -S "=> renegotiate" \
3345 -S "write hello request" \
3346 -S "SSL - An unexpected message was received from our peer" \
3347 -S "failed"
3348
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003349# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003350requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003351run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003352 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003353 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003354 0 \
3355 -c "client hello, adding renegotiation extension" \
3356 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3357 -s "found renegotiation extension" \
3358 -s "server hello, secure renegotiation extension" \
3359 -c "found renegotiation extension" \
3360 -s "record counter limit reached: renegotiate" \
3361 -c "=> renegotiate" \
3362 -s "=> renegotiate" \
3363 -s "write hello request" \
3364 -S "SSL - An unexpected message was received from our peer" \
3365 -S "failed"
3366
Hanno Becker6a243642017-10-12 15:18:45 +01003367requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003368run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003369 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003370 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003371 0 \
3372 -c "client hello, adding renegotiation extension" \
3373 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3374 -s "found renegotiation extension" \
3375 -s "server hello, secure renegotiation extension" \
3376 -c "found renegotiation extension" \
3377 -s "record counter limit reached: renegotiate" \
3378 -c "=> renegotiate" \
3379 -s "=> renegotiate" \
3380 -s "write hello request" \
3381 -S "SSL - An unexpected message was received from our peer" \
3382 -S "failed"
3383
Hanno Becker6a243642017-10-12 15:18:45 +01003384requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003385run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003386 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003387 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3388 0 \
3389 -C "client hello, adding renegotiation extension" \
3390 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3391 -S "found renegotiation extension" \
3392 -s "server hello, secure renegotiation extension" \
3393 -c "found renegotiation extension" \
3394 -S "record counter limit reached: renegotiate" \
3395 -C "=> renegotiate" \
3396 -S "=> renegotiate" \
3397 -S "write hello request" \
3398 -S "SSL - An unexpected message was received from our peer" \
3399 -S "failed"
3400
Hanno Becker6a243642017-10-12 15:18:45 +01003401requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003402run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003403 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003404 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003405 0 \
3406 -c "client hello, adding renegotiation extension" \
3407 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3408 -s "found renegotiation extension" \
3409 -s "server hello, secure renegotiation extension" \
3410 -c "found renegotiation extension" \
3411 -c "=> renegotiate" \
3412 -s "=> renegotiate" \
3413 -S "write hello request"
3414
Hanno Becker6a243642017-10-12 15:18:45 +01003415requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003416run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003417 "$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 +02003418 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003419 0 \
3420 -c "client hello, adding renegotiation extension" \
3421 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3422 -s "found renegotiation extension" \
3423 -s "server hello, secure renegotiation extension" \
3424 -c "found renegotiation extension" \
3425 -c "=> renegotiate" \
3426 -s "=> renegotiate" \
3427 -s "write hello request"
3428
Hanno Becker6a243642017-10-12 15:18:45 +01003429requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003430run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003431 "$O_SRV -www" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003432 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003433 0 \
3434 -c "client hello, adding renegotiation extension" \
3435 -c "found renegotiation extension" \
3436 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003437 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003438 -C "error" \
3439 -c "HTTP/1.0 200 [Oo][Kk]"
3440
Paul Bakker539d9722015-02-08 16:18:35 +01003441requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003442requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003443run_test "Renegotiation: gnutls server strict, client-initiated" \
3444 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003445 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003446 0 \
3447 -c "client hello, adding renegotiation extension" \
3448 -c "found renegotiation extension" \
3449 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003450 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003451 -C "error" \
3452 -c "HTTP/1.0 200 [Oo][Kk]"
3453
Paul Bakker539d9722015-02-08 16:18:35 +01003454requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003455requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003456run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3457 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003458 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003459 1 \
3460 -c "client hello, adding renegotiation extension" \
3461 -C "found renegotiation extension" \
3462 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003463 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003464 -c "error" \
3465 -C "HTTP/1.0 200 [Oo][Kk]"
3466
Paul Bakker539d9722015-02-08 16:18:35 +01003467requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003468requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003469run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3470 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003471 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003472 allow_legacy=0" \
3473 1 \
3474 -c "client hello, adding renegotiation extension" \
3475 -C "found renegotiation extension" \
3476 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003477 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003478 -c "error" \
3479 -C "HTTP/1.0 200 [Oo][Kk]"
3480
Paul Bakker539d9722015-02-08 16:18:35 +01003481requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003482requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003483run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3484 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003485 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003486 allow_legacy=1" \
3487 0 \
3488 -c "client hello, adding renegotiation extension" \
3489 -C "found renegotiation extension" \
3490 -c "=> renegotiate" \
3491 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003492 -C "error" \
3493 -c "HTTP/1.0 200 [Oo][Kk]"
3494
Hanno Becker6a243642017-10-12 15:18:45 +01003495requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003496run_test "Renegotiation: DTLS, client-initiated" \
3497 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3498 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3499 0 \
3500 -c "client hello, adding renegotiation extension" \
3501 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3502 -s "found renegotiation extension" \
3503 -s "server hello, secure renegotiation extension" \
3504 -c "found renegotiation extension" \
3505 -c "=> renegotiate" \
3506 -s "=> renegotiate" \
3507 -S "write hello request"
3508
Hanno Becker6a243642017-10-12 15:18:45 +01003509requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003510run_test "Renegotiation: DTLS, server-initiated" \
3511 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003512 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3513 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003514 0 \
3515 -c "client hello, adding renegotiation extension" \
3516 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3517 -s "found renegotiation extension" \
3518 -s "server hello, secure renegotiation extension" \
3519 -c "found renegotiation extension" \
3520 -c "=> renegotiate" \
3521 -s "=> renegotiate" \
3522 -s "write hello request"
3523
Hanno Becker6a243642017-10-12 15:18:45 +01003524requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003525run_test "Renegotiation: DTLS, renego_period overflow" \
3526 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3527 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3528 0 \
3529 -c "client hello, adding renegotiation extension" \
3530 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3531 -s "found renegotiation extension" \
3532 -s "server hello, secure renegotiation extension" \
3533 -s "record counter limit reached: renegotiate" \
3534 -c "=> renegotiate" \
3535 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003536 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003537
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003538requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003539requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003540run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3541 "$G_SRV -u --mtu 4096" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003542 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003543 0 \
3544 -c "client hello, adding renegotiation extension" \
3545 -c "found renegotiation extension" \
3546 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003547 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003548 -C "error" \
3549 -s "Extra-header:"
3550
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003551# Test for the "secure renegotation" extension only (no actual renegotiation)
3552
Paul Bakker539d9722015-02-08 16:18:35 +01003553requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003554run_test "Renego ext: gnutls server strict, client default" \
3555 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003556 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003557 0 \
3558 -c "found renegotiation extension" \
3559 -C "error" \
3560 -c "HTTP/1.0 200 [Oo][Kk]"
3561
Paul Bakker539d9722015-02-08 16:18:35 +01003562requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003563run_test "Renego ext: gnutls server unsafe, client default" \
3564 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003565 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003566 0 \
3567 -C "found renegotiation extension" \
3568 -C "error" \
3569 -c "HTTP/1.0 200 [Oo][Kk]"
3570
Paul Bakker539d9722015-02-08 16:18:35 +01003571requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003572run_test "Renego ext: gnutls server unsafe, client break legacy" \
3573 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3574 "$P_CLI debug_level=3 allow_legacy=-1" \
3575 1 \
3576 -C "found renegotiation extension" \
3577 -c "error" \
3578 -C "HTTP/1.0 200 [Oo][Kk]"
3579
Paul Bakker539d9722015-02-08 16:18:35 +01003580requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003581run_test "Renego ext: gnutls client strict, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003582 "$P_SRV debug_level=3 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003583 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003584 0 \
3585 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3586 -s "server hello, secure renegotiation extension"
3587
Paul Bakker539d9722015-02-08 16:18:35 +01003588requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003589run_test "Renego ext: gnutls client unsafe, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003590 "$P_SRV debug_level=3 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003591 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003592 0 \
3593 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3594 -S "server hello, secure renegotiation extension"
3595
Paul Bakker539d9722015-02-08 16:18:35 +01003596requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003597run_test "Renego ext: gnutls client unsafe, server break legacy" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003598 "$P_SRV debug_level=3 allow_legacy=-1 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003599 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003600 1 \
3601 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3602 -S "server hello, secure renegotiation extension"
3603
Janos Follath0b242342016-02-17 10:11:21 +00003604# Tests for silently dropping trailing extra bytes in .der certificates
3605
3606requires_gnutls
3607run_test "DER format: no trailing bytes" \
3608 "$P_SRV crt_file=data_files/server5-der0.crt \
3609 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003610 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003611 0 \
3612 -c "Handshake was completed" \
3613
3614requires_gnutls
3615run_test "DER format: with a trailing zero byte" \
3616 "$P_SRV crt_file=data_files/server5-der1a.crt \
3617 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003618 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003619 0 \
3620 -c "Handshake was completed" \
3621
3622requires_gnutls
3623run_test "DER format: with a trailing random byte" \
3624 "$P_SRV crt_file=data_files/server5-der1b.crt \
3625 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003626 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003627 0 \
3628 -c "Handshake was completed" \
3629
3630requires_gnutls
3631run_test "DER format: with 2 trailing random bytes" \
3632 "$P_SRV crt_file=data_files/server5-der2.crt \
3633 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003634 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003635 0 \
3636 -c "Handshake was completed" \
3637
3638requires_gnutls
3639run_test "DER format: with 4 trailing random bytes" \
3640 "$P_SRV crt_file=data_files/server5-der4.crt \
3641 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003642 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003643 0 \
3644 -c "Handshake was completed" \
3645
3646requires_gnutls
3647run_test "DER format: with 8 trailing random bytes" \
3648 "$P_SRV crt_file=data_files/server5-der8.crt \
3649 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003650 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003651 0 \
3652 -c "Handshake was completed" \
3653
3654requires_gnutls
3655run_test "DER format: with 9 trailing random bytes" \
3656 "$P_SRV crt_file=data_files/server5-der9.crt \
3657 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003658 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003659 0 \
3660 -c "Handshake was completed" \
3661
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003662# Tests for auth_mode
3663
Hanno Becker4a156fc2019-06-14 17:07:06 +01003664requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003665requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003666run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003667 "$P_SRV crt_file=data_files/server5-badsign.crt \
3668 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003669 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003670 1 \
3671 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003672 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003673 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003674 -c "X509 - Certificate verification failed"
3675
Hanno Becker4a156fc2019-06-14 17:07:06 +01003676requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003677requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003678run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003679 "$P_SRV crt_file=data_files/server5-badsign.crt \
3680 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003681 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003682 0 \
3683 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003684 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003685 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003686 -C "X509 - Certificate verification failed"
3687
Hanno Becker4a156fc2019-06-14 17:07:06 +01003688requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003689requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003690run_test "Authentication: server goodcert, client optional, no trusted CA" \
3691 "$P_SRV" \
3692 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3693 0 \
3694 -c "x509_verify_cert() returned" \
3695 -c "! The certificate is not correctly signed by the trusted CA" \
3696 -c "! Certificate verification flags"\
3697 -C "! mbedtls_ssl_handshake returned" \
3698 -C "X509 - Certificate verification failed" \
3699 -C "SSL - No CA Chain is set, but required to operate"
3700
Hanno Becker4a156fc2019-06-14 17:07:06 +01003701requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003702requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003703run_test "Authentication: server goodcert, client required, no trusted CA" \
3704 "$P_SRV" \
3705 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3706 1 \
3707 -c "x509_verify_cert() returned" \
3708 -c "! The certificate is not correctly signed by the trusted CA" \
3709 -c "! Certificate verification flags"\
3710 -c "! mbedtls_ssl_handshake returned" \
3711 -c "SSL - No CA Chain is set, but required to operate"
3712
3713# The purpose of the next two tests is to test the client's behaviour when receiving a server
3714# certificate with an unsupported elliptic curve. This should usually not happen because
3715# the client informs the server about the supported curves - it does, though, in the
3716# corner case of a static ECDH suite, because the server doesn't check the curve on that
3717# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3718# different means to have the server ignoring the client's supported curve list.
3719
3720requires_config_enabled MBEDTLS_ECP_C
3721run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3722 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3723 crt_file=data_files/server5.ku-ka.crt" \
3724 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3725 1 \
3726 -c "bad certificate (EC key curve)"\
3727 -c "! Certificate verification flags"\
3728 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3729
3730requires_config_enabled MBEDTLS_ECP_C
3731run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3732 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3733 crt_file=data_files/server5.ku-ka.crt" \
3734 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3735 1 \
3736 -c "bad certificate (EC key curve)"\
3737 -c "! Certificate verification flags"\
3738 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003740run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003741 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003742 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003743 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003744 0 \
3745 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003746 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003747 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003748 -C "X509 - Certificate verification failed"
3749
Simon Butcher99000142016-10-13 17:21:01 +01003750run_test "Authentication: client SHA256, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003751 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003752 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3753 key_file=data_files/server6.key \
3754 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3755 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003756 -c "Supported Signature Algorithm found: 5,"
3757
3758run_test "Authentication: client SHA384, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003759 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003760 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3761 key_file=data_files/server6.key \
3762 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3763 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003764 -c "Supported Signature Algorithm found: 5,"
3765
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003766requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3767run_test "Authentication: client has no cert, server required (SSLv3)" \
3768 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3769 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3770 key_file=data_files/server5.key" \
3771 1 \
3772 -S "skip write certificate request" \
3773 -C "skip parse certificate request" \
3774 -c "got a certificate request" \
3775 -c "got no certificate to send" \
3776 -S "x509_verify_cert() returned" \
3777 -s "client has no certificate" \
3778 -s "! mbedtls_ssl_handshake returned" \
3779 -c "! mbedtls_ssl_handshake returned" \
3780 -s "No client certification received from the client, but required by the authentication mode"
3781
3782run_test "Authentication: client has no cert, server required (TLS)" \
3783 "$P_SRV debug_level=3 auth_mode=required" \
3784 "$P_CLI debug_level=3 crt_file=none \
3785 key_file=data_files/server5.key" \
3786 1 \
3787 -S "skip write certificate request" \
3788 -C "skip parse certificate request" \
3789 -c "got a certificate request" \
3790 -c "= write certificate$" \
3791 -C "skip write certificate$" \
3792 -S "x509_verify_cert() returned" \
3793 -s "client has no certificate" \
3794 -s "! mbedtls_ssl_handshake returned" \
3795 -c "! mbedtls_ssl_handshake returned" \
3796 -s "No client certification received from the client, but required by the authentication mode"
3797
Hanno Becker4a156fc2019-06-14 17:07:06 +01003798requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003799requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003800run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003801 "$P_SRV debug_level=3 auth_mode=required" \
3802 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003803 key_file=data_files/server5.key" \
3804 1 \
3805 -S "skip write certificate request" \
3806 -C "skip parse certificate request" \
3807 -c "got a certificate request" \
3808 -C "skip write certificate" \
3809 -C "skip write certificate verify" \
3810 -S "skip parse certificate verify" \
3811 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003812 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003813 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003814 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003815 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003816 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003817# We don't check that the client receives the alert because it might
3818# detect that its write end of the connection is closed and abort
3819# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003820
Hanno Becker4a156fc2019-06-14 17:07:06 +01003821requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003822requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01003823run_test "Authentication: client cert not trusted, server required" \
3824 "$P_SRV debug_level=3 auth_mode=required" \
3825 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3826 key_file=data_files/server5.key" \
3827 1 \
3828 -S "skip write certificate request" \
3829 -C "skip parse certificate request" \
3830 -c "got a certificate request" \
3831 -C "skip write certificate" \
3832 -C "skip write certificate verify" \
3833 -S "skip parse certificate verify" \
3834 -s "x509_verify_cert() returned" \
3835 -s "! The certificate is not correctly signed by the trusted CA" \
3836 -s "! mbedtls_ssl_handshake returned" \
3837 -c "! mbedtls_ssl_handshake returned" \
3838 -s "X509 - Certificate verification failed"
3839
Hanno Becker4a156fc2019-06-14 17:07:06 +01003840requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003841requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003842run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003843 "$P_SRV debug_level=3 auth_mode=optional" \
3844 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003845 key_file=data_files/server5.key" \
3846 0 \
3847 -S "skip write certificate request" \
3848 -C "skip parse certificate request" \
3849 -c "got a certificate request" \
3850 -C "skip write certificate" \
3851 -C "skip write certificate verify" \
3852 -S "skip parse certificate verify" \
3853 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003854 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003855 -S "! mbedtls_ssl_handshake returned" \
3856 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003857 -S "X509 - Certificate verification failed"
3858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003859run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003860 "$P_SRV debug_level=3 auth_mode=none" \
3861 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003862 key_file=data_files/server5.key" \
3863 0 \
3864 -s "skip write certificate request" \
3865 -C "skip parse certificate request" \
3866 -c "got no certificate request" \
3867 -c "skip write certificate" \
3868 -c "skip write certificate verify" \
3869 -s "skip parse certificate verify" \
3870 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003871 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003872 -S "! mbedtls_ssl_handshake returned" \
3873 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003874 -S "X509 - Certificate verification failed"
3875
Hanno Becker4a156fc2019-06-14 17:07:06 +01003876requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003877requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003878run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003879 "$P_SRV debug_level=3 auth_mode=optional" \
3880 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003881 0 \
3882 -S "skip write certificate request" \
3883 -C "skip parse certificate request" \
3884 -c "got a certificate request" \
3885 -C "skip write certificate$" \
3886 -C "got no certificate to send" \
3887 -S "SSLv3 client has no certificate" \
3888 -c "skip write certificate verify" \
3889 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003890 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003891 -S "! mbedtls_ssl_handshake returned" \
3892 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003893 -S "X509 - Certificate verification failed"
3894
Hanno Becker4a156fc2019-06-14 17:07:06 +01003895requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003896requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003897run_test "Authentication: openssl client no cert, server optional" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003898 "$P_SRV debug_level=3 auth_mode=optional ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003899 "$O_CLI" \
3900 0 \
3901 -S "skip write certificate request" \
3902 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003903 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003904 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003905 -S "X509 - Certificate verification failed"
3906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003907run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003908 "$O_SRV -verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003909 "$P_CLI debug_level=3 crt_file=none key_file=none ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003910 0 \
3911 -C "skip parse certificate request" \
3912 -c "got a certificate request" \
3913 -C "skip write certificate$" \
3914 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003915 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003916
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003917run_test "Authentication: client no cert, openssl server required" \
3918 "$O_SRV -Verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003919 "$P_CLI debug_level=3 crt_file=none key_file=none ca_file=data_files/test-ca2.crt" \
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003920 1 \
3921 -C "skip parse certificate request" \
3922 -c "got a certificate request" \
3923 -C "skip write certificate$" \
3924 -c "skip write certificate verify" \
3925 -c "! mbedtls_ssl_handshake returned"
3926
Janos Follathe2681a42016-03-07 15:57:05 +00003927requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Hanno Beckerb2c63832019-06-17 08:35:16 +01003928requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003929requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003930run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003931 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003932 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003933 0 \
3934 -S "skip write certificate request" \
3935 -C "skip parse certificate request" \
3936 -c "got a certificate request" \
3937 -C "skip write certificate$" \
3938 -c "skip write certificate verify" \
3939 -c "got no certificate to send" \
3940 -s "SSLv3 client has no certificate" \
3941 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003942 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003943 -S "! mbedtls_ssl_handshake returned" \
3944 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003945 -S "X509 - Certificate verification failed"
3946
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02003947# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
3948# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003949
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003950MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01003951MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003952
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003953if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Hanno Beckerab9a29b2019-09-24 16:14:39 +01003954 printf "The configuration file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003955 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003956 printf "test value of ${MAX_IM_CA}. \n"
3957 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003958 printf "The tests assume this value and if it changes, the tests in this\n"
3959 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003960 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003961
3962 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003963fi
3964
Angus Grattonc4dd0732018-04-11 16:28:39 +10003965requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003966run_test "Authentication: server max_int chain, client default" \
3967 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
3968 key_file=data_files/dir-maxpath/09.key" \
3969 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
3970 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003971 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003972
Angus Grattonc4dd0732018-04-11 16:28:39 +10003973requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003974run_test "Authentication: server max_int+1 chain, client default" \
3975 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3976 key_file=data_files/dir-maxpath/10.key" \
3977 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
3978 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003979 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003980
Angus Grattonc4dd0732018-04-11 16:28:39 +10003981requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003982run_test "Authentication: server max_int+1 chain, client optional" \
3983 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3984 key_file=data_files/dir-maxpath/10.key" \
3985 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
3986 auth_mode=optional" \
3987 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003988 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003989
Angus Grattonc4dd0732018-04-11 16:28:39 +10003990requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003991run_test "Authentication: server max_int+1 chain, client none" \
3992 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3993 key_file=data_files/dir-maxpath/10.key" \
3994 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
3995 auth_mode=none" \
3996 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003997 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003998
Angus Grattonc4dd0732018-04-11 16:28:39 +10003999requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004000run_test "Authentication: client max_int+1 chain, server default" \
4001 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4002 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4003 key_file=data_files/dir-maxpath/10.key" \
4004 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004005 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004006
Angus Grattonc4dd0732018-04-11 16:28:39 +10004007requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004008run_test "Authentication: client max_int+1 chain, server optional" \
4009 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4010 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4011 key_file=data_files/dir-maxpath/10.key" \
4012 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004013 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004014
Angus Grattonc4dd0732018-04-11 16:28:39 +10004015requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004016run_test "Authentication: client max_int+1 chain, server required" \
4017 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4018 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4019 key_file=data_files/dir-maxpath/10.key" \
4020 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004021 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004022
Angus Grattonc4dd0732018-04-11 16:28:39 +10004023requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004024run_test "Authentication: client max_int chain, server required" \
4025 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4026 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4027 key_file=data_files/dir-maxpath/09.key" \
4028 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004029 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004030
Janos Follath89baba22017-04-10 14:34:35 +01004031# Tests for CA list in CertificateRequest messages
4032
4033run_test "Authentication: send CA list in CertificateRequest (default)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004034 "$P_SRV debug_level=3 auth_mode=required ca_file=data_files/test-ca2.crt" \
Janos Follath89baba22017-04-10 14:34:35 +01004035 "$P_CLI crt_file=data_files/server6.crt \
4036 key_file=data_files/server6.key" \
4037 0 \
4038 -s "requested DN"
4039
4040run_test "Authentication: do not send CA list in CertificateRequest" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004041 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0 ca_file=data_files/test-ca2.crt" \
Janos Follath89baba22017-04-10 14:34:35 +01004042 "$P_CLI crt_file=data_files/server6.crt \
4043 key_file=data_files/server6.key" \
4044 0 \
4045 -S "requested DN"
4046
Hanno Becker4a156fc2019-06-14 17:07:06 +01004047requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004048requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01004049run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4050 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4051 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4052 key_file=data_files/server5.key" \
4053 1 \
4054 -S "requested DN" \
4055 -s "x509_verify_cert() returned" \
4056 -s "! The certificate is not correctly signed by the trusted CA" \
4057 -s "! mbedtls_ssl_handshake returned" \
4058 -c "! mbedtls_ssl_handshake returned" \
4059 -s "X509 - Certificate verification failed"
4060
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004061# Tests for certificate selection based on SHA verson
4062
Hanno Becker4a156fc2019-06-14 17:07:06 +01004063requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004064requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004065run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4066 "$P_SRV crt_file=data_files/server5.crt \
4067 key_file=data_files/server5.key \
4068 crt_file2=data_files/server5-sha1.crt \
4069 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004070 "$P_CLI force_version=tls1_2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004071 0 \
4072 -c "signed using.*ECDSA with SHA256" \
4073 -C "signed using.*ECDSA with SHA1"
4074
Hanno Becker4a156fc2019-06-14 17:07:06 +01004075requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004076requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004077run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
4078 "$P_SRV crt_file=data_files/server5.crt \
4079 key_file=data_files/server5.key \
4080 crt_file2=data_files/server5-sha1.crt \
4081 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004082 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004083 0 \
4084 -C "signed using.*ECDSA with SHA256" \
4085 -c "signed using.*ECDSA with SHA1"
4086
Hanno Becker4a156fc2019-06-14 17:07:06 +01004087requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004088requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004089run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
4090 "$P_SRV crt_file=data_files/server5.crt \
4091 key_file=data_files/server5.key \
4092 crt_file2=data_files/server5-sha1.crt \
4093 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004094 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004095 0 \
4096 -C "signed using.*ECDSA with SHA256" \
4097 -c "signed using.*ECDSA with SHA1"
4098
Hanno Becker4a156fc2019-06-14 17:07:06 +01004099requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004100requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004101run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4102 "$P_SRV crt_file=data_files/server5.crt \
4103 key_file=data_files/server5.key \
4104 crt_file2=data_files/server6.crt \
4105 key_file2=data_files/server6.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004106 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004107 0 \
4108 -c "serial number.*09" \
4109 -c "signed using.*ECDSA with SHA256" \
4110 -C "signed using.*ECDSA with SHA1"
4111
Hanno Becker4a156fc2019-06-14 17:07:06 +01004112requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004113requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004114run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4115 "$P_SRV crt_file=data_files/server6.crt \
4116 key_file=data_files/server6.key \
4117 crt_file2=data_files/server5.crt \
4118 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004119 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004120 0 \
4121 -c "serial number.*0A" \
4122 -c "signed using.*ECDSA with SHA256" \
4123 -C "signed using.*ECDSA with SHA1"
4124
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004125# tests for SNI
4126
Hanno Becker4a156fc2019-06-14 17:07:06 +01004127requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004128requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004129run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004130 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004131 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004132 "$P_CLI server_name=localhost ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004133 0 \
4134 -S "parse ServerName extension" \
4135 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4136 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004137
Hanno Becker4a156fc2019-06-14 17:07:06 +01004138requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004139requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004140requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004141run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004142 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004143 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004144 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004145 "$P_CLI server_name=localhost ca_file=data_files/test-ca.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004146 0 \
4147 -s "parse ServerName extension" \
4148 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4149 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004150
Hanno Becker4a156fc2019-06-14 17:07:06 +01004151requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004152requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004153requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004154run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004155 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004156 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004157 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 +02004158 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004159 0 \
4160 -s "parse ServerName extension" \
4161 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4162 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004163
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004164requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004165run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004166 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004167 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004168 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 +02004169 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004170 1 \
4171 -s "parse ServerName extension" \
4172 -s "ssl_sni_wrapper() returned" \
4173 -s "mbedtls_ssl_handshake returned" \
4174 -c "mbedtls_ssl_handshake returned" \
4175 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004176
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004177run_test "SNI: client auth no override: optional" \
4178 "$P_SRV debug_level=3 auth_mode=optional \
4179 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4180 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4181 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004182 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004183 -S "skip write certificate request" \
4184 -C "skip parse certificate request" \
4185 -c "got a certificate request" \
4186 -C "skip write certificate" \
4187 -C "skip write certificate verify" \
4188 -S "skip parse certificate verify"
4189
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004190requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004191run_test "SNI: client auth override: none -> optional" \
4192 "$P_SRV debug_level=3 auth_mode=none \
4193 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4194 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4195 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004196 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004197 -S "skip write certificate request" \
4198 -C "skip parse certificate request" \
4199 -c "got a certificate request" \
4200 -C "skip write certificate" \
4201 -C "skip write certificate verify" \
4202 -S "skip parse certificate verify"
4203
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004204requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004205run_test "SNI: client auth override: optional -> none" \
4206 "$P_SRV debug_level=3 auth_mode=optional \
4207 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4208 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4209 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004210 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004211 -s "skip write certificate request" \
4212 -C "skip parse certificate request" \
4213 -c "got no certificate request" \
4214 -c "skip write certificate" \
4215 -c "skip write certificate verify" \
4216 -s "skip parse certificate verify"
4217
Hanno Becker4a156fc2019-06-14 17:07:06 +01004218requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004219requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004220requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004221run_test "SNI: CA no override" \
4222 "$P_SRV debug_level=3 auth_mode=optional \
4223 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4224 ca_file=data_files/test-ca.crt \
4225 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4226 "$P_CLI debug_level=3 server_name=localhost \
4227 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4228 1 \
4229 -S "skip write certificate request" \
4230 -C "skip parse certificate request" \
4231 -c "got a certificate request" \
4232 -C "skip write certificate" \
4233 -C "skip write certificate verify" \
4234 -S "skip parse certificate verify" \
4235 -s "x509_verify_cert() returned" \
4236 -s "! The certificate is not correctly signed by the trusted CA" \
4237 -S "The certificate has been revoked (is on a CRL)"
4238
Hanno Becker4a156fc2019-06-14 17:07:06 +01004239requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004240requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004241requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004242run_test "SNI: CA override" \
4243 "$P_SRV debug_level=3 auth_mode=optional \
4244 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4245 ca_file=data_files/test-ca.crt \
4246 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4247 "$P_CLI debug_level=3 server_name=localhost \
4248 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4249 0 \
4250 -S "skip write certificate request" \
4251 -C "skip parse certificate request" \
4252 -c "got a certificate request" \
4253 -C "skip write certificate" \
4254 -C "skip write certificate verify" \
4255 -S "skip parse certificate verify" \
4256 -S "x509_verify_cert() returned" \
4257 -S "! The certificate is not correctly signed by the trusted CA" \
4258 -S "The certificate has been revoked (is on a CRL)"
4259
Hanno Becker4a156fc2019-06-14 17:07:06 +01004260requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004261requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004262requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004263run_test "SNI: CA override with CRL" \
4264 "$P_SRV debug_level=3 auth_mode=optional \
4265 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4266 ca_file=data_files/test-ca.crt \
4267 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4268 "$P_CLI debug_level=3 server_name=localhost \
4269 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4270 1 \
4271 -S "skip write certificate request" \
4272 -C "skip parse certificate request" \
4273 -c "got a certificate request" \
4274 -C "skip write certificate" \
4275 -C "skip write certificate verify" \
4276 -S "skip parse certificate verify" \
4277 -s "x509_verify_cert() returned" \
4278 -S "! The certificate is not correctly signed by the trusted CA" \
4279 -s "The certificate has been revoked (is on a CRL)"
4280
Andres AG1a834452016-12-07 10:01:30 +00004281# Tests for SNI and DTLS
4282
Hanno Becker4a156fc2019-06-14 17:07:06 +01004283requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004284requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004285run_test "SNI: DTLS, no SNI callback" \
4286 "$P_SRV debug_level=3 dtls=1 \
4287 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004288 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca2.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004289 0 \
4290 -S "parse ServerName extension" \
4291 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4292 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4293
Hanno Becker4a156fc2019-06-14 17:07:06 +01004294requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004295requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004296requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004297run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004298 "$P_SRV debug_level=3 dtls=1 \
4299 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4300 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004301 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca.crt" \
Andres AG1a834452016-12-07 10:01:30 +00004302 0 \
4303 -s "parse ServerName extension" \
4304 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4305 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4306
Hanno Becker4a156fc2019-06-14 17:07:06 +01004307requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004308requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004309requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004310run_test "SNI: DTLS, matching cert 2" \
4311 "$P_SRV debug_level=3 dtls=1 \
4312 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4313 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004314 "$P_CLI server_name=polarssl.example dtls=1 ca_file=data_files/test-ca.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004315 0 \
4316 -s "parse ServerName extension" \
4317 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4318 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4319
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004320requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004321run_test "SNI: DTLS, no matching cert" \
4322 "$P_SRV debug_level=3 dtls=1 \
4323 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4324 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4325 "$P_CLI server_name=nonesuch.example dtls=1" \
4326 1 \
4327 -s "parse ServerName extension" \
4328 -s "ssl_sni_wrapper() returned" \
4329 -s "mbedtls_ssl_handshake returned" \
4330 -c "mbedtls_ssl_handshake returned" \
4331 -c "SSL - A fatal alert message was received from our peer"
4332
4333run_test "SNI: DTLS, client auth no override: optional" \
4334 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4335 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4336 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4337 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4338 0 \
4339 -S "skip write certificate request" \
4340 -C "skip parse certificate request" \
4341 -c "got a certificate request" \
4342 -C "skip write certificate" \
4343 -C "skip write certificate verify" \
4344 -S "skip parse certificate verify"
4345
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004346requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004347run_test "SNI: DTLS, client auth override: none -> optional" \
4348 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4349 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4350 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4351 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4352 0 \
4353 -S "skip write certificate request" \
4354 -C "skip parse certificate request" \
4355 -c "got a certificate request" \
4356 -C "skip write certificate" \
4357 -C "skip write certificate verify" \
4358 -S "skip parse certificate verify"
4359
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004360requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004361run_test "SNI: DTLS, client auth override: optional -> none" \
4362 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4363 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4364 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4365 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4366 0 \
4367 -s "skip write certificate request" \
4368 -C "skip parse certificate request" \
4369 -c "got no certificate request" \
4370 -c "skip write certificate" \
4371 -c "skip write certificate verify" \
4372 -s "skip parse certificate verify"
4373
Hanno Becker4a156fc2019-06-14 17:07:06 +01004374requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004375requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004376requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004377run_test "SNI: DTLS, CA no override" \
4378 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4379 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4380 ca_file=data_files/test-ca.crt \
4381 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4382 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4383 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4384 1 \
4385 -S "skip write certificate request" \
4386 -C "skip parse certificate request" \
4387 -c "got a certificate request" \
4388 -C "skip write certificate" \
4389 -C "skip write certificate verify" \
4390 -S "skip parse certificate verify" \
4391 -s "x509_verify_cert() returned" \
4392 -s "! The certificate is not correctly signed by the trusted CA" \
4393 -S "The certificate has been revoked (is on a CRL)"
4394
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004395requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004396run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004397 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4398 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4399 ca_file=data_files/test-ca.crt \
4400 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4401 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4402 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4403 0 \
4404 -S "skip write certificate request" \
4405 -C "skip parse certificate request" \
4406 -c "got a certificate request" \
4407 -C "skip write certificate" \
4408 -C "skip write certificate verify" \
4409 -S "skip parse certificate verify" \
4410 -S "x509_verify_cert() returned" \
4411 -S "! The certificate is not correctly signed by the trusted CA" \
4412 -S "The certificate has been revoked (is on a CRL)"
4413
Hanno Becker4a156fc2019-06-14 17:07:06 +01004414requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004415requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004416requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004417run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004418 "$P_SRV debug_level=3 auth_mode=optional \
4419 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4420 ca_file=data_files/test-ca.crt \
4421 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4422 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4423 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4424 1 \
4425 -S "skip write certificate request" \
4426 -C "skip parse certificate request" \
4427 -c "got a certificate request" \
4428 -C "skip write certificate" \
4429 -C "skip write certificate verify" \
4430 -S "skip parse certificate verify" \
4431 -s "x509_verify_cert() returned" \
4432 -S "! The certificate is not correctly signed by the trusted CA" \
4433 -s "The certificate has been revoked (is on a CRL)"
4434
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004435# Tests for non-blocking I/O: exercise a variety of handshake flows
4436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004437run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004438 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4439 "$P_CLI nbio=2 tickets=0" \
4440 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004441 -S "mbedtls_ssl_handshake returned" \
4442 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004443 -c "Read from server: .* bytes read"
4444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004445run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004446 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4447 "$P_CLI nbio=2 tickets=0" \
4448 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004449 -S "mbedtls_ssl_handshake returned" \
4450 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004451 -c "Read from server: .* bytes read"
4452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004453run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004454 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4455 "$P_CLI nbio=2 tickets=1" \
4456 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004457 -S "mbedtls_ssl_handshake returned" \
4458 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004459 -c "Read from server: .* bytes read"
4460
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004461run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004462 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4463 "$P_CLI nbio=2 tickets=1" \
4464 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004465 -S "mbedtls_ssl_handshake returned" \
4466 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004467 -c "Read from server: .* bytes read"
4468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004469run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004470 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4471 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4472 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004473 -S "mbedtls_ssl_handshake returned" \
4474 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004475 -c "Read from server: .* bytes read"
4476
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004477run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004478 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4479 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4480 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004481 -S "mbedtls_ssl_handshake returned" \
4482 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004483 -c "Read from server: .* bytes read"
4484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004485run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004486 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4487 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4488 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004489 -S "mbedtls_ssl_handshake returned" \
4490 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004491 -c "Read from server: .* bytes read"
4492
Hanno Becker00076712017-11-15 16:39:08 +00004493# Tests for event-driven I/O: exercise a variety of handshake flows
4494
4495run_test "Event-driven I/O: basic handshake" \
4496 "$P_SRV event=1 tickets=0 auth_mode=none" \
4497 "$P_CLI event=1 tickets=0" \
4498 0 \
4499 -S "mbedtls_ssl_handshake returned" \
4500 -C "mbedtls_ssl_handshake returned" \
4501 -c "Read from server: .* bytes read"
4502
4503run_test "Event-driven I/O: client auth" \
4504 "$P_SRV event=1 tickets=0 auth_mode=required" \
4505 "$P_CLI event=1 tickets=0" \
4506 0 \
4507 -S "mbedtls_ssl_handshake returned" \
4508 -C "mbedtls_ssl_handshake returned" \
4509 -c "Read from server: .* bytes read"
4510
4511run_test "Event-driven I/O: ticket" \
4512 "$P_SRV event=1 tickets=1 auth_mode=none" \
4513 "$P_CLI event=1 tickets=1" \
4514 0 \
4515 -S "mbedtls_ssl_handshake returned" \
4516 -C "mbedtls_ssl_handshake returned" \
4517 -c "Read from server: .* bytes read"
4518
4519run_test "Event-driven I/O: ticket + client auth" \
4520 "$P_SRV event=1 tickets=1 auth_mode=required" \
4521 "$P_CLI event=1 tickets=1" \
4522 0 \
4523 -S "mbedtls_ssl_handshake returned" \
4524 -C "mbedtls_ssl_handshake returned" \
4525 -c "Read from server: .* bytes read"
4526
4527run_test "Event-driven I/O: ticket + client auth + resume" \
4528 "$P_SRV event=1 tickets=1 auth_mode=required" \
4529 "$P_CLI event=1 tickets=1 reconnect=1" \
4530 0 \
4531 -S "mbedtls_ssl_handshake returned" \
4532 -C "mbedtls_ssl_handshake returned" \
4533 -c "Read from server: .* bytes read"
4534
4535run_test "Event-driven I/O: ticket + resume" \
4536 "$P_SRV event=1 tickets=1 auth_mode=none" \
4537 "$P_CLI event=1 tickets=1 reconnect=1" \
4538 0 \
4539 -S "mbedtls_ssl_handshake returned" \
4540 -C "mbedtls_ssl_handshake returned" \
4541 -c "Read from server: .* bytes read"
4542
4543run_test "Event-driven I/O: session-id resume" \
4544 "$P_SRV event=1 tickets=0 auth_mode=none" \
4545 "$P_CLI event=1 tickets=0 reconnect=1" \
4546 0 \
4547 -S "mbedtls_ssl_handshake returned" \
4548 -C "mbedtls_ssl_handshake returned" \
4549 -c "Read from server: .* bytes read"
4550
Hanno Becker6a33f592018-03-13 11:38:46 +00004551run_test "Event-driven I/O, DTLS: basic handshake" \
4552 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4553 "$P_CLI dtls=1 event=1 tickets=0" \
4554 0 \
4555 -c "Read from server: .* bytes read"
4556
4557run_test "Event-driven I/O, DTLS: client auth" \
4558 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4559 "$P_CLI dtls=1 event=1 tickets=0" \
4560 0 \
4561 -c "Read from server: .* bytes read"
4562
4563run_test "Event-driven I/O, DTLS: ticket" \
4564 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4565 "$P_CLI dtls=1 event=1 tickets=1" \
4566 0 \
4567 -c "Read from server: .* bytes read"
4568
4569run_test "Event-driven I/O, DTLS: ticket + client auth" \
4570 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4571 "$P_CLI dtls=1 event=1 tickets=1" \
4572 0 \
4573 -c "Read from server: .* bytes read"
4574
4575run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4576 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4577 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4578 0 \
4579 -c "Read from server: .* bytes read"
4580
4581run_test "Event-driven I/O, DTLS: ticket + resume" \
4582 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4583 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4584 0 \
4585 -c "Read from server: .* bytes read"
4586
4587run_test "Event-driven I/O, DTLS: session-id resume" \
4588 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4589 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4590 0 \
4591 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004592
4593# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4594# During session resumption, the client will send its ApplicationData record
4595# within the same datagram as the Finished messages. In this situation, the
4596# server MUST NOT idle on the underlying transport after handshake completion,
4597# because the ApplicationData request has already been queued internally.
4598run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004599 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004600 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4601 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4602 0 \
4603 -c "Read from server: .* bytes read"
4604
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004605# Tests for version negotiation
4606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004607run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004608 "$P_SRV" \
4609 "$P_CLI" \
4610 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004611 -S "mbedtls_ssl_handshake returned" \
4612 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004613 -s "Protocol is TLSv1.2" \
4614 -c "Protocol is TLSv1.2"
4615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004616run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004617 "$P_SRV" \
4618 "$P_CLI max_version=tls1_1" \
4619 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004620 -S "mbedtls_ssl_handshake returned" \
4621 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004622 -s "Protocol is TLSv1.1" \
4623 -c "Protocol is TLSv1.1"
4624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004625run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004626 "$P_SRV max_version=tls1_1" \
4627 "$P_CLI" \
4628 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004629 -S "mbedtls_ssl_handshake returned" \
4630 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004631 -s "Protocol is TLSv1.1" \
4632 -c "Protocol is TLSv1.1"
4633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004634run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004635 "$P_SRV max_version=tls1_1" \
4636 "$P_CLI max_version=tls1_1" \
4637 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004638 -S "mbedtls_ssl_handshake returned" \
4639 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004640 -s "Protocol is TLSv1.1" \
4641 -c "Protocol is TLSv1.1"
4642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004643run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004644 "$P_SRV min_version=tls1_1" \
4645 "$P_CLI max_version=tls1_1" \
4646 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004647 -S "mbedtls_ssl_handshake returned" \
4648 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004649 -s "Protocol is TLSv1.1" \
4650 -c "Protocol is TLSv1.1"
4651
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004652run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004653 "$P_SRV max_version=tls1_1" \
4654 "$P_CLI min_version=tls1_1" \
4655 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004656 -S "mbedtls_ssl_handshake returned" \
4657 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004658 -s "Protocol is TLSv1.1" \
4659 -c "Protocol is TLSv1.1"
4660
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004661run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004662 "$P_SRV max_version=tls1_1" \
4663 "$P_CLI min_version=tls1_2" \
4664 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004665 -s "mbedtls_ssl_handshake returned" \
4666 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004667 -c "SSL - Handshake protocol not within min/max boundaries"
4668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004669run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004670 "$P_SRV min_version=tls1_2" \
4671 "$P_CLI max_version=tls1_1" \
4672 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004673 -s "mbedtls_ssl_handshake returned" \
4674 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004675 -s "SSL - Handshake protocol not within min/max boundaries"
4676
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004677# Tests for ALPN extension
4678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004679run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004680 "$P_SRV debug_level=3" \
4681 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004682 0 \
4683 -C "client hello, adding alpn extension" \
4684 -S "found alpn extension" \
4685 -C "got an alert message, type: \\[2:120]" \
4686 -S "server hello, adding alpn extension" \
4687 -C "found alpn extension " \
4688 -C "Application Layer Protocol is" \
4689 -S "Application Layer Protocol is"
4690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004691run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004692 "$P_SRV debug_level=3" \
4693 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004694 0 \
4695 -c "client hello, adding alpn extension" \
4696 -s "found alpn extension" \
4697 -C "got an alert message, type: \\[2:120]" \
4698 -S "server hello, adding alpn extension" \
4699 -C "found alpn extension " \
4700 -c "Application Layer Protocol is (none)" \
4701 -S "Application Layer Protocol is"
4702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004703run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004704 "$P_SRV debug_level=3 alpn=abc,1234" \
4705 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004706 0 \
4707 -C "client hello, adding alpn extension" \
4708 -S "found alpn extension" \
4709 -C "got an alert message, type: \\[2:120]" \
4710 -S "server hello, adding alpn extension" \
4711 -C "found alpn extension " \
4712 -C "Application Layer Protocol is" \
4713 -s "Application Layer Protocol is (none)"
4714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004715run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004716 "$P_SRV debug_level=3 alpn=abc,1234" \
4717 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004718 0 \
4719 -c "client hello, adding alpn extension" \
4720 -s "found alpn extension" \
4721 -C "got an alert message, type: \\[2:120]" \
4722 -s "server hello, adding alpn extension" \
4723 -c "found alpn extension" \
4724 -c "Application Layer Protocol is abc" \
4725 -s "Application Layer Protocol is abc"
4726
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004727run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004728 "$P_SRV debug_level=3 alpn=abc,1234" \
4729 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004730 0 \
4731 -c "client hello, adding alpn extension" \
4732 -s "found alpn extension" \
4733 -C "got an alert message, type: \\[2:120]" \
4734 -s "server hello, adding alpn extension" \
4735 -c "found alpn extension" \
4736 -c "Application Layer Protocol is abc" \
4737 -s "Application Layer Protocol is abc"
4738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004739run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004740 "$P_SRV debug_level=3 alpn=abc,1234" \
4741 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004742 0 \
4743 -c "client hello, adding alpn extension" \
4744 -s "found alpn extension" \
4745 -C "got an alert message, type: \\[2:120]" \
4746 -s "server hello, adding alpn extension" \
4747 -c "found alpn extension" \
4748 -c "Application Layer Protocol is 1234" \
4749 -s "Application Layer Protocol is 1234"
4750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004751run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004752 "$P_SRV debug_level=3 alpn=abc,123" \
4753 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004754 1 \
4755 -c "client hello, adding alpn extension" \
4756 -s "found alpn extension" \
4757 -c "got an alert message, type: \\[2:120]" \
4758 -S "server hello, adding alpn extension" \
4759 -C "found alpn extension" \
4760 -C "Application Layer Protocol is 1234" \
4761 -S "Application Layer Protocol is 1234"
4762
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02004763
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004764# Tests for keyUsage in leaf certificates, part 1:
4765# server-side certificate/suite selection
4766
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004767run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004768 "$P_SRV key_file=data_files/server2.key \
4769 crt_file=data_files/server2.ku-ds.crt" \
4770 "$P_CLI" \
4771 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02004772 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004773
4774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004775run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004776 "$P_SRV key_file=data_files/server2.key \
4777 crt_file=data_files/server2.ku-ke.crt" \
4778 "$P_CLI" \
4779 0 \
4780 -c "Ciphersuite is TLS-RSA-WITH-"
4781
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004782run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004783 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004784 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004785 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004786 1 \
4787 -C "Ciphersuite is "
4788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004789run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004790 "$P_SRV key_file=data_files/server5.key \
4791 crt_file=data_files/server5.ku-ds.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004792 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004793 0 \
4794 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
4795
4796
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004797run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004798 "$P_SRV key_file=data_files/server5.key \
4799 crt_file=data_files/server5.ku-ka.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004800 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004801 0 \
4802 -c "Ciphersuite is TLS-ECDH-"
4803
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004804run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004805 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004806 crt_file=data_files/server5.ku-ke.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004807 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004808 1 \
4809 -C "Ciphersuite is "
4810
4811# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004812# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004814run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004815 "$O_SRV -key data_files/server2.key \
4816 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004817 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004818 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4819 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004820 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004821 -C "Processing of the Certificate handshake message failed" \
4822 -c "Ciphersuite is TLS-"
4823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004824run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004825 "$O_SRV -key data_files/server2.key \
4826 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004827 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004828 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4829 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004830 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004831 -C "Processing of the Certificate handshake message failed" \
4832 -c "Ciphersuite is TLS-"
4833
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004834run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004835 "$O_SRV -key data_files/server2.key \
4836 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004837 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004838 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4839 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004840 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004841 -C "Processing of the Certificate handshake message failed" \
4842 -c "Ciphersuite is TLS-"
4843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004844run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004845 "$O_SRV -key data_files/server2.key \
4846 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004847 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004848 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4849 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004850 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004851 -c "Processing of the Certificate handshake message failed" \
4852 -C "Ciphersuite is TLS-"
4853
Hanno Becker4a156fc2019-06-14 17:07:06 +01004854requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004855requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004856run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
4857 "$O_SRV -key data_files/server2.key \
4858 -cert data_files/server2.ku-ke.crt" \
4859 "$P_CLI debug_level=1 auth_mode=optional \
4860 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4861 0 \
4862 -c "bad certificate (usage extensions)" \
4863 -C "Processing of the Certificate handshake message failed" \
4864 -c "Ciphersuite is TLS-" \
4865 -c "! Usage does not match the keyUsage extension"
4866
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004867run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004868 "$O_SRV -key data_files/server2.key \
4869 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004870 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004871 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4872 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004873 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004874 -C "Processing of the Certificate handshake message failed" \
4875 -c "Ciphersuite is TLS-"
4876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004877run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004878 "$O_SRV -key data_files/server2.key \
4879 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004880 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004881 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4882 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004883 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004884 -c "Processing of the Certificate handshake message failed" \
4885 -C "Ciphersuite is TLS-"
4886
Hanno Becker4a156fc2019-06-14 17:07:06 +01004887requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004888requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004889run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
4890 "$O_SRV -key data_files/server2.key \
4891 -cert data_files/server2.ku-ds.crt" \
4892 "$P_CLI debug_level=1 auth_mode=optional \
4893 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4894 0 \
4895 -c "bad certificate (usage extensions)" \
4896 -C "Processing of the Certificate handshake message failed" \
4897 -c "Ciphersuite is TLS-" \
4898 -c "! Usage does not match the keyUsage extension"
4899
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004900# Tests for keyUsage in leaf certificates, part 3:
4901# server-side checking of client cert
4902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004903run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004904 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004905 "$O_CLI -key data_files/server2.key \
4906 -cert data_files/server2.ku-ds.crt" \
4907 0 \
4908 -S "bad certificate (usage extensions)" \
4909 -S "Processing of the Certificate handshake message failed"
4910
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004911run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004912 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004913 "$O_CLI -key data_files/server2.key \
4914 -cert data_files/server2.ku-ke.crt" \
4915 0 \
4916 -s "bad certificate (usage extensions)" \
4917 -S "Processing of the Certificate handshake message failed"
4918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004919run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004920 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004921 "$O_CLI -key data_files/server2.key \
4922 -cert data_files/server2.ku-ke.crt" \
4923 1 \
4924 -s "bad certificate (usage extensions)" \
4925 -s "Processing of the Certificate handshake message failed"
4926
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004927run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004928 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004929 "$O_CLI -key data_files/server5.key \
4930 -cert data_files/server5.ku-ds.crt" \
4931 0 \
4932 -S "bad certificate (usage extensions)" \
4933 -S "Processing of the Certificate handshake message failed"
4934
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004935run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004936 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004937 "$O_CLI -key data_files/server5.key \
4938 -cert data_files/server5.ku-ka.crt" \
4939 0 \
4940 -s "bad certificate (usage extensions)" \
4941 -S "Processing of the Certificate handshake message failed"
4942
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004943# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
4944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004945run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004946 "$P_SRV key_file=data_files/server5.key \
4947 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004948 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004949 0
4950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004951run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004952 "$P_SRV key_file=data_files/server5.key \
4953 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004954 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004955 0
4956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004957run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004958 "$P_SRV key_file=data_files/server5.key \
4959 crt_file=data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004960 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004961 0
4962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004963run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02004964 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004965 crt_file=data_files/server5.eku-cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004966 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004967 1
4968
4969# Tests for extendedKeyUsage, part 2: client-side checking of server cert
4970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004971run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004972 "$O_SRV -key data_files/server5.key \
4973 -cert data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004974 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004975 0 \
4976 -C "bad certificate (usage extensions)" \
4977 -C "Processing of the Certificate handshake message failed" \
4978 -c "Ciphersuite is TLS-"
4979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004980run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004981 "$O_SRV -key data_files/server5.key \
4982 -cert data_files/server5.eku-srv_cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004983 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004984 0 \
4985 -C "bad certificate (usage extensions)" \
4986 -C "Processing of the Certificate handshake message failed" \
4987 -c "Ciphersuite is TLS-"
4988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004989run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004990 "$O_SRV -key data_files/server5.key \
4991 -cert data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004992 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004993 0 \
4994 -C "bad certificate (usage extensions)" \
4995 -C "Processing of the Certificate handshake message failed" \
4996 -c "Ciphersuite is TLS-"
4997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004998run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004999 "$O_SRV -key data_files/server5.key \
5000 -cert data_files/server5.eku-cs.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005001 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005002 1 \
5003 -c "bad certificate (usage extensions)" \
5004 -c "Processing of the Certificate handshake message failed" \
5005 -C "Ciphersuite is TLS-"
5006
5007# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5008
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005009run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005010 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005011 "$O_CLI -key data_files/server5.key \
5012 -cert data_files/server5.eku-cli.crt" \
5013 0 \
5014 -S "bad certificate (usage extensions)" \
5015 -S "Processing of the Certificate handshake message failed"
5016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005017run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005018 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005019 "$O_CLI -key data_files/server5.key \
5020 -cert data_files/server5.eku-srv_cli.crt" \
5021 0 \
5022 -S "bad certificate (usage extensions)" \
5023 -S "Processing of the Certificate handshake message failed"
5024
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005025run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005026 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005027 "$O_CLI -key data_files/server5.key \
5028 -cert data_files/server5.eku-cs_any.crt" \
5029 0 \
5030 -S "bad certificate (usage extensions)" \
5031 -S "Processing of the Certificate handshake message failed"
5032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005033run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005034 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005035 "$O_CLI -key data_files/server5.key \
5036 -cert data_files/server5.eku-cs.crt" \
5037 0 \
5038 -s "bad certificate (usage extensions)" \
5039 -S "Processing of the Certificate handshake message failed"
5040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005041run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005042 "$P_SRV debug_level=1 auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005043 "$O_CLI -key data_files/server5.key \
5044 -cert data_files/server5.eku-cs.crt" \
5045 1 \
5046 -s "bad certificate (usage extensions)" \
5047 -s "Processing of the Certificate handshake message failed"
5048
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005049# Tests for DHM parameters loading
5050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005051run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005052 "$P_SRV" \
5053 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5054 debug_level=3" \
5055 0 \
5056 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005057 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005059run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005060 "$P_SRV dhm_file=data_files/dhparams.pem" \
5061 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5062 debug_level=3" \
5063 0 \
5064 -c "value of 'DHM: P ' (1024 bits)" \
5065 -c "value of 'DHM: G ' (2 bits)"
5066
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005067# Tests for DHM client-side size checking
5068
5069run_test "DHM size: server default, client default, OK" \
5070 "$P_SRV" \
5071 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5072 debug_level=1" \
5073 0 \
5074 -C "DHM prime too short:"
5075
5076run_test "DHM size: server default, client 2048, OK" \
5077 "$P_SRV" \
5078 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5079 debug_level=1 dhmlen=2048" \
5080 0 \
5081 -C "DHM prime too short:"
5082
5083run_test "DHM size: server 1024, client default, OK" \
5084 "$P_SRV dhm_file=data_files/dhparams.pem" \
5085 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5086 debug_level=1" \
5087 0 \
5088 -C "DHM prime too short:"
5089
5090run_test "DHM size: server 1000, client default, rejected" \
5091 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5092 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5093 debug_level=1" \
5094 1 \
5095 -c "DHM prime too short:"
5096
5097run_test "DHM size: server default, client 2049, rejected" \
5098 "$P_SRV" \
5099 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5100 debug_level=1 dhmlen=2049" \
5101 1 \
5102 -c "DHM prime too short:"
5103
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005104# Tests for PSK callback
5105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005106run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005107 "$P_SRV psk=abc123 psk_identity=foo" \
5108 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5109 psk_identity=foo psk=abc123" \
5110 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005111 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005112 -S "SSL - Unknown identity received" \
5113 -S "SSL - Verification of the message MAC failed"
5114
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005115run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005116 "$P_SRV" \
5117 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5118 psk_identity=foo psk=abc123" \
5119 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005120 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005121 -S "SSL - Unknown identity received" \
5122 -S "SSL - Verification of the message MAC failed"
5123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005124run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005125 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5126 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5127 psk_identity=foo psk=abc123" \
5128 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005129 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005130 -s "SSL - Unknown identity received" \
5131 -S "SSL - Verification of the message MAC failed"
5132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005133run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005134 "$P_SRV psk_list=abc,dead,def,beef" \
5135 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5136 psk_identity=abc psk=dead" \
5137 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005138 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005139 -S "SSL - Unknown identity received" \
5140 -S "SSL - Verification of the message MAC failed"
5141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005142run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005143 "$P_SRV psk_list=abc,dead,def,beef" \
5144 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5145 psk_identity=def psk=beef" \
5146 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005147 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005148 -S "SSL - Unknown identity received" \
5149 -S "SSL - Verification of the message MAC failed"
5150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005151run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005152 "$P_SRV psk_list=abc,dead,def,beef" \
5153 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5154 psk_identity=ghi psk=beef" \
5155 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005156 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005157 -s "SSL - Unknown identity received" \
5158 -S "SSL - Verification of the message MAC failed"
5159
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005160run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005161 "$P_SRV psk_list=abc,dead,def,beef" \
5162 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5163 psk_identity=abc psk=beef" \
5164 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005165 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005166 -S "SSL - Unknown identity received" \
5167 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005168
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005169# Tests for EC J-PAKE
5170
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005171requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005172run_test "ECJPAKE: client not configured" \
5173 "$P_SRV debug_level=3" \
5174 "$P_CLI debug_level=3" \
5175 0 \
5176 -C "add ciphersuite: c0ff" \
5177 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005178 -S "found ecjpake kkpp extension" \
5179 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005180 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005181 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005182 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005183 -S "None of the common ciphersuites is usable"
5184
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005185requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005186run_test "ECJPAKE: server not configured" \
5187 "$P_SRV debug_level=3" \
5188 "$P_CLI debug_level=3 ecjpake_pw=bla \
5189 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5190 1 \
5191 -c "add ciphersuite: c0ff" \
5192 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005193 -s "found ecjpake kkpp extension" \
5194 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005195 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005196 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005197 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005198 -s "None of the common ciphersuites is usable"
5199
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005200requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005201run_test "ECJPAKE: working, TLS" \
5202 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5203 "$P_CLI debug_level=3 ecjpake_pw=bla \
5204 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005205 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005206 -c "add ciphersuite: c0ff" \
5207 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005208 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005209 -s "found ecjpake kkpp extension" \
5210 -S "skip ecjpake kkpp extension" \
5211 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005212 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005213 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005214 -S "None of the common ciphersuites is usable" \
5215 -S "SSL - Verification of the message MAC failed"
5216
Janos Follath74537a62016-09-02 13:45:28 +01005217server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005218requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005219run_test "ECJPAKE: password mismatch, TLS" \
5220 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5221 "$P_CLI debug_level=3 ecjpake_pw=bad \
5222 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5223 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005224 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005225 -s "SSL - Verification of the message MAC failed"
5226
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005227requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005228run_test "ECJPAKE: working, DTLS" \
5229 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5230 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5231 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5232 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005233 -c "re-using cached ecjpake parameters" \
5234 -S "SSL - Verification of the message MAC failed"
5235
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005236requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005237run_test "ECJPAKE: working, DTLS, no cookie" \
5238 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5239 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5240 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5241 0 \
5242 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005243 -S "SSL - Verification of the message MAC failed"
5244
Janos Follath74537a62016-09-02 13:45:28 +01005245server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005246requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005247run_test "ECJPAKE: password mismatch, DTLS" \
5248 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5249 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5250 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5251 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005252 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005253 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005254
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005255# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005256requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005257run_test "ECJPAKE: working, DTLS, nolog" \
5258 "$P_SRV dtls=1 ecjpake_pw=bla" \
5259 "$P_CLI dtls=1 ecjpake_pw=bla \
5260 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5261 0
5262
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005263# Tests for ciphersuites per version
5264
Janos Follathe2681a42016-03-07 15:57:05 +00005265requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005266requires_config_enabled MBEDTLS_CAMELLIA_C
5267requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005268run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005269 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005270 "$P_CLI force_version=ssl3" \
5271 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005272 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005273
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005274requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5275requires_config_enabled MBEDTLS_CAMELLIA_C
5276requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005277run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005278 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01005279 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005280 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005281 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005282
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005283requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5284requires_config_enabled MBEDTLS_CAMELLIA_C
5285requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005286run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005287 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005288 "$P_CLI force_version=tls1_1" \
5289 0 \
5290 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5291
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005292requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5293requires_config_enabled MBEDTLS_CAMELLIA_C
5294requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005295run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005296 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005297 "$P_CLI force_version=tls1_2" \
5298 0 \
5299 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5300
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005301# Test for ClientHello without extensions
5302
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005303requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005304run_test "ClientHello without extensions, SHA-1 allowed" \
Ron Eldorb76e7652019-01-16 23:14:41 +02005305 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02005306 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005307 0 \
5308 -s "dumping 'client hello extensions' (0 bytes)"
5309
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005310requires_gnutls
5311run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
5312 "$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 +02005313 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005314 0 \
5315 -s "dumping 'client hello extensions' (0 bytes)"
5316
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005317# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005318
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005319run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005320 "$P_SRV" \
5321 "$P_CLI request_size=100" \
5322 0 \
5323 -s "Read from client: 100 bytes read$"
5324
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005325run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005326 "$P_SRV" \
5327 "$P_CLI request_size=500" \
5328 0 \
5329 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005330
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005331# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005332
Janos Follathe2681a42016-03-07 15:57:05 +00005333requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005334run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005335 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005336 "$P_CLI request_size=1 force_version=ssl3 \
5337 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5338 0 \
5339 -s "Read from client: 1 bytes read"
5340
Janos Follathe2681a42016-03-07 15:57:05 +00005341requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005342run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005343 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005344 "$P_CLI request_size=1 force_version=ssl3 \
5345 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5346 0 \
5347 -s "Read from client: 1 bytes read"
5348
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005349run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005350 "$P_SRV" \
5351 "$P_CLI request_size=1 force_version=tls1 \
5352 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5353 0 \
5354 -s "Read from client: 1 bytes read"
5355
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005356run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005357 "$P_SRV" \
5358 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5359 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5360 0 \
5361 -s "Read from client: 1 bytes read"
5362
Hanno Becker32c55012017-11-10 08:42:54 +00005363requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005364run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005365 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005366 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005367 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005368 0 \
5369 -s "Read from client: 1 bytes read"
5370
Hanno Becker32c55012017-11-10 08:42:54 +00005371requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005372run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005373 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005374 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005375 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005376 0 \
5377 -s "Read from client: 1 bytes read"
5378
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005379run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005380 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005381 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005382 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5383 0 \
5384 -s "Read from client: 1 bytes read"
5385
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005386run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005387 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5388 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005389 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005390 0 \
5391 -s "Read from client: 1 bytes read"
5392
5393requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005394run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005395 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005396 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005397 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005398 0 \
5399 -s "Read from client: 1 bytes read"
5400
Hanno Becker8501f982017-11-10 08:59:04 +00005401requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005402run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005403 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5404 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5405 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005406 0 \
5407 -s "Read from client: 1 bytes read"
5408
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005409run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005410 "$P_SRV" \
5411 "$P_CLI request_size=1 force_version=tls1_1 \
5412 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5413 0 \
5414 -s "Read from client: 1 bytes read"
5415
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005416run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005417 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005418 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005419 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005420 0 \
5421 -s "Read from client: 1 bytes read"
5422
5423requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005424run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005425 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005426 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005427 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005428 0 \
5429 -s "Read from client: 1 bytes read"
5430
5431requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005432run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005433 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005434 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005435 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005436 0 \
5437 -s "Read from client: 1 bytes read"
5438
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005439run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005440 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005441 "$P_CLI request_size=1 force_version=tls1_1 \
5442 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5443 0 \
5444 -s "Read from client: 1 bytes read"
5445
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005446run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005447 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005448 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005449 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005450 0 \
5451 -s "Read from client: 1 bytes read"
5452
Hanno Becker8501f982017-11-10 08:59:04 +00005453requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005454run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005455 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005456 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005457 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005458 0 \
5459 -s "Read from client: 1 bytes read"
5460
Hanno Becker32c55012017-11-10 08:42:54 +00005461requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005462run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005463 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005464 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005465 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005466 0 \
5467 -s "Read from client: 1 bytes read"
5468
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005469run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005470 "$P_SRV" \
5471 "$P_CLI request_size=1 force_version=tls1_2 \
5472 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5473 0 \
5474 -s "Read from client: 1 bytes read"
5475
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005476run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005477 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005478 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005479 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005480 0 \
5481 -s "Read from client: 1 bytes read"
5482
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005483run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005484 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005485 "$P_CLI request_size=1 force_version=tls1_2 \
5486 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005487 0 \
5488 -s "Read from client: 1 bytes read"
5489
Hanno Becker32c55012017-11-10 08:42:54 +00005490requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005491run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005492 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005493 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005494 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005495 0 \
5496 -s "Read from client: 1 bytes read"
5497
Hanno Becker8501f982017-11-10 08:59:04 +00005498requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005499run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005500 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005501 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005502 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005503 0 \
5504 -s "Read from client: 1 bytes read"
5505
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005506run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005507 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005508 "$P_CLI request_size=1 force_version=tls1_2 \
5509 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5510 0 \
5511 -s "Read from client: 1 bytes read"
5512
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005513run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005514 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005515 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005516 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005517 0 \
5518 -s "Read from client: 1 bytes read"
5519
Hanno Becker32c55012017-11-10 08:42:54 +00005520requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005521run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005522 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005523 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005524 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005525 0 \
5526 -s "Read from client: 1 bytes read"
5527
Hanno Becker8501f982017-11-10 08:59:04 +00005528requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005529run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005530 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005531 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005532 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005533 0 \
5534 -s "Read from client: 1 bytes read"
5535
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005536run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005537 "$P_SRV" \
5538 "$P_CLI request_size=1 force_version=tls1_2 \
5539 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5540 0 \
5541 -s "Read from client: 1 bytes read"
5542
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005543run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005544 "$P_SRV" \
5545 "$P_CLI request_size=1 force_version=tls1_2 \
5546 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5547 0 \
5548 -s "Read from client: 1 bytes read"
5549
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005550# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00005551
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005552run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005553 "$P_SRV dtls=1 force_version=dtls1" \
5554 "$P_CLI dtls=1 request_size=1 \
5555 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5556 0 \
5557 -s "Read from client: 1 bytes read"
5558
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005559run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00005560 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
5561 "$P_CLI dtls=1 request_size=1 \
5562 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5563 0 \
5564 -s "Read from client: 1 bytes read"
5565
Hanno Beckere2148042017-11-10 08:59:18 +00005566requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005567run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005568 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
5569 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00005570 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5571 0 \
5572 -s "Read from client: 1 bytes read"
5573
Hanno Beckere2148042017-11-10 08:59:18 +00005574requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005575run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005576 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005577 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005578 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005579 0 \
5580 -s "Read from client: 1 bytes read"
5581
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005582run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00005583 "$P_SRV dtls=1 force_version=dtls1_2" \
5584 "$P_CLI dtls=1 request_size=1 \
5585 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5586 0 \
5587 -s "Read from client: 1 bytes read"
5588
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005589run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005590 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005591 "$P_CLI dtls=1 request_size=1 \
5592 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5593 0 \
5594 -s "Read from client: 1 bytes read"
5595
Hanno Beckere2148042017-11-10 08:59:18 +00005596requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005597run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005598 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005599 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005600 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005601 0 \
5602 -s "Read from client: 1 bytes read"
5603
Hanno Beckere2148042017-11-10 08:59:18 +00005604requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005605run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005606 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005607 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005608 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005609 0 \
5610 -s "Read from client: 1 bytes read"
5611
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005612# Tests for small server packets
5613
5614requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5615run_test "Small server packet SSLv3 BlockCipher" \
5616 "$P_SRV response_size=1 min_version=ssl3" \
5617 "$P_CLI force_version=ssl3 \
5618 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5619 0 \
5620 -c "Read from server: 1 bytes read"
5621
5622requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5623run_test "Small server packet SSLv3 StreamCipher" \
5624 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5625 "$P_CLI force_version=ssl3 \
5626 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5627 0 \
5628 -c "Read from server: 1 bytes read"
5629
5630run_test "Small server packet TLS 1.0 BlockCipher" \
5631 "$P_SRV response_size=1" \
5632 "$P_CLI force_version=tls1 \
5633 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5634 0 \
5635 -c "Read from server: 1 bytes read"
5636
5637run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
5638 "$P_SRV response_size=1" \
5639 "$P_CLI force_version=tls1 etm=0 \
5640 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5641 0 \
5642 -c "Read from server: 1 bytes read"
5643
5644requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5645run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
5646 "$P_SRV response_size=1 trunc_hmac=1" \
5647 "$P_CLI force_version=tls1 \
5648 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5649 0 \
5650 -c "Read from server: 1 bytes read"
5651
5652requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5653run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
5654 "$P_SRV response_size=1 trunc_hmac=1" \
5655 "$P_CLI force_version=tls1 \
5656 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5657 0 \
5658 -c "Read from server: 1 bytes read"
5659
5660run_test "Small server packet TLS 1.0 StreamCipher" \
5661 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5662 "$P_CLI force_version=tls1 \
5663 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5664 0 \
5665 -c "Read from server: 1 bytes read"
5666
5667run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
5668 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5669 "$P_CLI force_version=tls1 \
5670 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5671 0 \
5672 -c "Read from server: 1 bytes read"
5673
5674requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5675run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
5676 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5677 "$P_CLI force_version=tls1 \
5678 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5679 0 \
5680 -c "Read from server: 1 bytes read"
5681
5682requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5683run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5684 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5685 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5686 trunc_hmac=1 etm=0" \
5687 0 \
5688 -c "Read from server: 1 bytes read"
5689
5690run_test "Small server packet TLS 1.1 BlockCipher" \
5691 "$P_SRV response_size=1" \
5692 "$P_CLI force_version=tls1_1 \
5693 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5694 0 \
5695 -c "Read from server: 1 bytes read"
5696
5697run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
5698 "$P_SRV response_size=1" \
5699 "$P_CLI force_version=tls1_1 \
5700 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5701 0 \
5702 -c "Read from server: 1 bytes read"
5703
5704requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5705run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
5706 "$P_SRV response_size=1 trunc_hmac=1" \
5707 "$P_CLI force_version=tls1_1 \
5708 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5709 0 \
5710 -c "Read from server: 1 bytes read"
5711
5712requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5713run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5714 "$P_SRV response_size=1 trunc_hmac=1" \
5715 "$P_CLI force_version=tls1_1 \
5716 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5717 0 \
5718 -c "Read from server: 1 bytes read"
5719
5720run_test "Small server packet TLS 1.1 StreamCipher" \
5721 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5722 "$P_CLI force_version=tls1_1 \
5723 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5724 0 \
5725 -c "Read from server: 1 bytes read"
5726
5727run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
5728 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5729 "$P_CLI force_version=tls1_1 \
5730 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5731 0 \
5732 -c "Read from server: 1 bytes read"
5733
5734requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5735run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
5736 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5737 "$P_CLI force_version=tls1_1 \
5738 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5739 0 \
5740 -c "Read from server: 1 bytes read"
5741
5742requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5743run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5744 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5745 "$P_CLI force_version=tls1_1 \
5746 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5747 0 \
5748 -c "Read from server: 1 bytes read"
5749
5750run_test "Small server packet TLS 1.2 BlockCipher" \
5751 "$P_SRV response_size=1" \
5752 "$P_CLI force_version=tls1_2 \
5753 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5754 0 \
5755 -c "Read from server: 1 bytes read"
5756
5757run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5758 "$P_SRV response_size=1" \
5759 "$P_CLI force_version=tls1_2 \
5760 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5761 0 \
5762 -c "Read from server: 1 bytes read"
5763
5764run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5765 "$P_SRV response_size=1" \
5766 "$P_CLI force_version=tls1_2 \
5767 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5768 0 \
5769 -c "Read from server: 1 bytes read"
5770
5771requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5772run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5773 "$P_SRV response_size=1 trunc_hmac=1" \
5774 "$P_CLI force_version=tls1_2 \
5775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5776 0 \
5777 -c "Read from server: 1 bytes read"
5778
5779requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5780run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5781 "$P_SRV response_size=1 trunc_hmac=1" \
5782 "$P_CLI force_version=tls1_2 \
5783 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5784 0 \
5785 -c "Read from server: 1 bytes read"
5786
5787run_test "Small server packet TLS 1.2 StreamCipher" \
5788 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5789 "$P_CLI force_version=tls1_2 \
5790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5791 0 \
5792 -c "Read from server: 1 bytes read"
5793
5794run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
5795 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5796 "$P_CLI force_version=tls1_2 \
5797 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5798 0 \
5799 -c "Read from server: 1 bytes read"
5800
5801requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5802run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
5803 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5804 "$P_CLI force_version=tls1_2 \
5805 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5806 0 \
5807 -c "Read from server: 1 bytes read"
5808
5809requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5810run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5811 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5812 "$P_CLI force_version=tls1_2 \
5813 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5814 0 \
5815 -c "Read from server: 1 bytes read"
5816
5817run_test "Small server packet TLS 1.2 AEAD" \
5818 "$P_SRV response_size=1" \
5819 "$P_CLI force_version=tls1_2 \
5820 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5821 0 \
5822 -c "Read from server: 1 bytes read"
5823
5824run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5825 "$P_SRV response_size=1" \
5826 "$P_CLI force_version=tls1_2 \
5827 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5828 0 \
5829 -c "Read from server: 1 bytes read"
5830
5831# Tests for small server packets in DTLS
5832
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005833run_test "Small server packet DTLS 1.0" \
5834 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
5835 "$P_CLI dtls=1 \
5836 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5837 0 \
5838 -c "Read from server: 1 bytes read"
5839
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005840run_test "Small server packet DTLS 1.0, without EtM" \
5841 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
5842 "$P_CLI dtls=1 \
5843 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5844 0 \
5845 -c "Read from server: 1 bytes read"
5846
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005847requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5848run_test "Small server packet DTLS 1.0, truncated hmac" \
5849 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
5850 "$P_CLI dtls=1 trunc_hmac=1 \
5851 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5852 0 \
5853 -c "Read from server: 1 bytes read"
5854
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005855requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5856run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
5857 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
5858 "$P_CLI dtls=1 \
5859 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5860 0 \
5861 -c "Read from server: 1 bytes read"
5862
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005863run_test "Small server packet DTLS 1.2" \
5864 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
5865 "$P_CLI dtls=1 \
5866 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5867 0 \
5868 -c "Read from server: 1 bytes read"
5869
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005870run_test "Small server packet DTLS 1.2, without EtM" \
5871 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5872 "$P_CLI dtls=1 \
5873 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5874 0 \
5875 -c "Read from server: 1 bytes read"
5876
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005877requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5878run_test "Small server packet DTLS 1.2, truncated hmac" \
5879 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5880 "$P_CLI dtls=1 \
5881 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5882 0 \
5883 -c "Read from server: 1 bytes read"
5884
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005885requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5886run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5887 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5888 "$P_CLI dtls=1 \
5889 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5890 0 \
5891 -c "Read from server: 1 bytes read"
5892
Janos Follath00efff72016-05-06 13:48:23 +01005893# A test for extensions in SSLv3
5894
5895requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5896run_test "SSLv3 with extensions, server side" \
5897 "$P_SRV min_version=ssl3 debug_level=3" \
5898 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
5899 0 \
5900 -S "dumping 'client hello extensions'" \
5901 -S "server hello, total extension length:"
5902
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005903# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005904
Angus Grattonc4dd0732018-04-11 16:28:39 +10005905# How many fragments do we expect to write $1 bytes?
5906fragments_for_write() {
5907 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
5908}
5909
Janos Follathe2681a42016-03-07 15:57:05 +00005910requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005911run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005912 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005913 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005914 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5915 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005916 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5917 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005918
Janos Follathe2681a42016-03-07 15:57:05 +00005919requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005920run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005921 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005922 "$P_CLI request_size=16384 force_version=ssl3 \
5923 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5924 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005925 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5926 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005927
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005928run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005929 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005930 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005931 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5932 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005933 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5934 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005935
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005936run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005937 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005938 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
5939 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5940 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005941 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005942
Hanno Becker32c55012017-11-10 08:42:54 +00005943requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005944run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005945 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005946 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005947 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005948 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005949 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5950 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005951
Hanno Becker32c55012017-11-10 08:42:54 +00005952requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005953run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005954 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005955 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005956 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005957 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005958 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005959
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005960run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005961 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005962 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005963 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5964 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005965 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005966
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005967run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005968 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5969 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005970 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005971 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005972 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005973
5974requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005975run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005976 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005977 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005978 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005979 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005980 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005981
Hanno Becker278fc7a2017-11-10 09:16:28 +00005982requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005983run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005984 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005985 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005986 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005987 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005988 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5989 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005990
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005991run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005992 "$P_SRV" \
5993 "$P_CLI request_size=16384 force_version=tls1_1 \
5994 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5995 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005996 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5997 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005998
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005999run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006000 "$P_SRV" \
6001 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6002 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006003 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006004 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006005
Hanno Becker32c55012017-11-10 08:42:54 +00006006requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006007run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006008 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006009 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006010 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006011 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006012 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006013
Hanno Becker32c55012017-11-10 08:42:54 +00006014requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006015run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006016 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006017 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006018 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006019 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006020 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006021
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006022run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006023 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6024 "$P_CLI request_size=16384 force_version=tls1_1 \
6025 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6026 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006027 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6028 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006029
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006030run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006031 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006032 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006033 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006034 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006035 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6036 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006037
Hanno Becker278fc7a2017-11-10 09:16:28 +00006038requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006039run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006040 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006041 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006042 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006043 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006044 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006045
Hanno Becker278fc7a2017-11-10 09:16:28 +00006046requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006047run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006048 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006049 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006050 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006051 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006052 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6053 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006054
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006055run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006056 "$P_SRV" \
6057 "$P_CLI request_size=16384 force_version=tls1_2 \
6058 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6059 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006060 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6061 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006062
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006063run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006064 "$P_SRV" \
6065 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6066 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6067 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006068 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006069
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006070run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006071 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006072 "$P_CLI request_size=16384 force_version=tls1_2 \
6073 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006074 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006075 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6076 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006077
Hanno Becker32c55012017-11-10 08:42:54 +00006078requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006079run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006080 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006081 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006082 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006083 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006084 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006085
Hanno Becker278fc7a2017-11-10 09:16:28 +00006086requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006087run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006088 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006089 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006090 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006091 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006092 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6093 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006094
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006095run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006096 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006097 "$P_CLI request_size=16384 force_version=tls1_2 \
6098 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6099 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006100 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6101 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006102
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006103run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006104 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006105 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006106 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6107 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006108 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006109
Hanno Becker32c55012017-11-10 08:42:54 +00006110requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006111run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006112 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006113 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006114 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006115 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006116 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006117
Hanno Becker278fc7a2017-11-10 09:16:28 +00006118requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006119run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006120 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006121 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006122 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006123 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006124 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6125 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006126
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006127run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006128 "$P_SRV" \
6129 "$P_CLI request_size=16384 force_version=tls1_2 \
6130 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6131 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006132 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6133 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006134
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006135run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006136 "$P_SRV" \
6137 "$P_CLI request_size=16384 force_version=tls1_2 \
6138 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6139 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006140 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6141 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006142
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006143# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006144requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6145run_test "Large server packet SSLv3 StreamCipher" \
6146 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6147 "$P_CLI force_version=ssl3 \
6148 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6149 0 \
6150 -c "Read from server: 16384 bytes read"
6151
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006152# Checking next 4 tests logs for 1n-1 split against BEAST too
6153requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6154run_test "Large server packet SSLv3 BlockCipher" \
6155 "$P_SRV response_size=16384 min_version=ssl3" \
6156 "$P_CLI force_version=ssl3 recsplit=0 \
6157 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6158 0 \
6159 -c "Read from server: 1 bytes read"\
6160 -c "16383 bytes read"\
6161 -C "Read from server: 16384 bytes read"
6162
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006163run_test "Large server packet TLS 1.0 BlockCipher" \
6164 "$P_SRV response_size=16384" \
6165 "$P_CLI force_version=tls1 recsplit=0 \
6166 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6167 0 \
6168 -c "Read from server: 1 bytes read"\
6169 -c "16383 bytes read"\
6170 -C "Read from server: 16384 bytes read"
6171
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006172run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6173 "$P_SRV response_size=16384" \
6174 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6175 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6176 0 \
6177 -c "Read from server: 1 bytes read"\
6178 -c "16383 bytes read"\
6179 -C "Read from server: 16384 bytes read"
6180
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006181requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6182run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6183 "$P_SRV response_size=16384" \
6184 "$P_CLI force_version=tls1 recsplit=0 \
6185 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6186 trunc_hmac=1" \
6187 0 \
6188 -c "Read from server: 1 bytes read"\
6189 -c "16383 bytes read"\
6190 -C "Read from server: 16384 bytes read"
6191
6192requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6193run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6194 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6195 "$P_CLI force_version=tls1 \
6196 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6197 trunc_hmac=1" \
6198 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006199 -s "16384 bytes written in 1 fragments" \
6200 -c "Read from server: 16384 bytes read"
6201
6202run_test "Large server packet TLS 1.0 StreamCipher" \
6203 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6204 "$P_CLI force_version=tls1 \
6205 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6206 0 \
6207 -s "16384 bytes written in 1 fragments" \
6208 -c "Read from server: 16384 bytes read"
6209
6210run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6211 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6212 "$P_CLI force_version=tls1 \
6213 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6214 0 \
6215 -s "16384 bytes written in 1 fragments" \
6216 -c "Read from server: 16384 bytes read"
6217
6218requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6219run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6220 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6221 "$P_CLI force_version=tls1 \
6222 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6223 0 \
6224 -s "16384 bytes written in 1 fragments" \
6225 -c "Read from server: 16384 bytes read"
6226
6227requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6228run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6229 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6230 "$P_CLI force_version=tls1 \
6231 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6232 0 \
6233 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006234 -c "Read from server: 16384 bytes read"
6235
6236run_test "Large server packet TLS 1.1 BlockCipher" \
6237 "$P_SRV response_size=16384" \
6238 "$P_CLI force_version=tls1_1 \
6239 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6240 0 \
6241 -c "Read from server: 16384 bytes read"
6242
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006243run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6244 "$P_SRV response_size=16384" \
6245 "$P_CLI force_version=tls1_1 etm=0 \
6246 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006247 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006248 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006249 -c "Read from server: 16384 bytes read"
6250
6251requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6252run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6253 "$P_SRV response_size=16384" \
6254 "$P_CLI force_version=tls1_1 \
6255 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6256 trunc_hmac=1" \
6257 0 \
6258 -c "Read from server: 16384 bytes read"
6259
6260requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006261run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6262 "$P_SRV response_size=16384 trunc_hmac=1" \
6263 "$P_CLI force_version=tls1_1 \
6264 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6265 0 \
6266 -s "16384 bytes written in 1 fragments" \
6267 -c "Read from server: 16384 bytes read"
6268
6269run_test "Large server packet TLS 1.1 StreamCipher" \
6270 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6271 "$P_CLI force_version=tls1_1 \
6272 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6273 0 \
6274 -c "Read from server: 16384 bytes read"
6275
6276run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6277 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6278 "$P_CLI force_version=tls1_1 \
6279 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6280 0 \
6281 -s "16384 bytes written in 1 fragments" \
6282 -c "Read from server: 16384 bytes read"
6283
6284requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006285run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6286 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6287 "$P_CLI force_version=tls1_1 \
6288 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6289 trunc_hmac=1" \
6290 0 \
6291 -c "Read from server: 16384 bytes read"
6292
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006293run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6294 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6295 "$P_CLI force_version=tls1_1 \
6296 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6297 0 \
6298 -s "16384 bytes written in 1 fragments" \
6299 -c "Read from server: 16384 bytes read"
6300
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006301run_test "Large server packet TLS 1.2 BlockCipher" \
6302 "$P_SRV response_size=16384" \
6303 "$P_CLI force_version=tls1_2 \
6304 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6305 0 \
6306 -c "Read from server: 16384 bytes read"
6307
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006308run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6309 "$P_SRV response_size=16384" \
6310 "$P_CLI force_version=tls1_2 etm=0 \
6311 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6312 0 \
6313 -s "16384 bytes written in 1 fragments" \
6314 -c "Read from server: 16384 bytes read"
6315
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006316run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6317 "$P_SRV response_size=16384" \
6318 "$P_CLI force_version=tls1_2 \
6319 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6320 0 \
6321 -c "Read from server: 16384 bytes read"
6322
6323requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6324run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6325 "$P_SRV response_size=16384" \
6326 "$P_CLI force_version=tls1_2 \
6327 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6328 trunc_hmac=1" \
6329 0 \
6330 -c "Read from server: 16384 bytes read"
6331
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006332run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6333 "$P_SRV response_size=16384 trunc_hmac=1" \
6334 "$P_CLI force_version=tls1_2 \
6335 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6336 0 \
6337 -s "16384 bytes written in 1 fragments" \
6338 -c "Read from server: 16384 bytes read"
6339
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006340run_test "Large server packet TLS 1.2 StreamCipher" \
6341 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6342 "$P_CLI force_version=tls1_2 \
6343 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6344 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006345 -s "16384 bytes written in 1 fragments" \
6346 -c "Read from server: 16384 bytes read"
6347
6348run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6349 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6350 "$P_CLI force_version=tls1_2 \
6351 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6352 0 \
6353 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006354 -c "Read from server: 16384 bytes read"
6355
6356requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6357run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6358 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6359 "$P_CLI force_version=tls1_2 \
6360 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6361 trunc_hmac=1" \
6362 0 \
6363 -c "Read from server: 16384 bytes read"
6364
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006365requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6366run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6367 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6368 "$P_CLI force_version=tls1_2 \
6369 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6370 0 \
6371 -s "16384 bytes written in 1 fragments" \
6372 -c "Read from server: 16384 bytes read"
6373
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006374run_test "Large server packet TLS 1.2 AEAD" \
6375 "$P_SRV response_size=16384" \
6376 "$P_CLI force_version=tls1_2 \
6377 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6378 0 \
6379 -c "Read from server: 16384 bytes read"
6380
6381run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6382 "$P_SRV response_size=16384" \
6383 "$P_CLI force_version=tls1_2 \
6384 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6385 0 \
6386 -c "Read from server: 16384 bytes read"
6387
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006388# Tests for restartable ECC
6389
6390requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6391run_test "EC restart: TLS, default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006392 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006393 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006394 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006395 debug_level=1" \
6396 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006397 -C "x509_verify_cert.*4b00" \
6398 -C "mbedtls_pk_verify.*4b00" \
6399 -C "mbedtls_ecdh_make_public.*4b00" \
6400 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006401
6402requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6403run_test "EC restart: TLS, max_ops=0" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006404 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006405 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006406 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006407 debug_level=1 ec_max_ops=0" \
6408 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006409 -C "x509_verify_cert.*4b00" \
6410 -C "mbedtls_pk_verify.*4b00" \
6411 -C "mbedtls_ecdh_make_public.*4b00" \
6412 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006413
6414requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6415run_test "EC restart: TLS, max_ops=65535" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006416 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006417 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006418 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006419 debug_level=1 ec_max_ops=65535" \
6420 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006421 -C "x509_verify_cert.*4b00" \
6422 -C "mbedtls_pk_verify.*4b00" \
6423 -C "mbedtls_ecdh_make_public.*4b00" \
6424 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006425
6426requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6427run_test "EC restart: TLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006428 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006429 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006430 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006431 debug_level=1 ec_max_ops=1000" \
6432 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006433 -c "x509_verify_cert.*4b00" \
6434 -c "mbedtls_pk_verify.*4b00" \
6435 -c "mbedtls_ecdh_make_public.*4b00" \
6436 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006437
6438requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Hanno Becker4a156fc2019-06-14 17:07:06 +01006439requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006440run_test "EC restart: TLS, max_ops=1000, badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006441 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006442 crt_file=data_files/server5-badsign.crt \
6443 key_file=data_files/server5.key" \
6444 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker03d77462019-08-27 16:24:56 +01006445 key_file=data_files/server5.key crt_file=data_files/server5.crt ca_file=data_files/test-ca2.crt \
6446 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6447 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006448 -c "x509_verify_cert.*4b00" \
Hanno Becker03d77462019-08-27 16:24:56 +01006449 -c "mbedtls_pk_verify.*4b00" \
6450 -c "mbedtls_ecdh_make_public.*4b00" \
6451 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006452 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006453
Hanno Becker4a156fc2019-06-14 17:07:06 +01006454requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006455requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6456run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006457 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006458 crt_file=data_files/server5-badsign.crt \
6459 key_file=data_files/server5.key" \
6460 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6461 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006462 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006463 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6464 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006465 -c "x509_verify_cert.*4b00" \
6466 -c "mbedtls_pk_verify.*4b00" \
6467 -c "mbedtls_ecdh_make_public.*4b00" \
6468 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006469 -c "! The certificate is not correctly signed by the trusted CA" \
6470 -C "! mbedtls_ssl_handshake returned" \
6471 -C "X509 - Certificate verification failed"
6472
Hanno Becker4a156fc2019-06-14 17:07:06 +01006473requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006474requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006475requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6476run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006477 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006478 crt_file=data_files/server5-badsign.crt \
6479 key_file=data_files/server5.key" \
6480 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006481 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006482 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6483 debug_level=1 ec_max_ops=1000 auth_mode=none" \
6484 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006485 -C "x509_verify_cert.*4b00" \
6486 -c "mbedtls_pk_verify.*4b00" \
6487 -c "mbedtls_ecdh_make_public.*4b00" \
6488 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006489 -C "! The certificate is not correctly signed by the trusted CA" \
6490 -C "! mbedtls_ssl_handshake returned" \
6491 -C "X509 - Certificate verification failed"
6492
6493requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006494run_test "EC restart: DTLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006495 "$P_SRV auth_mode=required dtls=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006496 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006497 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006498 dtls=1 debug_level=1 ec_max_ops=1000" \
6499 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006500 -c "x509_verify_cert.*4b00" \
6501 -c "mbedtls_pk_verify.*4b00" \
6502 -c "mbedtls_ecdh_make_public.*4b00" \
6503 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006504
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006505requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6506run_test "EC restart: TLS, max_ops=1000 no client auth" \
6507 "$P_SRV" \
6508 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6509 debug_level=1 ec_max_ops=1000" \
6510 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006511 -c "x509_verify_cert.*4b00" \
6512 -c "mbedtls_pk_verify.*4b00" \
6513 -c "mbedtls_ecdh_make_public.*4b00" \
6514 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006515
6516requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6517run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6518 "$P_SRV psk=abc123" \
6519 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6520 psk=abc123 debug_level=1 ec_max_ops=1000" \
6521 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006522 -C "x509_verify_cert.*4b00" \
6523 -C "mbedtls_pk_verify.*4b00" \
6524 -C "mbedtls_ecdh_make_public.*4b00" \
6525 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006526
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006527# Tests of asynchronous private key support in SSL
6528
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006529requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006530run_test "SSL async private: sign, delay=0" \
6531 "$P_SRV \
6532 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006533 "$P_CLI" \
6534 0 \
6535 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006536 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006537
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006538requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006539run_test "SSL async private: sign, delay=1" \
6540 "$P_SRV \
6541 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006542 "$P_CLI" \
6543 0 \
6544 -s "Async sign callback: using key slot " \
6545 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006546 -s "Async resume (slot [0-9]): sign done, status=0"
6547
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006548requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6549run_test "SSL async private: sign, delay=2" \
6550 "$P_SRV \
6551 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6552 "$P_CLI" \
6553 0 \
6554 -s "Async sign callback: using key slot " \
6555 -U "Async sign callback: using key slot " \
6556 -s "Async resume (slot [0-9]): call 1 more times." \
6557 -s "Async resume (slot [0-9]): call 0 more times." \
6558 -s "Async resume (slot [0-9]): sign done, status=0"
6559
Gilles Peskined3268832018-04-26 06:23:59 +02006560# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
6561# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
6562requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6563requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6564run_test "SSL async private: sign, RSA, TLS 1.1" \
6565 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
6566 async_operations=s async_private_delay1=0 async_private_delay2=0" \
6567 "$P_CLI force_version=tls1_1" \
6568 0 \
6569 -s "Async sign callback: using key slot " \
6570 -s "Async resume (slot [0-9]): sign done, status=0"
6571
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006572requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Hanno Beckerb2c63832019-06-17 08:35:16 +01006573requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03006574requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006575requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskine807d74a2018-04-30 10:30:49 +02006576run_test "SSL async private: sign, SNI" \
6577 "$P_SRV debug_level=3 \
6578 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6579 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6580 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6581 "$P_CLI server_name=polarssl.example" \
6582 0 \
6583 -s "Async sign callback: using key slot " \
6584 -s "Async resume (slot [0-9]): sign done, status=0" \
6585 -s "parse ServerName extension" \
6586 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6587 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6588
6589requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006590run_test "SSL async private: decrypt, delay=0" \
6591 "$P_SRV \
6592 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6593 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6594 0 \
6595 -s "Async decrypt callback: using key slot " \
6596 -s "Async resume (slot [0-9]): decrypt done, status=0"
6597
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006598requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006599run_test "SSL async private: decrypt, delay=1" \
6600 "$P_SRV \
6601 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6602 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6603 0 \
6604 -s "Async decrypt callback: using key slot " \
6605 -s "Async resume (slot [0-9]): call 0 more times." \
6606 -s "Async resume (slot [0-9]): decrypt done, status=0"
6607
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006608requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006609run_test "SSL async private: decrypt RSA-PSK, delay=0" \
6610 "$P_SRV psk=abc123 \
6611 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6612 "$P_CLI psk=abc123 \
6613 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6614 0 \
6615 -s "Async decrypt callback: using key slot " \
6616 -s "Async resume (slot [0-9]): decrypt done, status=0"
6617
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006618requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006619run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6620 "$P_SRV psk=abc123 \
6621 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6622 "$P_CLI psk=abc123 \
6623 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6624 0 \
6625 -s "Async decrypt callback: using key slot " \
6626 -s "Async resume (slot [0-9]): call 0 more times." \
6627 -s "Async resume (slot [0-9]): decrypt done, status=0"
6628
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006629requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006630run_test "SSL async private: sign callback not present" \
6631 "$P_SRV \
6632 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6633 "$P_CLI; [ \$? -eq 1 ] &&
6634 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6635 0 \
6636 -S "Async sign callback" \
6637 -s "! mbedtls_ssl_handshake returned" \
6638 -s "The own private key or pre-shared key is not set, but needed" \
6639 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6640 -s "Successful connection"
6641
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006642requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006643run_test "SSL async private: decrypt callback not present" \
6644 "$P_SRV debug_level=1 \
6645 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6646 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6647 [ \$? -eq 1 ] && $P_CLI" \
6648 0 \
6649 -S "Async decrypt callback" \
6650 -s "! mbedtls_ssl_handshake returned" \
6651 -s "got no RSA private key" \
6652 -s "Async resume (slot [0-9]): sign done, status=0" \
6653 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006654
6655# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006656requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006657run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006658 "$P_SRV \
6659 async_operations=s async_private_delay1=1 \
6660 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6661 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006662 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 ca_file=data_files/test-ca2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006663 0 \
6664 -s "Async sign callback: using key slot 0," \
6665 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006666 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006667
6668# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006669requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006670run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006671 "$P_SRV \
6672 async_operations=s async_private_delay2=1 \
6673 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6674 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006675 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6676 0 \
6677 -s "Async sign callback: using key slot 0," \
6678 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006679 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006680
6681# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006682requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006683run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006684 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006685 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006686 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6687 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006688 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6689 0 \
6690 -s "Async sign callback: using key slot 1," \
6691 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006692 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006693
6694# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006695requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006696run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006697 "$P_SRV \
6698 async_operations=s async_private_delay1=1 \
6699 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6700 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006701 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6702 0 \
6703 -s "Async sign callback: no key matches this certificate."
6704
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006705requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006706run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006707 "$P_SRV \
6708 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6709 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006710 "$P_CLI" \
6711 1 \
6712 -s "Async sign callback: injected error" \
6713 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006714 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006715 -s "! mbedtls_ssl_handshake returned"
6716
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006717requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006718run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006719 "$P_SRV \
6720 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6721 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006722 "$P_CLI" \
6723 1 \
6724 -s "Async sign callback: using key slot " \
6725 -S "Async resume" \
6726 -s "Async cancel"
6727
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006728requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006729run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006730 "$P_SRV \
6731 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6732 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006733 "$P_CLI" \
6734 1 \
6735 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006736 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006737 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006738 -s "! mbedtls_ssl_handshake returned"
6739
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006740requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006741run_test "SSL async private: decrypt, error in start" \
6742 "$P_SRV \
6743 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6744 async_private_error=1" \
6745 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6746 1 \
6747 -s "Async decrypt callback: injected error" \
6748 -S "Async resume" \
6749 -S "Async cancel" \
6750 -s "! mbedtls_ssl_handshake returned"
6751
6752requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6753run_test "SSL async private: decrypt, cancel after start" \
6754 "$P_SRV \
6755 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6756 async_private_error=2" \
6757 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6758 1 \
6759 -s "Async decrypt callback: using key slot " \
6760 -S "Async resume" \
6761 -s "Async cancel"
6762
6763requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6764run_test "SSL async private: decrypt, error in resume" \
6765 "$P_SRV \
6766 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6767 async_private_error=3" \
6768 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6769 1 \
6770 -s "Async decrypt callback: using key slot " \
6771 -s "Async resume callback: decrypt done but injected error" \
6772 -S "Async cancel" \
6773 -s "! mbedtls_ssl_handshake returned"
6774
6775requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006776run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006777 "$P_SRV \
6778 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6779 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006780 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6781 0 \
6782 -s "Async cancel" \
6783 -s "! mbedtls_ssl_handshake returned" \
6784 -s "Async resume" \
6785 -s "Successful connection"
6786
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006787requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006788run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006789 "$P_SRV \
6790 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6791 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006792 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6793 0 \
6794 -s "! mbedtls_ssl_handshake returned" \
6795 -s "Async resume" \
6796 -s "Successful connection"
6797
6798# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006799requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006800run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006801 "$P_SRV \
6802 async_operations=s async_private_delay1=1 async_private_error=-2 \
6803 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6804 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006805 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6806 [ \$? -eq 1 ] &&
6807 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6808 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006809 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006810 -S "Async resume" \
6811 -s "Async cancel" \
6812 -s "! mbedtls_ssl_handshake returned" \
6813 -s "Async sign callback: no key matches this certificate." \
6814 -s "Successful connection"
6815
6816# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006817requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006818run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006819 "$P_SRV \
6820 async_operations=s async_private_delay1=1 async_private_error=-3 \
6821 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6822 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006823 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6824 [ \$? -eq 1 ] &&
6825 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6826 0 \
6827 -s "Async resume" \
6828 -s "! mbedtls_ssl_handshake returned" \
6829 -s "Async sign callback: no key matches this certificate." \
6830 -s "Successful connection"
6831
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006832requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006833requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006834run_test "SSL async private: renegotiation: client-initiated; sign" \
6835 "$P_SRV \
6836 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006837 exchanges=2 renegotiation=1" \
6838 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6839 0 \
6840 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006841 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006842
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006843requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006844requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006845run_test "SSL async private: renegotiation: server-initiated; sign" \
6846 "$P_SRV \
6847 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006848 exchanges=2 renegotiation=1 renegotiate=1" \
6849 "$P_CLI exchanges=2 renegotiation=1" \
6850 0 \
6851 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006852 -s "Async resume (slot [0-9]): sign done, status=0"
6853
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006854requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006855requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6856run_test "SSL async private: renegotiation: client-initiated; decrypt" \
6857 "$P_SRV \
6858 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6859 exchanges=2 renegotiation=1" \
6860 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
6861 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6862 0 \
6863 -s "Async decrypt callback: using key slot " \
6864 -s "Async resume (slot [0-9]): decrypt done, status=0"
6865
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006866requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006867requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6868run_test "SSL async private: renegotiation: server-initiated; decrypt" \
6869 "$P_SRV \
6870 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6871 exchanges=2 renegotiation=1 renegotiate=1" \
6872 "$P_CLI exchanges=2 renegotiation=1 \
6873 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6874 0 \
6875 -s "Async decrypt callback: using key slot " \
6876 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006877
Ron Eldor58093c82018-06-28 13:22:05 +03006878# Tests for ECC extensions (rfc 4492)
6879
Ron Eldor643df7c2018-06-28 16:17:00 +03006880requires_config_enabled MBEDTLS_AES_C
6881requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6882requires_config_enabled MBEDTLS_SHA256_C
6883requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006884run_test "Force a non ECC ciphersuite in the client side" \
6885 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006886 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006887 0 \
6888 -C "client hello, adding supported_elliptic_curves extension" \
6889 -C "client hello, adding supported_point_formats extension" \
6890 -S "found supported elliptic curves extension" \
6891 -S "found supported point formats extension"
6892
Ron Eldor643df7c2018-06-28 16:17:00 +03006893requires_config_enabled MBEDTLS_AES_C
6894requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6895requires_config_enabled MBEDTLS_SHA256_C
6896requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006897run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006898 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006899 "$P_CLI debug_level=3" \
6900 0 \
6901 -C "found supported_point_formats extension" \
6902 -S "server hello, supported_point_formats extension"
6903
Ron Eldor643df7c2018-06-28 16:17:00 +03006904requires_config_enabled MBEDTLS_AES_C
6905requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6906requires_config_enabled MBEDTLS_SHA256_C
6907requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006908run_test "Force an ECC ciphersuite in the client side" \
6909 "$P_SRV debug_level=3" \
6910 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6911 0 \
6912 -c "client hello, adding supported_elliptic_curves extension" \
6913 -c "client hello, adding supported_point_formats extension" \
6914 -s "found supported elliptic curves extension" \
6915 -s "found supported point formats extension"
6916
Ron Eldor643df7c2018-06-28 16:17:00 +03006917requires_config_enabled MBEDTLS_AES_C
6918requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6919requires_config_enabled MBEDTLS_SHA256_C
6920requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006921run_test "Force an ECC ciphersuite in the server side" \
6922 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6923 "$P_CLI debug_level=3" \
6924 0 \
6925 -c "found supported_point_formats extension" \
6926 -s "server hello, supported_point_formats extension"
6927
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006928# Tests for DTLS HelloVerifyRequest
6929
6930run_test "DTLS cookie: enabled" \
6931 "$P_SRV dtls=1 debug_level=2" \
6932 "$P_CLI dtls=1 debug_level=2" \
6933 0 \
6934 -s "cookie verification failed" \
6935 -s "cookie verification passed" \
6936 -S "cookie verification skipped" \
6937 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006938 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006939 -S "SSL - The requested feature is not available"
6940
6941run_test "DTLS cookie: disabled" \
6942 "$P_SRV dtls=1 debug_level=2 cookies=0" \
6943 "$P_CLI dtls=1 debug_level=2" \
6944 0 \
6945 -S "cookie verification failed" \
6946 -S "cookie verification passed" \
6947 -s "cookie verification skipped" \
6948 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006949 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006950 -S "SSL - The requested feature is not available"
6951
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006952run_test "DTLS cookie: default (failing)" \
6953 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
6954 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
6955 1 \
6956 -s "cookie verification failed" \
6957 -S "cookie verification passed" \
6958 -S "cookie verification skipped" \
6959 -C "received hello verify request" \
6960 -S "hello verification requested" \
6961 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006962
6963requires_ipv6
6964run_test "DTLS cookie: enabled, IPv6" \
6965 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
6966 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
6967 0 \
6968 -s "cookie verification failed" \
6969 -s "cookie verification passed" \
6970 -S "cookie verification skipped" \
6971 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006972 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006973 -S "SSL - The requested feature is not available"
6974
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02006975run_test "DTLS cookie: enabled, nbio" \
6976 "$P_SRV dtls=1 nbio=2 debug_level=2" \
6977 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6978 0 \
6979 -s "cookie verification failed" \
6980 -s "cookie verification passed" \
6981 -S "cookie verification skipped" \
6982 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006983 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02006984 -S "SSL - The requested feature is not available"
6985
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006986# Tests for client reconnecting from the same port with DTLS
6987
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006988not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006989run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006990 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
6991 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006992 0 \
6993 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006994 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006995 -S "Client initiated reconnection from same port"
6996
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006997not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006998run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006999 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7000 "$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 +02007001 0 \
7002 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007003 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007004 -s "Client initiated reconnection from same port"
7005
Paul Bakker362689d2016-05-13 10:33:25 +01007006not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
7007run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007008 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7009 "$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 +02007010 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007011 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007012 -s "Client initiated reconnection from same port"
7013
Paul Bakker362689d2016-05-13 10:33:25 +01007014only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
7015run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7016 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7017 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7018 0 \
7019 -S "The operation timed out" \
7020 -s "Client initiated reconnection from same port"
7021
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007022run_test "DTLS client reconnect from same port: no cookies" \
7023 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007024 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7025 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007026 -s "The operation timed out" \
7027 -S "Client initiated reconnection from same port"
7028
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007029# Tests for various cases of client authentication with DTLS
7030# (focused on handshake flows and message parsing)
7031
7032run_test "DTLS client auth: required" \
7033 "$P_SRV dtls=1 auth_mode=required" \
7034 "$P_CLI dtls=1" \
7035 0 \
7036 -s "Verifying peer X.509 certificate... ok"
7037
Hanno Becker4a156fc2019-06-14 17:07:06 +01007038requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007039requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007040run_test "DTLS client auth: optional, client has no cert" \
7041 "$P_SRV dtls=1 auth_mode=optional" \
7042 "$P_CLI dtls=1 crt_file=none key_file=none" \
7043 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007044 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007045
Hanno Becker4a156fc2019-06-14 17:07:06 +01007046requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007047requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007048run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007049 "$P_SRV dtls=1 auth_mode=none" \
7050 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7051 0 \
7052 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007053 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007054
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007055run_test "DTLS wrong PSK: badmac alert" \
7056 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7057 "$P_CLI dtls=1 psk=abc124" \
7058 1 \
7059 -s "SSL - Verification of the message MAC failed" \
7060 -c "SSL - A fatal alert message was received from our peer"
7061
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007062# Tests for receiving fragmented handshake messages with DTLS
7063
7064requires_gnutls
7065run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7066 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007067 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007068 0 \
7069 -C "found fragmented DTLS handshake message" \
7070 -C "error"
7071
7072requires_gnutls
7073run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7074 "$G_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007075 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007076 0 \
7077 -c "found fragmented DTLS handshake message" \
7078 -C "error"
7079
7080requires_gnutls
7081run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7082 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007083 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007084 0 \
7085 -c "found fragmented DTLS handshake message" \
7086 -C "error"
7087
7088requires_gnutls
7089run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7090 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007091 "$P_CLI dtls=1 nbio=2 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007092 0 \
7093 -c "found fragmented DTLS handshake message" \
7094 -C "error"
7095
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007096requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007097requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007098run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7099 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007100 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007101 0 \
7102 -c "found fragmented DTLS handshake message" \
7103 -c "client hello, adding renegotiation extension" \
7104 -c "found renegotiation extension" \
7105 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007106 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007107 -C "error" \
7108 -s "Extra-header:"
7109
7110requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007111requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007112run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7113 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007114 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007115 0 \
7116 -c "found fragmented DTLS handshake message" \
7117 -c "client hello, adding renegotiation extension" \
7118 -c "found renegotiation extension" \
7119 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007120 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007121 -C "error" \
7122 -s "Extra-header:"
7123
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007124run_test "DTLS reassembly: no fragmentation (openssl server)" \
7125 "$O_SRV -dtls1 -mtu 2048" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007126 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007127 0 \
7128 -C "found fragmented DTLS handshake message" \
7129 -C "error"
7130
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007131run_test "DTLS reassembly: some fragmentation (openssl server)" \
7132 "$O_SRV -dtls1 -mtu 768" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007133 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007134 0 \
7135 -c "found fragmented DTLS handshake message" \
7136 -C "error"
7137
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007138run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007139 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007140 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007141 0 \
7142 -c "found fragmented DTLS handshake message" \
7143 -C "error"
7144
7145run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7146 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007147 "$P_CLI dtls=1 nbio=2 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007148 0 \
7149 -c "found fragmented DTLS handshake message" \
7150 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007151
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007152# Tests for sending fragmented handshake messages with DTLS
7153#
7154# Use client auth when we need the client to send large messages,
7155# and use large cert chains on both sides too (the long chains we have all use
7156# both RSA and ECDSA, but ideally we should have long chains with either).
7157# Sizes reached (UDP payload):
7158# - 2037B for server certificate
7159# - 1542B for client certificate
7160# - 1013B for newsessionticket
7161# - all others below 512B
7162# All those tests assume MAX_CONTENT_LEN is at least 2048
7163
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007164requires_config_enabled MBEDTLS_RSA_C
7165requires_config_enabled MBEDTLS_ECDSA_C
7166requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7167run_test "DTLS fragmenting: none (for reference)" \
7168 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7169 crt_file=data_files/server7_int-ca.crt \
7170 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007171 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007172 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007173 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007174 "$P_CLI dtls=1 debug_level=2 \
7175 crt_file=data_files/server8_int-ca2.crt \
7176 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007177 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007178 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007179 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007180 0 \
7181 -S "found fragmented DTLS handshake message" \
7182 -C "found fragmented DTLS handshake message" \
7183 -C "error"
7184
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007185requires_config_enabled MBEDTLS_RSA_C
7186requires_config_enabled MBEDTLS_ECDSA_C
7187requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007188run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007189 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7190 crt_file=data_files/server7_int-ca.crt \
7191 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007192 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007193 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007194 max_frag_len=1024" \
7195 "$P_CLI dtls=1 debug_level=2 \
7196 crt_file=data_files/server8_int-ca2.crt \
7197 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007198 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007199 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007200 max_frag_len=2048" \
7201 0 \
7202 -S "found fragmented DTLS handshake message" \
7203 -c "found fragmented DTLS handshake message" \
7204 -C "error"
7205
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007206# With the MFL extension, the server has no way of forcing
7207# the client to not exceed a certain MTU; hence, the following
7208# test can't be replicated with an MTU proxy such as the one
7209# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007210requires_config_enabled MBEDTLS_RSA_C
7211requires_config_enabled MBEDTLS_ECDSA_C
7212requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007213run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007214 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7215 crt_file=data_files/server7_int-ca.crt \
7216 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007217 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007218 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007219 max_frag_len=512" \
7220 "$P_CLI dtls=1 debug_level=2 \
7221 crt_file=data_files/server8_int-ca2.crt \
7222 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007223 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007224 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007225 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007226 0 \
7227 -S "found fragmented DTLS handshake message" \
7228 -c "found fragmented DTLS handshake message" \
7229 -C "error"
7230
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007231requires_config_enabled MBEDTLS_RSA_C
7232requires_config_enabled MBEDTLS_ECDSA_C
7233requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007234run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007235 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7236 crt_file=data_files/server7_int-ca.crt \
7237 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007238 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007239 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007240 max_frag_len=2048" \
7241 "$P_CLI dtls=1 debug_level=2 \
7242 crt_file=data_files/server8_int-ca2.crt \
7243 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007244 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007245 hs_timeout=2500-60000 \
7246 max_frag_len=1024" \
7247 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007248 -S "found fragmented DTLS handshake message" \
7249 -c "found fragmented DTLS handshake message" \
7250 -C "error"
7251
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007252# While not required by the standard defining the MFL extension
7253# (according to which it only applies to records, not to datagrams),
7254# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7255# as otherwise there wouldn't be any means to communicate MTU restrictions
7256# to the peer.
7257# The next test checks that no datagrams significantly larger than the
7258# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007259requires_config_enabled MBEDTLS_RSA_C
7260requires_config_enabled MBEDTLS_ECDSA_C
7261requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7262run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007263 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007264 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7265 crt_file=data_files/server7_int-ca.crt \
7266 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007267 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007268 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007269 max_frag_len=2048" \
7270 "$P_CLI dtls=1 debug_level=2 \
7271 crt_file=data_files/server8_int-ca2.crt \
7272 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007273 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007274 hs_timeout=2500-60000 \
7275 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007276 0 \
7277 -S "found fragmented DTLS handshake message" \
7278 -c "found fragmented DTLS handshake message" \
7279 -C "error"
7280
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007281requires_config_enabled MBEDTLS_RSA_C
7282requires_config_enabled MBEDTLS_ECDSA_C
7283requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007284run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007285 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7286 crt_file=data_files/server7_int-ca.crt \
7287 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007288 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007289 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007290 max_frag_len=2048" \
7291 "$P_CLI dtls=1 debug_level=2 \
7292 crt_file=data_files/server8_int-ca2.crt \
7293 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007294 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007295 hs_timeout=2500-60000 \
7296 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007297 0 \
7298 -s "found fragmented DTLS handshake message" \
7299 -c "found fragmented DTLS handshake message" \
7300 -C "error"
7301
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007302# While not required by the standard defining the MFL extension
7303# (according to which it only applies to records, not to datagrams),
7304# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7305# as otherwise there wouldn't be any means to communicate MTU restrictions
7306# to the peer.
7307# The next test checks that no datagrams significantly larger than the
7308# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007309requires_config_enabled MBEDTLS_RSA_C
7310requires_config_enabled MBEDTLS_ECDSA_C
7311requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7312run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007313 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007314 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7315 crt_file=data_files/server7_int-ca.crt \
7316 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007317 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007318 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007319 max_frag_len=2048" \
7320 "$P_CLI dtls=1 debug_level=2 \
7321 crt_file=data_files/server8_int-ca2.crt \
7322 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007323 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007324 hs_timeout=2500-60000 \
7325 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007326 0 \
7327 -s "found fragmented DTLS handshake message" \
7328 -c "found fragmented DTLS handshake message" \
7329 -C "error"
7330
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007331requires_config_enabled MBEDTLS_RSA_C
7332requires_config_enabled MBEDTLS_ECDSA_C
7333run_test "DTLS fragmenting: none (for reference) (MTU)" \
7334 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7335 crt_file=data_files/server7_int-ca.crt \
7336 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007337 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007338 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007339 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007340 "$P_CLI dtls=1 debug_level=2 \
7341 crt_file=data_files/server8_int-ca2.crt \
7342 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007343 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007344 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007345 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007346 0 \
7347 -S "found fragmented DTLS handshake message" \
7348 -C "found fragmented DTLS handshake message" \
7349 -C "error"
7350
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007351requires_config_enabled MBEDTLS_RSA_C
7352requires_config_enabled MBEDTLS_ECDSA_C
7353run_test "DTLS fragmenting: client (MTU)" \
7354 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7355 crt_file=data_files/server7_int-ca.crt \
7356 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007357 ca_file=data_files/test-ca.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007358 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007359 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007360 "$P_CLI dtls=1 debug_level=2 \
7361 crt_file=data_files/server8_int-ca2.crt \
7362 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007363 ca_file=data_files/test-ca2.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007364 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007365 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007366 0 \
7367 -s "found fragmented DTLS handshake message" \
7368 -C "found fragmented DTLS handshake message" \
7369 -C "error"
7370
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007371requires_config_enabled MBEDTLS_RSA_C
7372requires_config_enabled MBEDTLS_ECDSA_C
7373run_test "DTLS fragmenting: server (MTU)" \
7374 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7375 crt_file=data_files/server7_int-ca.crt \
7376 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007377 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007378 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007379 mtu=512" \
7380 "$P_CLI dtls=1 debug_level=2 \
7381 crt_file=data_files/server8_int-ca2.crt \
7382 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007383 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007384 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007385 mtu=2048" \
7386 0 \
7387 -S "found fragmented DTLS handshake message" \
7388 -c "found fragmented DTLS handshake message" \
7389 -C "error"
7390
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007391requires_config_enabled MBEDTLS_RSA_C
7392requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007393run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007394 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007395 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7396 crt_file=data_files/server7_int-ca.crt \
7397 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007398 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007399 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007400 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007401 "$P_CLI dtls=1 debug_level=2 \
7402 crt_file=data_files/server8_int-ca2.crt \
7403 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007404 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007405 hs_timeout=2500-60000 \
7406 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007407 0 \
7408 -s "found fragmented DTLS handshake message" \
7409 -c "found fragmented DTLS handshake message" \
7410 -C "error"
7411
Andrzej Kurek77826052018-10-11 07:34:08 -04007412# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007413requires_config_enabled MBEDTLS_RSA_C
7414requires_config_enabled MBEDTLS_ECDSA_C
7415requires_config_enabled MBEDTLS_SHA256_C
7416requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7417requires_config_enabled MBEDTLS_AES_C
7418requires_config_enabled MBEDTLS_GCM_C
7419run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007420 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007421 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7422 crt_file=data_files/server7_int-ca.crt \
7423 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007424 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007425 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007426 mtu=512" \
7427 "$P_CLI dtls=1 debug_level=2 \
7428 crt_file=data_files/server8_int-ca2.crt \
7429 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007430 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007431 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7432 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007433 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007434 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007435 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007436 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007437 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007438
Andrzej Kurek7311c782018-10-11 06:49:41 -04007439# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007440# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007441# The ratio of max/min timeout should ideally equal 4 to accept two
7442# retransmissions, but in some cases (like both the server and client using
7443# fragmentation and auto-reduction) an extra retransmission might occur,
7444# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007445not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007446requires_config_enabled MBEDTLS_RSA_C
7447requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007448requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7449requires_config_enabled MBEDTLS_AES_C
7450requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007451run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7452 -p "$P_PXY mtu=508" \
7453 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7454 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007455 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007456 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007457 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007458 "$P_CLI dtls=1 debug_level=2 \
7459 crt_file=data_files/server8_int-ca2.crt \
7460 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007461 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007462 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7463 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007464 0 \
7465 -s "found fragmented DTLS handshake message" \
7466 -c "found fragmented DTLS handshake message" \
7467 -C "error"
7468
Andrzej Kurek77826052018-10-11 07:34:08 -04007469# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01007470only_with_valgrind
Hanno Becker108992e2018-08-29 17:04:18 +01007471requires_config_enabled MBEDTLS_RSA_C
7472requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007473requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7474requires_config_enabled MBEDTLS_AES_C
7475requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01007476run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7477 -p "$P_PXY mtu=508" \
7478 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7479 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007480 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007481 ca_file=data_files/test-ca.crt \
Hanno Becker108992e2018-08-29 17:04:18 +01007482 hs_timeout=250-10000" \
7483 "$P_CLI dtls=1 debug_level=2 \
7484 crt_file=data_files/server8_int-ca2.crt \
7485 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007486 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007487 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01007488 hs_timeout=250-10000" \
7489 0 \
7490 -s "found fragmented DTLS handshake message" \
7491 -c "found fragmented DTLS handshake message" \
7492 -C "error"
7493
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007494# 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 +02007495# OTOH the client might resend if the server is to slow to reset after sending
7496# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007497not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007498requires_config_enabled MBEDTLS_RSA_C
7499requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007500run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007501 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007502 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7503 crt_file=data_files/server7_int-ca.crt \
7504 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007505 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007506 hs_timeout=10000-60000 \
7507 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007508 "$P_CLI dtls=1 debug_level=2 \
7509 crt_file=data_files/server8_int-ca2.crt \
7510 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007511 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007512 hs_timeout=10000-60000 \
7513 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007514 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007515 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007516 -s "found fragmented DTLS handshake message" \
7517 -c "found fragmented DTLS handshake message" \
7518 -C "error"
7519
Andrzej Kurek77826052018-10-11 07:34:08 -04007520# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007521# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
7522# OTOH the client might resend if the server is to slow to reset after sending
7523# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007524not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007525requires_config_enabled MBEDTLS_RSA_C
7526requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007527requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7528requires_config_enabled MBEDTLS_AES_C
7529requires_config_enabled MBEDTLS_GCM_C
7530run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007531 -p "$P_PXY mtu=512" \
7532 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7533 crt_file=data_files/server7_int-ca.crt \
7534 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007535 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007536 hs_timeout=10000-60000 \
7537 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007538 "$P_CLI dtls=1 debug_level=2 \
7539 crt_file=data_files/server8_int-ca2.crt \
7540 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007541 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007542 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7543 hs_timeout=10000-60000 \
7544 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007545 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007546 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007547 -s "found fragmented DTLS handshake message" \
7548 -c "found fragmented DTLS handshake message" \
7549 -C "error"
7550
Andrzej Kurek7311c782018-10-11 06:49:41 -04007551not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007552requires_config_enabled MBEDTLS_RSA_C
7553requires_config_enabled MBEDTLS_ECDSA_C
7554run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007555 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007556 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7557 crt_file=data_files/server7_int-ca.crt \
7558 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007559 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007560 hs_timeout=10000-60000 \
7561 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007562 "$P_CLI dtls=1 debug_level=2 \
7563 crt_file=data_files/server8_int-ca2.crt \
7564 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007565 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007566 hs_timeout=10000-60000 \
7567 mtu=1024 nbio=2" \
7568 0 \
7569 -S "autoreduction" \
7570 -s "found fragmented DTLS handshake message" \
7571 -c "found fragmented DTLS handshake message" \
7572 -C "error"
7573
Andrzej Kurek77826052018-10-11 07:34:08 -04007574# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007575not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007576requires_config_enabled MBEDTLS_RSA_C
7577requires_config_enabled MBEDTLS_ECDSA_C
7578requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7579requires_config_enabled MBEDTLS_AES_C
7580requires_config_enabled MBEDTLS_GCM_C
7581run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7582 -p "$P_PXY mtu=512" \
7583 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7584 crt_file=data_files/server7_int-ca.crt \
7585 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007586 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007587 hs_timeout=10000-60000 \
7588 mtu=512 nbio=2" \
7589 "$P_CLI dtls=1 debug_level=2 \
7590 crt_file=data_files/server8_int-ca2.crt \
7591 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007592 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007593 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7594 hs_timeout=10000-60000 \
7595 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007596 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007597 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007598 -s "found fragmented DTLS handshake message" \
7599 -c "found fragmented DTLS handshake message" \
7600 -C "error"
7601
Andrzej Kurek77826052018-10-11 07:34:08 -04007602# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007603# This ensures things still work after session_reset().
7604# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007605# Since we don't support reading fragmented ClientHello yet,
7606# up the MTU to 1450 (larger than ClientHello with session ticket,
7607# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007608# An autoreduction on the client-side might happen if the server is
7609# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007610# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007611# resumed listening, which would result in a spurious autoreduction.
7612not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007613requires_config_enabled MBEDTLS_RSA_C
7614requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007615requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7616requires_config_enabled MBEDTLS_AES_C
7617requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007618run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7619 -p "$P_PXY mtu=1450" \
7620 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7621 crt_file=data_files/server7_int-ca.crt \
7622 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007623 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007624 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007625 mtu=1450" \
7626 "$P_CLI dtls=1 debug_level=2 \
7627 crt_file=data_files/server8_int-ca2.crt \
7628 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007629 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007630 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007631 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007632 mtu=1450 reconnect=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007633 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007634 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007635 -s "found fragmented DTLS handshake message" \
7636 -c "found fragmented DTLS handshake message" \
7637 -C "error"
7638
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007639# An autoreduction on the client-side might happen if the server is
7640# slow to reset, therefore omitting '-C "autoreduction"' below.
7641not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007642requires_config_enabled MBEDTLS_RSA_C
7643requires_config_enabled MBEDTLS_ECDSA_C
7644requires_config_enabled MBEDTLS_SHA256_C
7645requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7646requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7647requires_config_enabled MBEDTLS_CHACHAPOLY_C
7648run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7649 -p "$P_PXY mtu=512" \
7650 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7651 crt_file=data_files/server7_int-ca.crt \
7652 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007653 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007654 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007655 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007656 mtu=512" \
7657 "$P_CLI dtls=1 debug_level=2 \
7658 crt_file=data_files/server8_int-ca2.crt \
7659 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007660 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007661 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007662 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007663 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007664 mtu=512" \
7665 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007666 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007667 -s "found fragmented DTLS handshake message" \
7668 -c "found fragmented DTLS handshake message" \
7669 -C "error"
7670
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007671# An autoreduction on the client-side might happen if the server is
7672# slow to reset, therefore omitting '-C "autoreduction"' below.
7673not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007674requires_config_enabled MBEDTLS_RSA_C
7675requires_config_enabled MBEDTLS_ECDSA_C
7676requires_config_enabled MBEDTLS_SHA256_C
7677requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7678requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7679requires_config_enabled MBEDTLS_AES_C
7680requires_config_enabled MBEDTLS_GCM_C
7681run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7682 -p "$P_PXY mtu=512" \
7683 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7684 crt_file=data_files/server7_int-ca.crt \
7685 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007686 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007687 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007688 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007689 mtu=512" \
7690 "$P_CLI dtls=1 debug_level=2 \
7691 crt_file=data_files/server8_int-ca2.crt \
7692 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007693 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007694 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007695 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007696 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007697 mtu=512" \
7698 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007699 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007700 -s "found fragmented DTLS handshake message" \
7701 -c "found fragmented DTLS handshake message" \
7702 -C "error"
7703
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007704# An autoreduction on the client-side might happen if the server is
7705# slow to reset, therefore omitting '-C "autoreduction"' below.
7706not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007707requires_config_enabled MBEDTLS_RSA_C
7708requires_config_enabled MBEDTLS_ECDSA_C
7709requires_config_enabled MBEDTLS_SHA256_C
7710requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7711requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7712requires_config_enabled MBEDTLS_AES_C
7713requires_config_enabled MBEDTLS_CCM_C
7714run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007715 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007716 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7717 crt_file=data_files/server7_int-ca.crt \
7718 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007719 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007720 exchanges=2 renegotiation=1 \
7721 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007722 hs_timeout=10000-60000 \
7723 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007724 "$P_CLI dtls=1 debug_level=2 \
7725 crt_file=data_files/server8_int-ca2.crt \
7726 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007727 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007728 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007729 hs_timeout=10000-60000 \
7730 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007731 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007732 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007733 -s "found fragmented DTLS handshake message" \
7734 -c "found fragmented DTLS handshake message" \
7735 -C "error"
7736
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007737# An autoreduction on the client-side might happen if the server is
7738# slow to reset, therefore omitting '-C "autoreduction"' below.
7739not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007740requires_config_enabled MBEDTLS_RSA_C
7741requires_config_enabled MBEDTLS_ECDSA_C
7742requires_config_enabled MBEDTLS_SHA256_C
7743requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7744requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7745requires_config_enabled MBEDTLS_AES_C
7746requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7747requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7748run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007749 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007750 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7751 crt_file=data_files/server7_int-ca.crt \
7752 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007753 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007754 exchanges=2 renegotiation=1 \
7755 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007756 hs_timeout=10000-60000 \
7757 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007758 "$P_CLI dtls=1 debug_level=2 \
7759 crt_file=data_files/server8_int-ca2.crt \
7760 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007761 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007762 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007763 hs_timeout=10000-60000 \
7764 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007765 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007766 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007767 -s "found fragmented DTLS handshake message" \
7768 -c "found fragmented DTLS handshake message" \
7769 -C "error"
7770
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007771# An autoreduction on the client-side might happen if the server is
7772# slow to reset, therefore omitting '-C "autoreduction"' below.
7773not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007774requires_config_enabled MBEDTLS_RSA_C
7775requires_config_enabled MBEDTLS_ECDSA_C
7776requires_config_enabled MBEDTLS_SHA256_C
7777requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7778requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7779requires_config_enabled MBEDTLS_AES_C
7780requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7781run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007782 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007783 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7784 crt_file=data_files/server7_int-ca.crt \
7785 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007786 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007787 exchanges=2 renegotiation=1 \
7788 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007789 hs_timeout=10000-60000 \
7790 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007791 "$P_CLI dtls=1 debug_level=2 \
7792 crt_file=data_files/server8_int-ca2.crt \
7793 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007794 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007795 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007796 hs_timeout=10000-60000 \
7797 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007798 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007799 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007800 -s "found fragmented DTLS handshake message" \
7801 -c "found fragmented DTLS handshake message" \
7802 -C "error"
7803
Andrzej Kurek77826052018-10-11 07:34:08 -04007804# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007805requires_config_enabled MBEDTLS_RSA_C
7806requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007807requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7808requires_config_enabled MBEDTLS_AES_C
7809requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007810client_needs_more_time 2
7811run_test "DTLS fragmenting: proxy MTU + 3d" \
7812 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007813 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007814 crt_file=data_files/server7_int-ca.crt \
7815 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007816 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007817 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007818 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007819 crt_file=data_files/server8_int-ca2.crt \
7820 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007821 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007822 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007823 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007824 0 \
7825 -s "found fragmented DTLS handshake message" \
7826 -c "found fragmented DTLS handshake message" \
7827 -C "error"
7828
Andrzej Kurek77826052018-10-11 07:34:08 -04007829# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007830requires_config_enabled MBEDTLS_RSA_C
7831requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007832requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7833requires_config_enabled MBEDTLS_AES_C
7834requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007835client_needs_more_time 2
7836run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7837 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7838 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7839 crt_file=data_files/server7_int-ca.crt \
7840 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007841 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007842 hs_timeout=250-10000 mtu=512 nbio=2" \
7843 "$P_CLI dtls=1 debug_level=2 \
7844 crt_file=data_files/server8_int-ca2.crt \
7845 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007846 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007847 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007848 hs_timeout=250-10000 mtu=512 nbio=2" \
7849 0 \
7850 -s "found fragmented DTLS handshake message" \
7851 -c "found fragmented DTLS handshake message" \
7852 -C "error"
7853
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007854# interop tests for DTLS fragmentating with reliable connection
7855#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007856# here and below we just want to test that the we fragment in a way that
7857# pleases other implementations, so we don't need the peer to fragment
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007858requires_config_enabled MBEDTLS_RSA_C
7859requires_config_enabled MBEDTLS_ECDSA_C
7860requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007861requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007862run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
7863 "$G_SRV -u" \
7864 "$P_CLI dtls=1 debug_level=2 \
7865 crt_file=data_files/server8_int-ca2.crt \
7866 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007867 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007868 mtu=512 force_version=dtls1_2" \
7869 0 \
7870 -c "fragmenting handshake message" \
7871 -C "error"
7872
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007873requires_config_enabled MBEDTLS_RSA_C
7874requires_config_enabled MBEDTLS_ECDSA_C
7875requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007876requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007877run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
7878 "$G_SRV -u" \
7879 "$P_CLI dtls=1 debug_level=2 \
7880 crt_file=data_files/server8_int-ca2.crt \
7881 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007882 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007883 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007884 0 \
7885 -c "fragmenting handshake message" \
7886 -C "error"
7887
Hanno Beckerb9a00862018-08-28 10:20:22 +01007888# We use --insecure for the GnuTLS client because it expects
7889# the hostname / IP it connects to to be the name used in the
7890# certificate obtained from the server. Here, however, it
7891# connects to 127.0.0.1 while our test certificates use 'localhost'
7892# as the server name in the certificate. This will make the
7893# certifiate validation fail, but passing --insecure makes
7894# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007895requires_config_enabled MBEDTLS_RSA_C
7896requires_config_enabled MBEDTLS_ECDSA_C
7897requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007898requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007899requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007900run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007901 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007902 crt_file=data_files/server7_int-ca.crt \
7903 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007904 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007905 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007906 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007907 0 \
7908 -s "fragmenting handshake message"
7909
Hanno Beckerb9a00862018-08-28 10:20:22 +01007910# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007911requires_config_enabled MBEDTLS_RSA_C
7912requires_config_enabled MBEDTLS_ECDSA_C
7913requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007914requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007915requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007916run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007917 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007918 crt_file=data_files/server7_int-ca.crt \
7919 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007920 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007921 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007922 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007923 0 \
7924 -s "fragmenting handshake message"
7925
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007926requires_config_enabled MBEDTLS_RSA_C
7927requires_config_enabled MBEDTLS_ECDSA_C
7928requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7929run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
7930 "$O_SRV -dtls1_2 -verify 10" \
7931 "$P_CLI dtls=1 debug_level=2 \
7932 crt_file=data_files/server8_int-ca2.crt \
7933 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007934 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007935 mtu=512 force_version=dtls1_2" \
7936 0 \
7937 -c "fragmenting handshake message" \
7938 -C "error"
7939
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007940requires_config_enabled MBEDTLS_RSA_C
7941requires_config_enabled MBEDTLS_ECDSA_C
7942requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7943run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
7944 "$O_SRV -dtls1 -verify 10" \
7945 "$P_CLI dtls=1 debug_level=2 \
7946 crt_file=data_files/server8_int-ca2.crt \
7947 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007948 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007949 mtu=512 force_version=dtls1" \
7950 0 \
7951 -c "fragmenting handshake message" \
7952 -C "error"
7953
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007954requires_config_enabled MBEDTLS_RSA_C
7955requires_config_enabled MBEDTLS_ECDSA_C
7956requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7957run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
7958 "$P_SRV dtls=1 debug_level=2 \
7959 crt_file=data_files/server7_int-ca.crt \
7960 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007961 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007962 mtu=512 force_version=dtls1_2" \
7963 "$O_CLI -dtls1_2" \
7964 0 \
7965 -s "fragmenting handshake message"
7966
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007967requires_config_enabled MBEDTLS_RSA_C
7968requires_config_enabled MBEDTLS_ECDSA_C
7969requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7970run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
7971 "$P_SRV dtls=1 debug_level=2 \
7972 crt_file=data_files/server7_int-ca.crt \
7973 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007974 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007975 mtu=512 force_version=dtls1" \
7976 "$O_CLI -dtls1" \
7977 0 \
7978 -s "fragmenting handshake message"
7979
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007980# interop tests for DTLS fragmentating with unreliable connection
7981#
7982# again we just want to test that the we fragment in a way that
7983# pleases other implementations, so we don't need the peer to fragment
7984requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007985requires_config_enabled MBEDTLS_RSA_C
7986requires_config_enabled MBEDTLS_ECDSA_C
7987requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007988client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007989run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
7990 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7991 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007992 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007993 crt_file=data_files/server8_int-ca2.crt \
7994 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007995 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007996 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007997 0 \
7998 -c "fragmenting handshake message" \
7999 -C "error"
8000
8001requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008002requires_config_enabled MBEDTLS_RSA_C
8003requires_config_enabled MBEDTLS_ECDSA_C
8004requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008005client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008006run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8007 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8008 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008009 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008010 crt_file=data_files/server8_int-ca2.crt \
8011 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008012 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008013 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008014 0 \
8015 -c "fragmenting handshake message" \
8016 -C "error"
8017
k-stachowiakabb843e2019-02-18 16:14:03 +01008018requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008019requires_config_enabled MBEDTLS_RSA_C
8020requires_config_enabled MBEDTLS_ECDSA_C
8021requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8022client_needs_more_time 4
8023run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8024 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8025 "$P_SRV dtls=1 debug_level=2 \
8026 crt_file=data_files/server7_int-ca.crt \
8027 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008028 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008029 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008030 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008031 0 \
8032 -s "fragmenting handshake message"
8033
k-stachowiakabb843e2019-02-18 16:14:03 +01008034requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008035requires_config_enabled MBEDTLS_RSA_C
8036requires_config_enabled MBEDTLS_ECDSA_C
8037requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8038client_needs_more_time 4
8039run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8040 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8041 "$P_SRV dtls=1 debug_level=2 \
8042 crt_file=data_files/server7_int-ca.crt \
8043 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008044 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008045 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008046 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008047 0 \
8048 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008049
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008050## Interop test with OpenSSL might trigger a bug in recent versions (including
8051## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008052## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008053## They should be re-enabled once a fixed version of OpenSSL is available
8054## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008055skip_next_test
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008056requires_config_enabled MBEDTLS_RSA_C
8057requires_config_enabled MBEDTLS_ECDSA_C
8058requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8059client_needs_more_time 4
8060run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8061 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8062 "$O_SRV -dtls1_2 -verify 10" \
8063 "$P_CLI dtls=1 debug_level=2 \
8064 crt_file=data_files/server8_int-ca2.crt \
8065 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008066 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008067 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8068 0 \
8069 -c "fragmenting handshake message" \
8070 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008071
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008072skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008073requires_config_enabled MBEDTLS_RSA_C
8074requires_config_enabled MBEDTLS_ECDSA_C
8075requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008076client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008077run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8078 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008079 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008080 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008081 crt_file=data_files/server8_int-ca2.crt \
8082 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008083 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008084 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008085 0 \
8086 -c "fragmenting handshake message" \
8087 -C "error"
8088
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008089skip_next_test
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008090requires_config_enabled MBEDTLS_RSA_C
8091requires_config_enabled MBEDTLS_ECDSA_C
8092requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8093client_needs_more_time 4
8094run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8095 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8096 "$P_SRV dtls=1 debug_level=2 \
8097 crt_file=data_files/server7_int-ca.crt \
8098 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008099 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008100 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8101 "$O_CLI -dtls1_2" \
8102 0 \
8103 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008104
8105# -nbio is added to prevent s_client from blocking in case of duplicated
8106# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008107skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008108requires_config_enabled MBEDTLS_RSA_C
8109requires_config_enabled MBEDTLS_ECDSA_C
8110requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008111client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008112run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8113 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008114 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008115 crt_file=data_files/server7_int-ca.crt \
8116 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008117 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008118 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008119 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008120 0 \
8121 -s "fragmenting handshake message"
8122
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008123# Tests for specific things with "unreliable" UDP connection
8124
8125not_with_valgrind # spurious resend due to timeout
8126run_test "DTLS proxy: reference" \
8127 -p "$P_PXY" \
8128 "$P_SRV dtls=1 debug_level=2" \
8129 "$P_CLI dtls=1 debug_level=2" \
8130 0 \
8131 -C "replayed record" \
8132 -S "replayed record" \
Hanno Beckere03eb7b2019-07-19 15:43:09 +01008133 -C "Buffer record from epoch" \
8134 -S "Buffer record from epoch" \
8135 -C "ssl_buffer_message" \
8136 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008137 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008138 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008139 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008140 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008141 -c "HTTP/1.0 200 OK"
8142
8143not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008144run_test "DTLS proxy: duplicate every packet" \
8145 -p "$P_PXY duplicate=1" \
Hanno Becker7f376f42019-06-12 16:20:48 +01008146 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008147 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008148 0 \
8149 -c "replayed record" \
8150 -s "replayed record" \
8151 -c "record from another epoch" \
8152 -s "record from another epoch" \
8153 -S "resend" \
8154 -s "Extra-header:" \
8155 -c "HTTP/1.0 200 OK"
8156
8157run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8158 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008159 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8160 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008161 0 \
8162 -c "replayed record" \
8163 -S "replayed record" \
8164 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008165 -s "record from another epoch" \
8166 -c "resend" \
8167 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008168 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008169 -c "HTTP/1.0 200 OK"
8170
8171run_test "DTLS proxy: multiple records in same datagram" \
8172 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008173 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8174 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008175 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008176 -c "next record in same datagram" \
8177 -s "next record in same datagram"
8178
8179run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8180 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008181 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8182 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008183 0 \
8184 -c "next record in same datagram" \
8185 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008186
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008187run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8188 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008189 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8190 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008191 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008192 -c "discarding invalid record (mac)" \
8193 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008194 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008195 -c "HTTP/1.0 200 OK" \
8196 -S "too many records with bad MAC" \
8197 -S "Verification of the message MAC failed"
8198
8199run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8200 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008201 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8202 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008203 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008204 -C "discarding invalid record (mac)" \
8205 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008206 -S "Extra-header:" \
8207 -C "HTTP/1.0 200 OK" \
8208 -s "too many records with bad MAC" \
8209 -s "Verification of the message MAC failed"
8210
8211run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8212 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008213 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8214 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008215 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008216 -c "discarding invalid record (mac)" \
8217 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008218 -s "Extra-header:" \
8219 -c "HTTP/1.0 200 OK" \
8220 -S "too many records with bad MAC" \
8221 -S "Verification of the message MAC failed"
8222
8223run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8224 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008225 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8226 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008227 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008228 -c "discarding invalid record (mac)" \
8229 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008230 -s "Extra-header:" \
8231 -c "HTTP/1.0 200 OK" \
8232 -s "too many records with bad MAC" \
8233 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008234
8235run_test "DTLS proxy: delay ChangeCipherSpec" \
8236 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008237 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8238 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008239 0 \
8240 -c "record from another epoch" \
8241 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008242 -s "Extra-header:" \
8243 -c "HTTP/1.0 200 OK"
8244
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008245# Tests for reordering support with DTLS
8246
Hanno Becker56cdfd12018-08-17 13:42:15 +01008247run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8248 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008249 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8250 hs_timeout=2500-60000" \
8251 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8252 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008253 0 \
8254 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008255 -c "Next handshake message has been buffered - load"\
8256 -S "Buffering HS message" \
8257 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008258 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008259 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008260 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008261 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008262
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008263run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8264 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008265 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8266 hs_timeout=2500-60000" \
8267 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8268 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008269 0 \
8270 -c "Buffering HS message" \
8271 -c "found fragmented DTLS handshake message"\
8272 -c "Next handshake message 1 not or only partially bufffered" \
8273 -c "Next handshake message has been buffered - load"\
8274 -S "Buffering HS message" \
8275 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008276 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008277 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008278 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008279 -S "Remember CCS message"
8280
Hanno Beckera1adcca2018-08-24 14:41:07 +01008281# The client buffers the ServerKeyExchange before receiving the fragmented
8282# Certificate message; at the time of writing, together these are aroudn 1200b
8283# in size, so that the bound below ensures that the certificate can be reassembled
8284# while keeping the ServerKeyExchange.
8285requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8286run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008287 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008288 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8289 hs_timeout=2500-60000" \
8290 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8291 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008292 0 \
8293 -c "Buffering HS message" \
8294 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008295 -C "attempt to make space by freeing buffered messages" \
8296 -S "Buffering HS message" \
8297 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008298 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008299 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008300 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008301 -S "Remember CCS message"
8302
8303# The size constraints ensure that the delayed certificate message can't
8304# be reassembled while keeping the ServerKeyExchange message, but it can
8305# when dropping it first.
8306requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8307requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8308run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8309 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008310 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8311 hs_timeout=2500-60000" \
8312 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8313 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008314 0 \
8315 -c "Buffering HS message" \
8316 -c "attempt to make space by freeing buffered future messages" \
8317 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008318 -S "Buffering HS message" \
8319 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008320 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008321 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008322 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008323 -S "Remember CCS message"
8324
Hanno Becker56cdfd12018-08-17 13:42:15 +01008325run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8326 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008327 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8328 hs_timeout=2500-60000" \
8329 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8330 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008331 0 \
8332 -C "Buffering HS message" \
8333 -C "Next handshake message has been buffered - load"\
8334 -s "Buffering HS message" \
8335 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008336 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008337 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008338 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008339 -S "Remember CCS message"
8340
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02008341# This needs session tickets; otherwise CCS is the first message in its flight
8342requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008343run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8344 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008345 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8346 hs_timeout=2500-60000" \
8347 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8348 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008349 0 \
8350 -C "Buffering HS message" \
8351 -C "Next handshake message has been buffered - load"\
8352 -S "Buffering HS message" \
8353 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008354 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008355 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008356 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008357 -S "Remember CCS message"
8358
8359run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8360 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008361 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8362 hs_timeout=2500-60000" \
8363 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8364 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008365 0 \
8366 -C "Buffering HS message" \
8367 -C "Next handshake message has been buffered - load"\
8368 -S "Buffering HS message" \
8369 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008370 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008371 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008372 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008373 -s "Remember CCS message"
8374
Hanno Beckera1adcca2018-08-24 14:41:07 +01008375run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008376 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008377 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8378 hs_timeout=2500-60000" \
8379 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8380 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008381 0 \
8382 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008383 -s "Found buffered record from current epoch - load" \
8384 -c "Buffer record from epoch 1" \
8385 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008386
Hanno Beckera1adcca2018-08-24 14:41:07 +01008387# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8388# from the server are delayed, so that the encrypted Finished message
8389# is received and buffered. When the fragmented NewSessionTicket comes
8390# in afterwards, the encrypted Finished message must be freed in order
8391# to make space for the NewSessionTicket to be reassembled.
8392# This works only in very particular circumstances:
8393# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8394# of the NewSessionTicket, but small enough to also allow buffering of
8395# the encrypted Finished message.
8396# - The MTU setting on the server must be so small that the NewSessionTicket
8397# needs to be fragmented.
8398# - All messages sent by the server must be small enough to be either sent
8399# without fragmentation or be reassembled within the bounds of
8400# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8401# handshake, omitting CRTs.
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008402requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8403requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008404run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8405 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008406 "$P_SRV mtu=140 response_size=90 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008407 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8408 0 \
8409 -s "Buffer record from epoch 1" \
8410 -s "Found buffered record from current epoch - load" \
8411 -c "Buffer record from epoch 1" \
8412 -C "Found buffered record from current epoch - load" \
8413 -c "Enough space available after freeing future epoch record"
8414
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008415# Tests for "randomly unreliable connection": try a variety of flows and peers
8416
8417client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008418run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8419 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008420 "$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 +02008421 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008422 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008423 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8424 0 \
8425 -s "Extra-header:" \
8426 -c "HTTP/1.0 200 OK"
8427
Janos Follath74537a62016-09-02 13:45:28 +01008428client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008429run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8430 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008431 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8432 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008433 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8434 0 \
8435 -s "Extra-header:" \
8436 -c "HTTP/1.0 200 OK"
8437
Janos Follath74537a62016-09-02 13:45:28 +01008438client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008439run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8440 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008441 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8442 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008443 0 \
8444 -s "Extra-header:" \
8445 -c "HTTP/1.0 200 OK"
8446
Janos Follath74537a62016-09-02 13:45:28 +01008447client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008448run_test "DTLS proxy: 3d, FS, client auth" \
8449 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008450 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8451 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008452 0 \
8453 -s "Extra-header:" \
8454 -c "HTTP/1.0 200 OK"
8455
Janos Follath74537a62016-09-02 13:45:28 +01008456client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008457run_test "DTLS proxy: 3d, FS, ticket" \
8458 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008459 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8460 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008461 0 \
8462 -s "Extra-header:" \
8463 -c "HTTP/1.0 200 OK"
8464
Janos Follath74537a62016-09-02 13:45:28 +01008465client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008466run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8467 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008468 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8469 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008470 0 \
8471 -s "Extra-header:" \
8472 -c "HTTP/1.0 200 OK"
8473
Janos Follath74537a62016-09-02 13:45:28 +01008474client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008475run_test "DTLS proxy: 3d, max handshake, nbio" \
8476 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008477 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008478 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008479 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008480 0 \
8481 -s "Extra-header:" \
8482 -c "HTTP/1.0 200 OK"
8483
Janos Follath74537a62016-09-02 13:45:28 +01008484client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008485requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008486requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008487requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008488run_test "DTLS proxy: 3d, min handshake, resumption" \
8489 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008490 "$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 +02008491 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008492 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008493 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8494 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8495 0 \
8496 -s "a session has been resumed" \
8497 -c "a session has been resumed" \
8498 -s "Extra-header:" \
8499 -c "HTTP/1.0 200 OK"
8500
Janos Follath74537a62016-09-02 13:45:28 +01008501client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008502requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008503requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008504requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008505run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8506 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008507 "$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 +02008508 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008509 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008510 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8511 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8512 0 \
8513 -s "a session has been resumed" \
8514 -c "a session has been resumed" \
8515 -s "Extra-header:" \
8516 -c "HTTP/1.0 200 OK"
8517
Janos Follath74537a62016-09-02 13:45:28 +01008518client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008519requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008520run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008521 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008522 "$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 +02008523 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008524 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008525 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008526 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8527 0 \
8528 -c "=> renegotiate" \
8529 -s "=> renegotiate" \
8530 -s "Extra-header:" \
8531 -c "HTTP/1.0 200 OK"
8532
Janos Follath74537a62016-09-02 13:45:28 +01008533client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008534requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008535run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8536 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008537 "$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 +02008538 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008539 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008540 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008541 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8542 0 \
8543 -c "=> renegotiate" \
8544 -s "=> renegotiate" \
8545 -s "Extra-header:" \
8546 -c "HTTP/1.0 200 OK"
8547
Janos Follath74537a62016-09-02 13:45:28 +01008548client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008549requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008550run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008551 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008552 "$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 +02008553 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008554 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008555 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008556 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008557 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8558 0 \
8559 -c "=> renegotiate" \
8560 -s "=> renegotiate" \
8561 -s "Extra-header:" \
8562 -c "HTTP/1.0 200 OK"
8563
Janos Follath74537a62016-09-02 13:45:28 +01008564client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008565requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008566run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008567 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008568 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008569 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008570 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008571 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008572 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008573 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8574 0 \
8575 -c "=> renegotiate" \
8576 -s "=> renegotiate" \
8577 -s "Extra-header:" \
8578 -c "HTTP/1.0 200 OK"
8579
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008580## Interop tests with OpenSSL might trigger a bug in recent versions (including
8581## all versions installed on the CI machines), reported here:
8582## Bug report: https://github.com/openssl/openssl/issues/6902
8583## They should be re-enabled once a fixed version of OpenSSL is available
8584## (this should happen in some 1.1.1_ release according to the ticket).
8585skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008586client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008587not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008588run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008589 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8590 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008591 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008592 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008593 -c "HTTP/1.0 200 OK"
8594
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008595skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008596client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008597not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008598run_test "DTLS proxy: 3d, openssl server, fragmentation" \
8599 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8600 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008601 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008602 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008603 -c "HTTP/1.0 200 OK"
8604
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008605skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008606client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008607not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008608run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8609 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8610 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008611 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008612 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008613 -c "HTTP/1.0 200 OK"
8614
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008615requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008616client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008617not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008618run_test "DTLS proxy: 3d, gnutls server" \
8619 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8620 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008621 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008622 0 \
8623 -s "Extra-header:" \
8624 -c "Extra-header:"
8625
k-stachowiakabb843e2019-02-18 16:14:03 +01008626requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008627client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008628not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008629run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
8630 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008631 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008632 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008633 0 \
8634 -s "Extra-header:" \
8635 -c "Extra-header:"
8636
k-stachowiakabb843e2019-02-18 16:14:03 +01008637requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008638client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008639not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008640run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8641 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008642 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008643 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008644 0 \
8645 -s "Extra-header:" \
8646 -c "Extra-header:"
8647
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008648# Final report
8649
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008650echo "------------------------------------------------------------------------"
8651
8652if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008653 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008654else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008655 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008656fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008657PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008658echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008659
8660exit $FAILS