blob: efd1fb34cc3288df7e478aef751941d246f46ed8 [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
Arto Kinnunenc0d2fa72019-09-26 10:33:56 +030024# Detect used test environment: Mbed TLS or Mbed OS
25if [ -f "../include/mbedtls/config.h" ]
26then
27 CONFIG_FILE=../include/mbedtls/config.h
28elif [ -f "../inc/mbedtls/test_config.h" ]
29then
30 CONFIG_FILE=../inc/mbedtls/test_config.h
31else
32 echo "Can't locate config file, must be run from mbed TLS root" >&2
33 exit 1
34fi
35
Jaeden Ameroa258ccd2019-07-03 13:51:04 +010036# Limit the size of each log to 10 GiB, in case of failures with this script
37# where it may output seemingly unlimited length error logs.
38ulimit -f 20971520
39
Angus Grattonc4dd0732018-04-11 16:28:39 +100040if cd $( dirname $0 ); then :; else
41 echo "cd $( dirname $0 ) failed" >&2
42 exit 1
43fi
44
Antonin Décimod5f47592019-01-23 15:24:37 +010045# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010046: ${P_SRV:=../programs/ssl/ssl_server2}
47: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020048: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010049: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020050: ${GNUTLS_CLI:=gnutls-cli}
51: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020052: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010053
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020054O_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 +010055O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020056G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010057G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020058TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010059
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020060# alternative versions of OpenSSL and GnuTLS (no default path)
61
62if [ -n "${OPENSSL_LEGACY:-}" ]; then
63 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
64 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
65else
66 O_LEGACY_SRV=false
67 O_LEGACY_CLI=false
68fi
69
Hanno Becker58e9dc32018-08-17 15:53:21 +010070if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020071 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
72else
73 G_NEXT_SRV=false
74fi
75
Hanno Becker58e9dc32018-08-17 15:53:21 +010076if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020077 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
78else
79 G_NEXT_CLI=false
80fi
81
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010082TESTS=0
83FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020084SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010085
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010086MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010087FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020088EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010089
Paul Bakkere20310a2016-05-10 11:18:17 +010090SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010091RUN_TEST_NUMBER=''
92
Paul Bakkeracaac852016-05-10 11:47:13 +010093PRESERVE_LOGS=0
94
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095# Pick a "unique" server port in the range 10000-19999, and a proxy
96# port which is this plus 10000. Each port number may be independently
97# overridden by a command line option.
98SRV_PORT=$(($$ % 10000 + 10000))
99PXY_PORT=$((SRV_PORT + 10000))
100
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100101print_usage() {
102 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100103 printf " -h|--help\tPrint this help.\n"
104 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200105 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
106 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +0100107 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +0100108 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +0100109 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200110 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
111 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100112 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100113}
114
115get_options() {
116 while [ $# -gt 0 ]; do
117 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100118 -f|--filter)
119 shift; FILTER=$1
120 ;;
121 -e|--exclude)
122 shift; EXCLUDE=$1
123 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100124 -m|--memcheck)
125 MEMCHECK=1
126 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100127 -n|--number)
128 shift; RUN_TEST_NUMBER=$1
129 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100130 -s|--show-numbers)
131 SHOW_TEST_NUMBER=1
132 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100133 -p|--preserve-logs)
134 PRESERVE_LOGS=1
135 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200136 --port)
137 shift; SRV_PORT=$1
138 ;;
139 --proxy-port)
140 shift; PXY_PORT=$1
141 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100142 --seed)
143 shift; SEED="$1"
144 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100145 -h|--help)
146 print_usage
147 exit 0
148 ;;
149 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200150 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100151 print_usage
152 exit 1
153 ;;
154 esac
155 shift
156 done
157}
158
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100159# Skip next test; use this macro to skip tests which are legitimate
160# in theory and expected to be re-introduced at some point, but
161# aren't expected to succeed at the moment due to problems outside
162# our control (such as bugs in other TLS implementations).
163skip_next_test() {
164 SKIP_NEXT="YES"
165}
166
Hanno Becker91900362019-07-03 13:22:59 +0100167requires_ciphersuite_enabled() {
168 if [ -z "$($P_CLI --help | grep "$1")" ]; then
169 SKIP_NEXT="YES"
170 fi
171}
172
Hanno Becker7c48dd12018-08-28 16:09:22 +0100173get_config_value_or_default() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100174 # This function uses the query_config command line option to query the
175 # required Mbed TLS compile time configuration from the ssl_server2
176 # program. The command will always return a success value if the
177 # configuration is defined and the value will be printed to stdout.
178 #
179 # Note that if the configuration is not defined or is defined to nothing,
180 # the output of this function will be an empty string.
181 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100182}
183
Hanno Beckerab9a29b2019-09-24 16:14:39 +0100184# skip next test if the flag is enabled in config.h
185requires_config_disabled() {
186 if get_config_value_or_default $1; then
187 SKIP_NEXT="YES"
188 fi
189}
190
191requires_config_enabled() {
192 if ! get_config_value_or_default $1; then
193 SKIP_NEXT="YES"
194 fi
195}
196
Hanno Becker7c48dd12018-08-28 16:09:22 +0100197requires_config_value_at_least() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100198 VAL="$( get_config_value_or_default "$1" )"
199 if [ -z "$VAL" ]; then
200 # Should never happen
201 echo "Mbed TLS configuration $1 is not defined"
202 exit 1
203 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100204 SKIP_NEXT="YES"
205 fi
206}
207
208requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100209 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100210 if [ -z "$VAL" ]; then
211 # Should never happen
212 echo "Mbed TLS configuration $1 is not defined"
213 exit 1
214 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100215 SKIP_NEXT="YES"
216 fi
217}
218
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200219# skip next test if OpenSSL doesn't support FALLBACK_SCSV
220requires_openssl_with_fallback_scsv() {
221 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
222 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
223 then
224 OPENSSL_HAS_FBSCSV="YES"
225 else
226 OPENSSL_HAS_FBSCSV="NO"
227 fi
228 fi
229 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
230 SKIP_NEXT="YES"
231 fi
232}
233
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200234# skip next test if GnuTLS isn't available
235requires_gnutls() {
236 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200237 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200238 GNUTLS_AVAILABLE="YES"
239 else
240 GNUTLS_AVAILABLE="NO"
241 fi
242 fi
243 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
244 SKIP_NEXT="YES"
245 fi
246}
247
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200248# skip next test if GnuTLS-next isn't available
249requires_gnutls_next() {
250 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
251 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
252 GNUTLS_NEXT_AVAILABLE="YES"
253 else
254 GNUTLS_NEXT_AVAILABLE="NO"
255 fi
256 fi
257 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
258 SKIP_NEXT="YES"
259 fi
260}
261
262# skip next test if OpenSSL-legacy isn't available
263requires_openssl_legacy() {
264 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
265 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
266 OPENSSL_LEGACY_AVAILABLE="YES"
267 else
268 OPENSSL_LEGACY_AVAILABLE="NO"
269 fi
270 fi
271 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
272 SKIP_NEXT="YES"
273 fi
274}
275
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200276# skip next test if IPv6 isn't available on this host
277requires_ipv6() {
278 if [ -z "${HAS_IPV6:-}" ]; then
279 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
280 SRV_PID=$!
281 sleep 1
282 kill $SRV_PID >/dev/null 2>&1
283 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
284 HAS_IPV6="NO"
285 else
286 HAS_IPV6="YES"
287 fi
288 rm -r $SRV_OUT
289 fi
290
291 if [ "$HAS_IPV6" = "NO" ]; then
292 SKIP_NEXT="YES"
293 fi
294}
295
Andrzej Kurekb4593462018-10-11 08:43:30 -0400296# skip next test if it's i686 or uname is not available
297requires_not_i686() {
298 if [ -z "${IS_I686:-}" ]; then
299 IS_I686="YES"
300 if which "uname" >/dev/null 2>&1; then
301 if [ -z "$(uname -a | grep i686)" ]; then
302 IS_I686="NO"
303 fi
304 fi
305 fi
306 if [ "$IS_I686" = "YES" ]; then
307 SKIP_NEXT="YES"
308 fi
309}
310
Angus Grattonc4dd0732018-04-11 16:28:39 +1000311# Calculate the input & output maximum content lengths set in the config
Arto Kinnunenc0d2fa72019-09-26 10:33:56 +0300312MAX_CONTENT_LEN=$( ../scripts/config.pl -f $CONFIG_FILE get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
313MAX_IN_LEN=$( ../scripts/config.pl -f $CONFIG_FILE get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
314MAX_OUT_LEN=$( ../scripts/config.pl -f $CONFIG_FILE get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
Angus Grattonc4dd0732018-04-11 16:28:39 +1000315
316if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
317 MAX_CONTENT_LEN="$MAX_IN_LEN"
318fi
319if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
320 MAX_CONTENT_LEN="$MAX_OUT_LEN"
321fi
322
323# skip the next test if the SSL output buffer is less than 16KB
324requires_full_size_output_buffer() {
325 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
326 SKIP_NEXT="YES"
327 fi
328}
329
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200330# skip the next test if valgrind is in use
331not_with_valgrind() {
332 if [ "$MEMCHECK" -gt 0 ]; then
333 SKIP_NEXT="YES"
334 fi
335}
336
Paul Bakker362689d2016-05-13 10:33:25 +0100337# skip the next test if valgrind is NOT in use
338only_with_valgrind() {
339 if [ "$MEMCHECK" -eq 0 ]; then
340 SKIP_NEXT="YES"
341 fi
342}
343
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200344# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100345client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200346 CLI_DELAY_FACTOR=$1
347}
348
Janos Follath74537a62016-09-02 13:45:28 +0100349# wait for the given seconds after the client finished in the next test
350server_needs_more_time() {
351 SRV_DELAY_SECONDS=$1
352}
353
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100354# print_name <name>
355print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100356 TESTS=$(( $TESTS + 1 ))
357 LINE=""
358
359 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
360 LINE="$TESTS "
361 fi
362
363 LINE="$LINE$1"
364 printf "$LINE "
365 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100366 for i in `seq 1 $LEN`; do printf '.'; done
367 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100368
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100369}
370
371# fail <message>
372fail() {
373 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100374 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100375
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200376 mv $SRV_OUT o-srv-${TESTS}.log
377 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200378 if [ -n "$PXY_CMD" ]; then
379 mv $PXY_OUT o-pxy-${TESTS}.log
380 fi
381 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100382
Azim Khan19d13732018-03-29 11:04:20 +0100383 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 +0200384 echo " ! server output:"
385 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200386 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200387 echo " ! client output:"
388 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200389 if [ -n "$PXY_CMD" ]; then
390 echo " ! ========================================================"
391 echo " ! proxy output:"
392 cat o-pxy-${TESTS}.log
393 fi
394 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200395 fi
396
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200397 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100398}
399
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100400# is_polar <cmd_line>
401is_polar() {
402 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
403}
404
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200405# openssl s_server doesn't have -www with DTLS
406check_osrv_dtls() {
407 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
408 NEEDS_INPUT=1
409 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
410 else
411 NEEDS_INPUT=0
412 fi
413}
414
415# provide input to commands that need it
416provide_input() {
417 if [ $NEEDS_INPUT -eq 0 ]; then
418 return
419 fi
420
421 while true; do
422 echo "HTTP/1.0 200 OK"
423 sleep 1
424 done
425}
426
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100427# has_mem_err <log_file_name>
428has_mem_err() {
429 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
430 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
431 then
432 return 1 # false: does not have errors
433 else
434 return 0 # true: has errors
435 fi
436}
437
Unknown43dc0d62019-09-02 10:42:57 -0400438# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100439if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400440 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100441 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200442 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100443 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200444 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100445 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200446 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100447 # Make a tight loop, server normally takes less than 1s to start.
448 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
449 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400450 echo "$3 START TIMEOUT"
451 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100452 break
453 fi
454 # Linux and *BSD support decimal arguments to sleep. On other
455 # OSes this may be a tight loop.
456 sleep 0.1 2>/dev/null || true
457 done
458 }
459else
Unknown43dc0d62019-09-02 10:42:57 -0400460 echo "Warning: lsof not available, wait_app_start = sleep"
461 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200462 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100463 }
464fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200465
Unknown43dc0d62019-09-02 10:42:57 -0400466# Wait for server process $2 to be listening on port $1.
467wait_server_start() {
468 wait_app_start $1 $2 "SERVER" $SRV_OUT
469}
470
471# Wait for proxy process $2 to be listening on port $1.
472wait_proxy_start() {
473 wait_app_start $1 $2 "PROXY" $PXY_OUT
474}
475
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100476# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100477# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100478# acceptable bounds
479check_server_hello_time() {
480 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100481 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100482 # Get the Unix timestamp for now
483 CUR_TIME=$(date +'%s')
484 THRESHOLD_IN_SECS=300
485
486 # Check if the ServerHello time was printed
487 if [ -z "$SERVER_HELLO_TIME" ]; then
488 return 1
489 fi
490
491 # Check the time in ServerHello is within acceptable bounds
492 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
493 # The time in ServerHello is at least 5 minutes before now
494 return 1
495 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100496 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100497 return 1
498 else
499 return 0
500 fi
501}
502
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200503# wait for client to terminate and set CLI_EXIT
504# must be called right after starting the client
505wait_client_done() {
506 CLI_PID=$!
507
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200508 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
509 CLI_DELAY_FACTOR=1
510
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200511 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200512 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200513
514 wait $CLI_PID
515 CLI_EXIT=$?
516
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200517 kill $DOG_PID >/dev/null 2>&1
518 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200519
520 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100521
522 sleep $SRV_DELAY_SECONDS
523 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200524}
525
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200526# check if the given command uses dtls and sets global variable DTLS
527detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200528 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200529 DTLS=1
530 else
531 DTLS=0
532 fi
533}
534
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100535# Strip off a particular parameter from the command line
536# and return its value.
537# Parameter 1: Command line parameter to strip off
538# ENV I/O: CMD command line to search and modify
539extract_cmdline_argument() {
540 __ARG=$(echo "$CMD" | sed -n "s/^.* $1=\([^ ]*\).*$/\1/p")
541 CMD=$(echo "$CMD" | sed "s/$1=\([^ ]*\)//")
542}
543
544# Check compatibility of the ssl_client2/ssl_server2 command-line
545# with a particular compile-time configurable option.
546# Parameter 1: Command-line argument (e.g. extended_ms)
547# Parameter 2: Corresponding compile-time configuration
548# (e.g. MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET)
549# ENV I/O: CMD command line to search and modify
550# SKIP_NEXT set to "YES" on a mismatch
551check_cmdline_param_compat() {
552 __VAL="$( get_config_value_or_default "$2" )"
553 if [ ! -z "$__VAL" ]; then
554 extract_cmdline_argument "$1"
555 if [ ! -z "$__ARG" ] && [ "$__ARG" != "$__VAL" ]; then
556 SKIP_NEXT="YES"
557 fi
558 fi
559}
560
Hanno Beckera43f85c2019-09-05 14:51:20 +0100561check_cmdline_check_tls_dtls() {
Hanno Becker73b72d12019-07-26 12:00:38 +0100562 detect_dtls "$CMD"
563 if [ "$DTLS" = "0" ]; then
564 requires_config_disabled MBEDTLS_SSL_PROTO_NO_TLS
Hanno Beckera43f85c2019-09-05 14:51:20 +0100565 elif [ "$DTLS" = "1" ]; then
566 requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Hanno Becker73b72d12019-07-26 12:00:38 +0100567 fi
568}
569
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100570check_cmdline_authmode_compat() {
571 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_AUTHMODE" )"
572 if [ ! -z "$__VAL" ]; then
573 extract_cmdline_argument "auth_mode"
574 if [ "$__ARG" = "none" ] && [ "$__VAL" != "0" ]; then
575 SKIP_NEXT="YES";
576 elif [ "$__ARG" = "optional" ] && [ "$__VAL" != "1" ]; then
577 SKIP_NEXT="YES"
578 elif [ "$__ARG" = "required" ] && [ "$__VAL" != "2" ]; then
579 SKIP_NEXT="YES"
580 fi
581 fi
582}
583
Hanno Beckerb0b2b672019-06-12 16:58:10 +0100584check_cmdline_legacy_renego_compat() {
585 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_ALLOW_LEGACY_RENEGOTIATION" )"
586 if [ ! -z "$__VAL" ]; then
587 extract_cmdline_argument "allow_legacy"
588 if [ "$__ARG" = "-1" ] && [ "$__VAL" != "2" ]; then
589 SKIP_NEXT="YES";
590 elif [ "$__ARG" = "0" ] && [ "$__VAL" != "0" ]; then
591 SKIP_NEXT="YES"
592 elif [ "$__ARG" = "1" ] && [ "$__VAL" != "1" ]; then
593 SKIP_NEXT="YES"
594 fi
595 fi
596}
597
Hanno Beckerd82a0302019-07-05 11:40:52 +0100598check_cmdline_min_minor_version_compat() {
599 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MIN_MINOR_VER" )"
600 if [ ! -z "$__VAL" ]; then
601 extract_cmdline_argument "min_version"
602 if [ "$__ARG" = "ssl3" ] && [ "$__VAL" != "0" ]; then
603 SKIP_NEXT="YES";
604 elif [ "$__ARG" = "tls1" ] && [ "$__VAL" != "1" ]; then
605 SKIP_NEXT="YES"
606 elif [ "$__ARG" = "tls1_1" ] && [ "$__VAL" != "2" ]; then
607 SKIP_NEXT="YES"
608 elif [ "$__ARG" = "tls1_2" ] && [ "$__VAL" != "3" ]; then
609 SKIP_NEXT="YES"
610 fi
611 fi
612}
613
614check_cmdline_max_minor_version_compat() {
615 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MAX_MINOR_VER" )"
616 if [ ! -z "$__VAL" ]; then
617 extract_cmdline_argument "max_version"
618 if [ "$__ARG" = "ssl3" ] && [ "$__VAL" != "0" ]; then
619 SKIP_NEXT="YES";
620 elif [ "$__ARG" = "tls1" ] && [ "$__VAL" != "1" ]; then
621 SKIP_NEXT="YES"
622 elif [ "$__ARG" = "tls1_1" ] && [ "$__VAL" != "2" ]; then
623 SKIP_NEXT="YES"
624 elif [ "$__ARG" = "tls1_2" ] && [ "$__VAL" != "3" ]; then
625 SKIP_NEXT="YES"
626 fi
627 fi
628}
629
630check_cmdline_force_version_compat() {
631 __VAL_MAX="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MAX_MINOR_VER" )"
632 __VAL_MIN="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MIN_MINOR_VER" )"
633 if [ ! -z "$__VAL_MIN" ]; then
634
635 # SSL cli/srv cmd line
636
637 extract_cmdline_argument "force_version"
638 if [ "$__ARG" = "ssl3" ] && \
639 ( [ "$__VAL_MIN" != "0" ] || [ "$__VAL_MAX" != "0" ] ); then
640 SKIP_NEXT="YES";
641 elif [ "$__ARG" = "tls1" ] && \
642 ( [ "$__VAL_MIN" != "1" ] || [ "$__VAL_MAX" != "1" ] ); then
643 SKIP_NEXT="YES"
644 elif ( [ "$__ARG" = "tls1_1" ] || [ "$__ARG" = "dtls1" ] ) && \
645 ( [ "$__VAL_MIN" != "2" ] || [ "$__VAL_MAX" != "2" ] ); then
646 SKIP_NEXT="YES"
647 elif ( [ "$__ARG" = "tls1_2" ] || [ "$__ARG" = "dtls1_2" ] ) && \
648 ( [ "$__VAL_MIN" != "3" ] || [ "$__VAL_MAX" != "3" ] ); then
649 echo "FORCE SKIP"
650 SKIP_NEXT="YES"
651 fi
652
653 # OpenSSL cmd line
654
655 if echo "$CMD" | grep -e "-tls1\($\|[^_]\)" > /dev/null; then
656 if [ "$__VAL_MIN" != "1" ] || [ "$__VAL_MAX" != "1" ]; then
657 SKIP_NEXT="YES"
658 fi
659 fi
660
661 if echo "$CMD" | grep -e "-\(dtls1\($\|[^_]\)\|tls1_1\)" > /dev/null; then
662 if [ "$__VAL_MIN" != "2" ] || [ "$__VAL_MAX" != "2" ]; then
663 SKIP_NEXT="YES"
664 fi
665 fi
666
667 if echo "$CMD" | grep -e "-\(dtls1_2\($\|[^_]\)\|tls1_2\)" > /dev/null; then
668 if [ "$__VAL_MIN" != "3" ] || [ "$__VAL_MAX" != "3" ]; then
669 SKIP_NEXT="YES"
670 fi
671 fi
672
673 fi
674}
675
Hanno Becker69c6cde2019-09-02 14:34:23 +0100676check_cmdline_crt_key_files_compat() {
677
678 # test-ca2.crt
679 if echo "$CMD" | grep -e "test-ca2" > /dev/null; then
680 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
681 fi
682
683 # Variants of server5.key and server5.crt
684 if echo "$CMD" | grep -e "server5" > /dev/null; then
685 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
686 fi
687
688 # Variants of server6.key and server6.crt
689 if echo "$CMD" | grep -e "server6" > /dev/null; then
690 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
691 fi
692
693}
694
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100695# Go through all options that can be hardcoded at compile-time and
696# detect whether the command line configures them in a conflicting
697# way. If so, skip the test. Otherwise, remove the corresponding
698# entry.
699# Parameter 1: Command line to inspect
700# Output: Modified command line
701# ENV I/O: SKIP_TEST set to 1 on mismatch.
702check_cmdline_compat() {
703 CMD="$1"
704
Hanno Becker69c6cde2019-09-02 14:34:23 +0100705 # Check that if we're specifying particular certificate and/or
706 # ECC key files, the corresponding curve is enabled.
707 check_cmdline_crt_key_files_compat
708
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100709 # ExtendedMasterSecret configuration
710 check_cmdline_param_compat "extended_ms" \
711 "MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET"
712 check_cmdline_param_compat "enforce_extended_master_secret" \
713 "MBEDTLS_SSL_CONF_ENFORCE_EXTENDED_MASTER_SECRET"
Hanno Becker7f376f42019-06-12 16:20:48 +0100714
715 # DTLS anti replay protection configuration
716 check_cmdline_param_compat "anti_replay" \
717 "MBEDTLS_SSL_CONF_ANTI_REPLAY"
718
Hanno Beckerde671542019-06-12 16:30:46 +0100719 # DTLS bad MAC limit
720 check_cmdline_param_compat "badmac_limit" \
721 "MBEDTLS_SSL_CONF_BADMAC_LIMIT"
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100722
Hanno Beckera43f85c2019-09-05 14:51:20 +0100723 # Skip tests relying on TLS/DTLS in configs that disable it.
724 check_cmdline_check_tls_dtls
Hanno Becker73b72d12019-07-26 12:00:38 +0100725
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100726 # Authentication mode
727 check_cmdline_authmode_compat
Hanno Beckerb0b2b672019-06-12 16:58:10 +0100728
729 # Legacy renegotiation
730 check_cmdline_legacy_renego_compat
Hanno Beckerd82a0302019-07-05 11:40:52 +0100731
732 # Version configuration
733 check_cmdline_min_minor_version_compat
734 check_cmdline_max_minor_version_compat
735 check_cmdline_force_version_compat
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100736}
737
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200738# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100739# Options: -s pattern pattern that must be present in server output
740# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100741# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100742# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100743# -S pattern pattern that must be absent in server output
744# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100745# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100746# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100747run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100748 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200749 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100750
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100751 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
752 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200753 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100754 return
755 fi
756
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100757 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100758
Paul Bakkerb7584a52016-05-10 10:50:43 +0100759 # Do we only run numbered tests?
760 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
761 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
762 else
763 SKIP_NEXT="YES"
764 fi
765
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200766 # does this test use a proxy?
767 if [ "X$1" = "X-p" ]; then
768 PXY_CMD="$2"
769 shift 2
770 else
771 PXY_CMD=""
772 fi
773
774 # get commands and client output
775 SRV_CMD="$1"
776 CLI_CMD="$2"
777 CLI_EXPECT="$3"
778 shift 3
779
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100780 check_cmdline_compat "$SRV_CMD"
781 SRV_CMD="$CMD"
782
783 check_cmdline_compat "$CLI_CMD"
784 CLI_CMD="$CMD"
785
Hanno Becker7a11e722019-05-10 14:38:42 +0100786 # Check if test uses files
787 TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
788 if [ ! -z "$TEST_USES_FILES" ]; then
789 requires_config_enabled MBEDTLS_FS_IO
790 fi
791
792 # should we skip?
793 if [ "X$SKIP_NEXT" = "XYES" ]; then
794 SKIP_NEXT="NO"
795 echo "SKIP"
796 SKIPS=$(( $SKIPS + 1 ))
797 return
798 fi
799
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200800 # fix client port
801 if [ -n "$PXY_CMD" ]; then
802 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
803 else
804 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
805 fi
806
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200807 # update DTLS variable
808 detect_dtls "$SRV_CMD"
809
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100810 # prepend valgrind to our commands if active
811 if [ "$MEMCHECK" -gt 0 ]; then
812 if is_polar "$SRV_CMD"; then
813 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
814 fi
815 if is_polar "$CLI_CMD"; then
816 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
817 fi
818 fi
819
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200820 TIMES_LEFT=2
821 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200822 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200823
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200824 # run the commands
825 if [ -n "$PXY_CMD" ]; then
826 echo "$PXY_CMD" > $PXY_OUT
827 $PXY_CMD >> $PXY_OUT 2>&1 &
828 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400829 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200830 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200831
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200832 check_osrv_dtls
833 echo "$SRV_CMD" > $SRV_OUT
834 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
835 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100836 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200837
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200838 echo "$CLI_CMD" > $CLI_OUT
839 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
840 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100841
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100842 sleep 0.05
843
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200844 # terminate the server (and the proxy)
845 kill $SRV_PID
846 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100847
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200848 if [ -n "$PXY_CMD" ]; then
849 kill $PXY_PID >/dev/null 2>&1
850 wait $PXY_PID
851 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100852
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200853 # retry only on timeouts
854 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
855 printf "RETRY "
856 else
857 TIMES_LEFT=0
858 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200859 done
860
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100861 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200862 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100863 # expected client exit to incorrectly succeed in case of catastrophic
864 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100865 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200866 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100867 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100868 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100869 return
870 fi
871 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100872 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200873 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100874 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100875 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100876 return
877 fi
878 fi
879
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100880 # check server exit code
881 if [ $? != 0 ]; then
882 fail "server fail"
883 return
884 fi
885
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100886 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100887 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
888 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100889 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200890 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100891 return
892 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100893
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100894 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200895 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100896 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100897 while [ $# -gt 0 ]
898 do
899 case $1 in
900 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100901 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 +0100902 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100903 return
904 fi
905 ;;
906
907 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100908 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 +0100909 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100910 return
911 fi
912 ;;
913
914 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100915 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 +0100916 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100917 return
918 fi
919 ;;
920
921 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100922 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 +0100923 fail "pattern '$2' MUST NOT be present in the Client output"
924 return
925 fi
926 ;;
927
928 # The filtering in the following two options (-u and -U) do the following
929 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100930 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100931 # - keep one of each non-unique line
932 # - count how many lines remain
933 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
934 # if there were no duplicates.
935 "-U")
936 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
937 fail "lines following pattern '$2' must be unique in Server output"
938 return
939 fi
940 ;;
941
942 "-u")
943 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
944 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100945 return
946 fi
947 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100948 "-F")
949 if ! $2 "$SRV_OUT"; then
950 fail "function call to '$2' failed on Server output"
951 return
952 fi
953 ;;
954 "-f")
955 if ! $2 "$CLI_OUT"; then
956 fail "function call to '$2' failed on Client output"
957 return
958 fi
959 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100960
961 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200962 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100963 exit 1
964 esac
965 shift 2
966 done
967
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100968 # check valgrind's results
969 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200970 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100971 fail "Server has memory errors"
972 return
973 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200974 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100975 fail "Client has memory errors"
976 return
977 fi
978 fi
979
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100980 # if we're here, everything is ok
981 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100982 if [ "$PRESERVE_LOGS" -gt 0 ]; then
983 mv $SRV_OUT o-srv-${TESTS}.log
984 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100985 if [ -n "$PXY_CMD" ]; then
986 mv $PXY_OUT o-pxy-${TESTS}.log
987 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100988 fi
989
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200990 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100991}
992
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100993cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200994 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200995 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
996 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
997 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
998 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100999 exit 1
1000}
1001
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +01001002#
1003# MAIN
1004#
1005
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +01001006get_options "$@"
1007
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001008# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +01001009P_SRV_BIN="${P_SRV%%[ ]*}"
1010P_CLI_BIN="${P_CLI%%[ ]*}"
1011P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +01001012if [ ! -x "$P_SRV_BIN" ]; then
1013 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001014 exit 1
1015fi
Hanno Becker17c04932017-10-10 14:44:53 +01001016if [ ! -x "$P_CLI_BIN" ]; then
1017 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001018 exit 1
1019fi
Hanno Becker17c04932017-10-10 14:44:53 +01001020if [ ! -x "$P_PXY_BIN" ]; then
1021 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001022 exit 1
1023fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +01001024if [ "$MEMCHECK" -gt 0 ]; then
1025 if which valgrind >/dev/null 2>&1; then :; else
1026 echo "Memcheck not possible. Valgrind not found"
1027 exit 1
1028 fi
1029fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +01001030if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
1031 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001032 exit 1
1033fi
1034
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +02001035# used by watchdog
1036MAIN_PID="$$"
1037
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001038# We use somewhat arbitrary delays for tests:
1039# - how long do we wait for the server to start (when lsof not available)?
1040# - how long do we allow for the client to finish?
1041# (not to check performance, just to avoid waiting indefinitely)
1042# Things are slower with valgrind, so give extra time here.
1043#
1044# Note: without lsof, there is a trade-off between the running time of this
1045# script and the risk of spurious errors because we didn't wait long enough.
1046# The watchdog delay on the other hand doesn't affect normal running time of
1047# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001048if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001049 START_DELAY=6
1050 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001051else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001052 START_DELAY=2
1053 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001054fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001055
1056# some particular tests need more time:
1057# - for the client, we multiply the usual watchdog limit by a factor
1058# - for the server, we sleep for a number of seconds after the client exits
1059# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001060CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001061SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001062
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001063# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001064# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001065P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1066P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001067P_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 +02001068O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001069O_CLI="$O_CLI -connect localhost:+SRV_PORT"
1070G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001071G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001072
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001073if [ -n "${OPENSSL_LEGACY:-}" ]; then
1074 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1075 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1076fi
1077
Hanno Becker58e9dc32018-08-17 15:53:21 +01001078if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001079 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1080fi
1081
Hanno Becker58e9dc32018-08-17 15:53:21 +01001082if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001083 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001084fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001085
Gilles Peskine62469d92017-05-10 10:13:59 +02001086# Allow SHA-1, because many of our test certificates use it
1087P_SRV="$P_SRV allow_sha1=1"
1088P_CLI="$P_CLI allow_sha1=1"
1089
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001090# Also pick a unique name for intermediate files
1091SRV_OUT="srv_out.$$"
1092CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001093PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001094SESSION="session.$$"
1095
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001096SKIP_NEXT="NO"
1097
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001098trap cleanup INT TERM HUP
1099
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001100# Basic test
1101
Hanno Becker91900362019-07-03 13:22:59 +01001102run_test "Default" \
1103 "$P_SRV debug_level=3" \
1104 "$P_CLI" \
1105 0
1106
1107run_test "Default, DTLS" \
1108 "$P_SRV dtls=1" \
1109 "$P_CLI dtls=1" \
1110 0
1111
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001112# Checks that:
1113# - things work with all ciphersuites active (used with config-full in all.sh)
1114# - the expected (highest security) parameters are selected
1115# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Hanno Becker91900362019-07-03 13:22:59 +01001116requires_ciphersuite_enabled "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
1117requires_config_enabled MBEDTLS_SHA512_C
1118requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
1119requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1120run_test "Default, choose highest security suite and hash" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001121 "$P_SRV debug_level=3" \
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03001122 "$P_CLI" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001123 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001124 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001125 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001126 -s "client hello v3, signature_algorithm ext: 6" \
1127 -s "ECDHE curve: secp521r1" \
1128 -S "error" \
1129 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001130
Hanno Becker91900362019-07-03 13:22:59 +01001131requires_ciphersuite_enabled "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
1132requires_config_enabled MBEDTLS_SHA512_C
1133requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
1134requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1135run_test "Default, choose highest security suite and hash, DTLS" \
1136 "$P_SRV debug_level=3 dtls=1" \
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001137 "$P_CLI dtls=1" \
1138 0 \
1139 -s "Protocol is DTLSv1.2" \
Hanno Becker91900362019-07-03 13:22:59 +01001140 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
1141 -s "client hello v3, signature_algorithm ext: 6" \
1142 -s "ECDHE curve: secp521r1"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001143
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001144# Test current time in ServerHello
1145requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001146run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001147 "$P_SRV debug_level=3" \
1148 "$P_CLI debug_level=3" \
1149 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001150 -f "check_server_hello_time" \
1151 -F "check_server_hello_time"
1152
Simon Butcher8e004102016-10-14 00:48:33 +01001153# Test for uniqueness of IVs in AEAD ciphersuites
1154run_test "Unique IV in GCM" \
1155 "$P_SRV exchanges=20 debug_level=4" \
1156 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1157 0 \
1158 -u "IV used" \
1159 -U "IV used"
1160
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001161# Tests for rc4 option
1162
Simon Butchera410af52016-05-19 22:12:18 +01001163requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001164run_test "RC4: server disabled, client enabled" \
1165 "$P_SRV" \
1166 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1167 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001168 -s "SSL - The server has no ciphersuites in common"
1169
Simon Butchera410af52016-05-19 22:12:18 +01001170requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001171run_test "RC4: server half, client enabled" \
1172 "$P_SRV arc4=1" \
1173 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1174 1 \
1175 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001176
1177run_test "RC4: server enabled, client disabled" \
1178 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1179 "$P_CLI" \
1180 1 \
1181 -s "SSL - The server has no ciphersuites in common"
1182
1183run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001184 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001185 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1186 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001187 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001188 -S "SSL - The server has no ciphersuites in common"
1189
Hanno Beckerd26bb202018-08-17 09:54:10 +01001190# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1191
1192requires_gnutls
1193requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1194run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1195 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001196 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001197 0
1198
1199requires_gnutls
1200requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1201run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1202 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001203 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001204 0
1205
Gilles Peskinebc70a182017-05-09 15:59:24 +02001206# Tests for SHA-1 support
1207
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001208requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001209requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001210requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001211run_test "SHA-1 forbidden by default in server certificate" \
1212 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1213 "$P_CLI debug_level=2 allow_sha1=0" \
1214 1 \
1215 -c "The certificate is signed with an unacceptable hash"
1216
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001217requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1218run_test "SHA-1 forbidden by default in server certificate" \
1219 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1220 "$P_CLI debug_level=2 allow_sha1=0" \
1221 0
1222
Gilles Peskinebc70a182017-05-09 15:59:24 +02001223run_test "SHA-1 explicitly allowed in server certificate" \
1224 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1225 "$P_CLI allow_sha1=1" \
1226 0
1227
1228run_test "SHA-256 allowed by default in server certificate" \
1229 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1230 "$P_CLI allow_sha1=0" \
1231 0
1232
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001233requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001234requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001235requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001236run_test "SHA-1 forbidden by default in client certificate" \
1237 "$P_SRV auth_mode=required allow_sha1=0" \
1238 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1239 1 \
1240 -s "The certificate is signed with an unacceptable hash"
1241
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001242requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1243run_test "SHA-1 forbidden by default in client certificate" \
1244 "$P_SRV auth_mode=required allow_sha1=0" \
1245 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1246 0
1247
Gilles Peskinebc70a182017-05-09 15:59:24 +02001248run_test "SHA-1 explicitly allowed in client certificate" \
1249 "$P_SRV auth_mode=required allow_sha1=1" \
1250 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1251 0
1252
1253run_test "SHA-256 allowed by default in client certificate" \
1254 "$P_SRV auth_mode=required allow_sha1=0" \
1255 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1256 0
1257
Hanno Becker7ae8a762018-08-14 15:43:35 +01001258# Tests for datagram packing
1259run_test "DTLS: multiple records in same datagram, client and server" \
1260 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1261 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1262 0 \
1263 -c "next record in same datagram" \
1264 -s "next record in same datagram"
1265
1266run_test "DTLS: multiple records in same datagram, client only" \
1267 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1268 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1269 0 \
1270 -s "next record in same datagram" \
1271 -C "next record in same datagram"
1272
1273run_test "DTLS: multiple records in same datagram, server only" \
1274 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1275 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1276 0 \
1277 -S "next record in same datagram" \
1278 -c "next record in same datagram"
1279
1280run_test "DTLS: multiple records in same datagram, neither client nor server" \
1281 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1282 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1283 0 \
1284 -S "next record in same datagram" \
1285 -C "next record in same datagram"
1286
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001287# Tests for Truncated HMAC extension
1288
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001289run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001290 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001291 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001292 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001293 -s "dumping 'expected mac' (20 bytes)" \
1294 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001295
Hanno Becker32c55012017-11-10 08:42:54 +00001296requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001297run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001298 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001299 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001300 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001301 -s "dumping 'expected mac' (20 bytes)" \
1302 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001303
Hanno Becker32c55012017-11-10 08:42:54 +00001304requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001305run_test "Truncated HMAC: client enabled, server default" \
1306 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001307 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001308 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001309 -s "dumping 'expected mac' (20 bytes)" \
1310 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001311
Hanno Becker32c55012017-11-10 08:42:54 +00001312requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001313run_test "Truncated HMAC: client enabled, server disabled" \
1314 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001315 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001316 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001317 -s "dumping 'expected mac' (20 bytes)" \
1318 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001319
Hanno Becker32c55012017-11-10 08:42:54 +00001320requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001321run_test "Truncated HMAC: client disabled, server enabled" \
1322 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001323 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001324 0 \
1325 -s "dumping 'expected mac' (20 bytes)" \
1326 -S "dumping 'expected mac' (10 bytes)"
1327
1328requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001329run_test "Truncated HMAC: client enabled, server enabled" \
1330 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001331 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001332 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001333 -S "dumping 'expected mac' (20 bytes)" \
1334 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001335
Hanno Becker4c4f4102017-11-10 09:16:05 +00001336run_test "Truncated HMAC, DTLS: client default, server default" \
1337 "$P_SRV dtls=1 debug_level=4" \
1338 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1339 0 \
1340 -s "dumping 'expected mac' (20 bytes)" \
1341 -S "dumping 'expected mac' (10 bytes)"
1342
1343requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1344run_test "Truncated HMAC, DTLS: client disabled, server default" \
1345 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001346 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001347 0 \
1348 -s "dumping 'expected mac' (20 bytes)" \
1349 -S "dumping 'expected mac' (10 bytes)"
1350
1351requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1352run_test "Truncated HMAC, DTLS: client enabled, server default" \
1353 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001354 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001355 0 \
1356 -s "dumping 'expected mac' (20 bytes)" \
1357 -S "dumping 'expected mac' (10 bytes)"
1358
1359requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1360run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1361 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001362 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001363 0 \
1364 -s "dumping 'expected mac' (20 bytes)" \
1365 -S "dumping 'expected mac' (10 bytes)"
1366
1367requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1368run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1369 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001370 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001371 0 \
1372 -s "dumping 'expected mac' (20 bytes)" \
1373 -S "dumping 'expected mac' (10 bytes)"
1374
1375requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1376run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1377 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001378 "$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 +01001379 0 \
1380 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001381 -s "dumping 'expected mac' (10 bytes)"
1382
Jarno Lamsafa45e602019-06-04 11:33:23 +03001383# Tests for Context serialization
1384
1385requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001386run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001387 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001388 "$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 +03001389 0 \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001390 -c "Deserializing connection..." \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001391 -S "Deserializing connection..."
1392
1393requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001394run_test "Context serialization, client serializes, ChaChaPoly" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001395 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001396 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001397 0 \
1398 -c "Deserializing connection..." \
1399 -S "Deserializing connection..."
1400
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001401requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001402run_test "Context serialization, client serializes, GCM" \
1403 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1404 "$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 +03001405 0 \
1406 -c "Deserializing connection..." \
1407 -S "Deserializing connection..."
Jarno Lamsacc281b82019-06-04 15:21:13 +03001408
Jarno Lamsafa45e602019-06-04 11:33:23 +03001409requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001410requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1411run_test "Context serialization, client serializes, with CID" \
1412 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1413 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1414 0 \
1415 -c "Deserializing connection..." \
1416 -S "Deserializing connection..."
1417
1418requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001419run_test "Context serialization, server serializes, CCM" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001420 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001421 "$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 +03001422 0 \
1423 -C "Deserializing connection..." \
1424 -s "Deserializing connection..."
1425
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001426requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001427run_test "Context serialization, server serializes, ChaChaPoly" \
1428 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1429 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1430 0 \
1431 -C "Deserializing connection..." \
1432 -s "Deserializing connection..."
1433
1434requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1435run_test "Context serialization, server serializes, GCM" \
1436 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1437 "$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 +03001438 0 \
1439 -C "Deserializing connection..." \
Jarno Lamsacc281b82019-06-04 15:21:13 +03001440 -s "Deserializing connection..."
Jarno Lamsafa45e602019-06-04 11:33:23 +03001441
1442requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001443requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1444run_test "Context serialization, server serializes, with CID" \
1445 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1446 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1447 0 \
1448 -C "Deserializing connection..." \
1449 -s "Deserializing connection..."
1450
1451requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001452run_test "Context serialization, both serialize, CCM" \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001453 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001454 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1455 0 \
1456 -c "Deserializing connection..." \
1457 -s "Deserializing connection..."
1458
1459requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1460run_test "Context serialization, both serialize, ChaChaPoly" \
1461 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1462 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1463 0 \
1464 -c "Deserializing connection..." \
1465 -s "Deserializing connection..."
1466
1467requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1468run_test "Context serialization, both serialize, GCM" \
1469 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1470 "$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 +03001471 0 \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001472 -c "Deserializing connection..." \
1473 -s "Deserializing connection..."
1474
1475requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001476requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1477run_test "Context serialization, both serialize, with CID" \
1478 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1479 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1480 0 \
1481 -c "Deserializing connection..." \
1482 -s "Deserializing connection..."
1483
1484requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001485run_test "Context serialization, re-init, client serializes, CCM" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001486 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001487 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1488 0 \
1489 -c "Deserializing connection..." \
1490 -S "Deserializing connection..."
1491
1492requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1493run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1494 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1495 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1496 0 \
1497 -c "Deserializing connection..." \
1498 -S "Deserializing connection..."
1499
1500requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1501run_test "Context serialization, re-init, client serializes, GCM" \
1502 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1503 "$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 +03001504 0 \
1505 -c "Deserializing connection..." \
1506 -S "Deserializing connection..."
1507
1508requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001509requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1510run_test "Context serialization, re-init, client serializes, with CID" \
1511 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1512 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1513 0 \
1514 -c "Deserializing connection..." \
1515 -S "Deserializing connection..."
1516
1517requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001518run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001519 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001520 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1521 0 \
1522 -C "Deserializing connection..." \
1523 -s "Deserializing connection..."
1524
1525requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1526run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1527 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1528 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1529 0 \
1530 -C "Deserializing connection..." \
1531 -s "Deserializing connection..."
1532
1533requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1534run_test "Context serialization, re-init, server serializes, GCM" \
1535 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1536 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001537 0 \
1538 -C "Deserializing connection..." \
1539 -s "Deserializing connection..."
1540
1541requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001542requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1543run_test "Context serialization, re-init, server serializes, with CID" \
1544 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1545 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1546 0 \
1547 -C "Deserializing connection..." \
1548 -s "Deserializing connection..."
1549
1550requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001551run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001552 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001553 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1554 0 \
1555 -c "Deserializing connection..." \
1556 -s "Deserializing connection..."
1557
1558requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1559run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1560 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1561 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1562 0 \
1563 -c "Deserializing connection..." \
1564 -s "Deserializing connection..."
1565
1566requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1567run_test "Context serialization, re-init, both serialize, GCM" \
1568 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1569 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001570 0 \
1571 -c "Deserializing connection..." \
1572 -s "Deserializing connection..."
1573
Hanno Beckere80c1b02019-08-30 11:18:59 +01001574requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1575requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1576run_test "Context serialization, re-init, both serialize, with CID" \
1577 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1578 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001579 0 \
1580 -c "Deserializing connection..." \
Hanno Becker73455992019-04-25 17:01:43 +01001581 -s "Deserializing connection..."
Hanno Beckerc008cb52019-04-26 14:17:56 +01001582
Hanno Becker4eb05872019-04-26 16:00:29 +01001583# Tests for DTLS Connection ID extension
Hanno Beckercf2a5652019-04-26 16:13:31 +01001584
Hanno Becker5e2cd142019-04-26 16:23:52 +01001585# So far, the CID API isn't implemented, so we can't
1586# grep for output witnessing its use. This needs to be
Hanno Becker6a3ff282019-04-26 17:19:46 +01001587# changed once the CID extension is implemented.
Hanno Beckerad8e2c92019-05-08 13:19:53 +01001588
Hanno Becker2dcdc922019-04-09 18:08:47 +01001589requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckera5a2b082019-05-15 14:03:01 +01001590run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001591 "$P_SRV debug_level=3 dtls=1 cid=0" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001592 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1593 0 \
1594 -s "Disable use of CID extension." \
1595 -s "found CID extension" \
Hanno Becker73455992019-04-25 17:01:43 +01001596 -s "Client sent CID extension, but CID disabled" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001597 -c "Enable use of CID extension." \
1598 -c "client hello, adding CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001599 -S "server hello, adding CID extension" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001600 -C "found CID extension" \
1601 -S "Copy CIDs into SSL transform" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001602 -C "Copy CIDs into SSL transform" \
1603 -c "Use of Connection ID was rejected by the server"
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001604
1605requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1606run_test "Connection ID: Cli disabled, Srv enabled" \
1607 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1608 "$P_CLI debug_level=3 dtls=1 cid=0" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001609 0 \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001610 -c "Disable use of CID extension." \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001611 -C "client hello, adding CID extension" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001612 -S "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001613 -s "Enable use of CID extension." \
1614 -S "server hello, adding CID extension" \
1615 -C "found CID extension" \
1616 -S "Copy CIDs into SSL transform" \
1617 -C "Copy CIDs into SSL transform" \
1618 -s "Use of Connection ID was not offered by client"
1619
1620requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1621run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
1622 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1623 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1624 0 \
1625 -c "Enable use of CID extension." \
1626 -s "Enable use of CID extension." \
1627 -c "client hello, adding CID extension" \
1628 -s "found CID extension" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001629 -s "Use of CID extension negotiated" \
1630 -s "server hello, adding CID extension" \
1631 -c "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001632 -c "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001633 -s "Copy CIDs into SSL transform" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001634 -c "Copy CIDs into SSL transform" \
1635 -c "Peer CID (length 2 Bytes): de ad" \
1636 -s "Peer CID (length 2 Bytes): be ef" \
1637 -s "Use of Connection ID has been negotiated" \
1638 -c "Use of Connection ID has been negotiated"
1639
1640requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1641run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
1642 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
1643 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1644 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1645 0 \
1646 -c "Enable use of CID extension." \
1647 -s "Enable use of CID extension." \
1648 -c "client hello, adding CID extension" \
1649 -s "found CID extension" \
1650 -s "Use of CID extension negotiated" \
1651 -s "server hello, adding CID extension" \
1652 -c "found CID extension" \
1653 -c "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001654 -s "Copy CIDs into SSL transform" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001655 -c "Copy CIDs into SSL transform" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001656 -c "Peer CID (length 2 Bytes): de ad" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001657 -s "Peer CID (length 2 Bytes): be ef" \
1658 -s "Use of Connection ID has been negotiated" \
1659 -c "Use of Connection ID has been negotiated" \
1660 -c "ignoring unexpected CID" \
1661 -s "ignoring unexpected CID"
1662
1663requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1664run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1665 -p "$P_PXY mtu=800" \
1666 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1667 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1668 0 \
1669 -c "Enable use of CID extension." \
1670 -s "Enable use of CID extension." \
1671 -c "client hello, adding CID extension" \
1672 -s "found CID extension" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001673 -s "Use of CID extension negotiated" \
1674 -s "server hello, adding CID extension" \
1675 -c "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001676 -c "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001677 -s "Copy CIDs into SSL transform" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001678 -c "Copy CIDs into SSL transform" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001679 -c "Peer CID (length 2 Bytes): de ad" \
1680 -s "Peer CID (length 2 Bytes): be ef" \
1681 -s "Use of Connection ID has been negotiated" \
1682 -c "Use of Connection ID has been negotiated"
Hanno Becker73455992019-04-25 17:01:43 +01001683
Hanno Beckerc008cb52019-04-26 14:17:56 +01001684requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1685run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001686 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001687 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1688 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001689 0 \
1690 -c "Enable use of CID extension." \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001691 -s "Enable use of CID extension." \
1692 -c "client hello, adding CID extension" \
1693 -s "found CID extension" \
1694 -s "Use of CID extension negotiated" \
1695 -s "server hello, adding CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001696 -c "found CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001697 -c "Use of CID extension negotiated" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001698 -s "Copy CIDs into SSL transform" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001699 -c "Copy CIDs into SSL transform" \
1700 -c "Peer CID (length 2 Bytes): de ad" \
1701 -s "Peer CID (length 2 Bytes): be ef" \
1702 -s "Use of Connection ID has been negotiated" \
Hanno Becker73455992019-04-25 17:01:43 +01001703 -c "Use of Connection ID has been negotiated" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001704 -c "ignoring unexpected CID" \
1705 -s "ignoring unexpected CID"
Hanno Becker4eb05872019-04-26 16:00:29 +01001706
Hanno Beckercf2a5652019-04-26 16:13:31 +01001707requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1708run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001709 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1710 "$P_CLI debug_level=3 dtls=1 cid=1" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001711 0 \
1712 -c "Enable use of CID extension." \
1713 -s "Enable use of CID extension." \
1714 -c "client hello, adding CID extension" \
1715 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001716 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001717 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001718 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001719 -c "Use of CID extension negotiated" \
1720 -s "Copy CIDs into SSL transform" \
1721 -c "Copy CIDs into SSL transform" \
1722 -c "Peer CID (length 4 Bytes): de ad be ef" \
Hanno Becker73455992019-04-25 17:01:43 +01001723 -s "Peer CID (length 0 Bytes):" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001724 -s "Use of Connection ID has been negotiated" \
1725 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001726
Hanno Beckercf2a5652019-04-26 16:13:31 +01001727requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1728run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001729 "$P_SRV debug_level=3 dtls=1 cid=1" \
1730 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001731 0 \
1732 -c "Enable use of CID extension." \
1733 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001734 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001735 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001736 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001737 -s "server hello, adding CID extension" \
1738 -c "found CID extension" \
1739 -c "Use of CID extension negotiated" \
1740 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001741 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001742 -s "Peer CID (length 4 Bytes): de ad be ef" \
1743 -c "Peer CID (length 0 Bytes):" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001744 -s "Use of Connection ID has been negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001745 -c "Use of Connection ID has been negotiated"
1746
Hanno Becker5e2cd142019-04-26 16:23:52 +01001747requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1748run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001749 "$P_SRV debug_level=3 dtls=1 cid=1" \
1750 "$P_CLI debug_level=3 dtls=1 cid=1" \
1751 0 \
1752 -c "Enable use of CID extension." \
1753 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001754 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001755 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001756 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001757 -s "server hello, adding CID extension" \
1758 -c "found CID extension" \
1759 -c "Use of CID extension negotiated" \
1760 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001761 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001762 -S "Use of Connection ID has been negotiated" \
1763 -C "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001764
Hanno Beckercf2a5652019-04-26 16:13:31 +01001765requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1766run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001767 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1768 "$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 +01001769 0 \
1770 -c "Enable use of CID extension." \
1771 -s "Enable use of CID extension." \
1772 -c "client hello, adding CID extension" \
1773 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001774 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001775 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001776 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001777 -c "Use of CID extension negotiated" \
1778 -s "Copy CIDs into SSL transform" \
1779 -c "Copy CIDs into SSL transform" \
1780 -c "Peer CID (length 2 Bytes): de ad" \
Hanno Becker73455992019-04-25 17:01:43 +01001781 -s "Peer CID (length 2 Bytes): be ef" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001782 -s "Use of Connection ID has been negotiated" \
1783 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001784
Hanno Beckercf2a5652019-04-26 16:13:31 +01001785requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1786run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001787 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1788 "$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 +01001789 0 \
1790 -c "Enable use of CID extension." \
1791 -s "Enable use of CID extension." \
1792 -c "client hello, adding CID extension" \
1793 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001794 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001795 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001796 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001797 -c "Use of CID extension negotiated" \
1798 -s "Copy CIDs into SSL transform" \
1799 -c "Copy CIDs into SSL transform" \
1800 -c "Peer CID (length 4 Bytes): de ad be ef" \
Hanno Becker73455992019-04-25 17:01:43 +01001801 -s "Peer CID (length 0 Bytes):" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001802 -s "Use of Connection ID has been negotiated" \
1803 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001804
Hanno Beckercf2a5652019-04-26 16:13:31 +01001805requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1806run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001807 "$P_SRV debug_level=3 dtls=1 cid=1" \
1808 "$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 +01001809 0 \
1810 -c "Enable use of CID extension." \
1811 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001812 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001813 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001814 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001815 -s "server hello, adding CID extension" \
1816 -c "found CID extension" \
1817 -c "Use of CID extension negotiated" \
1818 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001819 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001820 -s "Peer CID (length 4 Bytes): de ad be ef" \
1821 -c "Peer CID (length 0 Bytes):" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001822 -s "Use of Connection ID has been negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001823 -c "Use of Connection ID has been negotiated"
1824
Hanno Becker5e2cd142019-04-26 16:23:52 +01001825requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1826run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001827 "$P_SRV debug_level=3 dtls=1 cid=1" \
1828 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1829 0 \
1830 -c "Enable use of CID extension." \
1831 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001832 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001833 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001834 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001835 -s "server hello, adding CID extension" \
1836 -c "found CID extension" \
1837 -c "Use of CID extension negotiated" \
1838 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001839 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001840 -S "Use of Connection ID has been negotiated" \
1841 -C "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001842
Hanno Beckercf2a5652019-04-26 16:13:31 +01001843requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1844run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001845 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1846 "$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 +01001847 0 \
1848 -c "Enable use of CID extension." \
1849 -s "Enable use of CID extension." \
1850 -c "client hello, adding CID extension" \
1851 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001852 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001853 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001854 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001855 -c "Use of CID extension negotiated" \
1856 -s "Copy CIDs into SSL transform" \
1857 -c "Copy CIDs into SSL transform" \
1858 -c "Peer CID (length 2 Bytes): de ad" \
Hanno Becker73455992019-04-25 17:01:43 +01001859 -s "Peer CID (length 2 Bytes): be ef" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001860 -s "Use of Connection ID has been negotiated" \
1861 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001862
Hanno Beckercf2a5652019-04-26 16:13:31 +01001863requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1864run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001865 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1866 "$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 +01001867 0 \
1868 -c "Enable use of CID extension." \
1869 -s "Enable use of CID extension." \
1870 -c "client hello, adding CID extension" \
1871 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001872 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001873 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001874 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001875 -c "Use of CID extension negotiated" \
1876 -s "Copy CIDs into SSL transform" \
1877 -c "Copy CIDs into SSL transform" \
1878 -c "Peer CID (length 4 Bytes): de ad be ef" \
Hanno Becker73455992019-04-25 17:01:43 +01001879 -s "Peer CID (length 0 Bytes):" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001880 -s "Use of Connection ID has been negotiated" \
1881 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001882
Hanno Beckercf2a5652019-04-26 16:13:31 +01001883requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1884run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001885 "$P_SRV debug_level=3 dtls=1 cid=1" \
1886 "$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 +01001887 0 \
1888 -c "Enable use of CID extension." \
1889 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001890 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001891 -s "found CID extension" \
Hanno Becker963cb352019-04-23 11:52:44 +01001892 -s "Use of CID extension negotiated" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001893 -s "server hello, adding CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001894 -c "found CID extension" \
1895 -c "Use of CID extension negotiated" \
1896 -s "Copy CIDs into SSL transform" \
Hanno Becker96870292019-05-03 17:30:59 +01001897 -c "Copy CIDs into SSL transform" \
1898 -s "Peer CID (length 4 Bytes): de ad be ef" \
1899 -c "Peer CID (length 0 Bytes):" \
1900 -s "Use of Connection ID has been negotiated" \
1901 -c "Use of Connection ID has been negotiated"
1902
1903requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1904run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
1905 "$P_SRV debug_level=3 dtls=1 cid=1" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001906 "$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 +01001907 0 \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001908 -c "Enable use of CID extension." \
Hanno Becker96870292019-05-03 17:30:59 +01001909 -s "Enable use of CID extension." \
1910 -c "client hello, adding CID extension" \
1911 -s "found CID extension" \
1912 -s "Use of CID extension negotiated" \
1913 -s "server hello, adding CID extension" \
1914 -c "found CID extension" \
1915 -c "Use of CID extension negotiated" \
1916 -s "Copy CIDs into SSL transform" \
1917 -c "Copy CIDs into SSL transform" \
1918 -S "Use of Connection ID has been negotiated" \
1919 -C "Use of Connection ID has been negotiated"
1920
Hanno Beckera5a2b082019-05-15 14:03:01 +01001921requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01001922requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01001923run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
1924 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
1925 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
1926 0 \
1927 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1928 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1929 -s "(initial handshake) Use of Connection ID has been negotiated" \
1930 -c "(initial handshake) Use of Connection ID has been negotiated" \
1931 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1932 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1933 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1934 -c "(after renegotiation) Use of Connection ID has been negotiated"
1935
Hanno Beckera5a2b082019-05-15 14:03:01 +01001936requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01001937requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001938run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001939 "$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 +01001940 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1941 0 \
1942 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1943 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1944 -s "(initial handshake) Use of Connection ID has been negotiated" \
1945 -c "(initial handshake) Use of Connection ID has been negotiated" \
1946 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1947 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1948 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1949 -c "(after renegotiation) Use of Connection ID has been negotiated"
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001950
1951requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1952requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001953run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001954 "$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 +01001955 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1956 0 \
Hanno Becker96870292019-05-03 17:30:59 +01001957 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1958 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1959 -s "(initial handshake) Use of Connection ID has been negotiated" \
1960 -c "(initial handshake) Use of Connection ID has been negotiated" \
1961 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1962 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1963 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1964 -c "(after renegotiation) Use of Connection ID has been negotiated"
1965
1966requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1967requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
1968run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001969 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker96870292019-05-03 17:30:59 +01001970 "$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 +01001971 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1972 0 \
1973 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1974 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1975 -s "(initial handshake) Use of Connection ID has been negotiated" \
1976 -c "(initial handshake) Use of Connection ID has been negotiated" \
1977 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1978 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1979 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1980 -c "(after renegotiation) Use of Connection ID has been negotiated" \
1981 -c "ignoring unexpected CID" \
1982 -s "ignoring unexpected CID"
1983
Hanno Beckera5a2b082019-05-15 14:03:01 +01001984requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01001985requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001986run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001987 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001988 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
1989 0 \
1990 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1991 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1992 -s "(initial handshake) Use of Connection ID has been negotiated" \
1993 -c "(initial handshake) Use of Connection ID has been negotiated" \
1994 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1995 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1996 -C "(after renegotiation) Use of Connection ID has been negotiated" \
1997 -S "(after renegotiation) Use of Connection ID has been negotiated"
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001998
1999requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2000requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002001run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01002002 "$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 +01002003 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2004 0 \
Hanno Becker96870292019-05-03 17:30:59 +01002005 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2006 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2007 -s "(initial handshake) Use of Connection ID has been negotiated" \
2008 -c "(initial handshake) Use of Connection ID has been negotiated" \
2009 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2010 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2011 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2012 -S "(after renegotiation) Use of Connection ID has been negotiated"
2013
2014requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckera5a2b082019-05-15 14:03:01 +01002015requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker96870292019-05-03 17:30:59 +01002016run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Becker84bbc512019-05-08 16:20:46 +01002017 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
2018 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2019 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2020 0 \
2021 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2022 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2023 -s "(initial handshake) Use of Connection ID has been negotiated" \
2024 -c "(initial handshake) Use of Connection ID has been negotiated" \
2025 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2026 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2027 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01002028 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Becker84bbc512019-05-08 16:20:46 +01002029 -c "ignoring unexpected CID" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002030 -s "ignoring unexpected CID"
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002031
Hanno Becker04ca04c2019-05-08 13:31:15 +01002032requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2033requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2034run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
2035 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2036 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2037 0 \
2038 -S "(initial handshake) Use of Connection ID has been negotiated" \
2039 -C "(initial handshake) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002040 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2041 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2042 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002043 -s "(after renegotiation) Use of Connection ID has been negotiated"
Hanno Beckera5a2b082019-05-15 14:03:01 +01002044
Hanno Becker04ca04c2019-05-08 13:31:15 +01002045requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2046requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker96870292019-05-03 17:30:59 +01002047run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2048 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2049 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2050 0 \
2051 -S "(initial handshake) Use of Connection ID has been negotiated" \
2052 -C "(initial handshake) Use of Connection ID has been negotiated" \
2053 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2054 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2055 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2056 -s "(after renegotiation) Use of Connection ID has been negotiated"
2057
2058requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2059requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckera5a2b082019-05-15 14:03:01 +01002060run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Becker96870292019-05-03 17:30:59 +01002061 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002062 "$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 +01002063 "$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 +01002064 0 \
2065 -S "(initial handshake) Use of Connection ID has been negotiated" \
2066 -C "(initial handshake) Use of Connection ID has been negotiated" \
2067 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2068 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2069 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2070 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2071 -c "ignoring unexpected CID" \
2072 -s "ignoring unexpected CID"
2073
2074requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002075requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2076run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
2077 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002078 "$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 +01002079 0 \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002080 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2081 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2082 -s "(initial handshake) Use of Connection ID has been negotiated" \
2083 -c "(initial handshake) Use of Connection ID has been negotiated" \
2084 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2085 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2086 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2087 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2088 -s "(after renegotiation) Use of Connection ID was not offered by client"
2089
2090requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2091requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2092run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
2093 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
2094 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01002095 "$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 +01002096 0 \
2097 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002098 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
Hanno Becker96870292019-05-03 17:30:59 +01002099 -s "(initial handshake) Use of Connection ID has been negotiated" \
2100 -c "(initial handshake) Use of Connection ID has been negotiated" \
2101 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2102 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2103 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2104 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2105 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2106 -c "ignoring unexpected CID" \
2107 -s "ignoring unexpected CID"
2108
2109requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002110requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2111run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2112 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01002113 "$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 +01002114 0 \
2115 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2116 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002117 -s "(initial handshake) Use of Connection ID has been negotiated" \
2118 -c "(initial handshake) Use of Connection ID has been negotiated" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002119 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2120 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2121 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2122 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2123 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2124
2125requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2126requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2127run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
2128 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002129 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2130 "$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 +01002131 0 \
2132 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2133 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2134 -s "(initial handshake) Use of Connection ID has been negotiated" \
2135 -c "(initial handshake) Use of Connection ID has been negotiated" \
2136 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2137 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2138 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2139 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002140 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2141 -c "ignoring unexpected CID" \
2142 -s "ignoring unexpected CID"
2143
2144# Tests for Encrypt-then-MAC extension
2145
2146run_test "Encrypt then MAC: default" \
2147 "$P_SRV debug_level=3 \
2148 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2149 "$P_CLI debug_level=3" \
2150 0 \
2151 -c "client hello, adding encrypt_then_mac extension" \
2152 -s "found encrypt then mac extension" \
2153 -s "server hello, adding encrypt then mac extension" \
2154 -c "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002155 -c "using encrypt then mac" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002156 -s "using encrypt then mac"
2157
2158run_test "Encrypt then MAC: client enabled, server disabled" \
2159 "$P_SRV debug_level=3 etm=0 \
2160 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2161 "$P_CLI debug_level=3 etm=1" \
2162 0 \
2163 -c "client hello, adding encrypt_then_mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002164 -s "found encrypt then mac extension" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002165 -S "server hello, adding encrypt then mac extension" \
2166 -C "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002167 -C "using encrypt then mac" \
2168 -S "using encrypt then mac"
2169
2170run_test "Encrypt then MAC: client enabled, aead cipher" \
2171 "$P_SRV debug_level=3 etm=1 \
2172 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2173 "$P_CLI debug_level=3 etm=1" \
2174 0 \
2175 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathe2681a42016-03-07 15:57:05 +00002176 -s "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002177 -S "server hello, adding encrypt then mac extension" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002178 -C "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002179 -C "using encrypt then mac" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002180 -S "using encrypt then mac"
2181
2182run_test "Encrypt then MAC: client enabled, stream cipher" \
2183 "$P_SRV debug_level=3 etm=1 \
2184 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2185 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2186 0 \
2187 -c "client hello, adding encrypt_then_mac extension" \
2188 -s "found encrypt then mac extension" \
Janos Follathe2681a42016-03-07 15:57:05 +00002189 -S "server hello, adding encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002190 -C "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002191 -C "using encrypt then mac" \
2192 -S "using encrypt then mac"
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002193
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002194run_test "Encrypt then MAC: client disabled, server enabled" \
2195 "$P_SRV debug_level=3 etm=1 \
Janos Follath00efff72016-05-06 13:48:23 +01002196 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002197 "$P_CLI debug_level=3 etm=0" \
2198 0 \
2199 -C "client hello, adding encrypt_then_mac extension" \
2200 -S "found encrypt then mac extension" \
2201 -S "server hello, adding encrypt then mac extension" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002202 -C "found encrypt_then_mac extension" \
2203 -C "using encrypt then mac" \
Jarno Lamsa31d940b2019-06-12 10:21:33 +03002204 -S "using encrypt then mac"
2205
2206requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2207run_test "Encrypt then MAC: client SSLv3, server enabled" \
2208 "$P_SRV debug_level=3 min_version=ssl3 \
2209 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2210 "$P_CLI debug_level=3 force_version=ssl3" \
2211 0 \
2212 -C "client hello, adding encrypt_then_mac extension" \
2213 -S "found encrypt then mac extension" \
2214 -S "server hello, adding encrypt then mac extension" \
2215 -C "found encrypt_then_mac extension" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002216 -C "using encrypt then mac" \
2217 -S "using encrypt then mac"
2218
2219requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2220run_test "Encrypt then MAC: client enabled, server SSLv3" \
2221 "$P_SRV debug_level=3 force_version=ssl3 \
2222 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2223 "$P_CLI debug_level=3 min_version=ssl3" \
2224 0 \
2225 -c "client hello, adding encrypt_then_mac extension" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002226 -S "found encrypt then mac extension" \
2227 -S "server hello, adding encrypt then mac extension" \
2228 -C "found encrypt_then_mac extension" \
2229 -C "using encrypt then mac" \
2230 -S "using encrypt then mac"
2231
2232# Tests for Extended Master Secret extension
2233
2234run_test "Extended Master Secret: default (not enforcing)" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002235 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0 " \
2236 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01002237 0 \
2238 -c "client hello, adding extended_master_secret extension" \
2239 -s "found extended master secret extension" \
2240 -s "server hello, adding extended master secret extension" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002241 -c "found extended_master_secret extension" \
2242 -c "session hash for extended master secret" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002243 -s "session hash for extended master secret"
2244
Jarno Lamsa41b35912019-06-10 15:51:11 +03002245run_test "Extended Master Secret: both enabled, both enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002246 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2247 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002248 0 \
2249 -c "client hello, adding extended_master_secret extension" \
2250 -s "found extended master secret extension" \
2251 -s "server hello, adding extended master secret extension" \
2252 -c "found extended_master_secret extension" \
2253 -c "session hash for extended master secret" \
2254 -s "session hash for extended master secret"
2255
Jarno Lamsa20095af2019-06-11 17:16:58 +03002256run_test "Extended Master Secret: both enabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002257 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2258 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002259 0 \
2260 -c "client hello, adding extended_master_secret extension" \
2261 -s "found extended master secret extension" \
2262 -s "server hello, adding extended master secret extension" \
2263 -c "found extended_master_secret extension" \
2264 -c "session hash for extended master secret" \
2265 -s "session hash for extended master secret"
2266
2267run_test "Extended Master Secret: both enabled, server enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002268 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2269 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002270 0 \
2271 -c "client hello, adding extended_master_secret extension" \
2272 -s "found extended master secret extension" \
2273 -s "server hello, adding extended master secret extension" \
2274 -c "found extended_master_secret extension" \
2275 -c "session hash for extended master secret" \
2276 -s "session hash for extended master secret"
2277
2278run_test "Extended Master Secret: client enabled, server disabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002279 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002280 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2281 1 \
2282 -c "client hello, adding extended_master_secret extension" \
2283 -s "found extended master secret extension" \
2284 -S "server hello, adding extended master secret extension" \
2285 -C "found extended_master_secret extension" \
2286 -c "Peer not offering extended master secret, while it is enforced"
2287
Jarno Lamsa20095af2019-06-11 17:16:58 +03002288run_test "Extended Master Secret enforced: client disabled, server enabled, server enforcing" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002289 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002290 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002291 1 \
2292 -C "client hello, adding extended_master_secret extension" \
2293 -S "found extended master secret extension" \
2294 -S "server hello, adding extended master secret extension" \
2295 -C "found extended_master_secret extension" \
2296 -s "Peer not offering extended master secret, while it is enforced"
2297
Jarno Lamsa20095af2019-06-11 17:16:58 +03002298run_test "Extended Master Secret: client enabled, server disabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002299 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2300 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002301 0 \
2302 -c "client hello, adding extended_master_secret extension" \
2303 -s "found extended master secret extension" \
2304 -S "server hello, adding extended master secret extension" \
2305 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002306 -C "session hash for extended master secret" \
2307 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002308
Jarno Lamsa20095af2019-06-11 17:16:58 +03002309run_test "Extended Master Secret: client disabled, server enabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002310 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2311 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002312 0 \
2313 -C "client hello, adding extended_master_secret extension" \
2314 -S "found extended master secret extension" \
2315 -S "server hello, adding extended master secret extension" \
2316 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002317 -C "session hash for extended master secret" \
2318 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002319
Jarno Lamsa20095af2019-06-11 17:16:58 +03002320run_test "Extended Master Secret: client disabled, server disabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002321 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2322 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002323 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" \
2328 -C "session hash for extended master secret" \
2329 -S "session hash for extended master secret"
2330
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 SSLv3, server enabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002333 "$P_SRV debug_level=3 min_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2334 "$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 +02002335 0 \
2336 -C "client hello, adding extended_master_secret extension" \
2337 -S "found extended master secret extension" \
2338 -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
Janos Follathe2681a42016-03-07 15:57:05 +00002343requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002344run_test "Extended Master Secret: client enabled, server SSLv3" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002345 "$P_SRV debug_level=3 force_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2346 "$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 +02002347 0 \
2348 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002349 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002350 -S "server hello, adding extended master secret extension" \
2351 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002352 -C "session hash for extended master secret" \
2353 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002354
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002355# Tests for FALLBACK_SCSV
2356
2357run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002358 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002359 "$P_CLI debug_level=3 force_version=tls1_1" \
2360 0 \
2361 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002362 -S "received FALLBACK_SCSV" \
2363 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002364 -C "is a fatal alert message (msg 86)"
2365
2366run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002367 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002368 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2369 0 \
2370 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002371 -S "received FALLBACK_SCSV" \
2372 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002373 -C "is a fatal alert message (msg 86)"
2374
2375run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002376 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002377 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002378 1 \
2379 -c "adding FALLBACK_SCSV" \
2380 -s "received FALLBACK_SCSV" \
2381 -s "inapropriate fallback" \
2382 -c "is a fatal alert message (msg 86)"
2383
2384run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002385 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002386 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002387 0 \
2388 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002389 -s "received FALLBACK_SCSV" \
2390 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002391 -C "is a fatal alert message (msg 86)"
2392
2393requires_openssl_with_fallback_scsv
2394run_test "Fallback SCSV: default, openssl server" \
2395 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002396 "$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 +02002397 0 \
2398 -C "adding FALLBACK_SCSV" \
2399 -C "is a fatal alert message (msg 86)"
2400
2401requires_openssl_with_fallback_scsv
2402run_test "Fallback SCSV: enabled, openssl server" \
2403 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002404 "$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 +02002405 1 \
2406 -c "adding FALLBACK_SCSV" \
2407 -c "is a fatal alert message (msg 86)"
2408
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002409requires_openssl_with_fallback_scsv
2410run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002411 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002412 "$O_CLI -tls1_1" \
2413 0 \
2414 -S "received FALLBACK_SCSV" \
2415 -S "inapropriate fallback"
2416
2417requires_openssl_with_fallback_scsv
2418run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002419 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002420 "$O_CLI -tls1_1 -fallback_scsv" \
2421 1 \
2422 -s "received FALLBACK_SCSV" \
2423 -s "inapropriate fallback"
2424
2425requires_openssl_with_fallback_scsv
2426run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002427 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002428 "$O_CLI -fallback_scsv" \
2429 0 \
2430 -s "received FALLBACK_SCSV" \
2431 -S "inapropriate fallback"
2432
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002433# Test sending and receiving empty application data records
2434
2435run_test "Encrypt then MAC: empty application data record" \
2436 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2437 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2438 0 \
2439 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2440 -s "dumping 'input payload after decrypt' (0 bytes)" \
2441 -c "0 bytes written in 1 fragments"
2442
2443run_test "Default, no Encrypt then MAC: empty application data record" \
2444 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2445 "$P_CLI auth_mode=none etm=0 request_size=0" \
2446 0 \
2447 -s "dumping 'input payload after decrypt' (0 bytes)" \
2448 -c "0 bytes written in 1 fragments"
2449
2450run_test "Encrypt then MAC, DTLS: empty application data record" \
2451 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2452 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2453 0 \
2454 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2455 -s "dumping 'input payload after decrypt' (0 bytes)" \
2456 -c "0 bytes written in 1 fragments"
2457
2458run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
2459 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2460 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2461 0 \
2462 -s "dumping 'input payload after decrypt' (0 bytes)" \
2463 -c "0 bytes written in 1 fragments"
2464
Gilles Peskined50177f2017-05-16 17:53:03 +02002465## ClientHello generated with
2466## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2467## then manually twiddling the ciphersuite list.
2468## The ClientHello content is spelled out below as a hex string as
2469## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2470## The expected response is an inappropriate_fallback alert.
2471requires_openssl_with_fallback_scsv
2472run_test "Fallback SCSV: beginning of list" \
2473 "$P_SRV debug_level=2" \
2474 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2475 0 \
2476 -s "received FALLBACK_SCSV" \
2477 -s "inapropriate fallback"
2478
2479requires_openssl_with_fallback_scsv
2480run_test "Fallback SCSV: end of list" \
2481 "$P_SRV debug_level=2" \
2482 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2483 0 \
2484 -s "received FALLBACK_SCSV" \
2485 -s "inapropriate fallback"
2486
2487## Here the expected response is a valid ServerHello prefix, up to the random.
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02002488## Due to the way the clienthello was generated, this currently needs the
2489## server to have support for session tickets.
2490requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Gilles Peskined50177f2017-05-16 17:53:03 +02002491requires_openssl_with_fallback_scsv
2492run_test "Fallback SCSV: not in list" \
2493 "$P_SRV debug_level=2" \
2494 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2495 0 \
2496 -S "received FALLBACK_SCSV" \
2497 -S "inapropriate fallback"
2498
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002499# Tests for CBC 1/n-1 record splitting
2500
2501run_test "CBC Record splitting: TLS 1.2, no splitting" \
2502 "$P_SRV" \
2503 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2504 request_size=123 force_version=tls1_2" \
2505 0 \
2506 -s "Read from client: 123 bytes read" \
2507 -S "Read from client: 1 bytes read" \
2508 -S "122 bytes read"
2509
2510run_test "CBC Record splitting: TLS 1.1, no splitting" \
2511 "$P_SRV" \
2512 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2513 request_size=123 force_version=tls1_1" \
2514 0 \
2515 -s "Read from client: 123 bytes read" \
2516 -S "Read from client: 1 bytes read" \
2517 -S "122 bytes read"
2518
2519run_test "CBC Record splitting: TLS 1.0, splitting" \
2520 "$P_SRV" \
2521 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2522 request_size=123 force_version=tls1" \
2523 0 \
2524 -S "Read from client: 123 bytes read" \
2525 -s "Read from client: 1 bytes read" \
2526 -s "122 bytes read"
2527
Janos Follathe2681a42016-03-07 15:57:05 +00002528requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002529run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002530 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002531 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2532 request_size=123 force_version=ssl3" \
2533 0 \
2534 -S "Read from client: 123 bytes read" \
2535 -s "Read from client: 1 bytes read" \
2536 -s "122 bytes read"
2537
2538run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002539 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002540 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2541 request_size=123 force_version=tls1" \
2542 0 \
2543 -s "Read from client: 123 bytes read" \
2544 -S "Read from client: 1 bytes read" \
2545 -S "122 bytes read"
2546
2547run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2548 "$P_SRV" \
2549 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2550 request_size=123 force_version=tls1 recsplit=0" \
2551 0 \
2552 -s "Read from client: 123 bytes read" \
2553 -S "Read from client: 1 bytes read" \
2554 -S "122 bytes read"
2555
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002556run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2557 "$P_SRV nbio=2" \
2558 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2559 request_size=123 force_version=tls1" \
2560 0 \
2561 -S "Read from client: 123 bytes read" \
2562 -s "Read from client: 1 bytes read" \
2563 -s "122 bytes read"
2564
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002565# Tests for Session Tickets
2566
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002567requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002568requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002569run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002570 "$P_SRV debug_level=3 tickets=1" \
2571 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002572 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002573 -c "client hello, adding session ticket extension" \
2574 -s "found session ticket extension" \
2575 -s "server hello, adding session ticket extension" \
2576 -c "found session_ticket extension" \
2577 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002578 -S "session successfully restored from cache" \
2579 -s "session successfully restored from ticket" \
2580 -s "a session has been resumed" \
2581 -c "a session has been resumed"
2582
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002583requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002584requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002585run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002586 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2587 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002588 0 \
2589 -c "client hello, adding session ticket extension" \
2590 -s "found session ticket extension" \
2591 -s "server hello, adding session ticket extension" \
2592 -c "found session_ticket extension" \
2593 -c "parse new session ticket" \
2594 -S "session successfully restored from cache" \
2595 -s "session successfully restored from ticket" \
2596 -s "a session has been resumed" \
2597 -c "a session has been resumed"
2598
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002599requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002600requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002601run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002602 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2603 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002604 0 \
2605 -c "client hello, adding session ticket extension" \
2606 -s "found session ticket extension" \
2607 -s "server hello, adding session ticket extension" \
2608 -c "found session_ticket extension" \
2609 -c "parse new session ticket" \
2610 -S "session successfully restored from cache" \
2611 -S "session successfully restored from ticket" \
2612 -S "a session has been resumed" \
2613 -C "a session has been resumed"
2614
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002615requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002616requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002617run_test "Session resume using tickets: session copy" \
2618 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2619 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2620 0 \
2621 -c "client hello, adding session ticket extension" \
2622 -s "found session ticket extension" \
2623 -s "server hello, adding session ticket extension" \
2624 -c "found session_ticket extension" \
2625 -c "parse new session ticket" \
2626 -S "session successfully restored from cache" \
2627 -s "session successfully restored from ticket" \
2628 -s "a session has been resumed" \
2629 -c "a session has been resumed"
2630
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002631requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002632requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002633run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002634 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002635 "$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 +01002636 0 \
2637 -c "client hello, adding session ticket extension" \
2638 -c "found session_ticket extension" \
2639 -c "parse new session ticket" \
2640 -c "a session has been resumed"
2641
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002642requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002643requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002644run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002645 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002646 "( $O_CLI -sess_out $SESSION; \
2647 $O_CLI -sess_in $SESSION; \
2648 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002649 0 \
2650 -s "found session ticket extension" \
2651 -s "server hello, adding session ticket extension" \
2652 -S "session successfully restored from cache" \
2653 -s "session successfully restored from ticket" \
2654 -s "a session has been resumed"
2655
Hanno Becker1d739932018-08-21 13:55:22 +01002656# Tests for Session Tickets with DTLS
2657
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002658requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002659requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002660run_test "Session resume using tickets, DTLS: basic" \
2661 "$P_SRV debug_level=3 dtls=1 tickets=1" \
2662 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2663 0 \
2664 -c "client hello, adding session ticket extension" \
2665 -s "found session ticket extension" \
2666 -s "server hello, adding session ticket extension" \
2667 -c "found session_ticket extension" \
2668 -c "parse new session ticket" \
2669 -S "session successfully restored from cache" \
2670 -s "session successfully restored from ticket" \
2671 -s "a session has been resumed" \
2672 -c "a session has been resumed"
2673
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002674requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002675requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002676run_test "Session resume using tickets, DTLS: cache disabled" \
2677 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2678 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2679 0 \
2680 -c "client hello, adding session ticket extension" \
2681 -s "found session ticket extension" \
2682 -s "server hello, adding session ticket extension" \
2683 -c "found session_ticket extension" \
2684 -c "parse new session ticket" \
2685 -S "session successfully restored from cache" \
2686 -s "session successfully restored from ticket" \
2687 -s "a session has been resumed" \
2688 -c "a session has been resumed"
2689
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002690requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002691requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002692run_test "Session resume using tickets, DTLS: timeout" \
2693 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
2694 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_delay=2" \
2695 0 \
2696 -c "client hello, adding session ticket extension" \
2697 -s "found session ticket extension" \
2698 -s "server hello, adding session ticket extension" \
2699 -c "found session_ticket extension" \
2700 -c "parse new session ticket" \
2701 -S "session successfully restored from cache" \
2702 -S "session successfully restored from ticket" \
2703 -S "a session has been resumed" \
2704 -C "a session has been resumed"
2705
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002706requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002707requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002708run_test "Session resume using tickets, DTLS: session copy" \
2709 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2710 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_mode=0" \
2711 0 \
2712 -c "client hello, adding session ticket extension" \
2713 -s "found session ticket extension" \
2714 -s "server hello, adding session ticket extension" \
2715 -c "found session_ticket extension" \
2716 -c "parse new session ticket" \
2717 -S "session successfully restored from cache" \
2718 -s "session successfully restored from ticket" \
2719 -s "a session has been resumed" \
2720 -c "a session has been resumed"
2721
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002722requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002723requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002724run_test "Session resume using tickets, DTLS: openssl server" \
2725 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002726 "$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 +01002727 0 \
2728 -c "client hello, adding session ticket extension" \
2729 -c "found session_ticket extension" \
2730 -c "parse new session ticket" \
2731 -c "a session has been resumed"
2732
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002733requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002734requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002735run_test "Session resume using tickets, DTLS: openssl client" \
2736 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2737 "( $O_CLI -dtls1 -sess_out $SESSION; \
2738 $O_CLI -dtls1 -sess_in $SESSION; \
2739 rm -f $SESSION )" \
2740 0 \
2741 -s "found session ticket extension" \
2742 -s "server hello, adding session ticket extension" \
2743 -S "session successfully restored from cache" \
2744 -s "session successfully restored from ticket" \
2745 -s "a session has been resumed"
2746
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002747# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002748
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002749requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002750requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002751requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002752run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002753 "$P_SRV debug_level=3 tickets=0" \
2754 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002755 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002756 -c "client hello, adding session ticket extension" \
2757 -s "found session ticket extension" \
2758 -S "server hello, adding session ticket extension" \
2759 -C "found session_ticket extension" \
2760 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002761 -s "session successfully restored from cache" \
2762 -S "session successfully restored from ticket" \
2763 -s "a session has been resumed" \
2764 -c "a session has been resumed"
2765
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002766requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002767requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002768requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002769run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002770 "$P_SRV debug_level=3 tickets=1" \
2771 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002772 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002773 -C "client hello, adding session ticket extension" \
2774 -S "found session ticket extension" \
2775 -S "server hello, adding session ticket extension" \
2776 -C "found session_ticket extension" \
2777 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002778 -s "session successfully restored from cache" \
2779 -S "session successfully restored from ticket" \
2780 -s "a session has been resumed" \
2781 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002782
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002783requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2784requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002785run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002786 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2787 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002788 0 \
2789 -S "session successfully restored from cache" \
2790 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002791 -S "a session has been resumed" \
2792 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002793
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002794requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2795requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002796run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002797 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2798 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002799 0 \
2800 -s "session successfully restored from cache" \
2801 -S "session successfully restored from ticket" \
2802 -s "a session has been resumed" \
2803 -c "a session has been resumed"
2804
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002805requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2806requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002807run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002808 "$P_SRV debug_level=3 tickets=0" \
2809 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002810 0 \
2811 -s "session successfully restored from cache" \
2812 -S "session successfully restored from ticket" \
2813 -s "a session has been resumed" \
2814 -c "a session has been resumed"
2815
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002816requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2817requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002818run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002819 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2820 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002821 0 \
2822 -S "session successfully restored from cache" \
2823 -S "session successfully restored from ticket" \
2824 -S "a session has been resumed" \
2825 -C "a session has been resumed"
2826
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002827requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2828requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002829run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002830 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2831 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002832 0 \
2833 -s "session successfully restored from cache" \
2834 -S "session successfully restored from ticket" \
2835 -s "a session has been resumed" \
2836 -c "a session has been resumed"
2837
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002838requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2839requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002840run_test "Session resume using cache: session copy" \
2841 "$P_SRV debug_level=3 tickets=0" \
2842 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2843 0 \
2844 -s "session successfully restored from cache" \
2845 -S "session successfully restored from ticket" \
2846 -s "a session has been resumed" \
2847 -c "a session has been resumed"
2848
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002849requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2850requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002851run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002852 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002853 "( $O_CLI -sess_out $SESSION; \
2854 $O_CLI -sess_in $SESSION; \
2855 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002856 0 \
2857 -s "found session ticket extension" \
2858 -S "server hello, adding session ticket extension" \
2859 -s "session successfully restored from cache" \
2860 -S "session successfully restored from ticket" \
2861 -s "a session has been resumed"
2862
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002863requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2864requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002865run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002866 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002867 "$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 +01002868 0 \
2869 -C "found session_ticket extension" \
2870 -C "parse new session ticket" \
2871 -c "a session has been resumed"
2872
Hanno Becker1d739932018-08-21 13:55:22 +01002873# Tests for Session Resume based on session-ID and cache, DTLS
2874
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002875requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002876requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002877requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002878run_test "Session resume using cache, DTLS: tickets enabled on client" \
2879 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2880 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2881 0 \
2882 -c "client hello, adding session ticket extension" \
2883 -s "found session ticket extension" \
2884 -S "server hello, adding session ticket extension" \
2885 -C "found session_ticket extension" \
2886 -C "parse new session ticket" \
2887 -s "session successfully restored from cache" \
2888 -S "session successfully restored from ticket" \
2889 -s "a session has been resumed" \
2890 -c "a session has been resumed"
2891
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002892requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002893requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002894requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002895run_test "Session resume using cache, DTLS: tickets enabled on server" \
2896 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2897 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2898 0 \
2899 -C "client hello, adding session ticket extension" \
2900 -S "found session ticket extension" \
2901 -S "server hello, adding session ticket extension" \
2902 -C "found session_ticket extension" \
2903 -C "parse new session ticket" \
2904 -s "session successfully restored from cache" \
2905 -S "session successfully restored from ticket" \
2906 -s "a session has been resumed" \
2907 -c "a session has been resumed"
2908
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002909requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2910requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002911run_test "Session resume using cache, DTLS: cache_max=0" \
2912 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
2913 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2914 0 \
2915 -S "session successfully restored from cache" \
2916 -S "session successfully restored from ticket" \
2917 -S "a session has been resumed" \
2918 -C "a session has been resumed"
2919
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002920requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2921requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002922run_test "Session resume using cache, DTLS: cache_max=1" \
2923 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
2924 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2925 0 \
2926 -s "session successfully restored from cache" \
2927 -S "session successfully restored from ticket" \
2928 -s "a session has been resumed" \
2929 -c "a session has been resumed"
2930
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002931requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2932requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002933run_test "Session resume using cache, DTLS: timeout > delay" \
2934 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2935 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
2936 0 \
2937 -s "session successfully restored from cache" \
2938 -S "session successfully restored from ticket" \
2939 -s "a session has been resumed" \
2940 -c "a session has been resumed"
2941
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002942requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2943requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002944run_test "Session resume using cache, DTLS: timeout < delay" \
2945 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
2946 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2947 0 \
2948 -S "session successfully restored from cache" \
2949 -S "session successfully restored from ticket" \
2950 -S "a session has been resumed" \
2951 -C "a session has been resumed"
2952
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002953requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2954requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002955run_test "Session resume using cache, DTLS: no timeout" \
2956 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
2957 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2958 0 \
2959 -s "session successfully restored from cache" \
2960 -S "session successfully restored from ticket" \
2961 -s "a session has been resumed" \
2962 -c "a session has been resumed"
2963
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002964requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2965requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002966run_test "Session resume using cache, DTLS: session copy" \
2967 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2968 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2969 0 \
2970 -s "session successfully restored from cache" \
2971 -S "session successfully restored from ticket" \
2972 -s "a session has been resumed" \
2973 -c "a session has been resumed"
2974
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002975requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2976requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002977run_test "Session resume using cache, DTLS: openssl client" \
2978 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2979 "( $O_CLI -dtls1 -sess_out $SESSION; \
2980 $O_CLI -dtls1 -sess_in $SESSION; \
2981 rm -f $SESSION )" \
2982 0 \
2983 -s "found session ticket extension" \
2984 -S "server hello, adding session ticket extension" \
2985 -s "session successfully restored from cache" \
2986 -S "session successfully restored from ticket" \
2987 -s "a session has been resumed"
2988
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002989requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2990requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002991run_test "Session resume using cache, DTLS: openssl server" \
2992 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002993 "$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 +01002994 0 \
2995 -C "found session_ticket extension" \
2996 -C "parse new session ticket" \
2997 -c "a session has been resumed"
2998
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002999# Tests for Max Fragment Length extension
3000
Angus Grattonc4dd0732018-04-11 16:28:39 +10003001if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
Hanno Beckerab9a29b2019-09-24 16:14:39 +01003002 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 +01003003 exit 1
3004fi
3005
Angus Grattonc4dd0732018-04-11 16:28:39 +10003006if [ $MAX_CONTENT_LEN -ne 16384 ]; then
3007 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
3008fi
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" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003012 "$P_SRV debug_level=3" \
3013 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +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" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +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"
3021
Hanno Becker4aed27e2017-09-18 15:00:34 +01003022requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003023run_test "Max fragment length: enabled, default, larger message" \
3024 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003025 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003026 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003027 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3028 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003029 -C "client hello, adding max_fragment_length extension" \
3030 -S "found max fragment length extension" \
3031 -S "server hello, max_fragment_length extension" \
3032 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003033 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3034 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003035 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003036
3037requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3038run_test "Max fragment length, DTLS: enabled, default, larger message" \
3039 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003040 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003041 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003042 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3043 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003044 -C "client hello, adding max_fragment_length extension" \
3045 -S "found max fragment length extension" \
3046 -S "server hello, max_fragment_length extension" \
3047 -C "found max_fragment_length extension" \
3048 -c "fragment larger than.*maximum "
3049
Angus Grattonc4dd0732018-04-11 16:28:39 +10003050# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
3051# (session fragment length will be 16384 regardless of mbedtls
3052# content length configuration.)
3053
Hanno Beckerc5266962017-09-18 15:01:50 +01003054requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3055run_test "Max fragment length: disabled, larger message" \
3056 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003057 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003058 0 \
3059 -C "Maximum fragment length is 16384" \
3060 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003061 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3062 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003063 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003064
3065requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3066run_test "Max fragment length DTLS: disabled, larger message" \
3067 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003068 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003069 1 \
3070 -C "Maximum fragment length is 16384" \
3071 -S "Maximum fragment length is 16384" \
3072 -c "fragment larger than.*maximum "
3073
3074requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003075run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003076 "$P_SRV debug_level=3" \
3077 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003078 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003079 -c "Maximum fragment length is 4096" \
3080 -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"
3085
Hanno Becker4aed27e2017-09-18 15:00:34 +01003086requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003087run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003088 "$P_SRV debug_level=3 max_frag_len=4096" \
3089 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003090 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003091 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003092 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003093 -C "client hello, adding max_fragment_length extension" \
3094 -S "found max fragment length extension" \
3095 -S "server hello, max_fragment_length extension" \
3096 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003097
Hanno Becker4aed27e2017-09-18 15:00:34 +01003098requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003099requires_gnutls
3100run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003101 "$G_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003102 "$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 +02003103 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003104 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003105 -c "client hello, adding max_fragment_length extension" \
3106 -c "found max_fragment_length extension"
3107
Hanno Becker4aed27e2017-09-18 15:00:34 +01003108requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003109run_test "Max fragment length: client, message just fits" \
3110 "$P_SRV debug_level=3" \
3111 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3112 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003113 -c "Maximum fragment length is 2048" \
3114 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003115 -c "client hello, adding max_fragment_length extension" \
3116 -s "found max fragment length extension" \
3117 -s "server hello, max_fragment_length extension" \
3118 -c "found max_fragment_length extension" \
3119 -c "2048 bytes written in 1 fragments" \
3120 -s "2048 bytes read"
3121
Hanno Becker4aed27e2017-09-18 15:00:34 +01003122requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003123run_test "Max fragment length: client, larger message" \
3124 "$P_SRV debug_level=3" \
3125 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3126 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003127 -c "Maximum fragment length is 2048" \
3128 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003129 -c "client hello, adding max_fragment_length extension" \
3130 -s "found max fragment length extension" \
3131 -s "server hello, max_fragment_length extension" \
3132 -c "found max_fragment_length extension" \
3133 -c "2345 bytes written in 2 fragments" \
3134 -s "2048 bytes read" \
3135 -s "297 bytes read"
3136
Hanno Becker4aed27e2017-09-18 15:00:34 +01003137requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003138run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003139 "$P_SRV debug_level=3 dtls=1" \
3140 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3141 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003142 -c "Maximum fragment length is 2048" \
3143 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003144 -c "client hello, adding max_fragment_length extension" \
3145 -s "found max fragment length extension" \
3146 -s "server hello, max_fragment_length extension" \
3147 -c "found max_fragment_length extension" \
3148 -c "fragment larger than.*maximum"
3149
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003150# Tests for renegotiation
3151
Hanno Becker6a243642017-10-12 15:18:45 +01003152# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003153run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003154 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003155 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003156 0 \
3157 -C "client hello, adding renegotiation extension" \
3158 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3159 -S "found renegotiation extension" \
3160 -s "server hello, secure renegotiation extension" \
3161 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003162 -C "=> renegotiate" \
3163 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003164 -S "write hello request"
3165
Hanno Becker6a243642017-10-12 15:18:45 +01003166requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003167run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003168 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003169 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003170 0 \
3171 -c "client hello, adding renegotiation extension" \
3172 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3173 -s "found renegotiation extension" \
3174 -s "server hello, secure renegotiation extension" \
3175 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003176 -c "=> renegotiate" \
3177 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003178 -S "write hello request"
3179
Hanno Becker6a243642017-10-12 15:18:45 +01003180requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003181run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003182 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003183 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003184 0 \
3185 -c "client hello, adding renegotiation extension" \
3186 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3187 -s "found renegotiation extension" \
3188 -s "server hello, secure renegotiation extension" \
3189 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003190 -c "=> renegotiate" \
3191 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003192 -s "write hello request"
3193
Janos Follathb0f148c2017-10-05 12:29:42 +01003194# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3195# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3196# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003197requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003198run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3199 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3200 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3201 0 \
3202 -c "client hello, adding renegotiation extension" \
3203 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3204 -s "found renegotiation extension" \
3205 -s "server hello, secure renegotiation extension" \
3206 -c "found renegotiation extension" \
3207 -c "=> renegotiate" \
3208 -s "=> renegotiate" \
3209 -S "write hello request" \
3210 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3211
3212# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3213# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3214# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003215requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003216run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3217 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3218 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3219 0 \
3220 -c "client hello, adding renegotiation extension" \
3221 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3222 -s "found renegotiation extension" \
3223 -s "server hello, secure renegotiation extension" \
3224 -c "found renegotiation extension" \
3225 -c "=> renegotiate" \
3226 -s "=> renegotiate" \
3227 -s "write hello request" \
3228 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3229
Hanno Becker6a243642017-10-12 15:18:45 +01003230requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003231run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003232 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003233 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003234 0 \
3235 -c "client hello, adding renegotiation extension" \
3236 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3237 -s "found renegotiation extension" \
3238 -s "server hello, secure renegotiation extension" \
3239 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003240 -c "=> renegotiate" \
3241 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003242 -s "write hello request"
3243
Hanno Becker6a243642017-10-12 15:18:45 +01003244requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003245run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003246 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003247 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003248 1 \
3249 -c "client hello, adding renegotiation extension" \
3250 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3251 -S "found renegotiation extension" \
3252 -s "server hello, secure renegotiation extension" \
3253 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003254 -c "=> renegotiate" \
3255 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003256 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003257 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003258 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003259
Hanno Becker6a243642017-10-12 15:18:45 +01003260requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003261run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003262 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003263 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003264 0 \
3265 -C "client hello, adding renegotiation extension" \
3266 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3267 -S "found renegotiation extension" \
3268 -s "server hello, secure renegotiation extension" \
3269 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003270 -C "=> renegotiate" \
3271 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003272 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003273 -S "SSL - An unexpected message was received from our peer" \
3274 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003275
Hanno Becker6a243642017-10-12 15:18:45 +01003276requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003277run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003278 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003279 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003280 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003281 0 \
3282 -C "client hello, adding renegotiation extension" \
3283 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3284 -S "found renegotiation extension" \
3285 -s "server hello, secure renegotiation extension" \
3286 -c "found renegotiation extension" \
3287 -C "=> renegotiate" \
3288 -S "=> renegotiate" \
3289 -s "write hello request" \
3290 -S "SSL - An unexpected message was received from our peer" \
3291 -S "failed"
3292
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003293# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003294requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003295run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003296 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003297 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003298 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003299 0 \
3300 -C "client hello, adding renegotiation extension" \
3301 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3302 -S "found renegotiation extension" \
3303 -s "server hello, secure renegotiation extension" \
3304 -c "found renegotiation extension" \
3305 -C "=> renegotiate" \
3306 -S "=> renegotiate" \
3307 -s "write hello request" \
3308 -S "SSL - An unexpected message was received from our peer" \
3309 -S "failed"
3310
Hanno Becker6a243642017-10-12 15:18:45 +01003311requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003312run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003313 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003314 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003315 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003316 0 \
3317 -C "client hello, adding renegotiation extension" \
3318 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3319 -S "found renegotiation extension" \
3320 -s "server hello, secure renegotiation extension" \
3321 -c "found renegotiation extension" \
3322 -C "=> renegotiate" \
3323 -S "=> renegotiate" \
3324 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003325 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003326
Hanno Becker6a243642017-10-12 15:18:45 +01003327requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003328run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003329 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003330 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003331 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003332 0 \
3333 -c "client hello, adding renegotiation extension" \
3334 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3335 -s "found renegotiation extension" \
3336 -s "server hello, secure renegotiation extension" \
3337 -c "found renegotiation extension" \
3338 -c "=> renegotiate" \
3339 -s "=> renegotiate" \
3340 -s "write hello request" \
3341 -S "SSL - An unexpected message was received from our peer" \
3342 -S "failed"
3343
Hanno Becker6a243642017-10-12 15:18:45 +01003344requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003345run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003346 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003347 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3348 0 \
3349 -C "client hello, adding renegotiation extension" \
3350 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3351 -S "found renegotiation extension" \
3352 -s "server hello, secure renegotiation extension" \
3353 -c "found renegotiation extension" \
3354 -S "record counter limit reached: renegotiate" \
3355 -C "=> renegotiate" \
3356 -S "=> renegotiate" \
3357 -S "write hello request" \
3358 -S "SSL - An unexpected message was received from our peer" \
3359 -S "failed"
3360
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003361# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003362requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003363run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003364 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003365 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003366 0 \
3367 -c "client hello, adding renegotiation extension" \
3368 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3369 -s "found renegotiation extension" \
3370 -s "server hello, secure renegotiation extension" \
3371 -c "found renegotiation extension" \
3372 -s "record counter limit reached: renegotiate" \
3373 -c "=> renegotiate" \
3374 -s "=> renegotiate" \
3375 -s "write hello request" \
3376 -S "SSL - An unexpected message was received from our peer" \
3377 -S "failed"
3378
Hanno Becker6a243642017-10-12 15:18:45 +01003379requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003380run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003381 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003382 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003383 0 \
3384 -c "client hello, adding renegotiation extension" \
3385 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3386 -s "found renegotiation extension" \
3387 -s "server hello, secure renegotiation extension" \
3388 -c "found renegotiation extension" \
3389 -s "record counter limit reached: renegotiate" \
3390 -c "=> renegotiate" \
3391 -s "=> renegotiate" \
3392 -s "write hello request" \
3393 -S "SSL - An unexpected message was received from our peer" \
3394 -S "failed"
3395
Hanno Becker6a243642017-10-12 15:18:45 +01003396requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003397run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003398 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003399 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3400 0 \
3401 -C "client hello, adding renegotiation extension" \
3402 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3403 -S "found renegotiation extension" \
3404 -s "server hello, secure renegotiation extension" \
3405 -c "found renegotiation extension" \
3406 -S "record counter limit reached: renegotiate" \
3407 -C "=> renegotiate" \
3408 -S "=> renegotiate" \
3409 -S "write hello request" \
3410 -S "SSL - An unexpected message was received from our peer" \
3411 -S "failed"
3412
Hanno Becker6a243642017-10-12 15:18:45 +01003413requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003414run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003415 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003416 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003417 0 \
3418 -c "client hello, adding renegotiation extension" \
3419 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3420 -s "found renegotiation extension" \
3421 -s "server hello, secure renegotiation extension" \
3422 -c "found renegotiation extension" \
3423 -c "=> renegotiate" \
3424 -s "=> renegotiate" \
3425 -S "write hello request"
3426
Hanno Becker6a243642017-10-12 15:18:45 +01003427requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003428run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003429 "$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 +02003430 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003431 0 \
3432 -c "client hello, adding renegotiation extension" \
3433 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3434 -s "found renegotiation extension" \
3435 -s "server hello, secure renegotiation extension" \
3436 -c "found renegotiation extension" \
3437 -c "=> renegotiate" \
3438 -s "=> renegotiate" \
3439 -s "write hello request"
3440
Hanno Becker6a243642017-10-12 15:18:45 +01003441requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003442run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003443 "$O_SRV -www" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003444 "$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 +02003445 0 \
3446 -c "client hello, adding renegotiation extension" \
3447 -c "found renegotiation extension" \
3448 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003449 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003450 -C "error" \
3451 -c "HTTP/1.0 200 [Oo][Kk]"
3452
Paul Bakker539d9722015-02-08 16:18:35 +01003453requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003454requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003455run_test "Renegotiation: gnutls server strict, client-initiated" \
3456 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003457 "$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 +02003458 0 \
3459 -c "client hello, adding renegotiation extension" \
3460 -c "found renegotiation extension" \
3461 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003462 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003463 -C "error" \
3464 -c "HTTP/1.0 200 [Oo][Kk]"
3465
Paul Bakker539d9722015-02-08 16:18:35 +01003466requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003467requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003468run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3469 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003470 "$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 +01003471 1 \
3472 -c "client hello, adding renegotiation extension" \
3473 -C "found renegotiation extension" \
3474 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003475 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003476 -c "error" \
3477 -C "HTTP/1.0 200 [Oo][Kk]"
3478
Paul Bakker539d9722015-02-08 16:18:35 +01003479requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003480requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003481run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3482 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003483 "$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 +01003484 allow_legacy=0" \
3485 1 \
3486 -c "client hello, adding renegotiation extension" \
3487 -C "found renegotiation extension" \
3488 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003489 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003490 -c "error" \
3491 -C "HTTP/1.0 200 [Oo][Kk]"
3492
Paul Bakker539d9722015-02-08 16:18:35 +01003493requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003494requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003495run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3496 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003497 "$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 +01003498 allow_legacy=1" \
3499 0 \
3500 -c "client hello, adding renegotiation extension" \
3501 -C "found renegotiation extension" \
3502 -c "=> renegotiate" \
3503 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003504 -C "error" \
3505 -c "HTTP/1.0 200 [Oo][Kk]"
3506
Hanno Becker6a243642017-10-12 15:18:45 +01003507requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003508run_test "Renegotiation: DTLS, client-initiated" \
3509 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3510 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3511 0 \
3512 -c "client hello, adding renegotiation extension" \
3513 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3514 -s "found renegotiation extension" \
3515 -s "server hello, secure renegotiation extension" \
3516 -c "found renegotiation extension" \
3517 -c "=> renegotiate" \
3518 -s "=> renegotiate" \
3519 -S "write hello request"
3520
Hanno Becker6a243642017-10-12 15:18:45 +01003521requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003522run_test "Renegotiation: DTLS, server-initiated" \
3523 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003524 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3525 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003526 0 \
3527 -c "client hello, adding renegotiation extension" \
3528 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3529 -s "found renegotiation extension" \
3530 -s "server hello, secure renegotiation extension" \
3531 -c "found renegotiation extension" \
3532 -c "=> renegotiate" \
3533 -s "=> renegotiate" \
3534 -s "write hello request"
3535
Hanno Becker6a243642017-10-12 15:18:45 +01003536requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003537run_test "Renegotiation: DTLS, renego_period overflow" \
3538 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3539 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3540 0 \
3541 -c "client hello, adding renegotiation extension" \
3542 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3543 -s "found renegotiation extension" \
3544 -s "server hello, secure renegotiation extension" \
3545 -s "record counter limit reached: renegotiate" \
3546 -c "=> renegotiate" \
3547 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003548 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003549
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003550requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003551requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003552run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3553 "$G_SRV -u --mtu 4096" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003554 "$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 +02003555 0 \
3556 -c "client hello, adding renegotiation extension" \
3557 -c "found renegotiation extension" \
3558 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003559 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003560 -C "error" \
3561 -s "Extra-header:"
3562
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003563# Test for the "secure renegotation" extension only (no actual renegotiation)
3564
Paul Bakker539d9722015-02-08 16:18:35 +01003565requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003566run_test "Renego ext: gnutls server strict, client default" \
3567 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003568 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003569 0 \
3570 -c "found renegotiation extension" \
3571 -C "error" \
3572 -c "HTTP/1.0 200 [Oo][Kk]"
3573
Paul Bakker539d9722015-02-08 16:18:35 +01003574requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003575run_test "Renego ext: gnutls server unsafe, client default" \
3576 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003577 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003578 0 \
3579 -C "found renegotiation extension" \
3580 -C "error" \
3581 -c "HTTP/1.0 200 [Oo][Kk]"
3582
Paul Bakker539d9722015-02-08 16:18:35 +01003583requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003584run_test "Renego ext: gnutls server unsafe, client break legacy" \
3585 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3586 "$P_CLI debug_level=3 allow_legacy=-1" \
3587 1 \
3588 -C "found renegotiation extension" \
3589 -c "error" \
3590 -C "HTTP/1.0 200 [Oo][Kk]"
3591
Paul Bakker539d9722015-02-08 16:18:35 +01003592requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003593run_test "Renego ext: gnutls client strict, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003594 "$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 +02003595 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003596 0 \
3597 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3598 -s "server hello, secure renegotiation extension"
3599
Paul Bakker539d9722015-02-08 16:18:35 +01003600requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003601run_test "Renego ext: gnutls client unsafe, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003602 "$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 +02003603 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003604 0 \
3605 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3606 -S "server hello, secure renegotiation extension"
3607
Paul Bakker539d9722015-02-08 16:18:35 +01003608requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003609run_test "Renego ext: gnutls client unsafe, server break legacy" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003610 "$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 +02003611 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003612 1 \
3613 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3614 -S "server hello, secure renegotiation extension"
3615
Janos Follath0b242342016-02-17 10:11:21 +00003616# Tests for silently dropping trailing extra bytes in .der certificates
3617
3618requires_gnutls
3619run_test "DER format: no trailing bytes" \
3620 "$P_SRV crt_file=data_files/server5-der0.crt \
3621 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003622 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003623 0 \
3624 -c "Handshake was completed" \
3625
3626requires_gnutls
3627run_test "DER format: with a trailing zero byte" \
3628 "$P_SRV crt_file=data_files/server5-der1a.crt \
3629 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003630 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003631 0 \
3632 -c "Handshake was completed" \
3633
3634requires_gnutls
3635run_test "DER format: with a trailing random byte" \
3636 "$P_SRV crt_file=data_files/server5-der1b.crt \
3637 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003638 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003639 0 \
3640 -c "Handshake was completed" \
3641
3642requires_gnutls
3643run_test "DER format: with 2 trailing random bytes" \
3644 "$P_SRV crt_file=data_files/server5-der2.crt \
3645 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003646 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003647 0 \
3648 -c "Handshake was completed" \
3649
3650requires_gnutls
3651run_test "DER format: with 4 trailing random bytes" \
3652 "$P_SRV crt_file=data_files/server5-der4.crt \
3653 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003654 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003655 0 \
3656 -c "Handshake was completed" \
3657
3658requires_gnutls
3659run_test "DER format: with 8 trailing random bytes" \
3660 "$P_SRV crt_file=data_files/server5-der8.crt \
3661 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003662 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003663 0 \
3664 -c "Handshake was completed" \
3665
3666requires_gnutls
3667run_test "DER format: with 9 trailing random bytes" \
3668 "$P_SRV crt_file=data_files/server5-der9.crt \
3669 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003670 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003671 0 \
3672 -c "Handshake was completed" \
3673
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003674# Tests for auth_mode
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 required" \
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=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003682 1 \
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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003690run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003691 "$P_SRV crt_file=data_files/server5-badsign.crt \
3692 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003693 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003694 0 \
3695 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003696 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003697 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003698 -C "X509 - Certificate verification failed"
3699
Hanno Becker4a156fc2019-06-14 17:07:06 +01003700requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003701requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003702run_test "Authentication: server goodcert, client optional, no trusted CA" \
3703 "$P_SRV" \
3704 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3705 0 \
3706 -c "x509_verify_cert() returned" \
3707 -c "! The certificate is not correctly signed by the trusted CA" \
3708 -c "! Certificate verification flags"\
3709 -C "! mbedtls_ssl_handshake returned" \
3710 -C "X509 - Certificate verification failed" \
3711 -C "SSL - No CA Chain is set, but required to operate"
3712
Hanno Becker4a156fc2019-06-14 17:07:06 +01003713requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003714requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003715run_test "Authentication: server goodcert, client required, no trusted CA" \
3716 "$P_SRV" \
3717 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3718 1 \
3719 -c "x509_verify_cert() returned" \
3720 -c "! The certificate is not correctly signed by the trusted CA" \
3721 -c "! Certificate verification flags"\
3722 -c "! mbedtls_ssl_handshake returned" \
3723 -c "SSL - No CA Chain is set, but required to operate"
3724
3725# The purpose of the next two tests is to test the client's behaviour when receiving a server
3726# certificate with an unsupported elliptic curve. This should usually not happen because
3727# the client informs the server about the supported curves - it does, though, in the
3728# corner case of a static ECDH suite, because the server doesn't check the curve on that
3729# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3730# different means to have the server ignoring the client's supported curve list.
3731
3732requires_config_enabled MBEDTLS_ECP_C
3733run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3734 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3735 crt_file=data_files/server5.ku-ka.crt" \
3736 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3737 1 \
3738 -c "bad certificate (EC key curve)"\
3739 -c "! Certificate verification flags"\
3740 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3741
3742requires_config_enabled MBEDTLS_ECP_C
3743run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3744 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3745 crt_file=data_files/server5.ku-ka.crt" \
3746 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3747 1 \
3748 -c "bad certificate (EC key curve)"\
3749 -c "! Certificate verification flags"\
3750 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3751
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003752run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003753 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003754 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003755 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003756 0 \
3757 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003758 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003759 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003760 -C "X509 - Certificate verification failed"
3761
Simon Butcher99000142016-10-13 17:21:01 +01003762run_test "Authentication: client SHA256, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003763 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003764 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3765 key_file=data_files/server6.key \
3766 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3767 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003768 -c "Supported Signature Algorithm found: 5,"
3769
3770run_test "Authentication: client SHA384, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003771 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003772 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3773 key_file=data_files/server6.key \
3774 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3775 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003776 -c "Supported Signature Algorithm found: 5,"
3777
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003778requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3779run_test "Authentication: client has no cert, server required (SSLv3)" \
3780 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3781 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3782 key_file=data_files/server5.key" \
3783 1 \
3784 -S "skip write certificate request" \
3785 -C "skip parse certificate request" \
3786 -c "got a certificate request" \
3787 -c "got no certificate to send" \
3788 -S "x509_verify_cert() returned" \
3789 -s "client has no certificate" \
3790 -s "! mbedtls_ssl_handshake returned" \
3791 -c "! mbedtls_ssl_handshake returned" \
3792 -s "No client certification received from the client, but required by the authentication mode"
3793
3794run_test "Authentication: client has no cert, server required (TLS)" \
3795 "$P_SRV debug_level=3 auth_mode=required" \
3796 "$P_CLI debug_level=3 crt_file=none \
3797 key_file=data_files/server5.key" \
3798 1 \
3799 -S "skip write certificate request" \
3800 -C "skip parse certificate request" \
3801 -c "got a certificate request" \
3802 -c "= write certificate$" \
3803 -C "skip write certificate$" \
3804 -S "x509_verify_cert() returned" \
3805 -s "client has no certificate" \
3806 -s "! mbedtls_ssl_handshake returned" \
3807 -c "! mbedtls_ssl_handshake returned" \
3808 -s "No client certification received from the client, but required by the authentication mode"
3809
Hanno Becker4a156fc2019-06-14 17:07:06 +01003810requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003811requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003812run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003813 "$P_SRV debug_level=3 auth_mode=required" \
3814 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003815 key_file=data_files/server5.key" \
3816 1 \
3817 -S "skip write certificate request" \
3818 -C "skip parse certificate request" \
3819 -c "got a certificate request" \
3820 -C "skip write certificate" \
3821 -C "skip write certificate verify" \
3822 -S "skip parse certificate verify" \
3823 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003824 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003825 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003826 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003827 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003828 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003829# We don't check that the client receives the alert because it might
3830# detect that its write end of the connection is closed and abort
3831# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003832
Hanno Becker4a156fc2019-06-14 17:07:06 +01003833requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003834requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01003835run_test "Authentication: client cert not trusted, server required" \
3836 "$P_SRV debug_level=3 auth_mode=required" \
3837 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3838 key_file=data_files/server5.key" \
3839 1 \
3840 -S "skip write certificate request" \
3841 -C "skip parse certificate request" \
3842 -c "got a certificate request" \
3843 -C "skip write certificate" \
3844 -C "skip write certificate verify" \
3845 -S "skip parse certificate verify" \
3846 -s "x509_verify_cert() returned" \
3847 -s "! The certificate is not correctly signed by the trusted CA" \
3848 -s "! mbedtls_ssl_handshake returned" \
3849 -c "! mbedtls_ssl_handshake returned" \
3850 -s "X509 - Certificate verification failed"
3851
Hanno Becker4a156fc2019-06-14 17:07:06 +01003852requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003853requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003854run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003855 "$P_SRV debug_level=3 auth_mode=optional" \
3856 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003857 key_file=data_files/server5.key" \
3858 0 \
3859 -S "skip write certificate request" \
3860 -C "skip parse certificate request" \
3861 -c "got a certificate request" \
3862 -C "skip write certificate" \
3863 -C "skip write certificate verify" \
3864 -S "skip parse certificate verify" \
3865 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003866 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003867 -S "! mbedtls_ssl_handshake returned" \
3868 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003869 -S "X509 - Certificate verification failed"
3870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003871run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003872 "$P_SRV debug_level=3 auth_mode=none" \
3873 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003874 key_file=data_files/server5.key" \
3875 0 \
3876 -s "skip write certificate request" \
3877 -C "skip parse certificate request" \
3878 -c "got no certificate request" \
3879 -c "skip write certificate" \
3880 -c "skip write certificate verify" \
3881 -s "skip parse certificate verify" \
3882 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003883 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003884 -S "! mbedtls_ssl_handshake returned" \
3885 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003886 -S "X509 - Certificate verification failed"
3887
Hanno Becker4a156fc2019-06-14 17:07:06 +01003888requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003889requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003890run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003891 "$P_SRV debug_level=3 auth_mode=optional" \
3892 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003893 0 \
3894 -S "skip write certificate request" \
3895 -C "skip parse certificate request" \
3896 -c "got a certificate request" \
3897 -C "skip write certificate$" \
3898 -C "got no certificate to send" \
3899 -S "SSLv3 client has no certificate" \
3900 -c "skip write certificate verify" \
3901 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003902 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003903 -S "! mbedtls_ssl_handshake returned" \
3904 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003905 -S "X509 - Certificate verification failed"
3906
Hanno Becker4a156fc2019-06-14 17:07:06 +01003907requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003908requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003909run_test "Authentication: openssl client no cert, server optional" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003910 "$P_SRV debug_level=3 auth_mode=optional ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003911 "$O_CLI" \
3912 0 \
3913 -S "skip write certificate request" \
3914 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003915 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003916 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003917 -S "X509 - Certificate verification failed"
3918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003919run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003920 "$O_SRV -verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003921 "$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 +01003922 0 \
3923 -C "skip parse certificate request" \
3924 -c "got a certificate request" \
3925 -C "skip write certificate$" \
3926 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003927 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003928
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003929run_test "Authentication: client no cert, openssl server required" \
3930 "$O_SRV -Verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003931 "$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 +02003932 1 \
3933 -C "skip parse certificate request" \
3934 -c "got a certificate request" \
3935 -C "skip write certificate$" \
3936 -c "skip write certificate verify" \
3937 -c "! mbedtls_ssl_handshake returned"
3938
Janos Follathe2681a42016-03-07 15:57:05 +00003939requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Hanno Beckerb2c63832019-06-17 08:35:16 +01003940requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003941requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003942run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003943 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003944 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003945 0 \
3946 -S "skip write certificate request" \
3947 -C "skip parse certificate request" \
3948 -c "got a certificate request" \
3949 -C "skip write certificate$" \
3950 -c "skip write certificate verify" \
3951 -c "got no certificate to send" \
3952 -s "SSLv3 client has no certificate" \
3953 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003954 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003955 -S "! mbedtls_ssl_handshake returned" \
3956 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003957 -S "X509 - Certificate verification failed"
3958
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02003959# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
3960# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003961
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003962MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01003963MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003964
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003965if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Hanno Beckerab9a29b2019-09-24 16:14:39 +01003966 printf "The configuration file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003967 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003968 printf "test value of ${MAX_IM_CA}. \n"
3969 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003970 printf "The tests assume this value and if it changes, the tests in this\n"
3971 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003972 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003973
3974 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003975fi
3976
Angus Grattonc4dd0732018-04-11 16:28:39 +10003977requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003978run_test "Authentication: server max_int chain, client default" \
3979 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
3980 key_file=data_files/dir-maxpath/09.key" \
3981 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
3982 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003983 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003984
Angus Grattonc4dd0732018-04-11 16:28:39 +10003985requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003986run_test "Authentication: server max_int+1 chain, client default" \
3987 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3988 key_file=data_files/dir-maxpath/10.key" \
3989 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
3990 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003991 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003992
Angus Grattonc4dd0732018-04-11 16:28:39 +10003993requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003994run_test "Authentication: server max_int+1 chain, client optional" \
3995 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3996 key_file=data_files/dir-maxpath/10.key" \
3997 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
3998 auth_mode=optional" \
3999 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004000 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004001
Angus Grattonc4dd0732018-04-11 16:28:39 +10004002requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004003run_test "Authentication: server max_int+1 chain, client none" \
4004 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4005 key_file=data_files/dir-maxpath/10.key" \
4006 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4007 auth_mode=none" \
4008 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004009 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004010
Angus Grattonc4dd0732018-04-11 16:28:39 +10004011requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004012run_test "Authentication: client max_int+1 chain, server default" \
4013 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4014 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4015 key_file=data_files/dir-maxpath/10.key" \
4016 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004017 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004018
Angus Grattonc4dd0732018-04-11 16:28:39 +10004019requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004020run_test "Authentication: client max_int+1 chain, server optional" \
4021 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4022 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4023 key_file=data_files/dir-maxpath/10.key" \
4024 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004025 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004026
Angus Grattonc4dd0732018-04-11 16:28:39 +10004027requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004028run_test "Authentication: client max_int+1 chain, server required" \
4029 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4030 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4031 key_file=data_files/dir-maxpath/10.key" \
4032 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004033 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004034
Angus Grattonc4dd0732018-04-11 16:28:39 +10004035requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004036run_test "Authentication: client max_int chain, server required" \
4037 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4038 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4039 key_file=data_files/dir-maxpath/09.key" \
4040 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004041 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004042
Janos Follath89baba22017-04-10 14:34:35 +01004043# Tests for CA list in CertificateRequest messages
4044
4045run_test "Authentication: send CA list in CertificateRequest (default)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004046 "$P_SRV debug_level=3 auth_mode=required ca_file=data_files/test-ca2.crt" \
Janos Follath89baba22017-04-10 14:34:35 +01004047 "$P_CLI crt_file=data_files/server6.crt \
4048 key_file=data_files/server6.key" \
4049 0 \
4050 -s "requested DN"
4051
4052run_test "Authentication: do not send CA list in CertificateRequest" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004053 "$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 +01004054 "$P_CLI crt_file=data_files/server6.crt \
4055 key_file=data_files/server6.key" \
4056 0 \
4057 -S "requested DN"
4058
Hanno Becker4a156fc2019-06-14 17:07:06 +01004059requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004060requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01004061run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4062 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4063 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4064 key_file=data_files/server5.key" \
4065 1 \
4066 -S "requested DN" \
4067 -s "x509_verify_cert() returned" \
4068 -s "! The certificate is not correctly signed by the trusted CA" \
4069 -s "! mbedtls_ssl_handshake returned" \
4070 -c "! mbedtls_ssl_handshake returned" \
4071 -s "X509 - Certificate verification failed"
4072
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004073# Tests for certificate selection based on SHA verson
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.2 -> SHA-2" \
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_2 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.1 -> 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_1 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.0 -> SHA-1" \
4102 "$P_SRV crt_file=data_files/server5.crt \
4103 key_file=data_files/server5.key \
4104 crt_file2=data_files/server5-sha1.crt \
4105 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004106 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004107 0 \
4108 -C "signed using.*ECDSA with SHA256" \
4109 -c "signed using.*ECDSA with SHA1"
4110
Hanno Becker4a156fc2019-06-14 17:07:06 +01004111requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004112requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004113run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4114 "$P_SRV crt_file=data_files/server5.crt \
4115 key_file=data_files/server5.key \
4116 crt_file2=data_files/server6.crt \
4117 key_file2=data_files/server6.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004118 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004119 0 \
4120 -c "serial number.*09" \
4121 -c "signed using.*ECDSA with SHA256" \
4122 -C "signed using.*ECDSA with SHA1"
4123
Hanno Becker4a156fc2019-06-14 17:07:06 +01004124requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004125requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004126run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4127 "$P_SRV crt_file=data_files/server6.crt \
4128 key_file=data_files/server6.key \
4129 crt_file2=data_files/server5.crt \
4130 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004131 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004132 0 \
4133 -c "serial number.*0A" \
4134 -c "signed using.*ECDSA with SHA256" \
4135 -C "signed using.*ECDSA with SHA1"
4136
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004137# tests for SNI
4138
Hanno Becker4a156fc2019-06-14 17:07:06 +01004139requires_config_disabled MBEDTLS_X509_REMOVE_INFO
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: no SNI callback" \
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" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004144 "$P_CLI server_name=localhost ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004145 0 \
4146 -S "parse ServerName extension" \
4147 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4148 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004149
Hanno Becker4a156fc2019-06-14 17:07:06 +01004150requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004151requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004152requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004153run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004154 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004155 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004156 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 +01004157 "$P_CLI server_name=localhost ca_file=data_files/test-ca.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004158 0 \
4159 -s "parse ServerName extension" \
4160 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4161 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004162
Hanno Becker4a156fc2019-06-14 17:07:06 +01004163requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004164requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004165requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004166run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004167 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004168 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004169 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 +02004170 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004171 0 \
4172 -s "parse ServerName extension" \
4173 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4174 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004175
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004176requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004177run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004178 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004179 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004180 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 +02004181 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004182 1 \
4183 -s "parse ServerName extension" \
4184 -s "ssl_sni_wrapper() returned" \
4185 -s "mbedtls_ssl_handshake returned" \
4186 -c "mbedtls_ssl_handshake returned" \
4187 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004188
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004189run_test "SNI: client auth no override: optional" \
4190 "$P_SRV debug_level=3 auth_mode=optional \
4191 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4192 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4193 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004194 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004195 -S "skip write certificate request" \
4196 -C "skip parse certificate request" \
4197 -c "got a certificate request" \
4198 -C "skip write certificate" \
4199 -C "skip write certificate verify" \
4200 -S "skip parse certificate verify"
4201
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004202requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004203run_test "SNI: client auth override: none -> optional" \
4204 "$P_SRV debug_level=3 auth_mode=none \
4205 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4206 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4207 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004208 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004209 -S "skip write certificate request" \
4210 -C "skip parse certificate request" \
4211 -c "got a certificate request" \
4212 -C "skip write certificate" \
4213 -C "skip write certificate verify" \
4214 -S "skip parse certificate verify"
4215
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004216requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004217run_test "SNI: client auth override: optional -> none" \
4218 "$P_SRV debug_level=3 auth_mode=optional \
4219 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4220 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4221 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004222 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004223 -s "skip write certificate request" \
4224 -C "skip parse certificate request" \
4225 -c "got no certificate request" \
4226 -c "skip write certificate" \
4227 -c "skip write certificate verify" \
4228 -s "skip parse certificate verify"
4229
Hanno Becker4a156fc2019-06-14 17:07:06 +01004230requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004231requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004232requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004233run_test "SNI: CA no override" \
4234 "$P_SRV debug_level=3 auth_mode=optional \
4235 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4236 ca_file=data_files/test-ca.crt \
4237 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4238 "$P_CLI debug_level=3 server_name=localhost \
4239 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4240 1 \
4241 -S "skip write certificate request" \
4242 -C "skip parse certificate request" \
4243 -c "got a certificate request" \
4244 -C "skip write certificate" \
4245 -C "skip write certificate verify" \
4246 -S "skip parse certificate verify" \
4247 -s "x509_verify_cert() returned" \
4248 -s "! The certificate is not correctly signed by the trusted CA" \
4249 -S "The certificate has been revoked (is on a CRL)"
4250
Hanno Becker4a156fc2019-06-14 17:07:06 +01004251requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004252requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004253requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004254run_test "SNI: CA override" \
4255 "$P_SRV debug_level=3 auth_mode=optional \
4256 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4257 ca_file=data_files/test-ca.crt \
4258 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4259 "$P_CLI debug_level=3 server_name=localhost \
4260 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4261 0 \
4262 -S "skip write certificate request" \
4263 -C "skip parse certificate request" \
4264 -c "got a certificate request" \
4265 -C "skip write certificate" \
4266 -C "skip write certificate verify" \
4267 -S "skip parse certificate verify" \
4268 -S "x509_verify_cert() returned" \
4269 -S "! The certificate is not correctly signed by the trusted CA" \
4270 -S "The certificate has been revoked (is on a CRL)"
4271
Hanno Becker4a156fc2019-06-14 17:07:06 +01004272requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004273requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004274requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004275run_test "SNI: CA override with CRL" \
4276 "$P_SRV debug_level=3 auth_mode=optional \
4277 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4278 ca_file=data_files/test-ca.crt \
4279 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4280 "$P_CLI debug_level=3 server_name=localhost \
4281 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4282 1 \
4283 -S "skip write certificate request" \
4284 -C "skip parse certificate request" \
4285 -c "got a certificate request" \
4286 -C "skip write certificate" \
4287 -C "skip write certificate verify" \
4288 -S "skip parse certificate verify" \
4289 -s "x509_verify_cert() returned" \
4290 -S "! The certificate is not correctly signed by the trusted CA" \
4291 -s "The certificate has been revoked (is on a CRL)"
4292
Andres AG1a834452016-12-07 10:01:30 +00004293# Tests for SNI and DTLS
4294
Hanno Becker4a156fc2019-06-14 17:07:06 +01004295requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004296requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004297run_test "SNI: DTLS, no SNI callback" \
4298 "$P_SRV debug_level=3 dtls=1 \
4299 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004300 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca2.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004301 0 \
4302 -S "parse ServerName extension" \
4303 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4304 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4305
Hanno Becker4a156fc2019-06-14 17:07:06 +01004306requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004307requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004308requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004309run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004310 "$P_SRV debug_level=3 dtls=1 \
4311 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4312 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 +01004313 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca.crt" \
Andres AG1a834452016-12-07 10:01:30 +00004314 0 \
4315 -s "parse ServerName extension" \
4316 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4317 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4318
Hanno Becker4a156fc2019-06-14 17:07:06 +01004319requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004320requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004321requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004322run_test "SNI: DTLS, matching cert 2" \
4323 "$P_SRV debug_level=3 dtls=1 \
4324 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4325 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 +01004326 "$P_CLI server_name=polarssl.example dtls=1 ca_file=data_files/test-ca.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004327 0 \
4328 -s "parse ServerName extension" \
4329 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4330 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4331
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004332requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004333run_test "SNI: DTLS, no matching cert" \
4334 "$P_SRV debug_level=3 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,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4337 "$P_CLI server_name=nonesuch.example dtls=1" \
4338 1 \
4339 -s "parse ServerName extension" \
4340 -s "ssl_sni_wrapper() returned" \
4341 -s "mbedtls_ssl_handshake returned" \
4342 -c "mbedtls_ssl_handshake returned" \
4343 -c "SSL - A fatal alert message was received from our peer"
4344
4345run_test "SNI: DTLS, client auth no override: optional" \
4346 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4347 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4348 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4349 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4350 0 \
4351 -S "skip write certificate request" \
4352 -C "skip parse certificate request" \
4353 -c "got a certificate request" \
4354 -C "skip write certificate" \
4355 -C "skip write certificate verify" \
4356 -S "skip parse certificate verify"
4357
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004358requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004359run_test "SNI: DTLS, client auth override: none -> optional" \
4360 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4361 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4362 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4363 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4364 0 \
4365 -S "skip write certificate request" \
4366 -C "skip parse certificate request" \
4367 -c "got a certificate request" \
4368 -C "skip write certificate" \
4369 -C "skip write certificate verify" \
4370 -S "skip parse certificate verify"
4371
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004372requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004373run_test "SNI: DTLS, client auth override: optional -> none" \
4374 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4375 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4376 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4377 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4378 0 \
4379 -s "skip write certificate request" \
4380 -C "skip parse certificate request" \
4381 -c "got no certificate request" \
4382 -c "skip write certificate" \
4383 -c "skip write certificate verify" \
4384 -s "skip parse certificate verify"
4385
Hanno Becker4a156fc2019-06-14 17:07:06 +01004386requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004387requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004388requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004389run_test "SNI: DTLS, CA no override" \
4390 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4391 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4392 ca_file=data_files/test-ca.crt \
4393 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4394 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4395 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4396 1 \
4397 -S "skip write certificate request" \
4398 -C "skip parse certificate request" \
4399 -c "got a certificate request" \
4400 -C "skip write certificate" \
4401 -C "skip write certificate verify" \
4402 -S "skip parse certificate verify" \
4403 -s "x509_verify_cert() returned" \
4404 -s "! The certificate is not correctly signed by the trusted CA" \
4405 -S "The certificate has been revoked (is on a CRL)"
4406
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004407requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004408run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004409 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4410 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4411 ca_file=data_files/test-ca.crt \
4412 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4413 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4414 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4415 0 \
4416 -S "skip write certificate request" \
4417 -C "skip parse certificate request" \
4418 -c "got a certificate request" \
4419 -C "skip write certificate" \
4420 -C "skip write certificate verify" \
4421 -S "skip parse certificate verify" \
4422 -S "x509_verify_cert() returned" \
4423 -S "! The certificate is not correctly signed by the trusted CA" \
4424 -S "The certificate has been revoked (is on a CRL)"
4425
Hanno Becker4a156fc2019-06-14 17:07:06 +01004426requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004427requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004428requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004429run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004430 "$P_SRV debug_level=3 auth_mode=optional \
4431 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4432 ca_file=data_files/test-ca.crt \
4433 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4434 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4435 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4436 1 \
4437 -S "skip write certificate request" \
4438 -C "skip parse certificate request" \
4439 -c "got a certificate request" \
4440 -C "skip write certificate" \
4441 -C "skip write certificate verify" \
4442 -S "skip parse certificate verify" \
4443 -s "x509_verify_cert() returned" \
4444 -S "! The certificate is not correctly signed by the trusted CA" \
4445 -s "The certificate has been revoked (is on a CRL)"
4446
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004447# Tests for non-blocking I/O: exercise a variety of handshake flows
4448
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004449run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004450 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4451 "$P_CLI nbio=2 tickets=0" \
4452 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004453 -S "mbedtls_ssl_handshake returned" \
4454 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004455 -c "Read from server: .* bytes read"
4456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004457run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004458 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4459 "$P_CLI nbio=2 tickets=0" \
4460 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004461 -S "mbedtls_ssl_handshake returned" \
4462 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004463 -c "Read from server: .* bytes read"
4464
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004465run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004466 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4467 "$P_CLI nbio=2 tickets=1" \
4468 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004469 -S "mbedtls_ssl_handshake returned" \
4470 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004471 -c "Read from server: .* bytes read"
4472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004473run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004474 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4475 "$P_CLI nbio=2 tickets=1" \
4476 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004477 -S "mbedtls_ssl_handshake returned" \
4478 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004479 -c "Read from server: .* bytes read"
4480
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004481run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004482 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4483 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4484 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004485 -S "mbedtls_ssl_handshake returned" \
4486 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004487 -c "Read from server: .* bytes read"
4488
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004489run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004490 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4491 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4492 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004493 -S "mbedtls_ssl_handshake returned" \
4494 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004495 -c "Read from server: .* bytes read"
4496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004497run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004498 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4499 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4500 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004501 -S "mbedtls_ssl_handshake returned" \
4502 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004503 -c "Read from server: .* bytes read"
4504
Hanno Becker00076712017-11-15 16:39:08 +00004505# Tests for event-driven I/O: exercise a variety of handshake flows
4506
4507run_test "Event-driven I/O: basic handshake" \
4508 "$P_SRV event=1 tickets=0 auth_mode=none" \
4509 "$P_CLI event=1 tickets=0" \
4510 0 \
4511 -S "mbedtls_ssl_handshake returned" \
4512 -C "mbedtls_ssl_handshake returned" \
4513 -c "Read from server: .* bytes read"
4514
4515run_test "Event-driven I/O: client auth" \
4516 "$P_SRV event=1 tickets=0 auth_mode=required" \
4517 "$P_CLI event=1 tickets=0" \
4518 0 \
4519 -S "mbedtls_ssl_handshake returned" \
4520 -C "mbedtls_ssl_handshake returned" \
4521 -c "Read from server: .* bytes read"
4522
4523run_test "Event-driven I/O: ticket" \
4524 "$P_SRV event=1 tickets=1 auth_mode=none" \
4525 "$P_CLI event=1 tickets=1" \
4526 0 \
4527 -S "mbedtls_ssl_handshake returned" \
4528 -C "mbedtls_ssl_handshake returned" \
4529 -c "Read from server: .* bytes read"
4530
4531run_test "Event-driven I/O: ticket + client auth" \
4532 "$P_SRV event=1 tickets=1 auth_mode=required" \
4533 "$P_CLI event=1 tickets=1" \
4534 0 \
4535 -S "mbedtls_ssl_handshake returned" \
4536 -C "mbedtls_ssl_handshake returned" \
4537 -c "Read from server: .* bytes read"
4538
4539run_test "Event-driven I/O: ticket + client auth + resume" \
4540 "$P_SRV event=1 tickets=1 auth_mode=required" \
4541 "$P_CLI event=1 tickets=1 reconnect=1" \
4542 0 \
4543 -S "mbedtls_ssl_handshake returned" \
4544 -C "mbedtls_ssl_handshake returned" \
4545 -c "Read from server: .* bytes read"
4546
4547run_test "Event-driven I/O: ticket + resume" \
4548 "$P_SRV event=1 tickets=1 auth_mode=none" \
4549 "$P_CLI event=1 tickets=1 reconnect=1" \
4550 0 \
4551 -S "mbedtls_ssl_handshake returned" \
4552 -C "mbedtls_ssl_handshake returned" \
4553 -c "Read from server: .* bytes read"
4554
4555run_test "Event-driven I/O: session-id resume" \
4556 "$P_SRV event=1 tickets=0 auth_mode=none" \
4557 "$P_CLI event=1 tickets=0 reconnect=1" \
4558 0 \
4559 -S "mbedtls_ssl_handshake returned" \
4560 -C "mbedtls_ssl_handshake returned" \
4561 -c "Read from server: .* bytes read"
4562
Hanno Becker6a33f592018-03-13 11:38:46 +00004563run_test "Event-driven I/O, DTLS: basic handshake" \
4564 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4565 "$P_CLI dtls=1 event=1 tickets=0" \
4566 0 \
4567 -c "Read from server: .* bytes read"
4568
4569run_test "Event-driven I/O, DTLS: client auth" \
4570 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4571 "$P_CLI dtls=1 event=1 tickets=0" \
4572 0 \
4573 -c "Read from server: .* bytes read"
4574
4575run_test "Event-driven I/O, DTLS: ticket" \
4576 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4577 "$P_CLI dtls=1 event=1 tickets=1" \
4578 0 \
4579 -c "Read from server: .* bytes read"
4580
4581run_test "Event-driven I/O, DTLS: ticket + client auth" \
4582 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4583 "$P_CLI dtls=1 event=1 tickets=1" \
4584 0 \
4585 -c "Read from server: .* bytes read"
4586
4587run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4588 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4589 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4590 0 \
4591 -c "Read from server: .* bytes read"
4592
4593run_test "Event-driven I/O, DTLS: ticket + resume" \
4594 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4595 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4596 0 \
4597 -c "Read from server: .* bytes read"
4598
4599run_test "Event-driven I/O, DTLS: session-id resume" \
4600 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4601 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4602 0 \
4603 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004604
4605# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4606# During session resumption, the client will send its ApplicationData record
4607# within the same datagram as the Finished messages. In this situation, the
4608# server MUST NOT idle on the underlying transport after handshake completion,
4609# because the ApplicationData request has already been queued internally.
4610run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004611 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004612 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4613 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4614 0 \
4615 -c "Read from server: .* bytes read"
4616
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004617# Tests for version negotiation
4618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004619run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004620 "$P_SRV" \
4621 "$P_CLI" \
4622 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004623 -S "mbedtls_ssl_handshake returned" \
4624 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004625 -s "Protocol is TLSv1.2" \
4626 -c "Protocol is TLSv1.2"
4627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004628run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004629 "$P_SRV" \
4630 "$P_CLI max_version=tls1_1" \
4631 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004632 -S "mbedtls_ssl_handshake returned" \
4633 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004634 -s "Protocol is TLSv1.1" \
4635 -c "Protocol is TLSv1.1"
4636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004637run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004638 "$P_SRV max_version=tls1_1" \
4639 "$P_CLI" \
4640 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004641 -S "mbedtls_ssl_handshake returned" \
4642 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004643 -s "Protocol is TLSv1.1" \
4644 -c "Protocol is TLSv1.1"
4645
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004646run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004647 "$P_SRV max_version=tls1_1" \
4648 "$P_CLI max_version=tls1_1" \
4649 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004650 -S "mbedtls_ssl_handshake returned" \
4651 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004652 -s "Protocol is TLSv1.1" \
4653 -c "Protocol is TLSv1.1"
4654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004655run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004656 "$P_SRV min_version=tls1_1" \
4657 "$P_CLI max_version=tls1_1" \
4658 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004659 -S "mbedtls_ssl_handshake returned" \
4660 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004661 -s "Protocol is TLSv1.1" \
4662 -c "Protocol is TLSv1.1"
4663
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004664run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004665 "$P_SRV max_version=tls1_1" \
4666 "$P_CLI min_version=tls1_1" \
4667 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004668 -S "mbedtls_ssl_handshake returned" \
4669 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004670 -s "Protocol is TLSv1.1" \
4671 -c "Protocol is TLSv1.1"
4672
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004673run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004674 "$P_SRV max_version=tls1_1" \
4675 "$P_CLI min_version=tls1_2" \
4676 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004677 -s "mbedtls_ssl_handshake returned" \
4678 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004679 -c "SSL - Handshake protocol not within min/max boundaries"
4680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004681run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004682 "$P_SRV min_version=tls1_2" \
4683 "$P_CLI max_version=tls1_1" \
4684 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004685 -s "mbedtls_ssl_handshake returned" \
4686 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004687 -s "SSL - Handshake protocol not within min/max boundaries"
4688
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004689# Tests for ALPN extension
4690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004691run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004692 "$P_SRV debug_level=3" \
4693 "$P_CLI debug_level=3" \
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" \
4701 -S "Application Layer Protocol is"
4702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004703run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004704 "$P_SRV debug_level=3" \
4705 "$P_CLI debug_level=3 alpn=abc,1234" \
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 (none)" \
4713 -S "Application Layer Protocol is"
4714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004715run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004716 "$P_SRV debug_level=3 alpn=abc,1234" \
4717 "$P_CLI debug_level=3" \
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" \
4725 -s "Application Layer Protocol is (none)"
4726
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004727run_test "ALPN: both, common cli1-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=abc,1234" \
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 cli2-srv1" \
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,abc" \
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 abc" \
4749 -s "Application Layer Protocol is abc"
4750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004751run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004752 "$P_SRV debug_level=3 alpn=abc,1234" \
4753 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004754 0 \
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é-Gonnard8e03c712014-08-30 21:42:40 +02004763run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004764 "$P_SRV debug_level=3 alpn=abc,123" \
4765 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004766 1 \
4767 -c "client hello, adding alpn extension" \
4768 -s "found alpn extension" \
4769 -c "got an alert message, type: \\[2:120]" \
4770 -S "server hello, adding alpn extension" \
4771 -C "found alpn extension" \
4772 -C "Application Layer Protocol is 1234" \
4773 -S "Application Layer Protocol is 1234"
4774
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02004775
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004776# Tests for keyUsage in leaf certificates, part 1:
4777# server-side certificate/suite selection
4778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004779run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004780 "$P_SRV key_file=data_files/server2.key \
4781 crt_file=data_files/server2.ku-ds.crt" \
4782 "$P_CLI" \
4783 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02004784 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004785
4786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004787run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004788 "$P_SRV key_file=data_files/server2.key \
4789 crt_file=data_files/server2.ku-ke.crt" \
4790 "$P_CLI" \
4791 0 \
4792 -c "Ciphersuite is TLS-RSA-WITH-"
4793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004794run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004795 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004796 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004797 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004798 1 \
4799 -C "Ciphersuite is "
4800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004801run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004802 "$P_SRV key_file=data_files/server5.key \
4803 crt_file=data_files/server5.ku-ds.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004804 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004805 0 \
4806 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
4807
4808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004809run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004810 "$P_SRV key_file=data_files/server5.key \
4811 crt_file=data_files/server5.ku-ka.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004812 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004813 0 \
4814 -c "Ciphersuite is TLS-ECDH-"
4815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004816run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004817 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004818 crt_file=data_files/server5.ku-ke.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004819 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004820 1 \
4821 -C "Ciphersuite is "
4822
4823# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004824# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004826run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004827 "$O_SRV -key data_files/server2.key \
4828 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004829 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004830 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4831 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004832 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004833 -C "Processing of the Certificate handshake message failed" \
4834 -c "Ciphersuite is TLS-"
4835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004836run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004837 "$O_SRV -key data_files/server2.key \
4838 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004839 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004840 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4841 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004842 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004843 -C "Processing of the Certificate handshake message failed" \
4844 -c "Ciphersuite is TLS-"
4845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004846run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004847 "$O_SRV -key data_files/server2.key \
4848 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004849 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004850 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4851 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004852 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004853 -C "Processing of the Certificate handshake message failed" \
4854 -c "Ciphersuite is TLS-"
4855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004856run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004857 "$O_SRV -key data_files/server2.key \
4858 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004859 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004860 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4861 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004862 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004863 -c "Processing of the Certificate handshake message failed" \
4864 -C "Ciphersuite is TLS-"
4865
Hanno Becker4a156fc2019-06-14 17:07:06 +01004866requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004867requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004868run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
4869 "$O_SRV -key data_files/server2.key \
4870 -cert data_files/server2.ku-ke.crt" \
4871 "$P_CLI debug_level=1 auth_mode=optional \
4872 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4873 0 \
4874 -c "bad certificate (usage extensions)" \
4875 -C "Processing of the Certificate handshake message failed" \
4876 -c "Ciphersuite is TLS-" \
4877 -c "! Usage does not match the keyUsage extension"
4878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004879run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004880 "$O_SRV -key data_files/server2.key \
4881 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004882 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004883 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4884 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004885 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004886 -C "Processing of the Certificate handshake message failed" \
4887 -c "Ciphersuite is TLS-"
4888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004889run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004890 "$O_SRV -key data_files/server2.key \
4891 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004892 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004893 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4894 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004895 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004896 -c "Processing of the Certificate handshake message failed" \
4897 -C "Ciphersuite is TLS-"
4898
Hanno Becker4a156fc2019-06-14 17:07:06 +01004899requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004900requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004901run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
4902 "$O_SRV -key data_files/server2.key \
4903 -cert data_files/server2.ku-ds.crt" \
4904 "$P_CLI debug_level=1 auth_mode=optional \
4905 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4906 0 \
4907 -c "bad certificate (usage extensions)" \
4908 -C "Processing of the Certificate handshake message failed" \
4909 -c "Ciphersuite is TLS-" \
4910 -c "! Usage does not match the keyUsage extension"
4911
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004912# Tests for keyUsage in leaf certificates, part 3:
4913# server-side checking of client cert
4914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004915run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004916 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004917 "$O_CLI -key data_files/server2.key \
4918 -cert data_files/server2.ku-ds.crt" \
4919 0 \
4920 -S "bad certificate (usage extensions)" \
4921 -S "Processing of the Certificate handshake message failed"
4922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004923run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004924 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004925 "$O_CLI -key data_files/server2.key \
4926 -cert data_files/server2.ku-ke.crt" \
4927 0 \
4928 -s "bad certificate (usage extensions)" \
4929 -S "Processing of the Certificate handshake message failed"
4930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004931run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004932 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004933 "$O_CLI -key data_files/server2.key \
4934 -cert data_files/server2.ku-ke.crt" \
4935 1 \
4936 -s "bad certificate (usage extensions)" \
4937 -s "Processing of the Certificate handshake message failed"
4938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004939run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004940 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004941 "$O_CLI -key data_files/server5.key \
4942 -cert data_files/server5.ku-ds.crt" \
4943 0 \
4944 -S "bad certificate (usage extensions)" \
4945 -S "Processing of the Certificate handshake message failed"
4946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004947run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004948 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004949 "$O_CLI -key data_files/server5.key \
4950 -cert data_files/server5.ku-ka.crt" \
4951 0 \
4952 -s "bad certificate (usage extensions)" \
4953 -S "Processing of the Certificate handshake message failed"
4954
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004955# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
4956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004957run_test "extKeyUsage srv: serverAuth -> 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-srv.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: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004964 "$P_SRV key_file=data_files/server5.key \
4965 crt_file=data_files/server5.eku-srv.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 0
4968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004969run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004970 "$P_SRV key_file=data_files/server5.key \
4971 crt_file=data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004972 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004973 0
4974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004975run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02004976 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004977 crt_file=data_files/server5.eku-cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004978 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004979 1
4980
4981# Tests for extendedKeyUsage, part 2: client-side checking of server cert
4982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004983run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004984 "$O_SRV -key data_files/server5.key \
4985 -cert data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004986 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004987 0 \
4988 -C "bad certificate (usage extensions)" \
4989 -C "Processing of the Certificate handshake message failed" \
4990 -c "Ciphersuite is TLS-"
4991
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004992run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004993 "$O_SRV -key data_files/server5.key \
4994 -cert data_files/server5.eku-srv_cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004995 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004996 0 \
4997 -C "bad certificate (usage extensions)" \
4998 -C "Processing of the Certificate handshake message failed" \
4999 -c "Ciphersuite is TLS-"
5000
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005001run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005002 "$O_SRV -key data_files/server5.key \
5003 -cert data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005004 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005005 0 \
5006 -C "bad certificate (usage extensions)" \
5007 -C "Processing of the Certificate handshake message failed" \
5008 -c "Ciphersuite is TLS-"
5009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005010run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005011 "$O_SRV -key data_files/server5.key \
5012 -cert data_files/server5.eku-cs.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005013 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005014 1 \
5015 -c "bad certificate (usage extensions)" \
5016 -c "Processing of the Certificate handshake message failed" \
5017 -C "Ciphersuite is TLS-"
5018
5019# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005021run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005022 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005023 "$O_CLI -key data_files/server5.key \
5024 -cert data_files/server5.eku-cli.crt" \
5025 0 \
5026 -S "bad certificate (usage extensions)" \
5027 -S "Processing of the Certificate handshake message failed"
5028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005029run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005030 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005031 "$O_CLI -key data_files/server5.key \
5032 -cert data_files/server5.eku-srv_cli.crt" \
5033 0 \
5034 -S "bad certificate (usage extensions)" \
5035 -S "Processing of the Certificate handshake message failed"
5036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005037run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005038 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005039 "$O_CLI -key data_files/server5.key \
5040 -cert data_files/server5.eku-cs_any.crt" \
5041 0 \
5042 -S "bad certificate (usage extensions)" \
5043 -S "Processing of the Certificate handshake message failed"
5044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005045run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005046 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005047 "$O_CLI -key data_files/server5.key \
5048 -cert data_files/server5.eku-cs.crt" \
5049 0 \
5050 -s "bad certificate (usage extensions)" \
5051 -S "Processing of the Certificate handshake message failed"
5052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005053run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005054 "$P_SRV debug_level=1 auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005055 "$O_CLI -key data_files/server5.key \
5056 -cert data_files/server5.eku-cs.crt" \
5057 1 \
5058 -s "bad certificate (usage extensions)" \
5059 -s "Processing of the Certificate handshake message failed"
5060
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005061# Tests for DHM parameters loading
5062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005063run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005064 "$P_SRV" \
5065 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5066 debug_level=3" \
5067 0 \
5068 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005069 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005071run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005072 "$P_SRV dhm_file=data_files/dhparams.pem" \
5073 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5074 debug_level=3" \
5075 0 \
5076 -c "value of 'DHM: P ' (1024 bits)" \
5077 -c "value of 'DHM: G ' (2 bits)"
5078
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005079# Tests for DHM client-side size checking
5080
5081run_test "DHM size: server default, client default, OK" \
5082 "$P_SRV" \
5083 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5084 debug_level=1" \
5085 0 \
5086 -C "DHM prime too short:"
5087
5088run_test "DHM size: server default, client 2048, OK" \
5089 "$P_SRV" \
5090 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5091 debug_level=1 dhmlen=2048" \
5092 0 \
5093 -C "DHM prime too short:"
5094
5095run_test "DHM size: server 1024, client default, OK" \
5096 "$P_SRV dhm_file=data_files/dhparams.pem" \
5097 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5098 debug_level=1" \
5099 0 \
5100 -C "DHM prime too short:"
5101
5102run_test "DHM size: server 1000, client default, rejected" \
5103 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5104 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5105 debug_level=1" \
5106 1 \
5107 -c "DHM prime too short:"
5108
5109run_test "DHM size: server default, client 2049, rejected" \
5110 "$P_SRV" \
5111 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5112 debug_level=1 dhmlen=2049" \
5113 1 \
5114 -c "DHM prime too short:"
5115
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005116# Tests for PSK callback
5117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005118run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005119 "$P_SRV psk=abc123 psk_identity=foo" \
5120 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5121 psk_identity=foo psk=abc123" \
5122 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005123 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005124 -S "SSL - Unknown identity received" \
5125 -S "SSL - Verification of the message MAC failed"
5126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005127run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005128 "$P_SRV" \
5129 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5130 psk_identity=foo psk=abc123" \
5131 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005132 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005133 -S "SSL - Unknown identity received" \
5134 -S "SSL - Verification of the message MAC failed"
5135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005136run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005137 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5138 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5139 psk_identity=foo psk=abc123" \
5140 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005141 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005142 -s "SSL - Unknown identity received" \
5143 -S "SSL - Verification of the message MAC failed"
5144
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005145run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005146 "$P_SRV psk_list=abc,dead,def,beef" \
5147 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5148 psk_identity=abc psk=dead" \
5149 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005150 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005151 -S "SSL - Unknown identity received" \
5152 -S "SSL - Verification of the message MAC failed"
5153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005154run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005155 "$P_SRV psk_list=abc,dead,def,beef" \
5156 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5157 psk_identity=def psk=beef" \
5158 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005159 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005160 -S "SSL - Unknown identity received" \
5161 -S "SSL - Verification of the message MAC failed"
5162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005163run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005164 "$P_SRV psk_list=abc,dead,def,beef" \
5165 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5166 psk_identity=ghi psk=beef" \
5167 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005168 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005169 -s "SSL - Unknown identity received" \
5170 -S "SSL - Verification of the message MAC failed"
5171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005172run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005173 "$P_SRV psk_list=abc,dead,def,beef" \
5174 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5175 psk_identity=abc psk=beef" \
5176 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005177 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005178 -S "SSL - Unknown identity received" \
5179 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005180
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005181# Tests for EC J-PAKE
5182
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005183requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005184run_test "ECJPAKE: client not configured" \
5185 "$P_SRV debug_level=3" \
5186 "$P_CLI debug_level=3" \
5187 0 \
5188 -C "add ciphersuite: c0ff" \
5189 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005190 -S "found ecjpake kkpp extension" \
5191 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005192 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005193 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005194 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005195 -S "None of the common ciphersuites is usable"
5196
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005197requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005198run_test "ECJPAKE: server not configured" \
5199 "$P_SRV debug_level=3" \
5200 "$P_CLI debug_level=3 ecjpake_pw=bla \
5201 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5202 1 \
5203 -c "add ciphersuite: c0ff" \
5204 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005205 -s "found ecjpake kkpp extension" \
5206 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005207 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005208 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005209 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005210 -s "None of the common ciphersuites is usable"
5211
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005212requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005213run_test "ECJPAKE: working, TLS" \
5214 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5215 "$P_CLI debug_level=3 ecjpake_pw=bla \
5216 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005217 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005218 -c "add ciphersuite: c0ff" \
5219 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005220 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005221 -s "found ecjpake kkpp extension" \
5222 -S "skip ecjpake kkpp extension" \
5223 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005224 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005225 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005226 -S "None of the common ciphersuites is usable" \
5227 -S "SSL - Verification of the message MAC failed"
5228
Janos Follath74537a62016-09-02 13:45:28 +01005229server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005230requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005231run_test "ECJPAKE: password mismatch, TLS" \
5232 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5233 "$P_CLI debug_level=3 ecjpake_pw=bad \
5234 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5235 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005236 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005237 -s "SSL - Verification of the message MAC failed"
5238
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005239requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005240run_test "ECJPAKE: working, DTLS" \
5241 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5242 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5243 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5244 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005245 -c "re-using cached ecjpake parameters" \
5246 -S "SSL - Verification of the message MAC failed"
5247
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005248requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005249run_test "ECJPAKE: working, DTLS, no cookie" \
5250 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5251 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5252 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5253 0 \
5254 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005255 -S "SSL - Verification of the message MAC failed"
5256
Janos Follath74537a62016-09-02 13:45:28 +01005257server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005258requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005259run_test "ECJPAKE: password mismatch, DTLS" \
5260 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5261 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5262 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5263 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005264 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005265 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005266
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005267# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005268requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005269run_test "ECJPAKE: working, DTLS, nolog" \
5270 "$P_SRV dtls=1 ecjpake_pw=bla" \
5271 "$P_CLI dtls=1 ecjpake_pw=bla \
5272 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5273 0
5274
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005275# Tests for ciphersuites per version
5276
Janos Follathe2681a42016-03-07 15:57:05 +00005277requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005278requires_config_enabled MBEDTLS_CAMELLIA_C
5279requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005280run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005281 "$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 +02005282 "$P_CLI force_version=ssl3" \
5283 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005284 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005285
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005286requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5287requires_config_enabled MBEDTLS_CAMELLIA_C
5288requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005289run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005290 "$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 +01005291 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005292 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005293 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005294
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005295requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5296requires_config_enabled MBEDTLS_CAMELLIA_C
5297requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005298run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005299 "$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 +02005300 "$P_CLI force_version=tls1_1" \
5301 0 \
5302 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5303
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005304requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5305requires_config_enabled MBEDTLS_CAMELLIA_C
5306requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005307run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005308 "$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 +02005309 "$P_CLI force_version=tls1_2" \
5310 0 \
5311 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5312
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005313# Test for ClientHello without extensions
5314
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005315requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005316run_test "ClientHello without extensions, SHA-1 allowed" \
Ron Eldorb76e7652019-01-16 23:14:41 +02005317 "$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 +02005318 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005319 0 \
5320 -s "dumping 'client hello extensions' (0 bytes)"
5321
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005322requires_gnutls
5323run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
5324 "$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 +02005325 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005326 0 \
5327 -s "dumping 'client hello extensions' (0 bytes)"
5328
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005329# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005330
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005331run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005332 "$P_SRV" \
5333 "$P_CLI request_size=100" \
5334 0 \
5335 -s "Read from client: 100 bytes read$"
5336
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005337run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005338 "$P_SRV" \
5339 "$P_CLI request_size=500" \
5340 0 \
5341 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005342
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005343# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005344
Janos Follathe2681a42016-03-07 15:57:05 +00005345requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005346run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005347 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005348 "$P_CLI request_size=1 force_version=ssl3 \
5349 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5350 0 \
5351 -s "Read from client: 1 bytes read"
5352
Janos Follathe2681a42016-03-07 15:57:05 +00005353requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005354run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005355 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005356 "$P_CLI request_size=1 force_version=ssl3 \
5357 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5358 0 \
5359 -s "Read from client: 1 bytes read"
5360
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005361run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005362 "$P_SRV" \
5363 "$P_CLI request_size=1 force_version=tls1 \
5364 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5365 0 \
5366 -s "Read from client: 1 bytes read"
5367
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005368run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005369 "$P_SRV" \
5370 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5371 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5372 0 \
5373 -s "Read from client: 1 bytes read"
5374
Hanno Becker32c55012017-11-10 08:42:54 +00005375requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005376run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005377 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005378 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005379 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005380 0 \
5381 -s "Read from client: 1 bytes read"
5382
Hanno Becker32c55012017-11-10 08:42:54 +00005383requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005384run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005385 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005386 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005387 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005388 0 \
5389 -s "Read from client: 1 bytes read"
5390
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005391run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005392 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005393 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005394 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5395 0 \
5396 -s "Read from client: 1 bytes read"
5397
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005398run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005399 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5400 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005401 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005402 0 \
5403 -s "Read from client: 1 bytes read"
5404
5405requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005406run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005407 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005408 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005409 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005410 0 \
5411 -s "Read from client: 1 bytes read"
5412
Hanno Becker8501f982017-11-10 08:59:04 +00005413requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005414run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005415 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5416 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5417 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005418 0 \
5419 -s "Read from client: 1 bytes read"
5420
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005421run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005422 "$P_SRV" \
5423 "$P_CLI request_size=1 force_version=tls1_1 \
5424 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5425 0 \
5426 -s "Read from client: 1 bytes read"
5427
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005428run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005429 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005430 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005431 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005432 0 \
5433 -s "Read from client: 1 bytes read"
5434
5435requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005436run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005437 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005438 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005439 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005440 0 \
5441 -s "Read from client: 1 bytes read"
5442
5443requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005444run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005445 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005446 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005447 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005448 0 \
5449 -s "Read from client: 1 bytes read"
5450
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005451run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005452 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005453 "$P_CLI request_size=1 force_version=tls1_1 \
5454 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5455 0 \
5456 -s "Read from client: 1 bytes read"
5457
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005458run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005459 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005460 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005461 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005462 0 \
5463 -s "Read from client: 1 bytes read"
5464
Hanno Becker8501f982017-11-10 08:59:04 +00005465requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005466run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005467 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005468 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005469 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005470 0 \
5471 -s "Read from client: 1 bytes read"
5472
Hanno Becker32c55012017-11-10 08:42:54 +00005473requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005474run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005475 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005476 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005477 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005478 0 \
5479 -s "Read from client: 1 bytes read"
5480
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005481run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005482 "$P_SRV" \
5483 "$P_CLI request_size=1 force_version=tls1_2 \
5484 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5485 0 \
5486 -s "Read from client: 1 bytes read"
5487
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005488run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005489 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005490 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005491 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005492 0 \
5493 -s "Read from client: 1 bytes read"
5494
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005495run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005496 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005497 "$P_CLI request_size=1 force_version=tls1_2 \
5498 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005499 0 \
5500 -s "Read from client: 1 bytes read"
5501
Hanno Becker32c55012017-11-10 08:42:54 +00005502requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005503run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005504 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005505 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005506 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005507 0 \
5508 -s "Read from client: 1 bytes read"
5509
Hanno Becker8501f982017-11-10 08:59:04 +00005510requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005511run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005512 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005513 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005514 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005515 0 \
5516 -s "Read from client: 1 bytes read"
5517
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005518run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005519 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005520 "$P_CLI request_size=1 force_version=tls1_2 \
5521 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5522 0 \
5523 -s "Read from client: 1 bytes read"
5524
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005525run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005526 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005527 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005528 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005529 0 \
5530 -s "Read from client: 1 bytes read"
5531
Hanno Becker32c55012017-11-10 08:42:54 +00005532requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005533run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005534 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005535 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005536 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005537 0 \
5538 -s "Read from client: 1 bytes read"
5539
Hanno Becker8501f982017-11-10 08:59:04 +00005540requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005541run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005542 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005543 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005544 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005545 0 \
5546 -s "Read from client: 1 bytes read"
5547
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005548run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005549 "$P_SRV" \
5550 "$P_CLI request_size=1 force_version=tls1_2 \
5551 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5552 0 \
5553 -s "Read from client: 1 bytes read"
5554
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005555run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005556 "$P_SRV" \
5557 "$P_CLI request_size=1 force_version=tls1_2 \
5558 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5559 0 \
5560 -s "Read from client: 1 bytes read"
5561
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005562# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00005563
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005564run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005565 "$P_SRV dtls=1 force_version=dtls1" \
5566 "$P_CLI dtls=1 request_size=1 \
5567 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5568 0 \
5569 -s "Read from client: 1 bytes read"
5570
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005571run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00005572 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
5573 "$P_CLI dtls=1 request_size=1 \
5574 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5575 0 \
5576 -s "Read from client: 1 bytes read"
5577
Hanno Beckere2148042017-11-10 08:59:18 +00005578requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005579run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005580 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
5581 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00005582 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5583 0 \
5584 -s "Read from client: 1 bytes read"
5585
Hanno Beckere2148042017-11-10 08:59:18 +00005586requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005587run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005588 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005589 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005590 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005591 0 \
5592 -s "Read from client: 1 bytes read"
5593
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005594run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00005595 "$P_SRV dtls=1 force_version=dtls1_2" \
5596 "$P_CLI dtls=1 request_size=1 \
5597 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5598 0 \
5599 -s "Read from client: 1 bytes read"
5600
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005601run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005602 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005603 "$P_CLI dtls=1 request_size=1 \
5604 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5605 0 \
5606 -s "Read from client: 1 bytes read"
5607
Hanno Beckere2148042017-11-10 08:59:18 +00005608requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005609run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005610 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005611 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005612 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005613 0 \
5614 -s "Read from client: 1 bytes read"
5615
Hanno Beckere2148042017-11-10 08:59:18 +00005616requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005617run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005618 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005619 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005620 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005621 0 \
5622 -s "Read from client: 1 bytes read"
5623
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005624# Tests for small server packets
5625
5626requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5627run_test "Small server packet SSLv3 BlockCipher" \
5628 "$P_SRV response_size=1 min_version=ssl3" \
5629 "$P_CLI force_version=ssl3 \
5630 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5631 0 \
5632 -c "Read from server: 1 bytes read"
5633
5634requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5635run_test "Small server packet SSLv3 StreamCipher" \
5636 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5637 "$P_CLI force_version=ssl3 \
5638 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5639 0 \
5640 -c "Read from server: 1 bytes read"
5641
5642run_test "Small server packet TLS 1.0 BlockCipher" \
5643 "$P_SRV response_size=1" \
5644 "$P_CLI force_version=tls1 \
5645 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5646 0 \
5647 -c "Read from server: 1 bytes read"
5648
5649run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
5650 "$P_SRV response_size=1" \
5651 "$P_CLI force_version=tls1 etm=0 \
5652 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5653 0 \
5654 -c "Read from server: 1 bytes read"
5655
5656requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5657run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
5658 "$P_SRV response_size=1 trunc_hmac=1" \
5659 "$P_CLI force_version=tls1 \
5660 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5661 0 \
5662 -c "Read from server: 1 bytes read"
5663
5664requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5665run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
5666 "$P_SRV response_size=1 trunc_hmac=1" \
5667 "$P_CLI force_version=tls1 \
5668 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5669 0 \
5670 -c "Read from server: 1 bytes read"
5671
5672run_test "Small server packet TLS 1.0 StreamCipher" \
5673 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5674 "$P_CLI force_version=tls1 \
5675 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5676 0 \
5677 -c "Read from server: 1 bytes read"
5678
5679run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
5680 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5681 "$P_CLI force_version=tls1 \
5682 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5683 0 \
5684 -c "Read from server: 1 bytes read"
5685
5686requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5687run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
5688 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5689 "$P_CLI force_version=tls1 \
5690 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5691 0 \
5692 -c "Read from server: 1 bytes read"
5693
5694requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5695run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5696 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5697 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5698 trunc_hmac=1 etm=0" \
5699 0 \
5700 -c "Read from server: 1 bytes read"
5701
5702run_test "Small server packet TLS 1.1 BlockCipher" \
5703 "$P_SRV response_size=1" \
5704 "$P_CLI force_version=tls1_1 \
5705 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5706 0 \
5707 -c "Read from server: 1 bytes read"
5708
5709run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
5710 "$P_SRV response_size=1" \
5711 "$P_CLI force_version=tls1_1 \
5712 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5713 0 \
5714 -c "Read from server: 1 bytes read"
5715
5716requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5717run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
5718 "$P_SRV response_size=1 trunc_hmac=1" \
5719 "$P_CLI force_version=tls1_1 \
5720 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5721 0 \
5722 -c "Read from server: 1 bytes read"
5723
5724requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5725run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5726 "$P_SRV response_size=1 trunc_hmac=1" \
5727 "$P_CLI force_version=tls1_1 \
5728 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5729 0 \
5730 -c "Read from server: 1 bytes read"
5731
5732run_test "Small server packet TLS 1.1 StreamCipher" \
5733 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5734 "$P_CLI force_version=tls1_1 \
5735 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5736 0 \
5737 -c "Read from server: 1 bytes read"
5738
5739run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
5740 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5741 "$P_CLI force_version=tls1_1 \
5742 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5743 0 \
5744 -c "Read from server: 1 bytes read"
5745
5746requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5747run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
5748 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5749 "$P_CLI force_version=tls1_1 \
5750 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5751 0 \
5752 -c "Read from server: 1 bytes read"
5753
5754requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5755run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5756 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5757 "$P_CLI force_version=tls1_1 \
5758 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5759 0 \
5760 -c "Read from server: 1 bytes read"
5761
5762run_test "Small server packet TLS 1.2 BlockCipher" \
5763 "$P_SRV response_size=1" \
5764 "$P_CLI force_version=tls1_2 \
5765 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5766 0 \
5767 -c "Read from server: 1 bytes read"
5768
5769run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5770 "$P_SRV response_size=1" \
5771 "$P_CLI force_version=tls1_2 \
5772 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5773 0 \
5774 -c "Read from server: 1 bytes read"
5775
5776run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5777 "$P_SRV response_size=1" \
5778 "$P_CLI force_version=tls1_2 \
5779 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5780 0 \
5781 -c "Read from server: 1 bytes read"
5782
5783requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5784run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5785 "$P_SRV response_size=1 trunc_hmac=1" \
5786 "$P_CLI force_version=tls1_2 \
5787 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5788 0 \
5789 -c "Read from server: 1 bytes read"
5790
5791requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5792run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5793 "$P_SRV response_size=1 trunc_hmac=1" \
5794 "$P_CLI force_version=tls1_2 \
5795 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5796 0 \
5797 -c "Read from server: 1 bytes read"
5798
5799run_test "Small server packet TLS 1.2 StreamCipher" \
5800 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5801 "$P_CLI force_version=tls1_2 \
5802 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5803 0 \
5804 -c "Read from server: 1 bytes read"
5805
5806run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
5807 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5808 "$P_CLI force_version=tls1_2 \
5809 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5810 0 \
5811 -c "Read from server: 1 bytes read"
5812
5813requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5814run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
5815 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5816 "$P_CLI force_version=tls1_2 \
5817 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5818 0 \
5819 -c "Read from server: 1 bytes read"
5820
5821requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5822run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5823 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5824 "$P_CLI force_version=tls1_2 \
5825 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5826 0 \
5827 -c "Read from server: 1 bytes read"
5828
5829run_test "Small server packet TLS 1.2 AEAD" \
5830 "$P_SRV response_size=1" \
5831 "$P_CLI force_version=tls1_2 \
5832 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5833 0 \
5834 -c "Read from server: 1 bytes read"
5835
5836run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5837 "$P_SRV response_size=1" \
5838 "$P_CLI force_version=tls1_2 \
5839 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5840 0 \
5841 -c "Read from server: 1 bytes read"
5842
5843# Tests for small server packets in DTLS
5844
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005845run_test "Small server packet DTLS 1.0" \
5846 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
5847 "$P_CLI dtls=1 \
5848 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5849 0 \
5850 -c "Read from server: 1 bytes read"
5851
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005852run_test "Small server packet DTLS 1.0, without EtM" \
5853 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
5854 "$P_CLI dtls=1 \
5855 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5856 0 \
5857 -c "Read from server: 1 bytes read"
5858
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005859requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5860run_test "Small server packet DTLS 1.0, truncated hmac" \
5861 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
5862 "$P_CLI dtls=1 trunc_hmac=1 \
5863 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5864 0 \
5865 -c "Read from server: 1 bytes read"
5866
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005867requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5868run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
5869 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
5870 "$P_CLI dtls=1 \
5871 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5872 0 \
5873 -c "Read from server: 1 bytes read"
5874
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005875run_test "Small server packet DTLS 1.2" \
5876 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
5877 "$P_CLI dtls=1 \
5878 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5879 0 \
5880 -c "Read from server: 1 bytes read"
5881
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005882run_test "Small server packet DTLS 1.2, without EtM" \
5883 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5884 "$P_CLI dtls=1 \
5885 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5886 0 \
5887 -c "Read from server: 1 bytes read"
5888
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005889requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5890run_test "Small server packet DTLS 1.2, truncated hmac" \
5891 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5892 "$P_CLI dtls=1 \
5893 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5894 0 \
5895 -c "Read from server: 1 bytes read"
5896
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005897requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5898run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5899 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5900 "$P_CLI dtls=1 \
5901 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5902 0 \
5903 -c "Read from server: 1 bytes read"
5904
Janos Follath00efff72016-05-06 13:48:23 +01005905# A test for extensions in SSLv3
5906
5907requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5908run_test "SSLv3 with extensions, server side" \
5909 "$P_SRV min_version=ssl3 debug_level=3" \
5910 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
5911 0 \
5912 -S "dumping 'client hello extensions'" \
5913 -S "server hello, total extension length:"
5914
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005915# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005916
Angus Grattonc4dd0732018-04-11 16:28:39 +10005917# How many fragments do we expect to write $1 bytes?
5918fragments_for_write() {
5919 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
5920}
5921
Janos Follathe2681a42016-03-07 15:57:05 +00005922requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005923run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005924 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005925 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005926 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5927 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005928 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5929 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005930
Janos Follathe2681a42016-03-07 15:57:05 +00005931requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005932run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005933 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005934 "$P_CLI request_size=16384 force_version=ssl3 \
5935 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5936 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005937 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5938 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005939
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005940run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005941 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005942 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005943 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5944 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005945 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5946 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005947
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005948run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005949 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005950 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
5951 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5952 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005953 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005954
Hanno Becker32c55012017-11-10 08:42:54 +00005955requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005956run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005957 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005958 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005959 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005960 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005961 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5962 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005963
Hanno Becker32c55012017-11-10 08:42:54 +00005964requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005965run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005966 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005967 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005968 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005969 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005970 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005971
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005972run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005973 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005974 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005975 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5976 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005977 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005978
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005979run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005980 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5981 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005982 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005983 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005984 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005985
5986requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005987run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005988 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005989 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005990 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005991 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005992 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005993
Hanno Becker278fc7a2017-11-10 09:16:28 +00005994requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005995run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005996 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005997 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005998 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005999 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006000 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6001 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006002
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006003run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006004 "$P_SRV" \
6005 "$P_CLI request_size=16384 force_version=tls1_1 \
6006 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6007 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006008 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6009 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006010
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006011run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006012 "$P_SRV" \
6013 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6014 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006015 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006016 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006017
Hanno Becker32c55012017-11-10 08:42:54 +00006018requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006019run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006020 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006021 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006022 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006023 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006024 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006025
Hanno Becker32c55012017-11-10 08:42:54 +00006026requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006027run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006028 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006029 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006030 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006031 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006032 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006033
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006034run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006035 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6036 "$P_CLI request_size=16384 force_version=tls1_1 \
6037 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6038 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006039 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6040 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006041
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006042run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006043 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006044 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006045 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006046 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006047 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6048 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006049
Hanno Becker278fc7a2017-11-10 09:16:28 +00006050requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006051run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006052 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006053 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006054 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006055 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006056 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006057
Hanno Becker278fc7a2017-11-10 09:16:28 +00006058requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006059run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006060 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006061 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006062 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006063 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006064 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6065 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006066
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006067run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006068 "$P_SRV" \
6069 "$P_CLI request_size=16384 force_version=tls1_2 \
6070 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6071 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006072 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6073 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006074
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006075run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006076 "$P_SRV" \
6077 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6078 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6079 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006080 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006081
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006082run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006083 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006084 "$P_CLI request_size=16384 force_version=tls1_2 \
6085 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006086 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006087 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6088 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006089
Hanno Becker32c55012017-11-10 08:42:54 +00006090requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006091run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006092 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006093 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006094 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006095 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006096 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006097
Hanno Becker278fc7a2017-11-10 09:16:28 +00006098requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006099run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006100 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006101 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006102 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006103 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006104 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6105 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006106
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006107run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006108 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006109 "$P_CLI request_size=16384 force_version=tls1_2 \
6110 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6111 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006112 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6113 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006114
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006115run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006116 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006117 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006118 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6119 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006120 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006121
Hanno Becker32c55012017-11-10 08:42:54 +00006122requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006123run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006124 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006125 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006126 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006127 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006128 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006129
Hanno Becker278fc7a2017-11-10 09:16:28 +00006130requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006131run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006132 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006133 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006134 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006135 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006136 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6137 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006138
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006139run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006140 "$P_SRV" \
6141 "$P_CLI request_size=16384 force_version=tls1_2 \
6142 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6143 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006144 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6145 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006146
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006147run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006148 "$P_SRV" \
6149 "$P_CLI request_size=16384 force_version=tls1_2 \
6150 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6151 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006152 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6153 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006154
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006155# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006156requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6157run_test "Large server packet SSLv3 StreamCipher" \
6158 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6159 "$P_CLI force_version=ssl3 \
6160 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6161 0 \
6162 -c "Read from server: 16384 bytes read"
6163
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006164# Checking next 4 tests logs for 1n-1 split against BEAST too
6165requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6166run_test "Large server packet SSLv3 BlockCipher" \
6167 "$P_SRV response_size=16384 min_version=ssl3" \
6168 "$P_CLI force_version=ssl3 recsplit=0 \
6169 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6170 0 \
6171 -c "Read from server: 1 bytes read"\
6172 -c "16383 bytes read"\
6173 -C "Read from server: 16384 bytes read"
6174
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006175run_test "Large server packet TLS 1.0 BlockCipher" \
6176 "$P_SRV response_size=16384" \
6177 "$P_CLI force_version=tls1 recsplit=0 \
6178 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6179 0 \
6180 -c "Read from server: 1 bytes read"\
6181 -c "16383 bytes read"\
6182 -C "Read from server: 16384 bytes read"
6183
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006184run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6185 "$P_SRV response_size=16384" \
6186 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6187 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6188 0 \
6189 -c "Read from server: 1 bytes read"\
6190 -c "16383 bytes read"\
6191 -C "Read from server: 16384 bytes read"
6192
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006193requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6194run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6195 "$P_SRV response_size=16384" \
6196 "$P_CLI force_version=tls1 recsplit=0 \
6197 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6198 trunc_hmac=1" \
6199 0 \
6200 -c "Read from server: 1 bytes read"\
6201 -c "16383 bytes read"\
6202 -C "Read from server: 16384 bytes read"
6203
6204requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6205run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6206 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6207 "$P_CLI force_version=tls1 \
6208 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6209 trunc_hmac=1" \
6210 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006211 -s "16384 bytes written in 1 fragments" \
6212 -c "Read from server: 16384 bytes read"
6213
6214run_test "Large server packet TLS 1.0 StreamCipher" \
6215 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6216 "$P_CLI force_version=tls1 \
6217 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6218 0 \
6219 -s "16384 bytes written in 1 fragments" \
6220 -c "Read from server: 16384 bytes read"
6221
6222run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6223 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6224 "$P_CLI force_version=tls1 \
6225 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6226 0 \
6227 -s "16384 bytes written in 1 fragments" \
6228 -c "Read from server: 16384 bytes read"
6229
6230requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6231run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6232 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6233 "$P_CLI force_version=tls1 \
6234 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6235 0 \
6236 -s "16384 bytes written in 1 fragments" \
6237 -c "Read from server: 16384 bytes read"
6238
6239requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6240run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6241 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6242 "$P_CLI force_version=tls1 \
6243 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6244 0 \
6245 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006246 -c "Read from server: 16384 bytes read"
6247
6248run_test "Large server packet TLS 1.1 BlockCipher" \
6249 "$P_SRV response_size=16384" \
6250 "$P_CLI force_version=tls1_1 \
6251 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6252 0 \
6253 -c "Read from server: 16384 bytes read"
6254
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006255run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6256 "$P_SRV response_size=16384" \
6257 "$P_CLI force_version=tls1_1 etm=0 \
6258 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006259 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006260 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006261 -c "Read from server: 16384 bytes read"
6262
6263requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6264run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6265 "$P_SRV response_size=16384" \
6266 "$P_CLI force_version=tls1_1 \
6267 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6268 trunc_hmac=1" \
6269 0 \
6270 -c "Read from server: 16384 bytes read"
6271
6272requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006273run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6274 "$P_SRV response_size=16384 trunc_hmac=1" \
6275 "$P_CLI force_version=tls1_1 \
6276 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6277 0 \
6278 -s "16384 bytes written in 1 fragments" \
6279 -c "Read from server: 16384 bytes read"
6280
6281run_test "Large server packet TLS 1.1 StreamCipher" \
6282 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6283 "$P_CLI force_version=tls1_1 \
6284 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6285 0 \
6286 -c "Read from server: 16384 bytes read"
6287
6288run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6289 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6290 "$P_CLI force_version=tls1_1 \
6291 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6292 0 \
6293 -s "16384 bytes written in 1 fragments" \
6294 -c "Read from server: 16384 bytes read"
6295
6296requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006297run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6298 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6299 "$P_CLI force_version=tls1_1 \
6300 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6301 trunc_hmac=1" \
6302 0 \
6303 -c "Read from server: 16384 bytes read"
6304
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006305run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6306 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6307 "$P_CLI force_version=tls1_1 \
6308 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6309 0 \
6310 -s "16384 bytes written in 1 fragments" \
6311 -c "Read from server: 16384 bytes read"
6312
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006313run_test "Large server packet TLS 1.2 BlockCipher" \
6314 "$P_SRV response_size=16384" \
6315 "$P_CLI force_version=tls1_2 \
6316 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6317 0 \
6318 -c "Read from server: 16384 bytes read"
6319
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006320run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6321 "$P_SRV response_size=16384" \
6322 "$P_CLI force_version=tls1_2 etm=0 \
6323 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6324 0 \
6325 -s "16384 bytes written in 1 fragments" \
6326 -c "Read from server: 16384 bytes read"
6327
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006328run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6329 "$P_SRV response_size=16384" \
6330 "$P_CLI force_version=tls1_2 \
6331 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6332 0 \
6333 -c "Read from server: 16384 bytes read"
6334
6335requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6336run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6337 "$P_SRV response_size=16384" \
6338 "$P_CLI force_version=tls1_2 \
6339 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6340 trunc_hmac=1" \
6341 0 \
6342 -c "Read from server: 16384 bytes read"
6343
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006344run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6345 "$P_SRV response_size=16384 trunc_hmac=1" \
6346 "$P_CLI force_version=tls1_2 \
6347 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6348 0 \
6349 -s "16384 bytes written in 1 fragments" \
6350 -c "Read from server: 16384 bytes read"
6351
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006352run_test "Large server packet TLS 1.2 StreamCipher" \
6353 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6354 "$P_CLI force_version=tls1_2 \
6355 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6356 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006357 -s "16384 bytes written in 1 fragments" \
6358 -c "Read from server: 16384 bytes read"
6359
6360run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6361 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6362 "$P_CLI force_version=tls1_2 \
6363 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6364 0 \
6365 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006366 -c "Read from server: 16384 bytes read"
6367
6368requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6369run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6370 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6371 "$P_CLI force_version=tls1_2 \
6372 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6373 trunc_hmac=1" \
6374 0 \
6375 -c "Read from server: 16384 bytes read"
6376
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006377requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6378run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6379 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6380 "$P_CLI force_version=tls1_2 \
6381 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6382 0 \
6383 -s "16384 bytes written in 1 fragments" \
6384 -c "Read from server: 16384 bytes read"
6385
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006386run_test "Large server packet TLS 1.2 AEAD" \
6387 "$P_SRV response_size=16384" \
6388 "$P_CLI force_version=tls1_2 \
6389 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6390 0 \
6391 -c "Read from server: 16384 bytes read"
6392
6393run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6394 "$P_SRV response_size=16384" \
6395 "$P_CLI force_version=tls1_2 \
6396 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6397 0 \
6398 -c "Read from server: 16384 bytes read"
6399
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006400# Tests for restartable ECC
6401
6402requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6403run_test "EC restart: TLS, default" \
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" \
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=0" \
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=0" \
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=65535" \
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=65535" \
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
6439run_test "EC restart: TLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006440 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006441 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006442 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006443 debug_level=1 ec_max_ops=1000" \
6444 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006445 -c "x509_verify_cert.*4b00" \
6446 -c "mbedtls_pk_verify.*4b00" \
6447 -c "mbedtls_ecdh_make_public.*4b00" \
6448 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006449
6450requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Hanno Becker4a156fc2019-06-14 17:07:06 +01006451requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006452run_test "EC restart: TLS, max_ops=1000, badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006453 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006454 crt_file=data_files/server5-badsign.crt \
6455 key_file=data_files/server5.key" \
6456 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker03d77462019-08-27 16:24:56 +01006457 key_file=data_files/server5.key crt_file=data_files/server5.crt ca_file=data_files/test-ca2.crt \
6458 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6459 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006460 -c "x509_verify_cert.*4b00" \
Hanno Becker03d77462019-08-27 16:24:56 +01006461 -c "mbedtls_pk_verify.*4b00" \
6462 -c "mbedtls_ecdh_make_public.*4b00" \
6463 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006464 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006465
Hanno Becker4a156fc2019-06-14 17:07:06 +01006466requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006467requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6468run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006469 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006470 crt_file=data_files/server5-badsign.crt \
6471 key_file=data_files/server5.key" \
6472 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6473 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006474 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006475 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6476 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006477 -c "x509_verify_cert.*4b00" \
6478 -c "mbedtls_pk_verify.*4b00" \
6479 -c "mbedtls_ecdh_make_public.*4b00" \
6480 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006481 -c "! The certificate is not correctly signed by the trusted CA" \
6482 -C "! mbedtls_ssl_handshake returned" \
6483 -C "X509 - Certificate verification failed"
6484
Hanno Becker4a156fc2019-06-14 17:07:06 +01006485requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006486requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006487requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6488run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006489 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006490 crt_file=data_files/server5-badsign.crt \
6491 key_file=data_files/server5.key" \
6492 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006493 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006494 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6495 debug_level=1 ec_max_ops=1000 auth_mode=none" \
6496 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006497 -C "x509_verify_cert.*4b00" \
6498 -c "mbedtls_pk_verify.*4b00" \
6499 -c "mbedtls_ecdh_make_public.*4b00" \
6500 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006501 -C "! The certificate is not correctly signed by the trusted CA" \
6502 -C "! mbedtls_ssl_handshake returned" \
6503 -C "X509 - Certificate verification failed"
6504
6505requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006506run_test "EC restart: DTLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006507 "$P_SRV auth_mode=required dtls=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006508 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006509 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006510 dtls=1 debug_level=1 ec_max_ops=1000" \
6511 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006512 -c "x509_verify_cert.*4b00" \
6513 -c "mbedtls_pk_verify.*4b00" \
6514 -c "mbedtls_ecdh_make_public.*4b00" \
6515 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006516
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006517requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6518run_test "EC restart: TLS, max_ops=1000 no client auth" \
6519 "$P_SRV" \
6520 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6521 debug_level=1 ec_max_ops=1000" \
6522 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006523 -c "x509_verify_cert.*4b00" \
6524 -c "mbedtls_pk_verify.*4b00" \
6525 -c "mbedtls_ecdh_make_public.*4b00" \
6526 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006527
6528requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6529run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6530 "$P_SRV psk=abc123" \
6531 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6532 psk=abc123 debug_level=1 ec_max_ops=1000" \
6533 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006534 -C "x509_verify_cert.*4b00" \
6535 -C "mbedtls_pk_verify.*4b00" \
6536 -C "mbedtls_ecdh_make_public.*4b00" \
6537 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006538
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006539# Tests of asynchronous private key support in SSL
6540
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006541requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006542run_test "SSL async private: sign, delay=0" \
6543 "$P_SRV \
6544 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006545 "$P_CLI" \
6546 0 \
6547 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006548 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006549
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006550requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006551run_test "SSL async private: sign, delay=1" \
6552 "$P_SRV \
6553 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006554 "$P_CLI" \
6555 0 \
6556 -s "Async sign callback: using key slot " \
6557 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006558 -s "Async resume (slot [0-9]): sign done, status=0"
6559
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006560requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6561run_test "SSL async private: sign, delay=2" \
6562 "$P_SRV \
6563 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6564 "$P_CLI" \
6565 0 \
6566 -s "Async sign callback: using key slot " \
6567 -U "Async sign callback: using key slot " \
6568 -s "Async resume (slot [0-9]): call 1 more times." \
6569 -s "Async resume (slot [0-9]): call 0 more times." \
6570 -s "Async resume (slot [0-9]): sign done, status=0"
6571
Gilles Peskined3268832018-04-26 06:23:59 +02006572# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
6573# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
6574requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6575requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6576run_test "SSL async private: sign, RSA, TLS 1.1" \
6577 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
6578 async_operations=s async_private_delay1=0 async_private_delay2=0" \
6579 "$P_CLI force_version=tls1_1" \
6580 0 \
6581 -s "Async sign callback: using key slot " \
6582 -s "Async resume (slot [0-9]): sign done, status=0"
6583
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006584requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Hanno Beckerb2c63832019-06-17 08:35:16 +01006585requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03006586requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006587requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskine807d74a2018-04-30 10:30:49 +02006588run_test "SSL async private: sign, SNI" \
6589 "$P_SRV debug_level=3 \
6590 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6591 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6592 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6593 "$P_CLI server_name=polarssl.example" \
6594 0 \
6595 -s "Async sign callback: using key slot " \
6596 -s "Async resume (slot [0-9]): sign done, status=0" \
6597 -s "parse ServerName extension" \
6598 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6599 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6600
6601requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006602run_test "SSL async private: decrypt, delay=0" \
6603 "$P_SRV \
6604 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6605 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6606 0 \
6607 -s "Async decrypt callback: using key slot " \
6608 -s "Async resume (slot [0-9]): decrypt done, status=0"
6609
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006610requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006611run_test "SSL async private: decrypt, delay=1" \
6612 "$P_SRV \
6613 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6614 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6615 0 \
6616 -s "Async decrypt callback: using key slot " \
6617 -s "Async resume (slot [0-9]): call 0 more times." \
6618 -s "Async resume (slot [0-9]): decrypt done, status=0"
6619
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006620requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006621run_test "SSL async private: decrypt RSA-PSK, delay=0" \
6622 "$P_SRV psk=abc123 \
6623 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6624 "$P_CLI psk=abc123 \
6625 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6626 0 \
6627 -s "Async decrypt callback: using key slot " \
6628 -s "Async resume (slot [0-9]): decrypt done, status=0"
6629
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006630requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006631run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6632 "$P_SRV psk=abc123 \
6633 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6634 "$P_CLI psk=abc123 \
6635 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6636 0 \
6637 -s "Async decrypt callback: using key slot " \
6638 -s "Async resume (slot [0-9]): call 0 more times." \
6639 -s "Async resume (slot [0-9]): decrypt done, status=0"
6640
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006641requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006642run_test "SSL async private: sign callback not present" \
6643 "$P_SRV \
6644 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6645 "$P_CLI; [ \$? -eq 1 ] &&
6646 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6647 0 \
6648 -S "Async sign callback" \
6649 -s "! mbedtls_ssl_handshake returned" \
6650 -s "The own private key or pre-shared key is not set, but needed" \
6651 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6652 -s "Successful connection"
6653
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006654requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006655run_test "SSL async private: decrypt callback not present" \
6656 "$P_SRV debug_level=1 \
6657 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6658 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6659 [ \$? -eq 1 ] && $P_CLI" \
6660 0 \
6661 -S "Async decrypt callback" \
6662 -s "! mbedtls_ssl_handshake returned" \
6663 -s "got no RSA private key" \
6664 -s "Async resume (slot [0-9]): sign done, status=0" \
6665 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006666
6667# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006668requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006669run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006670 "$P_SRV \
6671 async_operations=s async_private_delay1=1 \
6672 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6673 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006674 "$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 +01006675 0 \
6676 -s "Async sign callback: using key slot 0," \
6677 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006678 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006679
6680# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006681requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006682run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006683 "$P_SRV \
6684 async_operations=s async_private_delay2=1 \
6685 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6686 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006687 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6688 0 \
6689 -s "Async sign callback: using key slot 0," \
6690 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006691 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006692
6693# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006694requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006695run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006696 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006697 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006698 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6699 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006700 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6701 0 \
6702 -s "Async sign callback: using key slot 1," \
6703 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006704 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006705
6706# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006707requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006708run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006709 "$P_SRV \
6710 async_operations=s async_private_delay1=1 \
6711 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6712 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006713 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6714 0 \
6715 -s "Async sign callback: no key matches this certificate."
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, error in 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=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006722 "$P_CLI" \
6723 1 \
6724 -s "Async sign callback: injected error" \
6725 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006726 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006727 -s "! mbedtls_ssl_handshake returned"
6728
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006729requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006730run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006731 "$P_SRV \
6732 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6733 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006734 "$P_CLI" \
6735 1 \
6736 -s "Async sign callback: using key slot " \
6737 -S "Async resume" \
6738 -s "Async cancel"
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: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006742 "$P_SRV \
6743 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6744 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006745 "$P_CLI" \
6746 1 \
6747 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006748 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006749 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006750 -s "! mbedtls_ssl_handshake returned"
6751
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006752requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006753run_test "SSL async private: decrypt, error in start" \
6754 "$P_SRV \
6755 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6756 async_private_error=1" \
6757 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6758 1 \
6759 -s "Async decrypt callback: injected error" \
6760 -S "Async resume" \
6761 -S "Async cancel" \
6762 -s "! mbedtls_ssl_handshake returned"
6763
6764requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6765run_test "SSL async private: decrypt, cancel after start" \
6766 "$P_SRV \
6767 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6768 async_private_error=2" \
6769 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6770 1 \
6771 -s "Async decrypt callback: using key slot " \
6772 -S "Async resume" \
6773 -s "Async cancel"
6774
6775requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6776run_test "SSL async private: decrypt, error in resume" \
6777 "$P_SRV \
6778 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6779 async_private_error=3" \
6780 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6781 1 \
6782 -s "Async decrypt callback: using key slot " \
6783 -s "Async resume callback: decrypt done but injected error" \
6784 -S "Async cancel" \
6785 -s "! mbedtls_ssl_handshake returned"
6786
6787requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006788run_test "SSL async private: cancel after start 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=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006792 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6793 0 \
6794 -s "Async cancel" \
6795 -s "! mbedtls_ssl_handshake returned" \
6796 -s "Async resume" \
6797 -s "Successful connection"
6798
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: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006801 "$P_SRV \
6802 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6803 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006804 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6805 0 \
6806 -s "! mbedtls_ssl_handshake returned" \
6807 -s "Async resume" \
6808 -s "Successful connection"
6809
6810# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006811requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006812run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006813 "$P_SRV \
6814 async_operations=s async_private_delay1=1 async_private_error=-2 \
6815 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6816 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006817 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6818 [ \$? -eq 1 ] &&
6819 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6820 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006821 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006822 -S "Async resume" \
6823 -s "Async cancel" \
6824 -s "! mbedtls_ssl_handshake returned" \
6825 -s "Async sign callback: no key matches this certificate." \
6826 -s "Successful connection"
6827
6828# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006829requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006830run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006831 "$P_SRV \
6832 async_operations=s async_private_delay1=1 async_private_error=-3 \
6833 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6834 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006835 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6836 [ \$? -eq 1 ] &&
6837 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6838 0 \
6839 -s "Async resume" \
6840 -s "! mbedtls_ssl_handshake returned" \
6841 -s "Async sign callback: no key matches this certificate." \
6842 -s "Successful connection"
6843
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006844requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006845requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006846run_test "SSL async private: renegotiation: client-initiated; sign" \
6847 "$P_SRV \
6848 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006849 exchanges=2 renegotiation=1" \
6850 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6851 0 \
6852 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006853 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006854
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006855requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006856requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006857run_test "SSL async private: renegotiation: server-initiated; sign" \
6858 "$P_SRV \
6859 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006860 exchanges=2 renegotiation=1 renegotiate=1" \
6861 "$P_CLI exchanges=2 renegotiation=1" \
6862 0 \
6863 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006864 -s "Async resume (slot [0-9]): sign 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: client-initiated; decrypt" \
6869 "$P_SRV \
6870 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6871 exchanges=2 renegotiation=1" \
6872 "$P_CLI exchanges=2 renegotiation=1 renegotiate=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"
6877
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006878requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006879requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6880run_test "SSL async private: renegotiation: server-initiated; decrypt" \
6881 "$P_SRV \
6882 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6883 exchanges=2 renegotiation=1 renegotiate=1" \
6884 "$P_CLI exchanges=2 renegotiation=1 \
6885 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6886 0 \
6887 -s "Async decrypt callback: using key slot " \
6888 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006889
Ron Eldor58093c82018-06-28 13:22:05 +03006890# Tests for ECC extensions (rfc 4492)
6891
Ron Eldor643df7c2018-06-28 16:17:00 +03006892requires_config_enabled MBEDTLS_AES_C
6893requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6894requires_config_enabled MBEDTLS_SHA256_C
6895requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006896run_test "Force a non ECC ciphersuite in the client side" \
6897 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006898 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006899 0 \
6900 -C "client hello, adding supported_elliptic_curves extension" \
6901 -C "client hello, adding supported_point_formats extension" \
6902 -S "found supported elliptic curves extension" \
6903 -S "found supported point formats extension"
6904
Ron Eldor643df7c2018-06-28 16:17:00 +03006905requires_config_enabled MBEDTLS_AES_C
6906requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6907requires_config_enabled MBEDTLS_SHA256_C
6908requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006909run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006910 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006911 "$P_CLI debug_level=3" \
6912 0 \
6913 -C "found supported_point_formats extension" \
6914 -S "server hello, supported_point_formats extension"
6915
Ron Eldor643df7c2018-06-28 16:17:00 +03006916requires_config_enabled MBEDTLS_AES_C
6917requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6918requires_config_enabled MBEDTLS_SHA256_C
6919requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006920run_test "Force an ECC ciphersuite in the client side" \
6921 "$P_SRV debug_level=3" \
6922 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6923 0 \
6924 -c "client hello, adding supported_elliptic_curves extension" \
6925 -c "client hello, adding supported_point_formats extension" \
6926 -s "found supported elliptic curves extension" \
6927 -s "found supported point formats extension"
6928
Ron Eldor643df7c2018-06-28 16:17:00 +03006929requires_config_enabled MBEDTLS_AES_C
6930requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6931requires_config_enabled MBEDTLS_SHA256_C
6932requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006933run_test "Force an ECC ciphersuite in the server side" \
6934 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6935 "$P_CLI debug_level=3" \
6936 0 \
6937 -c "found supported_point_formats extension" \
6938 -s "server hello, supported_point_formats extension"
6939
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006940# Tests for DTLS HelloVerifyRequest
6941
6942run_test "DTLS cookie: enabled" \
6943 "$P_SRV dtls=1 debug_level=2" \
6944 "$P_CLI dtls=1 debug_level=2" \
6945 0 \
6946 -s "cookie verification failed" \
6947 -s "cookie verification passed" \
6948 -S "cookie verification skipped" \
6949 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006950 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006951 -S "SSL - The requested feature is not available"
6952
6953run_test "DTLS cookie: disabled" \
6954 "$P_SRV dtls=1 debug_level=2 cookies=0" \
6955 "$P_CLI dtls=1 debug_level=2" \
6956 0 \
6957 -S "cookie verification failed" \
6958 -S "cookie verification passed" \
6959 -s "cookie verification skipped" \
6960 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006961 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006962 -S "SSL - The requested feature is not available"
6963
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006964run_test "DTLS cookie: default (failing)" \
6965 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
6966 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
6967 1 \
6968 -s "cookie verification failed" \
6969 -S "cookie verification passed" \
6970 -S "cookie verification skipped" \
6971 -C "received hello verify request" \
6972 -S "hello verification requested" \
6973 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006974
6975requires_ipv6
6976run_test "DTLS cookie: enabled, IPv6" \
6977 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
6978 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
6979 0 \
6980 -s "cookie verification failed" \
6981 -s "cookie verification passed" \
6982 -S "cookie verification skipped" \
6983 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006984 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006985 -S "SSL - The requested feature is not available"
6986
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02006987run_test "DTLS cookie: enabled, nbio" \
6988 "$P_SRV dtls=1 nbio=2 debug_level=2" \
6989 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6990 0 \
6991 -s "cookie verification failed" \
6992 -s "cookie verification passed" \
6993 -S "cookie verification skipped" \
6994 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006995 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02006996 -S "SSL - The requested feature is not available"
6997
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006998# Tests for client reconnecting from the same port with DTLS
6999
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007000not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007001run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007002 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7003 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007004 0 \
7005 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007006 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007007 -S "Client initiated reconnection from same port"
7008
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007009not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007010run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007011 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7012 "$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 +02007013 0 \
7014 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007015 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007016 -s "Client initiated reconnection from same port"
7017
Paul Bakker362689d2016-05-13 10:33:25 +01007018not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
7019run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007020 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7021 "$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 +02007022 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007023 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007024 -s "Client initiated reconnection from same port"
7025
Paul Bakker362689d2016-05-13 10:33:25 +01007026only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
7027run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7028 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7029 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7030 0 \
7031 -S "The operation timed out" \
7032 -s "Client initiated reconnection from same port"
7033
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007034run_test "DTLS client reconnect from same port: no cookies" \
7035 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007036 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7037 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007038 -s "The operation timed out" \
7039 -S "Client initiated reconnection from same port"
7040
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007041# Tests for various cases of client authentication with DTLS
7042# (focused on handshake flows and message parsing)
7043
7044run_test "DTLS client auth: required" \
7045 "$P_SRV dtls=1 auth_mode=required" \
7046 "$P_CLI dtls=1" \
7047 0 \
7048 -s "Verifying peer X.509 certificate... ok"
7049
Hanno Becker4a156fc2019-06-14 17:07:06 +01007050requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007051requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007052run_test "DTLS client auth: optional, client has no cert" \
7053 "$P_SRV dtls=1 auth_mode=optional" \
7054 "$P_CLI dtls=1 crt_file=none key_file=none" \
7055 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007056 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007057
Hanno Becker4a156fc2019-06-14 17:07:06 +01007058requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007059requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007060run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007061 "$P_SRV dtls=1 auth_mode=none" \
7062 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7063 0 \
7064 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007065 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007066
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007067run_test "DTLS wrong PSK: badmac alert" \
7068 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7069 "$P_CLI dtls=1 psk=abc124" \
7070 1 \
7071 -s "SSL - Verification of the message MAC failed" \
7072 -c "SSL - A fatal alert message was received from our peer"
7073
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007074# Tests for receiving fragmented handshake messages with DTLS
7075
7076requires_gnutls
7077run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7078 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007079 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007080 0 \
7081 -C "found fragmented DTLS handshake message" \
7082 -C "error"
7083
7084requires_gnutls
7085run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7086 "$G_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007087 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007088 0 \
7089 -c "found fragmented DTLS handshake message" \
7090 -C "error"
7091
7092requires_gnutls
7093run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7094 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007095 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007096 0 \
7097 -c "found fragmented DTLS handshake message" \
7098 -C "error"
7099
7100requires_gnutls
7101run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7102 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007103 "$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 +02007104 0 \
7105 -c "found fragmented DTLS handshake message" \
7106 -C "error"
7107
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007108requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007109requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007110run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7111 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007112 "$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 +02007113 0 \
7114 -c "found fragmented DTLS handshake message" \
7115 -c "client hello, adding renegotiation extension" \
7116 -c "found renegotiation extension" \
7117 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007118 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007119 -C "error" \
7120 -s "Extra-header:"
7121
7122requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007123requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007124run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7125 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007126 "$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 +02007127 0 \
7128 -c "found fragmented DTLS handshake message" \
7129 -c "client hello, adding renegotiation extension" \
7130 -c "found renegotiation extension" \
7131 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007132 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007133 -C "error" \
7134 -s "Extra-header:"
7135
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007136run_test "DTLS reassembly: no fragmentation (openssl server)" \
7137 "$O_SRV -dtls1 -mtu 2048" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007138 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007139 0 \
7140 -C "found fragmented DTLS handshake message" \
7141 -C "error"
7142
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007143run_test "DTLS reassembly: some fragmentation (openssl server)" \
7144 "$O_SRV -dtls1 -mtu 768" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007145 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007146 0 \
7147 -c "found fragmented DTLS handshake message" \
7148 -C "error"
7149
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007150run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007151 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007152 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007153 0 \
7154 -c "found fragmented DTLS handshake message" \
7155 -C "error"
7156
7157run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7158 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007159 "$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 +02007160 0 \
7161 -c "found fragmented DTLS handshake message" \
7162 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007163
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007164# Tests for sending fragmented handshake messages with DTLS
7165#
7166# Use client auth when we need the client to send large messages,
7167# and use large cert chains on both sides too (the long chains we have all use
7168# both RSA and ECDSA, but ideally we should have long chains with either).
7169# Sizes reached (UDP payload):
7170# - 2037B for server certificate
7171# - 1542B for client certificate
7172# - 1013B for newsessionticket
7173# - all others below 512B
7174# All those tests assume MAX_CONTENT_LEN is at least 2048
7175
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007176requires_config_enabled MBEDTLS_RSA_C
7177requires_config_enabled MBEDTLS_ECDSA_C
7178requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7179run_test "DTLS fragmenting: none (for reference)" \
7180 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7181 crt_file=data_files/server7_int-ca.crt \
7182 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007183 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007184 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007185 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007186 "$P_CLI dtls=1 debug_level=2 \
7187 crt_file=data_files/server8_int-ca2.crt \
7188 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007189 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007190 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007191 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007192 0 \
7193 -S "found fragmented DTLS handshake message" \
7194 -C "found fragmented DTLS handshake message" \
7195 -C "error"
7196
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007197requires_config_enabled MBEDTLS_RSA_C
7198requires_config_enabled MBEDTLS_ECDSA_C
7199requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007200run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007201 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7202 crt_file=data_files/server7_int-ca.crt \
7203 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007204 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007205 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007206 max_frag_len=1024" \
7207 "$P_CLI dtls=1 debug_level=2 \
7208 crt_file=data_files/server8_int-ca2.crt \
7209 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007210 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007211 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007212 max_frag_len=2048" \
7213 0 \
7214 -S "found fragmented DTLS handshake message" \
7215 -c "found fragmented DTLS handshake message" \
7216 -C "error"
7217
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007218# With the MFL extension, the server has no way of forcing
7219# the client to not exceed a certain MTU; hence, the following
7220# test can't be replicated with an MTU proxy such as the one
7221# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007222requires_config_enabled MBEDTLS_RSA_C
7223requires_config_enabled MBEDTLS_ECDSA_C
7224requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007225run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007226 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7227 crt_file=data_files/server7_int-ca.crt \
7228 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007229 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007230 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007231 max_frag_len=512" \
7232 "$P_CLI dtls=1 debug_level=2 \
7233 crt_file=data_files/server8_int-ca2.crt \
7234 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007235 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007236 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007237 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007238 0 \
7239 -S "found fragmented DTLS handshake message" \
7240 -c "found fragmented DTLS handshake message" \
7241 -C "error"
7242
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007243requires_config_enabled MBEDTLS_RSA_C
7244requires_config_enabled MBEDTLS_ECDSA_C
7245requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007246run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007247 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7248 crt_file=data_files/server7_int-ca.crt \
7249 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007250 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007251 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007252 max_frag_len=2048" \
7253 "$P_CLI dtls=1 debug_level=2 \
7254 crt_file=data_files/server8_int-ca2.crt \
7255 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007256 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007257 hs_timeout=2500-60000 \
7258 max_frag_len=1024" \
7259 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007260 -S "found fragmented DTLS handshake message" \
7261 -c "found fragmented DTLS handshake message" \
7262 -C "error"
7263
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007264# While not required by the standard defining the MFL extension
7265# (according to which it only applies to records, not to datagrams),
7266# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7267# as otherwise there wouldn't be any means to communicate MTU restrictions
7268# to the peer.
7269# The next test checks that no datagrams significantly larger than the
7270# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007271requires_config_enabled MBEDTLS_RSA_C
7272requires_config_enabled MBEDTLS_ECDSA_C
7273requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7274run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007275 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007276 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7277 crt_file=data_files/server7_int-ca.crt \
7278 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007279 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007280 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007281 max_frag_len=2048" \
7282 "$P_CLI dtls=1 debug_level=2 \
7283 crt_file=data_files/server8_int-ca2.crt \
7284 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007285 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007286 hs_timeout=2500-60000 \
7287 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007288 0 \
7289 -S "found fragmented DTLS handshake message" \
7290 -c "found fragmented DTLS handshake message" \
7291 -C "error"
7292
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007293requires_config_enabled MBEDTLS_RSA_C
7294requires_config_enabled MBEDTLS_ECDSA_C
7295requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007296run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007297 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7298 crt_file=data_files/server7_int-ca.crt \
7299 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007300 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007301 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007302 max_frag_len=2048" \
7303 "$P_CLI dtls=1 debug_level=2 \
7304 crt_file=data_files/server8_int-ca2.crt \
7305 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007306 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007307 hs_timeout=2500-60000 \
7308 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007309 0 \
7310 -s "found fragmented DTLS handshake message" \
7311 -c "found fragmented DTLS handshake message" \
7312 -C "error"
7313
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007314# While not required by the standard defining the MFL extension
7315# (according to which it only applies to records, not to datagrams),
7316# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7317# as otherwise there wouldn't be any means to communicate MTU restrictions
7318# to the peer.
7319# The next test checks that no datagrams significantly larger than the
7320# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007321requires_config_enabled MBEDTLS_RSA_C
7322requires_config_enabled MBEDTLS_ECDSA_C
7323requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7324run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007325 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007326 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7327 crt_file=data_files/server7_int-ca.crt \
7328 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007329 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007330 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007331 max_frag_len=2048" \
7332 "$P_CLI dtls=1 debug_level=2 \
7333 crt_file=data_files/server8_int-ca2.crt \
7334 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007335 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007336 hs_timeout=2500-60000 \
7337 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007338 0 \
7339 -s "found fragmented DTLS handshake message" \
7340 -c "found fragmented DTLS handshake message" \
7341 -C "error"
7342
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007343requires_config_enabled MBEDTLS_RSA_C
7344requires_config_enabled MBEDTLS_ECDSA_C
7345run_test "DTLS fragmenting: none (for reference) (MTU)" \
7346 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7347 crt_file=data_files/server7_int-ca.crt \
7348 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007349 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007350 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007351 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007352 "$P_CLI dtls=1 debug_level=2 \
7353 crt_file=data_files/server8_int-ca2.crt \
7354 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007355 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007356 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007357 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007358 0 \
7359 -S "found fragmented DTLS handshake message" \
7360 -C "found fragmented DTLS handshake message" \
7361 -C "error"
7362
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007363requires_config_enabled MBEDTLS_RSA_C
7364requires_config_enabled MBEDTLS_ECDSA_C
7365run_test "DTLS fragmenting: client (MTU)" \
7366 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7367 crt_file=data_files/server7_int-ca.crt \
7368 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007369 ca_file=data_files/test-ca.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007370 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007371 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007372 "$P_CLI dtls=1 debug_level=2 \
7373 crt_file=data_files/server8_int-ca2.crt \
7374 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007375 ca_file=data_files/test-ca2.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007376 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007377 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007378 0 \
7379 -s "found fragmented DTLS handshake message" \
7380 -C "found fragmented DTLS handshake message" \
7381 -C "error"
7382
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007383requires_config_enabled MBEDTLS_RSA_C
7384requires_config_enabled MBEDTLS_ECDSA_C
7385run_test "DTLS fragmenting: server (MTU)" \
7386 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7387 crt_file=data_files/server7_int-ca.crt \
7388 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007389 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007390 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007391 mtu=512" \
7392 "$P_CLI dtls=1 debug_level=2 \
7393 crt_file=data_files/server8_int-ca2.crt \
7394 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007395 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007396 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007397 mtu=2048" \
7398 0 \
7399 -S "found fragmented DTLS handshake message" \
7400 -c "found fragmented DTLS handshake message" \
7401 -C "error"
7402
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007403requires_config_enabled MBEDTLS_RSA_C
7404requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007405run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007406 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007407 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7408 crt_file=data_files/server7_int-ca.crt \
7409 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007410 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007411 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007412 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007413 "$P_CLI dtls=1 debug_level=2 \
7414 crt_file=data_files/server8_int-ca2.crt \
7415 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007416 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007417 hs_timeout=2500-60000 \
7418 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007419 0 \
7420 -s "found fragmented DTLS handshake message" \
7421 -c "found fragmented DTLS handshake message" \
7422 -C "error"
7423
Andrzej Kurek77826052018-10-11 07:34:08 -04007424# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007425requires_config_enabled MBEDTLS_RSA_C
7426requires_config_enabled MBEDTLS_ECDSA_C
7427requires_config_enabled MBEDTLS_SHA256_C
7428requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7429requires_config_enabled MBEDTLS_AES_C
7430requires_config_enabled MBEDTLS_GCM_C
7431run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007432 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007433 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7434 crt_file=data_files/server7_int-ca.crt \
7435 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007436 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007437 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007438 mtu=512" \
7439 "$P_CLI dtls=1 debug_level=2 \
7440 crt_file=data_files/server8_int-ca2.crt \
7441 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007442 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007443 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7444 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007445 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007446 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007447 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007448 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007449 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007450
Andrzej Kurek7311c782018-10-11 06:49:41 -04007451# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007452# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007453# The ratio of max/min timeout should ideally equal 4 to accept two
7454# retransmissions, but in some cases (like both the server and client using
7455# fragmentation and auto-reduction) an extra retransmission might occur,
7456# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007457not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007458requires_config_enabled MBEDTLS_RSA_C
7459requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007460requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7461requires_config_enabled MBEDTLS_AES_C
7462requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007463run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7464 -p "$P_PXY mtu=508" \
7465 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7466 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007467 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007468 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007469 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007470 "$P_CLI dtls=1 debug_level=2 \
7471 crt_file=data_files/server8_int-ca2.crt \
7472 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007473 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007474 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7475 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007476 0 \
7477 -s "found fragmented DTLS handshake message" \
7478 -c "found fragmented DTLS handshake message" \
7479 -C "error"
7480
Andrzej Kurek77826052018-10-11 07:34:08 -04007481# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01007482only_with_valgrind
Hanno Becker108992e2018-08-29 17:04:18 +01007483requires_config_enabled MBEDTLS_RSA_C
7484requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007485requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7486requires_config_enabled MBEDTLS_AES_C
7487requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01007488run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7489 -p "$P_PXY mtu=508" \
7490 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7491 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007492 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007493 ca_file=data_files/test-ca.crt \
Hanno Becker108992e2018-08-29 17:04:18 +01007494 hs_timeout=250-10000" \
7495 "$P_CLI dtls=1 debug_level=2 \
7496 crt_file=data_files/server8_int-ca2.crt \
7497 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007498 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007499 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01007500 hs_timeout=250-10000" \
7501 0 \
7502 -s "found fragmented DTLS handshake message" \
7503 -c "found fragmented DTLS handshake message" \
7504 -C "error"
7505
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007506# 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 +02007507# OTOH the client might resend if the server is to slow to reset after sending
7508# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007509not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007510requires_config_enabled MBEDTLS_RSA_C
7511requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007512run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007513 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007514 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7515 crt_file=data_files/server7_int-ca.crt \
7516 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007517 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007518 hs_timeout=10000-60000 \
7519 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007520 "$P_CLI dtls=1 debug_level=2 \
7521 crt_file=data_files/server8_int-ca2.crt \
7522 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007523 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007524 hs_timeout=10000-60000 \
7525 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007526 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007527 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007528 -s "found fragmented DTLS handshake message" \
7529 -c "found fragmented DTLS handshake message" \
7530 -C "error"
7531
Andrzej Kurek77826052018-10-11 07:34:08 -04007532# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007533# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
7534# OTOH the client might resend if the server is to slow to reset after sending
7535# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007536not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007537requires_config_enabled MBEDTLS_RSA_C
7538requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007539requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7540requires_config_enabled MBEDTLS_AES_C
7541requires_config_enabled MBEDTLS_GCM_C
7542run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007543 -p "$P_PXY mtu=512" \
7544 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7545 crt_file=data_files/server7_int-ca.crt \
7546 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007547 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007548 hs_timeout=10000-60000 \
7549 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007550 "$P_CLI dtls=1 debug_level=2 \
7551 crt_file=data_files/server8_int-ca2.crt \
7552 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007553 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007554 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7555 hs_timeout=10000-60000 \
7556 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007557 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007558 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007559 -s "found fragmented DTLS handshake message" \
7560 -c "found fragmented DTLS handshake message" \
7561 -C "error"
7562
Andrzej Kurek7311c782018-10-11 06:49:41 -04007563not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007564requires_config_enabled MBEDTLS_RSA_C
7565requires_config_enabled MBEDTLS_ECDSA_C
7566run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007567 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007568 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7569 crt_file=data_files/server7_int-ca.crt \
7570 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007571 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007572 hs_timeout=10000-60000 \
7573 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007574 "$P_CLI dtls=1 debug_level=2 \
7575 crt_file=data_files/server8_int-ca2.crt \
7576 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007577 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007578 hs_timeout=10000-60000 \
7579 mtu=1024 nbio=2" \
7580 0 \
7581 -S "autoreduction" \
7582 -s "found fragmented DTLS handshake message" \
7583 -c "found fragmented DTLS handshake message" \
7584 -C "error"
7585
Andrzej Kurek77826052018-10-11 07:34:08 -04007586# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007587not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007588requires_config_enabled MBEDTLS_RSA_C
7589requires_config_enabled MBEDTLS_ECDSA_C
7590requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7591requires_config_enabled MBEDTLS_AES_C
7592requires_config_enabled MBEDTLS_GCM_C
7593run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7594 -p "$P_PXY mtu=512" \
7595 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7596 crt_file=data_files/server7_int-ca.crt \
7597 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007598 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007599 hs_timeout=10000-60000 \
7600 mtu=512 nbio=2" \
7601 "$P_CLI dtls=1 debug_level=2 \
7602 crt_file=data_files/server8_int-ca2.crt \
7603 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007604 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007605 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7606 hs_timeout=10000-60000 \
7607 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007608 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007609 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007610 -s "found fragmented DTLS handshake message" \
7611 -c "found fragmented DTLS handshake message" \
7612 -C "error"
7613
Andrzej Kurek77826052018-10-11 07:34:08 -04007614# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007615# This ensures things still work after session_reset().
7616# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007617# Since we don't support reading fragmented ClientHello yet,
7618# up the MTU to 1450 (larger than ClientHello with session ticket,
7619# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007620# An autoreduction on the client-side might happen if the server is
7621# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007622# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007623# resumed listening, which would result in a spurious autoreduction.
7624not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007625requires_config_enabled MBEDTLS_RSA_C
7626requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007627requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7628requires_config_enabled MBEDTLS_AES_C
7629requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007630run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7631 -p "$P_PXY mtu=1450" \
7632 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7633 crt_file=data_files/server7_int-ca.crt \
7634 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007635 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007636 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007637 mtu=1450" \
7638 "$P_CLI dtls=1 debug_level=2 \
7639 crt_file=data_files/server8_int-ca2.crt \
7640 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007641 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007642 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007643 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007644 mtu=1450 reconnect=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007645 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007646 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007647 -s "found fragmented DTLS handshake message" \
7648 -c "found fragmented DTLS handshake message" \
7649 -C "error"
7650
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007651# An autoreduction on the client-side might happen if the server is
7652# slow to reset, therefore omitting '-C "autoreduction"' below.
7653not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007654requires_config_enabled MBEDTLS_RSA_C
7655requires_config_enabled MBEDTLS_ECDSA_C
7656requires_config_enabled MBEDTLS_SHA256_C
7657requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7658requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7659requires_config_enabled MBEDTLS_CHACHAPOLY_C
7660run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7661 -p "$P_PXY mtu=512" \
7662 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7663 crt_file=data_files/server7_int-ca.crt \
7664 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007665 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007666 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007667 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007668 mtu=512" \
7669 "$P_CLI dtls=1 debug_level=2 \
7670 crt_file=data_files/server8_int-ca2.crt \
7671 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007672 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007673 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007674 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007675 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007676 mtu=512" \
7677 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007678 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007679 -s "found fragmented DTLS handshake message" \
7680 -c "found fragmented DTLS handshake message" \
7681 -C "error"
7682
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007683# An autoreduction on the client-side might happen if the server is
7684# slow to reset, therefore omitting '-C "autoreduction"' below.
7685not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007686requires_config_enabled MBEDTLS_RSA_C
7687requires_config_enabled MBEDTLS_ECDSA_C
7688requires_config_enabled MBEDTLS_SHA256_C
7689requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7690requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7691requires_config_enabled MBEDTLS_AES_C
7692requires_config_enabled MBEDTLS_GCM_C
7693run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7694 -p "$P_PXY mtu=512" \
7695 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7696 crt_file=data_files/server7_int-ca.crt \
7697 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007698 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007699 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007700 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007701 mtu=512" \
7702 "$P_CLI dtls=1 debug_level=2 \
7703 crt_file=data_files/server8_int-ca2.crt \
7704 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007705 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007706 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007707 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007708 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007709 mtu=512" \
7710 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007711 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007712 -s "found fragmented DTLS handshake message" \
7713 -c "found fragmented DTLS handshake message" \
7714 -C "error"
7715
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007716# An autoreduction on the client-side might happen if the server is
7717# slow to reset, therefore omitting '-C "autoreduction"' below.
7718not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007719requires_config_enabled MBEDTLS_RSA_C
7720requires_config_enabled MBEDTLS_ECDSA_C
7721requires_config_enabled MBEDTLS_SHA256_C
7722requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7723requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7724requires_config_enabled MBEDTLS_AES_C
7725requires_config_enabled MBEDTLS_CCM_C
7726run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007727 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007728 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7729 crt_file=data_files/server7_int-ca.crt \
7730 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007731 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007732 exchanges=2 renegotiation=1 \
7733 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007734 hs_timeout=10000-60000 \
7735 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007736 "$P_CLI dtls=1 debug_level=2 \
7737 crt_file=data_files/server8_int-ca2.crt \
7738 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007739 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007740 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007741 hs_timeout=10000-60000 \
7742 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007743 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007744 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007745 -s "found fragmented DTLS handshake message" \
7746 -c "found fragmented DTLS handshake message" \
7747 -C "error"
7748
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007749# An autoreduction on the client-side might happen if the server is
7750# slow to reset, therefore omitting '-C "autoreduction"' below.
7751not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007752requires_config_enabled MBEDTLS_RSA_C
7753requires_config_enabled MBEDTLS_ECDSA_C
7754requires_config_enabled MBEDTLS_SHA256_C
7755requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7756requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7757requires_config_enabled MBEDTLS_AES_C
7758requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7759requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7760run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007761 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007762 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7763 crt_file=data_files/server7_int-ca.crt \
7764 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007765 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007766 exchanges=2 renegotiation=1 \
7767 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007768 hs_timeout=10000-60000 \
7769 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007770 "$P_CLI dtls=1 debug_level=2 \
7771 crt_file=data_files/server8_int-ca2.crt \
7772 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007773 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007774 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007775 hs_timeout=10000-60000 \
7776 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007777 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007778 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007779 -s "found fragmented DTLS handshake message" \
7780 -c "found fragmented DTLS handshake message" \
7781 -C "error"
7782
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007783# An autoreduction on the client-side might happen if the server is
7784# slow to reset, therefore omitting '-C "autoreduction"' below.
7785not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007786requires_config_enabled MBEDTLS_RSA_C
7787requires_config_enabled MBEDTLS_ECDSA_C
7788requires_config_enabled MBEDTLS_SHA256_C
7789requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7790requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7791requires_config_enabled MBEDTLS_AES_C
7792requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7793run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007794 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007795 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7796 crt_file=data_files/server7_int-ca.crt \
7797 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007798 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007799 exchanges=2 renegotiation=1 \
7800 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007801 hs_timeout=10000-60000 \
7802 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007803 "$P_CLI dtls=1 debug_level=2 \
7804 crt_file=data_files/server8_int-ca2.crt \
7805 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007806 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007807 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007808 hs_timeout=10000-60000 \
7809 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007810 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007811 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007812 -s "found fragmented DTLS handshake message" \
7813 -c "found fragmented DTLS handshake message" \
7814 -C "error"
7815
Andrzej Kurek77826052018-10-11 07:34:08 -04007816# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007817requires_config_enabled MBEDTLS_RSA_C
7818requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007819requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7820requires_config_enabled MBEDTLS_AES_C
7821requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007822client_needs_more_time 2
7823run_test "DTLS fragmenting: proxy MTU + 3d" \
7824 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007825 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007826 crt_file=data_files/server7_int-ca.crt \
7827 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007828 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007829 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007830 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007831 crt_file=data_files/server8_int-ca2.crt \
7832 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007833 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007834 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007835 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007836 0 \
7837 -s "found fragmented DTLS handshake message" \
7838 -c "found fragmented DTLS handshake message" \
7839 -C "error"
7840
Andrzej Kurek77826052018-10-11 07:34:08 -04007841# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007842requires_config_enabled MBEDTLS_RSA_C
7843requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007844requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7845requires_config_enabled MBEDTLS_AES_C
7846requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007847client_needs_more_time 2
7848run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7849 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7850 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7851 crt_file=data_files/server7_int-ca.crt \
7852 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007853 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007854 hs_timeout=250-10000 mtu=512 nbio=2" \
7855 "$P_CLI dtls=1 debug_level=2 \
7856 crt_file=data_files/server8_int-ca2.crt \
7857 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007858 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007859 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007860 hs_timeout=250-10000 mtu=512 nbio=2" \
7861 0 \
7862 -s "found fragmented DTLS handshake message" \
7863 -c "found fragmented DTLS handshake message" \
7864 -C "error"
7865
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007866# interop tests for DTLS fragmentating with reliable connection
7867#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007868# here and below we just want to test that the we fragment in a way that
7869# pleases other implementations, so we don't need the peer to fragment
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007870requires_config_enabled MBEDTLS_RSA_C
7871requires_config_enabled MBEDTLS_ECDSA_C
7872requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007873requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007874run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
7875 "$G_SRV -u" \
7876 "$P_CLI dtls=1 debug_level=2 \
7877 crt_file=data_files/server8_int-ca2.crt \
7878 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007879 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007880 mtu=512 force_version=dtls1_2" \
7881 0 \
7882 -c "fragmenting handshake message" \
7883 -C "error"
7884
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007885requires_config_enabled MBEDTLS_RSA_C
7886requires_config_enabled MBEDTLS_ECDSA_C
7887requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007888requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007889run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
7890 "$G_SRV -u" \
7891 "$P_CLI dtls=1 debug_level=2 \
7892 crt_file=data_files/server8_int-ca2.crt \
7893 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007894 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007895 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007896 0 \
7897 -c "fragmenting handshake message" \
7898 -C "error"
7899
Hanno Beckerb9a00862018-08-28 10:20:22 +01007900# We use --insecure for the GnuTLS client because it expects
7901# the hostname / IP it connects to to be the name used in the
7902# certificate obtained from the server. Here, however, it
7903# connects to 127.0.0.1 while our test certificates use 'localhost'
7904# as the server name in the certificate. This will make the
7905# certifiate validation fail, but passing --insecure makes
7906# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007907requires_config_enabled MBEDTLS_RSA_C
7908requires_config_enabled MBEDTLS_ECDSA_C
7909requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007910requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007911requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007912run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007913 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007914 crt_file=data_files/server7_int-ca.crt \
7915 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007916 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007917 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007918 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007919 0 \
7920 -s "fragmenting handshake message"
7921
Hanno Beckerb9a00862018-08-28 10:20:22 +01007922# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007923requires_config_enabled MBEDTLS_RSA_C
7924requires_config_enabled MBEDTLS_ECDSA_C
7925requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007926requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007927requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007928run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007929 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007930 crt_file=data_files/server7_int-ca.crt \
7931 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007932 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007933 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007934 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007935 0 \
7936 -s "fragmenting handshake message"
7937
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007938requires_config_enabled MBEDTLS_RSA_C
7939requires_config_enabled MBEDTLS_ECDSA_C
7940requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7941run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
7942 "$O_SRV -dtls1_2 -verify 10" \
7943 "$P_CLI dtls=1 debug_level=2 \
7944 crt_file=data_files/server8_int-ca2.crt \
7945 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007946 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007947 mtu=512 force_version=dtls1_2" \
7948 0 \
7949 -c "fragmenting handshake message" \
7950 -C "error"
7951
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007952requires_config_enabled MBEDTLS_RSA_C
7953requires_config_enabled MBEDTLS_ECDSA_C
7954requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7955run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
7956 "$O_SRV -dtls1 -verify 10" \
7957 "$P_CLI dtls=1 debug_level=2 \
7958 crt_file=data_files/server8_int-ca2.crt \
7959 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007960 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007961 mtu=512 force_version=dtls1" \
7962 0 \
7963 -c "fragmenting handshake message" \
7964 -C "error"
7965
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007966requires_config_enabled MBEDTLS_RSA_C
7967requires_config_enabled MBEDTLS_ECDSA_C
7968requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7969run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
7970 "$P_SRV dtls=1 debug_level=2 \
7971 crt_file=data_files/server7_int-ca.crt \
7972 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007973 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007974 mtu=512 force_version=dtls1_2" \
7975 "$O_CLI -dtls1_2" \
7976 0 \
7977 -s "fragmenting handshake message"
7978
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007979requires_config_enabled MBEDTLS_RSA_C
7980requires_config_enabled MBEDTLS_ECDSA_C
7981requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7982run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
7983 "$P_SRV dtls=1 debug_level=2 \
7984 crt_file=data_files/server7_int-ca.crt \
7985 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007986 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007987 mtu=512 force_version=dtls1" \
7988 "$O_CLI -dtls1" \
7989 0 \
7990 -s "fragmenting handshake message"
7991
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007992# interop tests for DTLS fragmentating with unreliable connection
7993#
7994# again we just want to test that the we fragment in a way that
7995# pleases other implementations, so we don't need the peer to fragment
7996requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007997requires_config_enabled MBEDTLS_RSA_C
7998requires_config_enabled MBEDTLS_ECDSA_C
7999requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008000client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008001run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8002 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8003 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008004 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008005 crt_file=data_files/server8_int-ca2.crt \
8006 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008007 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008008 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008009 0 \
8010 -c "fragmenting handshake message" \
8011 -C "error"
8012
8013requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008014requires_config_enabled MBEDTLS_RSA_C
8015requires_config_enabled MBEDTLS_ECDSA_C
8016requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008017client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008018run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8019 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8020 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008021 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008022 crt_file=data_files/server8_int-ca2.crt \
8023 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008024 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008025 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008026 0 \
8027 -c "fragmenting handshake message" \
8028 -C "error"
8029
k-stachowiakabb843e2019-02-18 16:14:03 +01008030requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008031requires_config_enabled MBEDTLS_RSA_C
8032requires_config_enabled MBEDTLS_ECDSA_C
8033requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8034client_needs_more_time 4
8035run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8036 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8037 "$P_SRV dtls=1 debug_level=2 \
8038 crt_file=data_files/server7_int-ca.crt \
8039 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008040 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008041 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008042 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008043 0 \
8044 -s "fragmenting handshake message"
8045
k-stachowiakabb843e2019-02-18 16:14:03 +01008046requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008047requires_config_enabled MBEDTLS_RSA_C
8048requires_config_enabled MBEDTLS_ECDSA_C
8049requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8050client_needs_more_time 4
8051run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8052 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8053 "$P_SRV dtls=1 debug_level=2 \
8054 crt_file=data_files/server7_int-ca.crt \
8055 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008056 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008057 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008058 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008059 0 \
8060 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008061
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008062## Interop test with OpenSSL might trigger a bug in recent versions (including
8063## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008064## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008065## They should be re-enabled once a fixed version of OpenSSL is available
8066## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008067skip_next_test
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008068requires_config_enabled MBEDTLS_RSA_C
8069requires_config_enabled MBEDTLS_ECDSA_C
8070requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8071client_needs_more_time 4
8072run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8073 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8074 "$O_SRV -dtls1_2 -verify 10" \
8075 "$P_CLI dtls=1 debug_level=2 \
8076 crt_file=data_files/server8_int-ca2.crt \
8077 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008078 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008079 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8080 0 \
8081 -c "fragmenting handshake message" \
8082 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008083
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008084skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008085requires_config_enabled MBEDTLS_RSA_C
8086requires_config_enabled MBEDTLS_ECDSA_C
8087requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008088client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008089run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8090 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008091 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008092 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008093 crt_file=data_files/server8_int-ca2.crt \
8094 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008095 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008096 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008097 0 \
8098 -c "fragmenting handshake message" \
8099 -C "error"
8100
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008101skip_next_test
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008102requires_config_enabled MBEDTLS_RSA_C
8103requires_config_enabled MBEDTLS_ECDSA_C
8104requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8105client_needs_more_time 4
8106run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8107 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8108 "$P_SRV dtls=1 debug_level=2 \
8109 crt_file=data_files/server7_int-ca.crt \
8110 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008111 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008112 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8113 "$O_CLI -dtls1_2" \
8114 0 \
8115 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008116
8117# -nbio is added to prevent s_client from blocking in case of duplicated
8118# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008119skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008120requires_config_enabled MBEDTLS_RSA_C
8121requires_config_enabled MBEDTLS_ECDSA_C
8122requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008123client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008124run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8125 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008126 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008127 crt_file=data_files/server7_int-ca.crt \
8128 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008129 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008130 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008131 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008132 0 \
8133 -s "fragmenting handshake message"
8134
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008135# Tests for specific things with "unreliable" UDP connection
8136
8137not_with_valgrind # spurious resend due to timeout
8138run_test "DTLS proxy: reference" \
8139 -p "$P_PXY" \
8140 "$P_SRV dtls=1 debug_level=2" \
8141 "$P_CLI dtls=1 debug_level=2" \
8142 0 \
8143 -C "replayed record" \
8144 -S "replayed record" \
Hanno Beckere03eb7b2019-07-19 15:43:09 +01008145 -C "Buffer record from epoch" \
8146 -S "Buffer record from epoch" \
8147 -C "ssl_buffer_message" \
8148 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008149 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008150 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008151 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008152 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008153 -c "HTTP/1.0 200 OK"
8154
8155not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008156run_test "DTLS proxy: duplicate every packet" \
8157 -p "$P_PXY duplicate=1" \
Hanno Becker7f376f42019-06-12 16:20:48 +01008158 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008159 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008160 0 \
8161 -c "replayed record" \
8162 -s "replayed record" \
8163 -c "record from another epoch" \
8164 -s "record from another epoch" \
8165 -S "resend" \
8166 -s "Extra-header:" \
8167 -c "HTTP/1.0 200 OK"
8168
8169run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8170 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008171 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8172 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008173 0 \
8174 -c "replayed record" \
8175 -S "replayed record" \
8176 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008177 -s "record from another epoch" \
8178 -c "resend" \
8179 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008180 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008181 -c "HTTP/1.0 200 OK"
8182
8183run_test "DTLS proxy: multiple records in same datagram" \
8184 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008185 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8186 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008187 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008188 -c "next record in same datagram" \
8189 -s "next record in same datagram"
8190
8191run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8192 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008193 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8194 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008195 0 \
8196 -c "next record in same datagram" \
8197 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008198
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008199run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
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" \
8202 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008203 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008204 -c "discarding invalid record (mac)" \
8205 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008206 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008207 -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 1" \
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=1" \
8214 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008215 1 \
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" \
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" \
8226 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008227 0 \
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"
8234
8235run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8236 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008237 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8238 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008239 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008240 -c "discarding invalid record (mac)" \
8241 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008242 -s "Extra-header:" \
8243 -c "HTTP/1.0 200 OK" \
8244 -s "too many records with bad MAC" \
8245 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008246
8247run_test "DTLS proxy: delay ChangeCipherSpec" \
8248 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008249 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8250 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008251 0 \
8252 -c "record from another epoch" \
8253 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008254 -s "Extra-header:" \
8255 -c "HTTP/1.0 200 OK"
8256
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008257# Tests for reordering support with DTLS
8258
Hanno Becker56cdfd12018-08-17 13:42:15 +01008259run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8260 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008261 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8262 hs_timeout=2500-60000" \
8263 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8264 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008265 0 \
8266 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008267 -c "Next handshake message has been buffered - load"\
8268 -S "Buffering HS message" \
8269 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008270 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008271 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008272 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008273 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008274
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008275run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8276 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008277 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8278 hs_timeout=2500-60000" \
8279 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8280 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008281 0 \
8282 -c "Buffering HS message" \
8283 -c "found fragmented DTLS handshake message"\
8284 -c "Next handshake message 1 not or only partially bufffered" \
8285 -c "Next handshake message has been buffered - load"\
8286 -S "Buffering HS message" \
8287 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008288 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008289 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008290 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008291 -S "Remember CCS message"
8292
Hanno Beckera1adcca2018-08-24 14:41:07 +01008293# The client buffers the ServerKeyExchange before receiving the fragmented
8294# Certificate message; at the time of writing, together these are aroudn 1200b
8295# in size, so that the bound below ensures that the certificate can be reassembled
8296# while keeping the ServerKeyExchange.
8297requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8298run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008299 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008300 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8301 hs_timeout=2500-60000" \
8302 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8303 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008304 0 \
8305 -c "Buffering HS message" \
8306 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008307 -C "attempt to make space by freeing buffered messages" \
8308 -S "Buffering HS message" \
8309 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008310 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008311 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008312 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008313 -S "Remember CCS message"
8314
8315# The size constraints ensure that the delayed certificate message can't
8316# be reassembled while keeping the ServerKeyExchange message, but it can
8317# when dropping it first.
8318requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8319requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8320run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8321 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008322 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8323 hs_timeout=2500-60000" \
8324 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8325 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008326 0 \
8327 -c "Buffering HS message" \
8328 -c "attempt to make space by freeing buffered future messages" \
8329 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008330 -S "Buffering HS message" \
8331 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008332 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008333 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008334 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008335 -S "Remember CCS message"
8336
Hanno Becker56cdfd12018-08-17 13:42:15 +01008337run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8338 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008339 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8340 hs_timeout=2500-60000" \
8341 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8342 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008343 0 \
8344 -C "Buffering HS message" \
8345 -C "Next handshake message has been buffered - load"\
8346 -s "Buffering HS message" \
8347 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008348 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008349 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008350 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008351 -S "Remember CCS message"
8352
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02008353# This needs session tickets; otherwise CCS is the first message in its flight
8354requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008355run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8356 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008357 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8358 hs_timeout=2500-60000" \
8359 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8360 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008361 0 \
8362 -C "Buffering HS message" \
8363 -C "Next handshake message has been buffered - load"\
8364 -S "Buffering HS message" \
8365 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008366 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008367 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008368 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008369 -S "Remember CCS message"
8370
8371run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8372 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008373 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8374 hs_timeout=2500-60000" \
8375 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8376 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008377 0 \
8378 -C "Buffering HS message" \
8379 -C "Next handshake message has been buffered - load"\
8380 -S "Buffering HS message" \
8381 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008382 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008383 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008384 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008385 -s "Remember CCS message"
8386
Hanno Beckera1adcca2018-08-24 14:41:07 +01008387run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008388 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008389 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8390 hs_timeout=2500-60000" \
8391 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8392 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008393 0 \
8394 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008395 -s "Found buffered record from current epoch - load" \
8396 -c "Buffer record from epoch 1" \
8397 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008398
Hanno Beckera1adcca2018-08-24 14:41:07 +01008399# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8400# from the server are delayed, so that the encrypted Finished message
8401# is received and buffered. When the fragmented NewSessionTicket comes
8402# in afterwards, the encrypted Finished message must be freed in order
8403# to make space for the NewSessionTicket to be reassembled.
8404# This works only in very particular circumstances:
8405# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8406# of the NewSessionTicket, but small enough to also allow buffering of
8407# the encrypted Finished message.
8408# - The MTU setting on the server must be so small that the NewSessionTicket
8409# needs to be fragmented.
8410# - All messages sent by the server must be small enough to be either sent
8411# without fragmentation or be reassembled within the bounds of
8412# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8413# handshake, omitting CRTs.
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008414requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8415requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008416run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8417 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008418 "$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 +01008419 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8420 0 \
8421 -s "Buffer record from epoch 1" \
8422 -s "Found buffered record from current epoch - load" \
8423 -c "Buffer record from epoch 1" \
8424 -C "Found buffered record from current epoch - load" \
8425 -c "Enough space available after freeing future epoch record"
8426
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008427# Tests for "randomly unreliable connection": try a variety of flows and peers
8428
8429client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008430run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8431 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008432 "$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 +02008433 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008434 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008435 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8436 0 \
8437 -s "Extra-header:" \
8438 -c "HTTP/1.0 200 OK"
8439
Janos Follath74537a62016-09-02 13:45:28 +01008440client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008441run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8442 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008443 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8444 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008445 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8446 0 \
8447 -s "Extra-header:" \
8448 -c "HTTP/1.0 200 OK"
8449
Janos Follath74537a62016-09-02 13:45:28 +01008450client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008451run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8452 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008453 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8454 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008455 0 \
8456 -s "Extra-header:" \
8457 -c "HTTP/1.0 200 OK"
8458
Janos Follath74537a62016-09-02 13:45:28 +01008459client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008460run_test "DTLS proxy: 3d, FS, client auth" \
8461 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008462 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8463 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008464 0 \
8465 -s "Extra-header:" \
8466 -c "HTTP/1.0 200 OK"
8467
Janos Follath74537a62016-09-02 13:45:28 +01008468client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008469run_test "DTLS proxy: 3d, FS, ticket" \
8470 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008471 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8472 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008473 0 \
8474 -s "Extra-header:" \
8475 -c "HTTP/1.0 200 OK"
8476
Janos Follath74537a62016-09-02 13:45:28 +01008477client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008478run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8479 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008480 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8481 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008482 0 \
8483 -s "Extra-header:" \
8484 -c "HTTP/1.0 200 OK"
8485
Janos Follath74537a62016-09-02 13:45:28 +01008486client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008487run_test "DTLS proxy: 3d, max handshake, nbio" \
8488 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008489 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008490 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008491 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008492 0 \
8493 -s "Extra-header:" \
8494 -c "HTTP/1.0 200 OK"
8495
Janos Follath74537a62016-09-02 13:45:28 +01008496client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008497requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008498requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008499requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008500run_test "DTLS proxy: 3d, min handshake, resumption" \
8501 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008502 "$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 +02008503 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008504 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008505 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8506 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8507 0 \
8508 -s "a session has been resumed" \
8509 -c "a session has been resumed" \
8510 -s "Extra-header:" \
8511 -c "HTTP/1.0 200 OK"
8512
Janos Follath74537a62016-09-02 13:45:28 +01008513client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008514requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008515requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008516requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008517run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8518 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008519 "$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 +02008520 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008521 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008522 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8523 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8524 0 \
8525 -s "a session has been resumed" \
8526 -c "a session has been resumed" \
8527 -s "Extra-header:" \
8528 -c "HTTP/1.0 200 OK"
8529
Janos Follath74537a62016-09-02 13:45:28 +01008530client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008531requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008532run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008533 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008534 "$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 +02008535 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008536 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008537 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008538 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8539 0 \
8540 -c "=> renegotiate" \
8541 -s "=> renegotiate" \
8542 -s "Extra-header:" \
8543 -c "HTTP/1.0 200 OK"
8544
Janos Follath74537a62016-09-02 13:45:28 +01008545client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008546requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008547run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8548 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008549 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008550 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008551 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008552 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008553 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8554 0 \
8555 -c "=> renegotiate" \
8556 -s "=> renegotiate" \
8557 -s "Extra-header:" \
8558 -c "HTTP/1.0 200 OK"
8559
Janos Follath74537a62016-09-02 13:45:28 +01008560client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008561requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008562run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008563 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008564 "$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 +02008565 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008566 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008567 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008568 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008569 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8570 0 \
8571 -c "=> renegotiate" \
8572 -s "=> renegotiate" \
8573 -s "Extra-header:" \
8574 -c "HTTP/1.0 200 OK"
8575
Janos Follath74537a62016-09-02 13:45:28 +01008576client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008577requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008578run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008579 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008580 "$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 +02008581 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008582 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008583 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008584 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008585 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8586 0 \
8587 -c "=> renegotiate" \
8588 -s "=> renegotiate" \
8589 -s "Extra-header:" \
8590 -c "HTTP/1.0 200 OK"
8591
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008592## Interop tests with OpenSSL might trigger a bug in recent versions (including
8593## all versions installed on the CI machines), reported here:
8594## Bug report: https://github.com/openssl/openssl/issues/6902
8595## They should be re-enabled once a fixed version of OpenSSL is available
8596## (this should happen in some 1.1.1_ release according to the ticket).
8597skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008598client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008599not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008600run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008601 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8602 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008603 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008604 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008605 -c "HTTP/1.0 200 OK"
8606
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008607skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008608client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008609not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008610run_test "DTLS proxy: 3d, openssl server, fragmentation" \
8611 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8612 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008613 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008614 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008615 -c "HTTP/1.0 200 OK"
8616
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008617skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008618client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008619not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008620run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8621 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8622 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008623 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008624 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008625 -c "HTTP/1.0 200 OK"
8626
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008627requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008628client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008629not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008630run_test "DTLS proxy: 3d, gnutls server" \
8631 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8632 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008633 "$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 +02008634 0 \
8635 -s "Extra-header:" \
8636 -c "Extra-header:"
8637
k-stachowiakabb843e2019-02-18 16:14:03 +01008638requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008639client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008640not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008641run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
8642 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008643 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008644 "$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 +02008645 0 \
8646 -s "Extra-header:" \
8647 -c "Extra-header:"
8648
k-stachowiakabb843e2019-02-18 16:14:03 +01008649requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008650client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008651not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008652run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8653 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008654 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008655 "$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 +02008656 0 \
8657 -s "Extra-header:" \
8658 -c "Extra-header:"
8659
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008660# Final report
8661
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008662echo "------------------------------------------------------------------------"
8663
8664if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008665 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008666else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008667 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008668fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008669PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008670echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008671
8672exit $FAILS