blob: 28f789910d85d1c44ea63368575cfec40dc8936a [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Angus Grattonc4dd0732018-04-11 16:28:39 +100024if cd $( dirname $0 ); then :; else
25 echo "cd $( dirname $0 ) failed" >&2
26 exit 1
27fi
28
Antonin Décimo36e89b52019-01-23 15:24:37 +010029# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010030: ${P_SRV:=../programs/ssl/ssl_server2}
31: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020032: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010033: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020034: ${GNUTLS_CLI:=gnutls-cli}
35: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020036: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010037
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020038O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010039O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020040G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010041G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020042TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010043
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020044# alternative versions of OpenSSL and GnuTLS (no default path)
45
46if [ -n "${OPENSSL_LEGACY:-}" ]; then
47 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
48 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
49else
50 O_LEGACY_SRV=false
51 O_LEGACY_CLI=false
52fi
53
Hanno Becker58e9dc32018-08-17 15:53:21 +010054if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020055 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
56else
57 G_NEXT_SRV=false
58fi
59
Hanno Becker58e9dc32018-08-17 15:53:21 +010060if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020061 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
62else
63 G_NEXT_CLI=false
64fi
65
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010066TESTS=0
67FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020068SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010069
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000070CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020071
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010073FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020074EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010075
Paul Bakkere20310a2016-05-10 11:18:17 +010076SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010077RUN_TEST_NUMBER=''
78
Paul Bakkeracaac852016-05-10 11:47:13 +010079PRESERVE_LOGS=0
80
Gilles Peskinef93c7d32017-04-14 17:55:28 +020081# Pick a "unique" server port in the range 10000-19999, and a proxy
82# port which is this plus 10000. Each port number may be independently
83# overridden by a command line option.
84SRV_PORT=$(($$ % 10000 + 10000))
85PXY_PORT=$((SRV_PORT + 10000))
86
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010087print_usage() {
88 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010089 printf " -h|--help\tPrint this help.\n"
90 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020091 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
92 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010093 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010094 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010095 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020096 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
97 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010098 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010099}
100
101get_options() {
102 while [ $# -gt 0 ]; do
103 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100104 -f|--filter)
105 shift; FILTER=$1
106 ;;
107 -e|--exclude)
108 shift; EXCLUDE=$1
109 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 -m|--memcheck)
111 MEMCHECK=1
112 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100113 -n|--number)
114 shift; RUN_TEST_NUMBER=$1
115 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100116 -s|--show-numbers)
117 SHOW_TEST_NUMBER=1
118 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100119 -p|--preserve-logs)
120 PRESERVE_LOGS=1
121 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200122 --port)
123 shift; SRV_PORT=$1
124 ;;
125 --proxy-port)
126 shift; PXY_PORT=$1
127 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100128 --seed)
129 shift; SEED="$1"
130 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100131 -h|--help)
132 print_usage
133 exit 0
134 ;;
135 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200136 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100137 print_usage
138 exit 1
139 ;;
140 esac
141 shift
142 done
143}
144
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100145# Skip next test; use this macro to skip tests which are legitimate
146# in theory and expected to be re-introduced at some point, but
147# aren't expected to succeed at the moment due to problems outside
148# our control (such as bugs in other TLS implementations).
149skip_next_test() {
150 SKIP_NEXT="YES"
151}
152
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100153# skip next test if the flag is not enabled in config.h
154requires_config_enabled() {
155 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
156 SKIP_NEXT="YES"
157 fi
158}
159
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200160# skip next test if the flag is enabled in config.h
161requires_config_disabled() {
162 if grep "^#define $1" $CONFIG_H > /dev/null; then
163 SKIP_NEXT="YES"
164 fi
165}
166
Hanno Becker7c48dd12018-08-28 16:09:22 +0100167get_config_value_or_default() {
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100168 # This function uses the query_config command line option to query the
169 # required Mbed TLS compile time configuration from the ssl_server2
170 # program. The command will always return a success value if the
171 # configuration is defined and the value will be printed to stdout.
172 #
173 # Note that if the configuration is not defined or is defined to nothing,
174 # the output of this function will be an empty string.
175 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100176}
177
178requires_config_value_at_least() {
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100179 VAL="$( get_config_value_or_default "$1" )"
180 if [ -z "$VAL" ]; then
181 # Should never happen
182 echo "Mbed TLS configuration $1 is not defined"
183 exit 1
184 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100185 SKIP_NEXT="YES"
186 fi
187}
188
189requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100190 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100191 if [ -z "$VAL" ]; then
192 # Should never happen
193 echo "Mbed TLS configuration $1 is not defined"
194 exit 1
195 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100196 SKIP_NEXT="YES"
197 fi
198}
199
Hanno Becker9d76d562018-11-16 17:27:29 +0000200requires_ciphersuite_enabled() {
Hanno Beckera0dc9cf2018-11-20 11:31:17 +0000201 if [ -z "$($P_CLI --help | grep $1)" ]; then
Hanno Becker9d76d562018-11-16 17:27:29 +0000202 SKIP_NEXT="YES"
203 fi
204}
205
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200206# skip next test if OpenSSL doesn't support FALLBACK_SCSV
207requires_openssl_with_fallback_scsv() {
208 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
209 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
210 then
211 OPENSSL_HAS_FBSCSV="YES"
212 else
213 OPENSSL_HAS_FBSCSV="NO"
214 fi
215 fi
216 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
217 SKIP_NEXT="YES"
218 fi
219}
220
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200221# skip next test if GnuTLS isn't available
222requires_gnutls() {
223 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200224 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200225 GNUTLS_AVAILABLE="YES"
226 else
227 GNUTLS_AVAILABLE="NO"
228 fi
229 fi
230 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
231 SKIP_NEXT="YES"
232 fi
233}
234
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200235# skip next test if GnuTLS-next isn't available
236requires_gnutls_next() {
237 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
238 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
239 GNUTLS_NEXT_AVAILABLE="YES"
240 else
241 GNUTLS_NEXT_AVAILABLE="NO"
242 fi
243 fi
244 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
245 SKIP_NEXT="YES"
246 fi
247}
248
249# skip next test if OpenSSL-legacy isn't available
250requires_openssl_legacy() {
251 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
252 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
253 OPENSSL_LEGACY_AVAILABLE="YES"
254 else
255 OPENSSL_LEGACY_AVAILABLE="NO"
256 fi
257 fi
258 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
259 SKIP_NEXT="YES"
260 fi
261}
262
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200263# skip next test if IPv6 isn't available on this host
264requires_ipv6() {
265 if [ -z "${HAS_IPV6:-}" ]; then
266 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
267 SRV_PID=$!
268 sleep 1
269 kill $SRV_PID >/dev/null 2>&1
270 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
271 HAS_IPV6="NO"
272 else
273 HAS_IPV6="YES"
274 fi
275 rm -r $SRV_OUT
276 fi
277
278 if [ "$HAS_IPV6" = "NO" ]; then
279 SKIP_NEXT="YES"
280 fi
281}
282
Andrzej Kurekb4593462018-10-11 08:43:30 -0400283# skip next test if it's i686 or uname is not available
284requires_not_i686() {
285 if [ -z "${IS_I686:-}" ]; then
286 IS_I686="YES"
287 if which "uname" >/dev/null 2>&1; then
288 if [ -z "$(uname -a | grep i686)" ]; then
289 IS_I686="NO"
290 fi
291 fi
292 fi
293 if [ "$IS_I686" = "YES" ]; then
294 SKIP_NEXT="YES"
295 fi
296}
297
Angus Grattonc4dd0732018-04-11 16:28:39 +1000298# Calculate the input & output maximum content lengths set in the config
299MAX_CONTENT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
300MAX_IN_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
301MAX_OUT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
302
303if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
304 MAX_CONTENT_LEN="$MAX_IN_LEN"
305fi
306if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
307 MAX_CONTENT_LEN="$MAX_OUT_LEN"
308fi
309
310# skip the next test if the SSL output buffer is less than 16KB
311requires_full_size_output_buffer() {
312 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
313 SKIP_NEXT="YES"
314 fi
315}
316
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200317# skip the next test if valgrind is in use
318not_with_valgrind() {
319 if [ "$MEMCHECK" -gt 0 ]; then
320 SKIP_NEXT="YES"
321 fi
322}
323
Paul Bakker362689d2016-05-13 10:33:25 +0100324# skip the next test if valgrind is NOT in use
325only_with_valgrind() {
326 if [ "$MEMCHECK" -eq 0 ]; then
327 SKIP_NEXT="YES"
328 fi
329}
330
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200331# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100332client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200333 CLI_DELAY_FACTOR=$1
334}
335
Janos Follath74537a62016-09-02 13:45:28 +0100336# wait for the given seconds after the client finished in the next test
337server_needs_more_time() {
338 SRV_DELAY_SECONDS=$1
339}
340
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100341# print_name <name>
342print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100343 TESTS=$(( $TESTS + 1 ))
344 LINE=""
345
346 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
347 LINE="$TESTS "
348 fi
349
350 LINE="$LINE$1"
351 printf "$LINE "
352 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100353 for i in `seq 1 $LEN`; do printf '.'; done
354 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100355
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100356}
357
358# fail <message>
359fail() {
360 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100361 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100362
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200363 mv $SRV_OUT o-srv-${TESTS}.log
364 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200365 if [ -n "$PXY_CMD" ]; then
366 mv $PXY_OUT o-pxy-${TESTS}.log
367 fi
368 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100369
Azim Khan19d13732018-03-29 11:04:20 +0100370 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 +0200371 echo " ! server output:"
372 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200373 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200374 echo " ! client output:"
375 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200376 if [ -n "$PXY_CMD" ]; then
377 echo " ! ========================================================"
378 echo " ! proxy output:"
379 cat o-pxy-${TESTS}.log
380 fi
381 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200382 fi
383
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200384 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100385}
386
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100387# is_polar <cmd_line>
388is_polar() {
389 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
390}
391
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200392# openssl s_server doesn't have -www with DTLS
393check_osrv_dtls() {
394 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
395 NEEDS_INPUT=1
396 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
397 else
398 NEEDS_INPUT=0
399 fi
400}
401
402# provide input to commands that need it
403provide_input() {
404 if [ $NEEDS_INPUT -eq 0 ]; then
405 return
406 fi
407
408 while true; do
409 echo "HTTP/1.0 200 OK"
410 sleep 1
411 done
412}
413
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100414# has_mem_err <log_file_name>
415has_mem_err() {
416 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
417 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
418 then
419 return 1 # false: does not have errors
420 else
421 return 0 # true: has errors
422 fi
423}
424
Gilles Peskine418b5362017-12-14 18:58:42 +0100425# Wait for process $2 to be listening on port $1
426if type lsof >/dev/null 2>/dev/null; then
427 wait_server_start() {
428 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200429 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100430 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200431 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100432 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200433 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100434 # Make a tight loop, server normally takes less than 1s to start.
435 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
436 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
437 echo "SERVERSTART TIMEOUT"
438 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
439 break
440 fi
441 # Linux and *BSD support decimal arguments to sleep. On other
442 # OSes this may be a tight loop.
443 sleep 0.1 2>/dev/null || true
444 done
445 }
446else
Gilles Peskinea9312652018-06-29 15:48:13 +0200447 echo "Warning: lsof not available, wait_server_start = sleep"
Gilles Peskine418b5362017-12-14 18:58:42 +0100448 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200449 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100450 }
451fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200452
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100453# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100454# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100455# acceptable bounds
456check_server_hello_time() {
457 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100458 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100459 # Get the Unix timestamp for now
460 CUR_TIME=$(date +'%s')
461 THRESHOLD_IN_SECS=300
462
463 # Check if the ServerHello time was printed
464 if [ -z "$SERVER_HELLO_TIME" ]; then
465 return 1
466 fi
467
468 # Check the time in ServerHello is within acceptable bounds
469 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
470 # The time in ServerHello is at least 5 minutes before now
471 return 1
472 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100473 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100474 return 1
475 else
476 return 0
477 fi
478}
479
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200480# wait for client to terminate and set CLI_EXIT
481# must be called right after starting the client
482wait_client_done() {
483 CLI_PID=$!
484
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200485 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
486 CLI_DELAY_FACTOR=1
487
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200488 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200489 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200490
491 wait $CLI_PID
492 CLI_EXIT=$?
493
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200494 kill $DOG_PID >/dev/null 2>&1
495 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200496
497 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100498
499 sleep $SRV_DELAY_SECONDS
500 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200501}
502
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200503# check if the given command uses dtls and sets global variable DTLS
504detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200505 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200506 DTLS=1
507 else
508 DTLS=0
509 fi
510}
511
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200512# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100513# Options: -s pattern pattern that must be present in server output
514# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100515# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100516# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100517# -S pattern pattern that must be absent in server output
518# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100519# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100520# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100521run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100522 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200523 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100524
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100525 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
526 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200527 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100528 return
529 fi
530
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100531 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100532
Paul Bakkerb7584a52016-05-10 10:50:43 +0100533 # Do we only run numbered tests?
534 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
535 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
536 else
537 SKIP_NEXT="YES"
538 fi
539
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200540 # does this test use a proxy?
541 if [ "X$1" = "X-p" ]; then
542 PXY_CMD="$2"
543 shift 2
544 else
545 PXY_CMD=""
546 fi
547
548 # get commands and client output
549 SRV_CMD="$1"
550 CLI_CMD="$2"
551 CLI_EXPECT="$3"
552 shift 3
553
Hanno Becker9d76d562018-11-16 17:27:29 +0000554 # Check if server forces ciphersuite
555 FORCE_CIPHERSUITE=$(echo "$SRV_CMD" | sed -n 's/^.*force_ciphersuite=\([a-zA-Z0-9\-]*\).*$/\1/p')
556 if [ ! -z "$FORCE_CIPHERSUITE" ]; then
557 requires_ciphersuite_enabled $FORCE_CIPHERSUITE
558 fi
559
560 # Check if client forces ciphersuite
561 FORCE_CIPHERSUITE=$(echo "$CLI_CMD" | sed -n 's/^.*force_ciphersuite=\([a-zA-Z0-9\-]*\).*$/\1/p')
562 if [ ! -z "$FORCE_CIPHERSUITE" ]; then
563 requires_ciphersuite_enabled $FORCE_CIPHERSUITE
564 fi
565
566 # should we skip?
567 if [ "X$SKIP_NEXT" = "XYES" ]; then
568 SKIP_NEXT="NO"
569 echo "SKIP"
570 SKIPS=$(( $SKIPS + 1 ))
571 return
572 fi
573
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200574 # fix client port
575 if [ -n "$PXY_CMD" ]; then
576 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
577 else
578 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
579 fi
580
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200581 # update DTLS variable
582 detect_dtls "$SRV_CMD"
583
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100584 # prepend valgrind to our commands if active
585 if [ "$MEMCHECK" -gt 0 ]; then
586 if is_polar "$SRV_CMD"; then
587 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
588 fi
589 if is_polar "$CLI_CMD"; then
590 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
591 fi
592 fi
593
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200594 TIMES_LEFT=2
595 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200596 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200597
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200598 # run the commands
599 if [ -n "$PXY_CMD" ]; then
600 echo "$PXY_CMD" > $PXY_OUT
601 $PXY_CMD >> $PXY_OUT 2>&1 &
602 PXY_PID=$!
603 # assume proxy starts faster than server
604 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200605
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200606 check_osrv_dtls
607 echo "$SRV_CMD" > $SRV_OUT
608 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
609 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100610 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200611
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200612 echo "$CLI_CMD" > $CLI_OUT
613 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
614 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100615
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100616 sleep 0.05
617
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200618 # terminate the server (and the proxy)
619 kill $SRV_PID
620 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100621
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200622 if [ -n "$PXY_CMD" ]; then
623 kill $PXY_PID >/dev/null 2>&1
624 wait $PXY_PID
625 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100626
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200627 # retry only on timeouts
628 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
629 printf "RETRY "
630 else
631 TIMES_LEFT=0
632 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200633 done
634
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100635 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200636 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100637 # expected client exit to incorrectly succeed in case of catastrophic
638 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100639 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200640 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100641 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100642 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100643 return
644 fi
645 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100646 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200647 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100648 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100649 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100650 return
651 fi
652 fi
653
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100654 # check server exit code
655 if [ $? != 0 ]; then
656 fail "server fail"
657 return
658 fi
659
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100660 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100661 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
662 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100663 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200664 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100665 return
666 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100667
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100668 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200669 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100670 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100671 while [ $# -gt 0 ]
672 do
673 case $1 in
674 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100675 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 +0100676 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100677 return
678 fi
679 ;;
680
681 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100682 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 +0100683 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100684 return
685 fi
686 ;;
687
688 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100689 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 +0100690 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100691 return
692 fi
693 ;;
694
695 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100696 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 +0100697 fail "pattern '$2' MUST NOT be present in the Client output"
698 return
699 fi
700 ;;
701
702 # The filtering in the following two options (-u and -U) do the following
703 # - ignore valgrind output
Antonin Décimo36e89b52019-01-23 15:24:37 +0100704 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100705 # - keep one of each non-unique line
706 # - count how many lines remain
707 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
708 # if there were no duplicates.
709 "-U")
710 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
711 fail "lines following pattern '$2' must be unique in Server output"
712 return
713 fi
714 ;;
715
716 "-u")
717 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
718 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100719 return
720 fi
721 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100722 "-F")
723 if ! $2 "$SRV_OUT"; then
724 fail "function call to '$2' failed on Server output"
725 return
726 fi
727 ;;
728 "-f")
729 if ! $2 "$CLI_OUT"; then
730 fail "function call to '$2' failed on Client output"
731 return
732 fi
733 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100734
735 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200736 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100737 exit 1
738 esac
739 shift 2
740 done
741
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100742 # check valgrind's results
743 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200744 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100745 fail "Server has memory errors"
746 return
747 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200748 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100749 fail "Client has memory errors"
750 return
751 fi
752 fi
753
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100754 # if we're here, everything is ok
755 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100756 if [ "$PRESERVE_LOGS" -gt 0 ]; then
757 mv $SRV_OUT o-srv-${TESTS}.log
758 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100759 if [ -n "$PXY_CMD" ]; then
760 mv $PXY_OUT o-pxy-${TESTS}.log
761 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100762 fi
763
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200764 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100765}
766
Hanno Becker9b5853c2018-11-16 17:28:40 +0000767run_test_psa() {
768 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
Hanno Beckere9420c22018-11-20 11:37:34 +0000769 run_test "PSA-supported ciphersuite: $1" \
Hanno Becker4c8c7aa2019-04-10 09:25:41 +0100770 "$P_SRV debug_level=3 force_version=tls1_2" \
771 "$P_CLI debug_level=3 force_version=tls1_2 force_ciphersuite=$1" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000772 0 \
773 -c "Successfully setup PSA-based decryption cipher context" \
774 -c "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500775 -c "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500776 -c "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000777 -s "Successfully setup PSA-based decryption cipher context" \
778 -s "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500779 -s "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500780 -s "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000781 -C "Failed to setup PSA-based cipher context"\
782 -S "Failed to setup PSA-based cipher context"\
783 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +0000784 -c "Perform PSA-based ECDH computation."\
Andrzej Kureke85414e2019-01-15 05:23:59 -0500785 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000786 -S "error" \
787 -C "error"
788}
789
Hanno Becker354e2482019-01-08 11:40:25 +0000790run_test_psa_force_curve() {
791 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
792 run_test "PSA - ECDH with $1" \
793 "$P_SRV debug_level=4 force_version=tls1_2" \
794 "$P_CLI debug_level=4 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=$1" \
795 0 \
Hanno Becker28f78442019-02-18 16:47:50 +0000796 -c "Successfully setup PSA-based decryption cipher context" \
797 -c "Successfully setup PSA-based encryption cipher context" \
798 -c "PSA calc verify" \
799 -c "calc PSA finished" \
800 -s "Successfully setup PSA-based decryption cipher context" \
801 -s "Successfully setup PSA-based encryption cipher context" \
802 -s "PSA calc verify" \
803 -s "calc PSA finished" \
804 -C "Failed to setup PSA-based cipher context"\
805 -S "Failed to setup PSA-based cipher context"\
Hanno Becker354e2482019-01-08 11:40:25 +0000806 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +0000807 -c "Perform PSA-based ECDH computation."\
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100808 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200809 -S "error" \
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200810 -C "error"
811}
812
813cleanup() {
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100814 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
815 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
816 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100817 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
818 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
819 exit 1
820}
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100821
822#
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100823# MAIN
Hanno Becker4ac73e72017-10-23 15:27:37 +0100824#
825
826get_options "$@"
Hanno Becker17c04932017-10-10 14:44:53 +0100827
828# sanity checks, avoid an avalanche of errors
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100829P_SRV_BIN="${P_SRV%%[ ]*}"
830P_CLI_BIN="${P_CLI%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100831P_PXY_BIN="${P_PXY%%[ ]*}"
832if [ ! -x "$P_SRV_BIN" ]; then
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100833 echo "Command '$P_SRV_BIN' is not an executable file"
834 exit 1
Hanno Becker17c04932017-10-10 14:44:53 +0100835fi
836if [ ! -x "$P_CLI_BIN" ]; then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200837 echo "Command '$P_CLI_BIN' is not an executable file"
838 exit 1
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100839fi
840if [ ! -x "$P_PXY_BIN" ]; then
841 echo "Command '$P_PXY_BIN' is not an executable file"
842 exit 1
843fi
844if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100845 if which valgrind >/dev/null 2>&1; then :; else
846 echo "Memcheck not possible. Valgrind not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100847 exit 1
848 fi
849fi
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200850if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
851 echo "Command '$OPENSSL_CMD' not found"
852 exit 1
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100853fi
854
855# used by watchdog
856MAIN_PID="$$"
857
858# We use somewhat arbitrary delays for tests:
859# - how long do we wait for the server to start (when lsof not available)?
860# - how long do we allow for the client to finish?
861# (not to check performance, just to avoid waiting indefinitely)
862# Things are slower with valgrind, so give extra time here.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200863#
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100864# Note: without lsof, there is a trade-off between the running time of this
865# script and the risk of spurious errors because we didn't wait long enough.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200866# The watchdog delay on the other hand doesn't affect normal running time of
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100867# the script, only the case where a client or server gets stuck.
868if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200869 START_DELAY=6
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100870 DOG_DELAY=60
871else
872 START_DELAY=2
873 DOG_DELAY=20
874fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200875
Janos Follath74537a62016-09-02 13:45:28 +0100876# some particular tests need more time:
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200877# - for the client, we multiply the usual watchdog limit by a factor
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200878# - for the server, we sleep for a number of seconds after the client exits
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000879# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200880CLI_DELAY_FACTOR=1
881SRV_DELAY_SECONDS=0
Andres AGf04f54d2016-10-10 15:46:20 +0100882
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200883# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200884# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
885P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200886P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200887P_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é-Gonnard38110df2018-08-17 12:44:54 +0200888O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
889O_CLI="$O_CLI -connect localhost:+SRV_PORT"
890G_SRV="$G_SRV -p $SRV_PORT"
891G_CLI="$G_CLI -p +SRV_PORT"
892
Hanno Becker58e9dc32018-08-17 15:53:21 +0100893if [ -n "${OPENSSL_LEGACY:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200894 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
895 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
896fi
Hanno Becker58e9dc32018-08-17 15:53:21 +0100897
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200898if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200899 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100900fi
Gilles Peskine62469d92017-05-10 10:13:59 +0200901
902if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
903 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
904fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200905
906# Allow SHA-1, because many of our test certificates use it
907P_SRV="$P_SRV allow_sha1=1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200908P_CLI="$P_CLI allow_sha1=1"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200909
910# Also pick a unique name for intermediate files
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200911SRV_OUT="srv_out.$$"
912CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100913PXY_OUT="pxy_out.$$"
914SESSION="session.$$"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200915
916SKIP_NEXT="NO"
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200917
918trap cleanup INT TERM HUP
919
920# Basic test
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200921
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200922# Checks that:
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200923# - things work with all ciphersuites active (used with config-full in all.sh)
924# - the expected (highest security) parameters are selected
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200925# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200926run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200927 "$P_SRV debug_level=3" \
928 "$P_CLI" \
929 0 \
930 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200931 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000932 -s "client hello v3, signature_algorithm ext: 6" \
933 -s "ECDHE curve: secp521r1" \
934 -S "error" \
935 -C "error"
936
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200937run_test "Default, DTLS" \
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000938 "$P_SRV dtls=1" \
Manuel Pégourié-Gonnardcfdf8f42018-11-08 09:52:25 +0100939 "$P_CLI dtls=1" \
940 0 \
941 -s "Protocol is DTLSv1.2" \
942 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
943
Hanno Becker746aaf32019-03-28 15:25:23 +0000944requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
945run_test "CA callback on client" \
946 "$P_SRV debug_level=3" \
947 "$P_CLI ca_callback=1 debug_level=3 " \
948 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +0100949 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +0000950 -S "error" \
951 -C "error"
952
953requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
954requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
955requires_config_enabled MBEDTLS_ECDSA_C
956requires_config_enabled MBEDTLS_SHA256_C
957run_test "CA callback on server" \
958 "$P_SRV auth_mode=required" \
959 "$P_CLI ca_callback=1 debug_level=3 crt_file=data_files/server5.crt \
960 key_file=data_files/server5.key" \
961 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +0100962 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +0000963 -s "Verifying peer X.509 certificate... ok" \
964 -S "error" \
965 -C "error"
966
Manuel Pégourié-Gonnardcfdf8f42018-11-08 09:52:25 +0100967# Test using an opaque private key for client authentication
968requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
969requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
970requires_config_enabled MBEDTLS_ECDSA_C
971requires_config_enabled MBEDTLS_SHA256_C
972run_test "Opaque key for client authentication" \
973 "$P_SRV auth_mode=required" \
974 "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \
975 key_file=data_files/server5.key" \
976 0 \
977 -c "key type: Opaque" \
978 -s "Verifying peer X.509 certificate... ok" \
979 -S "error" \
980 -C "error"
981
Hanno Becker9b5853c2018-11-16 17:28:40 +0000982# Test ciphersuites which we expect to be fully supported by PSA Crypto
983# and check that we don't fall back to Mbed TLS' internal crypto primitives.
984run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM
985run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
986run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM
987run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8
988run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
989run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384
990run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA
991run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
992run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384
993
Hanno Becker354e2482019-01-08 11:40:25 +0000994requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
995run_test_psa_force_curve "secp521r1"
996requires_config_enabled MBEDTLS_ECP_DP_BP512R1_ENABLED
997run_test_psa_force_curve "brainpoolP512r1"
998requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
999run_test_psa_force_curve "secp384r1"
1000requires_config_enabled MBEDTLS_ECP_DP_BP384R1_ENABLED
1001run_test_psa_force_curve "brainpoolP384r1"
1002requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED
1003run_test_psa_force_curve "secp256r1"
1004requires_config_enabled MBEDTLS_ECP_DP_SECP256K1_ENABLED
1005run_test_psa_force_curve "secp256k1"
1006requires_config_enabled MBEDTLS_ECP_DP_BP256R1_ENABLED
1007run_test_psa_force_curve "brainpoolP256r1"
1008requires_config_enabled MBEDTLS_ECP_DP_SECP224R1_ENABLED
1009run_test_psa_force_curve "secp224r1"
1010requires_config_enabled MBEDTLS_ECP_DP_SECP224K1_ENABLED
1011run_test_psa_force_curve "secp224k1"
1012requires_config_enabled MBEDTLS_ECP_DP_SECP192R1_ENABLED
1013run_test_psa_force_curve "secp192r1"
1014requires_config_enabled MBEDTLS_ECP_DP_SECP192K1_ENABLED
1015run_test_psa_force_curve "secp192k1"
1016
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001017# Test current time in ServerHello
1018requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001019run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001020 "$P_SRV debug_level=3" \
1021 "$P_CLI debug_level=3" \
1022 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001023 -f "check_server_hello_time" \
1024 -F "check_server_hello_time"
1025
Simon Butcher8e004102016-10-14 00:48:33 +01001026# Test for uniqueness of IVs in AEAD ciphersuites
1027run_test "Unique IV in GCM" \
1028 "$P_SRV exchanges=20 debug_level=4" \
1029 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1030 0 \
1031 -u "IV used" \
1032 -U "IV used"
1033
Janos Follathee11be62019-04-04 12:03:30 +01001034# Tests for certificate verification callback
1035run_test "Configuration-specific CRT verification callback" \
1036 "$P_SRV debug_level=3" \
1037 "$P_CLI context_crt_cb=0 debug_level=3" \
1038 0 \
Janos Follathee11be62019-04-04 12:03:30 +01001039 -S "error" \
1040 -c "Verify requested for " \
1041 -c "Use configuration-specific verification callback" \
1042 -C "Use context-specific verification callback" \
1043 -C "error"
1044
Hanno Beckerefb440a2019-04-03 13:04:33 +01001045run_test "Context-specific CRT verification callback" \
1046 "$P_SRV debug_level=3" \
1047 "$P_CLI context_crt_cb=1 debug_level=3" \
1048 0 \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001049 -S "error" \
Janos Follathee11be62019-04-04 12:03:30 +01001050 -c "Verify requested for " \
1051 -c "Use context-specific verification callback" \
1052 -C "Use configuration-specific verification callback" \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001053 -C "error"
1054
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001055# Tests for rc4 option
1056
Simon Butchera410af52016-05-19 22:12:18 +01001057requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001058run_test "RC4: server disabled, client enabled" \
1059 "$P_SRV" \
1060 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1061 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001062 -s "SSL - The server has no ciphersuites in common"
1063
Simon Butchera410af52016-05-19 22:12:18 +01001064requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001065run_test "RC4: server half, client enabled" \
1066 "$P_SRV arc4=1" \
1067 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1068 1 \
1069 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001070
1071run_test "RC4: server enabled, client disabled" \
1072 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1073 "$P_CLI" \
1074 1 \
1075 -s "SSL - The server has no ciphersuites in common"
1076
1077run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001078 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001079 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1080 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001081 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001082 -S "SSL - The server has no ciphersuites in common"
1083
Hanno Beckerd26bb202018-08-17 09:54:10 +01001084# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1085
1086requires_gnutls
1087requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1088run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1089 "$G_SRV"\
1090 "$P_CLI force_version=tls1_1" \
1091 0
1092
1093requires_gnutls
1094requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1095run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1096 "$G_SRV"\
1097 "$P_CLI force_version=tls1" \
1098 0
1099
Gilles Peskinebc70a182017-05-09 15:59:24 +02001100# Tests for SHA-1 support
1101
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001102requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001103run_test "SHA-1 forbidden by default in server certificate" \
1104 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1105 "$P_CLI debug_level=2 allow_sha1=0" \
1106 1 \
1107 -c "The certificate is signed with an unacceptable hash"
1108
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001109requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1110run_test "SHA-1 forbidden by default in server certificate" \
1111 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1112 "$P_CLI debug_level=2 allow_sha1=0" \
1113 0
1114
Gilles Peskinebc70a182017-05-09 15:59:24 +02001115run_test "SHA-1 explicitly allowed in server certificate" \
1116 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1117 "$P_CLI allow_sha1=1" \
1118 0
1119
1120run_test "SHA-256 allowed by default in server certificate" \
1121 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1122 "$P_CLI allow_sha1=0" \
1123 0
1124
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001125requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001126run_test "SHA-1 forbidden by default in client certificate" \
1127 "$P_SRV auth_mode=required allow_sha1=0" \
1128 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1129 1 \
1130 -s "The certificate is signed with an unacceptable hash"
1131
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001132requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1133run_test "SHA-1 forbidden by default in client certificate" \
1134 "$P_SRV auth_mode=required allow_sha1=0" \
1135 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1136 0
1137
Gilles Peskinebc70a182017-05-09 15:59:24 +02001138run_test "SHA-1 explicitly allowed in client certificate" \
1139 "$P_SRV auth_mode=required allow_sha1=1" \
1140 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1141 0
1142
1143run_test "SHA-256 allowed by default in client certificate" \
1144 "$P_SRV auth_mode=required allow_sha1=0" \
1145 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1146 0
1147
Hanno Becker7ae8a762018-08-14 15:43:35 +01001148# Tests for datagram packing
1149run_test "DTLS: multiple records in same datagram, client and server" \
1150 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1151 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1152 0 \
1153 -c "next record in same datagram" \
1154 -s "next record in same datagram"
1155
1156run_test "DTLS: multiple records in same datagram, client only" \
1157 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1158 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1159 0 \
1160 -s "next record in same datagram" \
1161 -C "next record in same datagram"
1162
1163run_test "DTLS: multiple records in same datagram, server only" \
1164 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1165 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1166 0 \
1167 -S "next record in same datagram" \
1168 -c "next record in same datagram"
1169
1170run_test "DTLS: multiple records in same datagram, neither client nor server" \
1171 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1172 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1173 0 \
1174 -S "next record in same datagram" \
1175 -C "next record in same datagram"
1176
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001177# Tests for Truncated HMAC extension
1178
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001179run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001180 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001181 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001182 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001183 -s "dumping 'expected mac' (20 bytes)" \
1184 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001185
Hanno Becker32c55012017-11-10 08:42:54 +00001186requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001187run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001188 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001189 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001190 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001191 -s "dumping 'expected mac' (20 bytes)" \
1192 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001193
Hanno Becker32c55012017-11-10 08:42:54 +00001194requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001195run_test "Truncated HMAC: client enabled, server default" \
1196 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001197 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001198 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001199 -s "dumping 'expected mac' (20 bytes)" \
1200 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001201
Hanno Becker32c55012017-11-10 08:42:54 +00001202requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001203run_test "Truncated HMAC: client enabled, server disabled" \
1204 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001205 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001206 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001207 -s "dumping 'expected mac' (20 bytes)" \
1208 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001209
Hanno Becker32c55012017-11-10 08:42:54 +00001210requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001211run_test "Truncated HMAC: client disabled, server enabled" \
1212 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001213 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001214 0 \
1215 -s "dumping 'expected mac' (20 bytes)" \
1216 -S "dumping 'expected mac' (10 bytes)"
1217
1218requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001219run_test "Truncated HMAC: client enabled, server enabled" \
1220 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001221 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001222 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001223 -S "dumping 'expected mac' (20 bytes)" \
1224 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001225
Hanno Becker4c4f4102017-11-10 09:16:05 +00001226run_test "Truncated HMAC, DTLS: client default, server default" \
1227 "$P_SRV dtls=1 debug_level=4" \
1228 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1229 0 \
1230 -s "dumping 'expected mac' (20 bytes)" \
1231 -S "dumping 'expected mac' (10 bytes)"
1232
1233requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1234run_test "Truncated HMAC, DTLS: client disabled, server default" \
1235 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001236 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001237 0 \
1238 -s "dumping 'expected mac' (20 bytes)" \
1239 -S "dumping 'expected mac' (10 bytes)"
1240
1241requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1242run_test "Truncated HMAC, DTLS: client enabled, server default" \
1243 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001244 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001245 0 \
1246 -s "dumping 'expected mac' (20 bytes)" \
1247 -S "dumping 'expected mac' (10 bytes)"
1248
1249requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1250run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1251 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001252 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001253 0 \
1254 -s "dumping 'expected mac' (20 bytes)" \
1255 -S "dumping 'expected mac' (10 bytes)"
1256
1257requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1258run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1259 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001260 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001261 0 \
1262 -s "dumping 'expected mac' (20 bytes)" \
1263 -S "dumping 'expected mac' (10 bytes)"
1264
1265requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1266run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1267 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001268 "$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 +01001269 0 \
1270 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001271 -s "dumping 'expected mac' (10 bytes)"
1272
Hanno Becker7cf463e2019-04-09 18:08:47 +01001273# Tests for DTLS Connection ID extension
1274
Hanno Becker7cf463e2019-04-09 18:08:47 +01001275# So far, the CID API isn't implemented, so we can't
1276# grep for output witnessing its use. This needs to be
1277# changed once the CID extension is implemented.
1278
1279requires_config_enabled MBEDTLS_SSL_CID
Hanno Becker78c91372019-05-08 13:31:15 +01001280run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001281 "$P_SRV debug_level=3 dtls=1 cid=0" \
1282 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1283 0 \
1284 -s "Disable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001285 -s "found CID extension" \
1286 -s "Client sent CID extension, but CID disabled" \
Hanno Becker6b78c832019-04-25 17:01:43 +01001287 -c "Enable use of CID extension." \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001288 -c "client hello, adding CID extension" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001289 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001290 -C "found CID extension" \
1291 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001292 -C "Copy CIDs into SSL transform" \
1293 -c "Use of Connection ID was rejected by the server"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001294
1295requires_config_enabled MBEDTLS_SSL_CID
Hanno Becker78c91372019-05-08 13:31:15 +01001296run_test "Connection ID: Cli disabled, Srv enabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001297 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1298 "$P_CLI debug_level=3 dtls=1 cid=0" \
1299 0 \
1300 -c "Disable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001301 -C "client hello, adding CID extension" \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001302 -S "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001303 -s "Enable use of CID extension." \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001304 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001305 -C "found CID extension" \
1306 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001307 -C "Copy CIDs into SSL transform" \
Hanno Beckerb3e9dd52019-05-08 13:19:53 +01001308 -s "Use of Connection ID was not offered by client"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001309
1310requires_config_enabled MBEDTLS_SSL_CID
Hanno Becker78c91372019-05-08 13:31:15 +01001311run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001312 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1313 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1314 0 \
1315 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001316 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001317 -c "client hello, adding CID extension" \
1318 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001319 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001320 -s "server hello, adding CID extension" \
1321 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001322 -c "Use of CID extension negotiated" \
1323 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001324 -c "Copy CIDs into SSL transform" \
1325 -c "Peer CID (length 2 Bytes): de ad" \
1326 -s "Peer CID (length 2 Bytes): be ef" \
1327 -s "Use of Connection ID has been negotiated" \
1328 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001329
1330requires_config_enabled MBEDTLS_SSL_CID
Hanno Becker78c91372019-05-08 13:31:15 +01001331run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
1332 -p "$P_PXY drop=5 delay=5 duplicate=5" \
1333 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1334 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1335 0 \
1336 -c "Enable use of CID extension." \
1337 -s "Enable use of CID extension." \
1338 -c "client hello, adding CID extension" \
1339 -s "found CID extension" \
1340 -s "Use of CID extension negotiated" \
1341 -s "server hello, adding CID extension" \
1342 -c "found CID extension" \
1343 -c "Use of CID extension negotiated" \
1344 -s "Copy CIDs into SSL transform" \
1345 -c "Copy CIDs into SSL transform" \
1346 -c "Peer CID (length 2 Bytes): de ad" \
1347 -s "Peer CID (length 2 Bytes): be ef" \
1348 -s "Use of Connection ID has been negotiated" \
1349 -c "Use of Connection ID has been negotiated"
1350
1351requires_config_enabled MBEDTLS_SSL_CID
1352run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1353 -p "$P_PXY mtu=800" \
1354 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1355 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1356 0 \
1357 -c "Enable use of CID extension." \
1358 -s "Enable use of CID extension." \
1359 -c "client hello, adding CID extension" \
1360 -s "found CID extension" \
1361 -s "Use of CID extension negotiated" \
1362 -s "server hello, adding CID extension" \
1363 -c "found CID extension" \
1364 -c "Use of CID extension negotiated" \
1365 -s "Copy CIDs into SSL transform" \
1366 -c "Copy CIDs into SSL transform" \
1367 -c "Peer CID (length 2 Bytes): de ad" \
1368 -s "Peer CID (length 2 Bytes): be ef" \
1369 -s "Use of Connection ID has been negotiated" \
1370 -c "Use of Connection ID has been negotiated"
1371
1372requires_config_enabled MBEDTLS_SSL_CID
1373run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1374 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5" \
1375 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1376 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1377 0 \
1378 -c "Enable use of CID extension." \
1379 -s "Enable use of CID extension." \
1380 -c "client hello, adding CID extension" \
1381 -s "found CID extension" \
1382 -s "Use of CID extension negotiated" \
1383 -s "server hello, adding CID extension" \
1384 -c "found CID extension" \
1385 -c "Use of CID extension negotiated" \
1386 -s "Copy CIDs into SSL transform" \
1387 -c "Copy CIDs into SSL transform" \
1388 -c "Peer CID (length 2 Bytes): de ad" \
1389 -s "Peer CID (length 2 Bytes): be ef" \
1390 -s "Use of Connection ID has been negotiated" \
1391 -c "Use of Connection ID has been negotiated"
1392
1393requires_config_enabled MBEDTLS_SSL_CID
1394run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001395 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1396 "$P_CLI debug_level=3 dtls=1 cid=1" \
1397 0 \
1398 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001399 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001400 -c "client hello, adding CID extension" \
1401 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001402 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001403 -s "server hello, adding CID extension" \
1404 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001405 -c "Use of CID extension negotiated" \
1406 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001407 -c "Copy CIDs into SSL transform" \
1408 -c "Peer CID (length 4 Bytes): de ad be ef" \
1409 -s "Peer CID (length 0 Bytes):" \
1410 -s "Use of Connection ID has been negotiated" \
1411 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001412
1413requires_config_enabled MBEDTLS_SSL_CID
Hanno Becker78c91372019-05-08 13:31:15 +01001414run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001415 "$P_SRV debug_level=3 dtls=1 cid=1" \
1416 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1417 0 \
1418 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001419 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001420 -c "client hello, adding CID extension" \
1421 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001422 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001423 -s "server hello, adding CID extension" \
1424 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001425 -c "Use of CID extension negotiated" \
1426 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001427 -c "Copy CIDs into SSL transform" \
1428 -s "Peer CID (length 4 Bytes): de ad be ef" \
1429 -c "Peer CID (length 0 Bytes):" \
1430 -s "Use of Connection ID has been negotiated" \
1431 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001432
1433requires_config_enabled MBEDTLS_SSL_CID
Hanno Becker78c91372019-05-08 13:31:15 +01001434run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001435 "$P_SRV debug_level=3 dtls=1 cid=1" \
1436 "$P_CLI debug_level=3 dtls=1 cid=1" \
1437 0 \
1438 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001439 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001440 -c "client hello, adding CID extension" \
1441 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001442 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001443 -s "server hello, adding CID extension" \
1444 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001445 -c "Use of CID extension negotiated" \
1446 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001447 -c "Copy CIDs into SSL transform" \
1448 -S "Use of Connection ID has been negotiated" \
1449 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001450
1451requires_config_enabled MBEDTLS_SSL_CID
Hanno Becker78c91372019-05-08 13:31:15 +01001452run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001453 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1454 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1455 0 \
1456 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001457 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001458 -c "client hello, adding CID extension" \
1459 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001460 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001461 -s "server hello, adding CID extension" \
1462 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001463 -c "Use of CID extension negotiated" \
1464 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001465 -c "Copy CIDs into SSL transform" \
1466 -c "Peer CID (length 2 Bytes): de ad" \
1467 -s "Peer CID (length 2 Bytes): be ef" \
1468 -s "Use of Connection ID has been negotiated" \
1469 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001470
1471requires_config_enabled MBEDTLS_SSL_CID
Hanno Becker78c91372019-05-08 13:31:15 +01001472run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001473 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1474 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1475 0 \
1476 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001477 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001478 -c "client hello, adding CID extension" \
1479 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001480 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001481 -s "server hello, adding CID extension" \
1482 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001483 -c "Use of CID extension negotiated" \
1484 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001485 -c "Copy CIDs into SSL transform" \
1486 -c "Peer CID (length 4 Bytes): de ad be ef" \
1487 -s "Peer CID (length 0 Bytes):" \
1488 -s "Use of Connection ID has been negotiated" \
1489 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001490
1491requires_config_enabled MBEDTLS_SSL_CID
Hanno Becker78c91372019-05-08 13:31:15 +01001492run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001493 "$P_SRV debug_level=3 dtls=1 cid=1" \
1494 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1495 0 \
1496 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001497 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001498 -c "client hello, adding CID extension" \
1499 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001500 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001501 -s "server hello, adding CID extension" \
1502 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001503 -c "Use of CID extension negotiated" \
1504 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001505 -c "Copy CIDs into SSL transform" \
1506 -s "Peer CID (length 4 Bytes): de ad be ef" \
1507 -c "Peer CID (length 0 Bytes):" \
1508 -s "Use of Connection ID has been negotiated" \
1509 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001510
1511requires_config_enabled MBEDTLS_SSL_CID
Hanno Becker78c91372019-05-08 13:31:15 +01001512run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001513 "$P_SRV debug_level=3 dtls=1 cid=1" \
1514 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1515 0 \
1516 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001517 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001518 -c "client hello, adding CID extension" \
1519 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001520 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001521 -s "server hello, adding CID extension" \
1522 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001523 -c "Use of CID extension negotiated" \
1524 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001525 -c "Copy CIDs into SSL transform" \
1526 -S "Use of Connection ID has been negotiated" \
1527 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001528
1529requires_config_enabled MBEDTLS_SSL_CID
Hanno Becker78c91372019-05-08 13:31:15 +01001530run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001531 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1532 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1533 0 \
1534 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001535 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001536 -c "client hello, adding CID extension" \
1537 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001538 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001539 -s "server hello, adding CID extension" \
1540 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001541 -c "Use of CID extension negotiated" \
1542 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001543 -c "Copy CIDs into SSL transform" \
1544 -c "Peer CID (length 2 Bytes): de ad" \
1545 -s "Peer CID (length 2 Bytes): be ef" \
1546 -s "Use of Connection ID has been negotiated" \
1547 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001548
1549requires_config_enabled MBEDTLS_SSL_CID
Hanno Becker78c91372019-05-08 13:31:15 +01001550run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001551 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1552 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1553 0 \
1554 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001555 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001556 -c "client hello, adding CID extension" \
1557 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001558 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001559 -s "server hello, adding CID extension" \
1560 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001561 -c "Use of CID extension negotiated" \
1562 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001563 -c "Copy CIDs into SSL transform" \
1564 -c "Peer CID (length 4 Bytes): de ad be ef" \
1565 -s "Peer CID (length 0 Bytes):" \
1566 -s "Use of Connection ID has been negotiated" \
1567 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001568
1569requires_config_enabled MBEDTLS_SSL_CID
Hanno Becker78c91372019-05-08 13:31:15 +01001570run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001571 "$P_SRV debug_level=3 dtls=1 cid=1" \
1572 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1573 0 \
1574 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001575 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001576 -c "client hello, adding CID extension" \
1577 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001578 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001579 -s "server hello, adding CID extension" \
1580 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001581 -c "Use of CID extension negotiated" \
1582 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001583 -c "Copy CIDs into SSL transform" \
1584 -s "Peer CID (length 4 Bytes): de ad be ef" \
1585 -c "Peer CID (length 0 Bytes):" \
1586 -s "Use of Connection ID has been negotiated" \
1587 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001588
1589requires_config_enabled MBEDTLS_SSL_CID
Hanno Becker78c91372019-05-08 13:31:15 +01001590run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001591 "$P_SRV debug_level=3 dtls=1 cid=1" \
1592 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1593 0 \
1594 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001595 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001596 -c "client hello, adding CID extension" \
1597 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001598 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001599 -s "server hello, adding CID extension" \
1600 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001601 -c "Use of CID extension negotiated" \
1602 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001603 -c "Copy CIDs into SSL transform" \
1604 -S "Use of Connection ID has been negotiated" \
1605 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001606
Hanno Becker9bae30d2019-04-23 11:52:44 +01001607requires_config_enabled MBEDTLS_SSL_CID
1608requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01001609run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001610 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
1611 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
1612 0 \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01001613 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1614 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1615 -s "(initial handshake) Use of Connection ID has been negotiated" \
1616 -c "(initial handshake) Use of Connection ID has been negotiated" \
1617 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1618 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1619 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1620 -c "(after renegotiation) Use of Connection ID has been negotiated"
1621
1622requires_config_enabled MBEDTLS_SSL_CID
1623requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01001624run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01001625 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
1626 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1627 0 \
1628 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1629 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1630 -s "(initial handshake) Use of Connection ID has been negotiated" \
1631 -c "(initial handshake) Use of Connection ID has been negotiated" \
1632 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1633 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1634 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1635 -c "(after renegotiation) Use of Connection ID has been negotiated"
1636
1637requires_config_enabled MBEDTLS_SSL_CID
1638requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01001639run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
1640 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5" \
1641 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
1642 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1643 0 \
1644 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1645 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1646 -s "(initial handshake) Use of Connection ID has been negotiated" \
1647 -c "(initial handshake) Use of Connection ID has been negotiated" \
1648 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1649 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1650 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1651 -c "(after renegotiation) Use of Connection ID has been negotiated"
1652
1653requires_config_enabled MBEDTLS_SSL_CID
1654requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
1655run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01001656 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
1657 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
1658 0 \
1659 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1660 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1661 -s "(initial handshake) Use of Connection ID has been negotiated" \
1662 -c "(initial handshake) Use of Connection ID has been negotiated" \
1663 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1664 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1665 -C "(after renegotiation) Use of Connection ID has been negotiated" \
1666 -S "(after renegotiation) Use of Connection ID has been negotiated"
1667
1668requires_config_enabled MBEDTLS_SSL_CID
1669requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01001670run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
1671 -p "$P_PXY drop=5 delay=5 duplicate=5" \
1672 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
1673 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
1674 0 \
1675 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1676 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1677 -s "(initial handshake) Use of Connection ID has been negotiated" \
1678 -c "(initial handshake) Use of Connection ID has been negotiated" \
1679 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1680 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1681 -C "(after renegotiation) Use of Connection ID has been negotiated" \
1682 -S "(after renegotiation) Use of Connection ID has been negotiated"
1683
1684requires_config_enabled MBEDTLS_SSL_CID
1685requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
1686run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01001687 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
1688 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
1689 0 \
1690 -S "(initial handshake) Use of Connection ID has been negotiated" \
1691 -C "(initial handshake) Use of Connection ID has been negotiated" \
1692 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1693 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1694 -c "(after renegotiation) Use of Connection ID has been negotiated" \
1695 -s "(after renegotiation) Use of Connection ID has been negotiated"
1696
1697requires_config_enabled MBEDTLS_SSL_CID
1698requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01001699run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
1700 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5" \
1701 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
1702 "$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" \
1703 0 \
1704 -S "(initial handshake) Use of Connection ID has been negotiated" \
1705 -C "(initial handshake) Use of Connection ID has been negotiated" \
1706 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1707 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1708 -c "(after renegotiation) Use of Connection ID has been negotiated" \
1709 -s "(after renegotiation) Use of Connection ID has been negotiated"
1710
1711requires_config_enabled MBEDTLS_SSL_CID
1712requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
1713run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01001714 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
1715 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
1716 0 \
1717 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1718 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1719 -s "(initial handshake) Use of Connection ID has been negotiated" \
1720 -c "(initial handshake) Use of Connection ID has been negotiated" \
1721 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1722 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1723 -C "(after renegotiation) Use of Connection ID has been negotiated" \
1724 -S "(after renegotiation) Use of Connection ID has been negotiated" \
1725 -s "(after renegotiation) Use of Connection ID was not offered by client"
1726
1727requires_config_enabled MBEDTLS_SSL_CID
1728requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01001729run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
1730 -p "$P_PXY drop=5 delay=5 duplicate=5" \
1731 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
1732 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
1733 0 \
1734 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1735 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1736 -s "(initial handshake) Use of Connection ID has been negotiated" \
1737 -c "(initial handshake) Use of Connection ID has been negotiated" \
1738 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1739 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1740 -C "(after renegotiation) Use of Connection ID has been negotiated" \
1741 -S "(after renegotiation) Use of Connection ID has been negotiated" \
1742 -s "(after renegotiation) Use of Connection ID was not offered by client"
1743
1744requires_config_enabled MBEDTLS_SSL_CID
1745requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
1746run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
1747 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
1748 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
1749 0 \
1750 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1751 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1752 -s "(initial handshake) Use of Connection ID has been negotiated" \
1753 -c "(initial handshake) Use of Connection ID has been negotiated" \
1754 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1755 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1756 -C "(after renegotiation) Use of Connection ID has been negotiated" \
1757 -S "(after renegotiation) Use of Connection ID has been negotiated" \
1758 -c "(after renegotiation) Use of Connection ID was rejected by the server"
1759
1760requires_config_enabled MBEDTLS_SSL_CID
1761requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
1762run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
1763 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01001764 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
1765 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
1766 0 \
1767 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1768 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1769 -s "(initial handshake) Use of Connection ID has been negotiated" \
1770 -c "(initial handshake) Use of Connection ID has been negotiated" \
1771 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1772 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1773 -C "(after renegotiation) Use of Connection ID has been negotiated" \
1774 -S "(after renegotiation) Use of Connection ID has been negotiated" \
1775 -c "(after renegotiation) Use of Connection ID was rejected by the server"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001776
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001777# Tests for Encrypt-then-MAC extension
1778
1779run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001780 "$P_SRV debug_level=3 \
1781 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001782 "$P_CLI debug_level=3" \
1783 0 \
1784 -c "client hello, adding encrypt_then_mac extension" \
1785 -s "found encrypt then mac extension" \
1786 -s "server hello, adding encrypt then mac extension" \
1787 -c "found encrypt_then_mac extension" \
1788 -c "using encrypt then mac" \
1789 -s "using encrypt then mac"
1790
1791run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001792 "$P_SRV debug_level=3 etm=0 \
1793 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001794 "$P_CLI debug_level=3 etm=1" \
1795 0 \
1796 -c "client hello, adding encrypt_then_mac extension" \
1797 -s "found encrypt then mac extension" \
1798 -S "server hello, adding encrypt then mac extension" \
1799 -C "found encrypt_then_mac extension" \
1800 -C "using encrypt then mac" \
1801 -S "using encrypt then mac"
1802
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001803run_test "Encrypt then MAC: client enabled, aead cipher" \
1804 "$P_SRV debug_level=3 etm=1 \
1805 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1806 "$P_CLI debug_level=3 etm=1" \
1807 0 \
1808 -c "client hello, adding encrypt_then_mac extension" \
1809 -s "found encrypt then mac extension" \
1810 -S "server hello, adding encrypt then mac extension" \
1811 -C "found encrypt_then_mac extension" \
1812 -C "using encrypt then mac" \
1813 -S "using encrypt then mac"
1814
1815run_test "Encrypt then MAC: client enabled, stream cipher" \
1816 "$P_SRV debug_level=3 etm=1 \
1817 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001818 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001819 0 \
1820 -c "client hello, adding encrypt_then_mac extension" \
1821 -s "found encrypt then mac extension" \
1822 -S "server hello, adding encrypt then mac extension" \
1823 -C "found encrypt_then_mac extension" \
1824 -C "using encrypt then mac" \
1825 -S "using encrypt then mac"
1826
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001827run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001828 "$P_SRV debug_level=3 etm=1 \
1829 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001830 "$P_CLI debug_level=3 etm=0" \
1831 0 \
1832 -C "client hello, adding encrypt_then_mac extension" \
1833 -S "found encrypt then mac extension" \
1834 -S "server hello, adding encrypt then mac extension" \
1835 -C "found encrypt_then_mac extension" \
1836 -C "using encrypt then mac" \
1837 -S "using encrypt then mac"
1838
Janos Follathe2681a42016-03-07 15:57:05 +00001839requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001840run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001841 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001842 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001843 "$P_CLI debug_level=3 force_version=ssl3" \
1844 0 \
1845 -C "client hello, adding encrypt_then_mac extension" \
1846 -S "found encrypt then mac extension" \
1847 -S "server hello, adding encrypt then mac extension" \
1848 -C "found encrypt_then_mac extension" \
1849 -C "using encrypt then mac" \
1850 -S "using encrypt then mac"
1851
Janos Follathe2681a42016-03-07 15:57:05 +00001852requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001853run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001854 "$P_SRV debug_level=3 force_version=ssl3 \
1855 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001856 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001857 0 \
1858 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001859 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001860 -S "server hello, adding encrypt then mac extension" \
1861 -C "found encrypt_then_mac extension" \
1862 -C "using encrypt then mac" \
1863 -S "using encrypt then mac"
1864
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001865# Tests for Extended Master Secret extension
1866
1867run_test "Extended Master Secret: default" \
1868 "$P_SRV debug_level=3" \
1869 "$P_CLI debug_level=3" \
1870 0 \
1871 -c "client hello, adding extended_master_secret extension" \
1872 -s "found extended master secret extension" \
1873 -s "server hello, adding extended master secret extension" \
1874 -c "found extended_master_secret extension" \
1875 -c "using extended master secret" \
1876 -s "using extended master secret"
1877
1878run_test "Extended Master Secret: client enabled, server disabled" \
1879 "$P_SRV debug_level=3 extended_ms=0" \
1880 "$P_CLI debug_level=3 extended_ms=1" \
1881 0 \
1882 -c "client hello, adding extended_master_secret extension" \
1883 -s "found extended master secret extension" \
1884 -S "server hello, adding extended master secret extension" \
1885 -C "found extended_master_secret extension" \
1886 -C "using extended master secret" \
1887 -S "using extended master secret"
1888
1889run_test "Extended Master Secret: client disabled, server enabled" \
1890 "$P_SRV debug_level=3 extended_ms=1" \
1891 "$P_CLI debug_level=3 extended_ms=0" \
1892 0 \
1893 -C "client hello, adding extended_master_secret extension" \
1894 -S "found extended master secret extension" \
1895 -S "server hello, adding extended master secret extension" \
1896 -C "found extended_master_secret extension" \
1897 -C "using extended master secret" \
1898 -S "using extended master secret"
1899
Janos Follathe2681a42016-03-07 15:57:05 +00001900requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001901run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001902 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001903 "$P_CLI debug_level=3 force_version=ssl3" \
1904 0 \
1905 -C "client hello, adding extended_master_secret extension" \
1906 -S "found extended master secret extension" \
1907 -S "server hello, adding extended master secret extension" \
1908 -C "found extended_master_secret extension" \
1909 -C "using extended master secret" \
1910 -S "using extended master secret"
1911
Janos Follathe2681a42016-03-07 15:57:05 +00001912requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001913run_test "Extended Master Secret: client enabled, server SSLv3" \
1914 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001915 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001916 0 \
1917 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001918 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001919 -S "server hello, adding extended master secret extension" \
1920 -C "found extended_master_secret extension" \
1921 -C "using extended master secret" \
1922 -S "using extended master secret"
1923
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001924# Tests for FALLBACK_SCSV
1925
1926run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001927 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001928 "$P_CLI debug_level=3 force_version=tls1_1" \
1929 0 \
1930 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001931 -S "received FALLBACK_SCSV" \
1932 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001933 -C "is a fatal alert message (msg 86)"
1934
1935run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001936 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001937 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1938 0 \
1939 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001940 -S "received FALLBACK_SCSV" \
1941 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001942 -C "is a fatal alert message (msg 86)"
1943
1944run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001945 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001946 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001947 1 \
1948 -c "adding FALLBACK_SCSV" \
1949 -s "received FALLBACK_SCSV" \
1950 -s "inapropriate fallback" \
1951 -c "is a fatal alert message (msg 86)"
1952
1953run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001954 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001955 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001956 0 \
1957 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001958 -s "received FALLBACK_SCSV" \
1959 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001960 -C "is a fatal alert message (msg 86)"
1961
1962requires_openssl_with_fallback_scsv
1963run_test "Fallback SCSV: default, openssl server" \
1964 "$O_SRV" \
1965 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1966 0 \
1967 -C "adding FALLBACK_SCSV" \
1968 -C "is a fatal alert message (msg 86)"
1969
1970requires_openssl_with_fallback_scsv
1971run_test "Fallback SCSV: enabled, openssl server" \
1972 "$O_SRV" \
1973 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1974 1 \
1975 -c "adding FALLBACK_SCSV" \
1976 -c "is a fatal alert message (msg 86)"
1977
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001978requires_openssl_with_fallback_scsv
1979run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001980 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001981 "$O_CLI -tls1_1" \
1982 0 \
1983 -S "received FALLBACK_SCSV" \
1984 -S "inapropriate fallback"
1985
1986requires_openssl_with_fallback_scsv
1987run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001988 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001989 "$O_CLI -tls1_1 -fallback_scsv" \
1990 1 \
1991 -s "received FALLBACK_SCSV" \
1992 -s "inapropriate fallback"
1993
1994requires_openssl_with_fallback_scsv
1995run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001996 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001997 "$O_CLI -fallback_scsv" \
1998 0 \
1999 -s "received FALLBACK_SCSV" \
2000 -S "inapropriate fallback"
2001
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002002# Test sending and receiving empty application data records
2003
2004run_test "Encrypt then MAC: empty application data record" \
2005 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2006 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2007 0 \
2008 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2009 -s "dumping 'input payload after decrypt' (0 bytes)" \
2010 -c "0 bytes written in 1 fragments"
2011
2012run_test "Default, no Encrypt then MAC: empty application data record" \
2013 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2014 "$P_CLI auth_mode=none etm=0 request_size=0" \
2015 0 \
2016 -s "dumping 'input payload after decrypt' (0 bytes)" \
2017 -c "0 bytes written in 1 fragments"
2018
2019run_test "Encrypt then MAC, DTLS: empty application data record" \
2020 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2021 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2022 0 \
2023 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2024 -s "dumping 'input payload after decrypt' (0 bytes)" \
2025 -c "0 bytes written in 1 fragments"
2026
2027run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
2028 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2029 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2030 0 \
2031 -s "dumping 'input payload after decrypt' (0 bytes)" \
2032 -c "0 bytes written in 1 fragments"
2033
Gilles Peskined50177f2017-05-16 17:53:03 +02002034## ClientHello generated with
2035## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2036## then manually twiddling the ciphersuite list.
2037## The ClientHello content is spelled out below as a hex string as
2038## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2039## The expected response is an inappropriate_fallback alert.
2040requires_openssl_with_fallback_scsv
2041run_test "Fallback SCSV: beginning of list" \
2042 "$P_SRV debug_level=2" \
2043 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2044 0 \
2045 -s "received FALLBACK_SCSV" \
2046 -s "inapropriate fallback"
2047
2048requires_openssl_with_fallback_scsv
2049run_test "Fallback SCSV: end of list" \
2050 "$P_SRV debug_level=2" \
2051 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2052 0 \
2053 -s "received FALLBACK_SCSV" \
2054 -s "inapropriate fallback"
2055
2056## Here the expected response is a valid ServerHello prefix, up to the random.
2057requires_openssl_with_fallback_scsv
2058run_test "Fallback SCSV: not in list" \
2059 "$P_SRV debug_level=2" \
2060 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2061 0 \
2062 -S "received FALLBACK_SCSV" \
2063 -S "inapropriate fallback"
2064
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002065# Tests for CBC 1/n-1 record splitting
2066
2067run_test "CBC Record splitting: TLS 1.2, no splitting" \
2068 "$P_SRV" \
2069 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2070 request_size=123 force_version=tls1_2" \
2071 0 \
2072 -s "Read from client: 123 bytes read" \
2073 -S "Read from client: 1 bytes read" \
2074 -S "122 bytes read"
2075
2076run_test "CBC Record splitting: TLS 1.1, no splitting" \
2077 "$P_SRV" \
2078 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2079 request_size=123 force_version=tls1_1" \
2080 0 \
2081 -s "Read from client: 123 bytes read" \
2082 -S "Read from client: 1 bytes read" \
2083 -S "122 bytes read"
2084
2085run_test "CBC Record splitting: TLS 1.0, splitting" \
2086 "$P_SRV" \
2087 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2088 request_size=123 force_version=tls1" \
2089 0 \
2090 -S "Read from client: 123 bytes read" \
2091 -s "Read from client: 1 bytes read" \
2092 -s "122 bytes read"
2093
Janos Follathe2681a42016-03-07 15:57:05 +00002094requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002095run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002096 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002097 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2098 request_size=123 force_version=ssl3" \
2099 0 \
2100 -S "Read from client: 123 bytes read" \
2101 -s "Read from client: 1 bytes read" \
2102 -s "122 bytes read"
2103
2104run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002105 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002106 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2107 request_size=123 force_version=tls1" \
2108 0 \
2109 -s "Read from client: 123 bytes read" \
2110 -S "Read from client: 1 bytes read" \
2111 -S "122 bytes read"
2112
2113run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2114 "$P_SRV" \
2115 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2116 request_size=123 force_version=tls1 recsplit=0" \
2117 0 \
2118 -s "Read from client: 123 bytes read" \
2119 -S "Read from client: 1 bytes read" \
2120 -S "122 bytes read"
2121
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002122run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2123 "$P_SRV nbio=2" \
2124 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2125 request_size=123 force_version=tls1" \
2126 0 \
2127 -S "Read from client: 123 bytes read" \
2128 -s "Read from client: 1 bytes read" \
2129 -s "122 bytes read"
2130
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002131# Tests for Session Tickets
2132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002133run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002134 "$P_SRV debug_level=3 tickets=1" \
2135 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002136 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002137 -c "client hello, adding session ticket extension" \
2138 -s "found session ticket extension" \
2139 -s "server hello, adding session ticket extension" \
2140 -c "found session_ticket extension" \
2141 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002142 -S "session successfully restored from cache" \
2143 -s "session successfully restored from ticket" \
2144 -s "a session has been resumed" \
2145 -c "a session has been resumed"
2146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002147run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002148 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2149 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002150 0 \
2151 -c "client hello, adding session ticket extension" \
2152 -s "found session ticket extension" \
2153 -s "server hello, adding session ticket extension" \
2154 -c "found session_ticket extension" \
2155 -c "parse new session ticket" \
2156 -S "session successfully restored from cache" \
2157 -s "session successfully restored from ticket" \
2158 -s "a session has been resumed" \
2159 -c "a session has been resumed"
2160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002161run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002162 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2163 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002164 0 \
2165 -c "client hello, adding session ticket extension" \
2166 -s "found session ticket extension" \
2167 -s "server hello, adding session ticket extension" \
2168 -c "found session_ticket extension" \
2169 -c "parse new session ticket" \
2170 -S "session successfully restored from cache" \
2171 -S "session successfully restored from ticket" \
2172 -S "a session has been resumed" \
2173 -C "a session has been resumed"
2174
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002175run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002176 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002177 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002178 0 \
2179 -c "client hello, adding session ticket extension" \
2180 -c "found session_ticket extension" \
2181 -c "parse new session ticket" \
2182 -c "a session has been resumed"
2183
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002184run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002185 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002186 "( $O_CLI -sess_out $SESSION; \
2187 $O_CLI -sess_in $SESSION; \
2188 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002189 0 \
2190 -s "found session ticket extension" \
2191 -s "server hello, adding session ticket extension" \
2192 -S "session successfully restored from cache" \
2193 -s "session successfully restored from ticket" \
2194 -s "a session has been resumed"
2195
Hanno Becker1d739932018-08-21 13:55:22 +01002196# Tests for Session Tickets with DTLS
2197
2198run_test "Session resume using tickets, DTLS: basic" \
2199 "$P_SRV debug_level=3 dtls=1 tickets=1" \
2200 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2201 0 \
2202 -c "client hello, adding session ticket extension" \
2203 -s "found session ticket extension" \
2204 -s "server hello, adding session ticket extension" \
2205 -c "found session_ticket extension" \
2206 -c "parse new session ticket" \
2207 -S "session successfully restored from cache" \
2208 -s "session successfully restored from ticket" \
2209 -s "a session has been resumed" \
2210 -c "a session has been resumed"
2211
2212run_test "Session resume using tickets, DTLS: cache disabled" \
2213 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2214 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2215 0 \
2216 -c "client hello, adding session ticket extension" \
2217 -s "found session ticket extension" \
2218 -s "server hello, adding session ticket extension" \
2219 -c "found session_ticket extension" \
2220 -c "parse new session ticket" \
2221 -S "session successfully restored from cache" \
2222 -s "session successfully restored from ticket" \
2223 -s "a session has been resumed" \
2224 -c "a session has been resumed"
2225
2226run_test "Session resume using tickets, DTLS: timeout" \
2227 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
2228 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_delay=2" \
2229 0 \
2230 -c "client hello, adding session ticket extension" \
2231 -s "found session ticket extension" \
2232 -s "server hello, adding session ticket extension" \
2233 -c "found session_ticket extension" \
2234 -c "parse new session ticket" \
2235 -S "session successfully restored from cache" \
2236 -S "session successfully restored from ticket" \
2237 -S "a session has been resumed" \
2238 -C "a session has been resumed"
2239
2240run_test "Session resume using tickets, DTLS: openssl server" \
2241 "$O_SRV -dtls1" \
2242 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2243 0 \
2244 -c "client hello, adding session ticket extension" \
2245 -c "found session_ticket extension" \
2246 -c "parse new session ticket" \
2247 -c "a session has been resumed"
2248
2249run_test "Session resume using tickets, DTLS: openssl client" \
2250 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2251 "( $O_CLI -dtls1 -sess_out $SESSION; \
2252 $O_CLI -dtls1 -sess_in $SESSION; \
2253 rm -f $SESSION )" \
2254 0 \
2255 -s "found session ticket extension" \
2256 -s "server hello, adding session ticket extension" \
2257 -S "session successfully restored from cache" \
2258 -s "session successfully restored from ticket" \
2259 -s "a session has been resumed"
2260
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002261# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002262
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002263run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002264 "$P_SRV debug_level=3 tickets=0" \
2265 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002266 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002267 -c "client hello, adding session ticket extension" \
2268 -s "found session ticket extension" \
2269 -S "server hello, adding session ticket extension" \
2270 -C "found session_ticket extension" \
2271 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002272 -s "session successfully restored from cache" \
2273 -S "session successfully restored from ticket" \
2274 -s "a session has been resumed" \
2275 -c "a session has been resumed"
2276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002277run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002278 "$P_SRV debug_level=3 tickets=1" \
2279 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002280 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002281 -C "client hello, adding session ticket extension" \
2282 -S "found session ticket extension" \
2283 -S "server hello, adding session ticket extension" \
2284 -C "found session_ticket extension" \
2285 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002286 -s "session successfully restored from cache" \
2287 -S "session successfully restored from ticket" \
2288 -s "a session has been resumed" \
2289 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002291run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002292 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2293 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002294 0 \
2295 -S "session successfully restored from cache" \
2296 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002297 -S "a session has been resumed" \
2298 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002300run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002301 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2302 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002303 0 \
2304 -s "session successfully restored from cache" \
2305 -S "session successfully restored from ticket" \
2306 -s "a session has been resumed" \
2307 -c "a session has been resumed"
2308
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002309run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002310 "$P_SRV debug_level=3 tickets=0" \
2311 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002312 0 \
2313 -s "session successfully restored from cache" \
2314 -S "session successfully restored from ticket" \
2315 -s "a session has been resumed" \
2316 -c "a session has been resumed"
2317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002318run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002319 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2320 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002321 0 \
2322 -S "session successfully restored from cache" \
2323 -S "session successfully restored from ticket" \
2324 -S "a session has been resumed" \
2325 -C "a session has been resumed"
2326
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002327run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002328 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2329 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002330 0 \
2331 -s "session successfully restored from cache" \
2332 -S "session successfully restored from ticket" \
2333 -s "a session has been resumed" \
2334 -c "a session has been resumed"
2335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002336run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002337 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002338 "( $O_CLI -sess_out $SESSION; \
2339 $O_CLI -sess_in $SESSION; \
2340 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002341 0 \
2342 -s "found session ticket extension" \
2343 -S "server hello, adding session ticket extension" \
2344 -s "session successfully restored from cache" \
2345 -S "session successfully restored from ticket" \
2346 -s "a session has been resumed"
2347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002348run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002349 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002350 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002351 0 \
2352 -C "found session_ticket extension" \
2353 -C "parse new session ticket" \
2354 -c "a session has been resumed"
2355
Hanno Becker1d739932018-08-21 13:55:22 +01002356# Tests for Session Resume based on session-ID and cache, DTLS
2357
2358run_test "Session resume using cache, DTLS: tickets enabled on client" \
2359 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2360 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2361 0 \
2362 -c "client hello, adding session ticket extension" \
2363 -s "found session ticket extension" \
2364 -S "server hello, adding session ticket extension" \
2365 -C "found session_ticket extension" \
2366 -C "parse new session ticket" \
2367 -s "session successfully restored from cache" \
2368 -S "session successfully restored from ticket" \
2369 -s "a session has been resumed" \
2370 -c "a session has been resumed"
2371
2372run_test "Session resume using cache, DTLS: tickets enabled on server" \
2373 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2374 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2375 0 \
2376 -C "client hello, adding session ticket extension" \
2377 -S "found session ticket extension" \
2378 -S "server hello, adding session ticket extension" \
2379 -C "found session_ticket extension" \
2380 -C "parse new session ticket" \
2381 -s "session successfully restored from cache" \
2382 -S "session successfully restored from ticket" \
2383 -s "a session has been resumed" \
2384 -c "a session has been resumed"
2385
2386run_test "Session resume using cache, DTLS: cache_max=0" \
2387 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
2388 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2389 0 \
2390 -S "session successfully restored from cache" \
2391 -S "session successfully restored from ticket" \
2392 -S "a session has been resumed" \
2393 -C "a session has been resumed"
2394
2395run_test "Session resume using cache, DTLS: cache_max=1" \
2396 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
2397 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2398 0 \
2399 -s "session successfully restored from cache" \
2400 -S "session successfully restored from ticket" \
2401 -s "a session has been resumed" \
2402 -c "a session has been resumed"
2403
2404run_test "Session resume using cache, DTLS: timeout > delay" \
2405 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2406 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
2407 0 \
2408 -s "session successfully restored from cache" \
2409 -S "session successfully restored from ticket" \
2410 -s "a session has been resumed" \
2411 -c "a session has been resumed"
2412
2413run_test "Session resume using cache, DTLS: timeout < delay" \
2414 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
2415 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2416 0 \
2417 -S "session successfully restored from cache" \
2418 -S "session successfully restored from ticket" \
2419 -S "a session has been resumed" \
2420 -C "a session has been resumed"
2421
2422run_test "Session resume using cache, DTLS: no timeout" \
2423 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
2424 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2425 0 \
2426 -s "session successfully restored from cache" \
2427 -S "session successfully restored from ticket" \
2428 -s "a session has been resumed" \
2429 -c "a session has been resumed"
2430
2431run_test "Session resume using cache, DTLS: openssl client" \
2432 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2433 "( $O_CLI -dtls1 -sess_out $SESSION; \
2434 $O_CLI -dtls1 -sess_in $SESSION; \
2435 rm -f $SESSION )" \
2436 0 \
2437 -s "found session ticket extension" \
2438 -S "server hello, adding session ticket extension" \
2439 -s "session successfully restored from cache" \
2440 -S "session successfully restored from ticket" \
2441 -s "a session has been resumed"
2442
2443run_test "Session resume using cache, DTLS: openssl server" \
2444 "$O_SRV -dtls1" \
2445 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2446 0 \
2447 -C "found session_ticket extension" \
2448 -C "parse new session ticket" \
2449 -c "a session has been resumed"
2450
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002451# Tests for Max Fragment Length extension
2452
Angus Grattonc4dd0732018-04-11 16:28:39 +10002453if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
2454 printf "${CONFIG_H} defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n"
Hanno Becker6428f8d2017-09-22 16:58:50 +01002455 exit 1
2456fi
2457
Angus Grattonc4dd0732018-04-11 16:28:39 +10002458if [ $MAX_CONTENT_LEN -ne 16384 ]; then
2459 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
2460fi
2461
Hanno Becker4aed27e2017-09-18 15:00:34 +01002462requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002463run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002464 "$P_SRV debug_level=3" \
2465 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002466 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002467 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
2468 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002469 -C "client hello, adding max_fragment_length extension" \
2470 -S "found max fragment length extension" \
2471 -S "server hello, max_fragment_length extension" \
2472 -C "found max_fragment_length extension"
2473
Hanno Becker4aed27e2017-09-18 15:00:34 +01002474requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002475run_test "Max fragment length: enabled, default, larger message" \
2476 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002477 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002478 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002479 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
2480 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002481 -C "client hello, adding max_fragment_length extension" \
2482 -S "found max fragment length extension" \
2483 -S "server hello, max_fragment_length extension" \
2484 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002485 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2486 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002487 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002488
2489requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2490run_test "Max fragment length, DTLS: enabled, default, larger message" \
2491 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002492 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002493 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002494 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
2495 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002496 -C "client hello, adding max_fragment_length extension" \
2497 -S "found max fragment length extension" \
2498 -S "server hello, max_fragment_length extension" \
2499 -C "found max_fragment_length extension" \
2500 -c "fragment larger than.*maximum "
2501
Angus Grattonc4dd0732018-04-11 16:28:39 +10002502# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
2503# (session fragment length will be 16384 regardless of mbedtls
2504# content length configuration.)
2505
Hanno Beckerc5266962017-09-18 15:01:50 +01002506requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2507run_test "Max fragment length: disabled, larger message" \
2508 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002509 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002510 0 \
2511 -C "Maximum fragment length is 16384" \
2512 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002513 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2514 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002515 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002516
2517requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2518run_test "Max fragment length DTLS: disabled, larger message" \
2519 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002520 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002521 1 \
2522 -C "Maximum fragment length is 16384" \
2523 -S "Maximum fragment length is 16384" \
2524 -c "fragment larger than.*maximum "
2525
2526requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002527run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002528 "$P_SRV debug_level=3" \
2529 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002530 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002531 -c "Maximum fragment length is 4096" \
2532 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002533 -c "client hello, adding max_fragment_length extension" \
2534 -s "found max fragment length extension" \
2535 -s "server hello, max_fragment_length extension" \
2536 -c "found max_fragment_length extension"
2537
Hanno Becker4aed27e2017-09-18 15:00:34 +01002538requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002539run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002540 "$P_SRV debug_level=3 max_frag_len=4096" \
2541 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002542 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002543 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002544 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002545 -C "client hello, adding max_fragment_length extension" \
2546 -S "found max fragment length extension" \
2547 -S "server hello, max_fragment_length extension" \
2548 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002549
Hanno Becker4aed27e2017-09-18 15:00:34 +01002550requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002551requires_gnutls
2552run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002553 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002554 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002555 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002556 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002557 -c "client hello, adding max_fragment_length extension" \
2558 -c "found max_fragment_length extension"
2559
Hanno Becker4aed27e2017-09-18 15:00:34 +01002560requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002561run_test "Max fragment length: client, message just fits" \
2562 "$P_SRV debug_level=3" \
2563 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
2564 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002565 -c "Maximum fragment length is 2048" \
2566 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002567 -c "client hello, adding max_fragment_length extension" \
2568 -s "found max fragment length extension" \
2569 -s "server hello, max_fragment_length extension" \
2570 -c "found max_fragment_length extension" \
2571 -c "2048 bytes written in 1 fragments" \
2572 -s "2048 bytes read"
2573
Hanno Becker4aed27e2017-09-18 15:00:34 +01002574requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002575run_test "Max fragment length: client, larger message" \
2576 "$P_SRV debug_level=3" \
2577 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2578 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002579 -c "Maximum fragment length is 2048" \
2580 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002581 -c "client hello, adding max_fragment_length extension" \
2582 -s "found max fragment length extension" \
2583 -s "server hello, max_fragment_length extension" \
2584 -c "found max_fragment_length extension" \
2585 -c "2345 bytes written in 2 fragments" \
2586 -s "2048 bytes read" \
2587 -s "297 bytes read"
2588
Hanno Becker4aed27e2017-09-18 15:00:34 +01002589requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002590run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002591 "$P_SRV debug_level=3 dtls=1" \
2592 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2593 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002594 -c "Maximum fragment length is 2048" \
2595 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002596 -c "client hello, adding max_fragment_length extension" \
2597 -s "found max fragment length extension" \
2598 -s "server hello, max_fragment_length extension" \
2599 -c "found max_fragment_length extension" \
2600 -c "fragment larger than.*maximum"
2601
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002602# Tests for renegotiation
2603
Hanno Becker6a243642017-10-12 15:18:45 +01002604# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002605run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002606 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002607 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002608 0 \
2609 -C "client hello, adding renegotiation extension" \
2610 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2611 -S "found renegotiation extension" \
2612 -s "server hello, secure renegotiation extension" \
2613 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002614 -C "=> renegotiate" \
2615 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002616 -S "write hello request"
2617
Hanno Becker6a243642017-10-12 15:18:45 +01002618requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002619run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002620 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002621 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002622 0 \
2623 -c "client hello, adding renegotiation extension" \
2624 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2625 -s "found renegotiation extension" \
2626 -s "server hello, secure renegotiation extension" \
2627 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002628 -c "=> renegotiate" \
2629 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002630 -S "write hello request"
2631
Hanno Becker6a243642017-10-12 15:18:45 +01002632requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002633run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002634 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002635 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002636 0 \
2637 -c "client hello, adding renegotiation extension" \
2638 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2639 -s "found renegotiation extension" \
2640 -s "server hello, secure renegotiation extension" \
2641 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002642 -c "=> renegotiate" \
2643 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002644 -s "write hello request"
2645
Janos Follathb0f148c2017-10-05 12:29:42 +01002646# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2647# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2648# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002649requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002650run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2651 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2652 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2653 0 \
2654 -c "client hello, adding renegotiation extension" \
2655 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2656 -s "found renegotiation extension" \
2657 -s "server hello, secure renegotiation extension" \
2658 -c "found renegotiation extension" \
2659 -c "=> renegotiate" \
2660 -s "=> renegotiate" \
2661 -S "write hello request" \
2662 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2663
2664# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2665# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2666# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002667requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002668run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2669 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2670 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2671 0 \
2672 -c "client hello, adding renegotiation extension" \
2673 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2674 -s "found renegotiation extension" \
2675 -s "server hello, secure renegotiation extension" \
2676 -c "found renegotiation extension" \
2677 -c "=> renegotiate" \
2678 -s "=> renegotiate" \
2679 -s "write hello request" \
2680 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2681
Hanno Becker6a243642017-10-12 15:18:45 +01002682requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002683run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002684 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002685 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002686 0 \
2687 -c "client hello, adding renegotiation extension" \
2688 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2689 -s "found renegotiation extension" \
2690 -s "server hello, secure renegotiation extension" \
2691 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002692 -c "=> renegotiate" \
2693 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002694 -s "write hello request"
2695
Hanno Becker6a243642017-10-12 15:18:45 +01002696requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002697run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002698 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002699 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002700 1 \
2701 -c "client hello, adding renegotiation extension" \
2702 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2703 -S "found renegotiation extension" \
2704 -s "server hello, secure renegotiation extension" \
2705 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002706 -c "=> renegotiate" \
2707 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002708 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002709 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002710 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002711
Hanno Becker6a243642017-10-12 15:18:45 +01002712requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002713run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002714 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002715 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002716 0 \
2717 -C "client hello, adding renegotiation extension" \
2718 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2719 -S "found renegotiation extension" \
2720 -s "server hello, secure renegotiation extension" \
2721 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002722 -C "=> renegotiate" \
2723 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002724 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002725 -S "SSL - An unexpected message was received from our peer" \
2726 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002727
Hanno Becker6a243642017-10-12 15:18:45 +01002728requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002729run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002730 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002731 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002732 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002733 0 \
2734 -C "client hello, adding renegotiation extension" \
2735 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2736 -S "found renegotiation extension" \
2737 -s "server hello, secure renegotiation extension" \
2738 -c "found renegotiation extension" \
2739 -C "=> renegotiate" \
2740 -S "=> renegotiate" \
2741 -s "write hello request" \
2742 -S "SSL - An unexpected message was received from our peer" \
2743 -S "failed"
2744
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002745# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002746requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002747run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002748 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002749 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002750 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002751 0 \
2752 -C "client hello, adding renegotiation extension" \
2753 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2754 -S "found renegotiation extension" \
2755 -s "server hello, secure renegotiation extension" \
2756 -c "found renegotiation extension" \
2757 -C "=> renegotiate" \
2758 -S "=> renegotiate" \
2759 -s "write hello request" \
2760 -S "SSL - An unexpected message was received from our peer" \
2761 -S "failed"
2762
Hanno Becker6a243642017-10-12 15:18:45 +01002763requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002764run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002765 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002766 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002767 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002768 0 \
2769 -C "client hello, adding renegotiation extension" \
2770 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2771 -S "found renegotiation extension" \
2772 -s "server hello, secure renegotiation extension" \
2773 -c "found renegotiation extension" \
2774 -C "=> renegotiate" \
2775 -S "=> renegotiate" \
2776 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002777 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002778
Hanno Becker6a243642017-10-12 15:18:45 +01002779requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002780run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002781 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002782 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002783 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002784 0 \
2785 -c "client hello, adding renegotiation extension" \
2786 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2787 -s "found renegotiation extension" \
2788 -s "server hello, secure renegotiation extension" \
2789 -c "found renegotiation extension" \
2790 -c "=> renegotiate" \
2791 -s "=> renegotiate" \
2792 -s "write hello request" \
2793 -S "SSL - An unexpected message was received from our peer" \
2794 -S "failed"
2795
Hanno Becker6a243642017-10-12 15:18:45 +01002796requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002797run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002798 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002799 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2800 0 \
2801 -C "client hello, adding renegotiation extension" \
2802 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2803 -S "found renegotiation extension" \
2804 -s "server hello, secure renegotiation extension" \
2805 -c "found renegotiation extension" \
2806 -S "record counter limit reached: renegotiate" \
2807 -C "=> renegotiate" \
2808 -S "=> renegotiate" \
2809 -S "write hello request" \
2810 -S "SSL - An unexpected message was received from our peer" \
2811 -S "failed"
2812
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002813# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002814requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002815run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002816 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002817 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002818 0 \
2819 -c "client hello, adding renegotiation extension" \
2820 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2821 -s "found renegotiation extension" \
2822 -s "server hello, secure renegotiation extension" \
2823 -c "found renegotiation extension" \
2824 -s "record counter limit reached: renegotiate" \
2825 -c "=> renegotiate" \
2826 -s "=> renegotiate" \
2827 -s "write hello request" \
2828 -S "SSL - An unexpected message was received from our peer" \
2829 -S "failed"
2830
Hanno Becker6a243642017-10-12 15:18:45 +01002831requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002832run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002833 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002834 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002835 0 \
2836 -c "client hello, adding renegotiation extension" \
2837 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2838 -s "found renegotiation extension" \
2839 -s "server hello, secure renegotiation extension" \
2840 -c "found renegotiation extension" \
2841 -s "record counter limit reached: renegotiate" \
2842 -c "=> renegotiate" \
2843 -s "=> renegotiate" \
2844 -s "write hello request" \
2845 -S "SSL - An unexpected message was received from our peer" \
2846 -S "failed"
2847
Hanno Becker6a243642017-10-12 15:18:45 +01002848requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002849run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002850 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002851 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2852 0 \
2853 -C "client hello, adding renegotiation extension" \
2854 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2855 -S "found renegotiation extension" \
2856 -s "server hello, secure renegotiation extension" \
2857 -c "found renegotiation extension" \
2858 -S "record counter limit reached: renegotiate" \
2859 -C "=> renegotiate" \
2860 -S "=> renegotiate" \
2861 -S "write hello request" \
2862 -S "SSL - An unexpected message was received from our peer" \
2863 -S "failed"
2864
Hanno Becker6a243642017-10-12 15:18:45 +01002865requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002866run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002867 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002868 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002869 0 \
2870 -c "client hello, adding renegotiation extension" \
2871 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2872 -s "found renegotiation extension" \
2873 -s "server hello, secure renegotiation extension" \
2874 -c "found renegotiation extension" \
2875 -c "=> renegotiate" \
2876 -s "=> renegotiate" \
2877 -S "write hello request"
2878
Hanno Becker6a243642017-10-12 15:18:45 +01002879requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002880run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002881 "$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 +02002882 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002883 0 \
2884 -c "client hello, adding renegotiation extension" \
2885 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2886 -s "found renegotiation extension" \
2887 -s "server hello, secure renegotiation extension" \
2888 -c "found renegotiation extension" \
2889 -c "=> renegotiate" \
2890 -s "=> renegotiate" \
2891 -s "write hello request"
2892
Hanno Becker6a243642017-10-12 15:18:45 +01002893requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002894run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002895 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002896 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002897 0 \
2898 -c "client hello, adding renegotiation extension" \
2899 -c "found renegotiation extension" \
2900 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002901 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002902 -C "error" \
2903 -c "HTTP/1.0 200 [Oo][Kk]"
2904
Paul Bakker539d9722015-02-08 16:18:35 +01002905requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002906requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002907run_test "Renegotiation: gnutls server strict, client-initiated" \
2908 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002909 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002910 0 \
2911 -c "client hello, adding renegotiation extension" \
2912 -c "found renegotiation extension" \
2913 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002914 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002915 -C "error" \
2916 -c "HTTP/1.0 200 [Oo][Kk]"
2917
Paul Bakker539d9722015-02-08 16:18:35 +01002918requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002919requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002920run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2921 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2922 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2923 1 \
2924 -c "client hello, adding renegotiation extension" \
2925 -C "found renegotiation extension" \
2926 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002927 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002928 -c "error" \
2929 -C "HTTP/1.0 200 [Oo][Kk]"
2930
Paul Bakker539d9722015-02-08 16:18:35 +01002931requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002932requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002933run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2934 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2935 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2936 allow_legacy=0" \
2937 1 \
2938 -c "client hello, adding renegotiation extension" \
2939 -C "found renegotiation extension" \
2940 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002941 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002942 -c "error" \
2943 -C "HTTP/1.0 200 [Oo][Kk]"
2944
Paul Bakker539d9722015-02-08 16:18:35 +01002945requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002946requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002947run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2948 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2949 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2950 allow_legacy=1" \
2951 0 \
2952 -c "client hello, adding renegotiation extension" \
2953 -C "found renegotiation extension" \
2954 -c "=> renegotiate" \
2955 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002956 -C "error" \
2957 -c "HTTP/1.0 200 [Oo][Kk]"
2958
Hanno Becker6a243642017-10-12 15:18:45 +01002959requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002960run_test "Renegotiation: DTLS, client-initiated" \
2961 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2962 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2963 0 \
2964 -c "client hello, adding renegotiation extension" \
2965 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2966 -s "found renegotiation extension" \
2967 -s "server hello, secure renegotiation extension" \
2968 -c "found renegotiation extension" \
2969 -c "=> renegotiate" \
2970 -s "=> renegotiate" \
2971 -S "write hello request"
2972
Hanno Becker6a243642017-10-12 15:18:45 +01002973requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002974run_test "Renegotiation: DTLS, server-initiated" \
2975 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002976 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2977 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002978 0 \
2979 -c "client hello, adding renegotiation extension" \
2980 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2981 -s "found renegotiation extension" \
2982 -s "server hello, secure renegotiation extension" \
2983 -c "found renegotiation extension" \
2984 -c "=> renegotiate" \
2985 -s "=> renegotiate" \
2986 -s "write hello request"
2987
Hanno Becker6a243642017-10-12 15:18:45 +01002988requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002989run_test "Renegotiation: DTLS, renego_period overflow" \
2990 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2991 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2992 0 \
2993 -c "client hello, adding renegotiation extension" \
2994 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2995 -s "found renegotiation extension" \
2996 -s "server hello, secure renegotiation extension" \
2997 -s "record counter limit reached: renegotiate" \
2998 -c "=> renegotiate" \
2999 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003000 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003001
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003002requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003003requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003004run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3005 "$G_SRV -u --mtu 4096" \
3006 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
3007 0 \
3008 -c "client hello, adding renegotiation extension" \
3009 -c "found renegotiation extension" \
3010 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003011 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003012 -C "error" \
3013 -s "Extra-header:"
3014
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003015# Test for the "secure renegotation" extension only (no actual renegotiation)
3016
Paul Bakker539d9722015-02-08 16:18:35 +01003017requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003018run_test "Renego ext: gnutls server strict, client default" \
3019 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
3020 "$P_CLI debug_level=3" \
3021 0 \
3022 -c "found renegotiation extension" \
3023 -C "error" \
3024 -c "HTTP/1.0 200 [Oo][Kk]"
3025
Paul Bakker539d9722015-02-08 16:18:35 +01003026requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003027run_test "Renego ext: gnutls server unsafe, client default" \
3028 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3029 "$P_CLI debug_level=3" \
3030 0 \
3031 -C "found renegotiation extension" \
3032 -C "error" \
3033 -c "HTTP/1.0 200 [Oo][Kk]"
3034
Paul Bakker539d9722015-02-08 16:18:35 +01003035requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003036run_test "Renego ext: gnutls server unsafe, client break legacy" \
3037 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3038 "$P_CLI debug_level=3 allow_legacy=-1" \
3039 1 \
3040 -C "found renegotiation extension" \
3041 -c "error" \
3042 -C "HTTP/1.0 200 [Oo][Kk]"
3043
Paul Bakker539d9722015-02-08 16:18:35 +01003044requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003045run_test "Renego ext: gnutls client strict, server default" \
3046 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003047 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003048 0 \
3049 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3050 -s "server hello, secure renegotiation extension"
3051
Paul Bakker539d9722015-02-08 16:18:35 +01003052requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003053run_test "Renego ext: gnutls client unsafe, server default" \
3054 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003055 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003056 0 \
3057 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3058 -S "server hello, secure renegotiation extension"
3059
Paul Bakker539d9722015-02-08 16:18:35 +01003060requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003061run_test "Renego ext: gnutls client unsafe, server break legacy" \
3062 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003063 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003064 1 \
3065 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3066 -S "server hello, secure renegotiation extension"
3067
Janos Follath0b242342016-02-17 10:11:21 +00003068# Tests for silently dropping trailing extra bytes in .der certificates
3069
3070requires_gnutls
3071run_test "DER format: no trailing bytes" \
3072 "$P_SRV crt_file=data_files/server5-der0.crt \
3073 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003074 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003075 0 \
3076 -c "Handshake was completed" \
3077
3078requires_gnutls
3079run_test "DER format: with a trailing zero byte" \
3080 "$P_SRV crt_file=data_files/server5-der1a.crt \
3081 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003082 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003083 0 \
3084 -c "Handshake was completed" \
3085
3086requires_gnutls
3087run_test "DER format: with a trailing random byte" \
3088 "$P_SRV crt_file=data_files/server5-der1b.crt \
3089 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003090 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003091 0 \
3092 -c "Handshake was completed" \
3093
3094requires_gnutls
3095run_test "DER format: with 2 trailing random bytes" \
3096 "$P_SRV crt_file=data_files/server5-der2.crt \
3097 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003098 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003099 0 \
3100 -c "Handshake was completed" \
3101
3102requires_gnutls
3103run_test "DER format: with 4 trailing random bytes" \
3104 "$P_SRV crt_file=data_files/server5-der4.crt \
3105 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003106 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003107 0 \
3108 -c "Handshake was completed" \
3109
3110requires_gnutls
3111run_test "DER format: with 8 trailing random bytes" \
3112 "$P_SRV crt_file=data_files/server5-der8.crt \
3113 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003114 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003115 0 \
3116 -c "Handshake was completed" \
3117
3118requires_gnutls
3119run_test "DER format: with 9 trailing random bytes" \
3120 "$P_SRV crt_file=data_files/server5-der9.crt \
3121 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003122 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003123 0 \
3124 -c "Handshake was completed" \
3125
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03003126# Tests for auth_mode, there are duplicated tests using ca callback for authentication
3127# When updating these tests, modify the matching authentication tests accordingly
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003129run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003130 "$P_SRV crt_file=data_files/server5-badsign.crt \
3131 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003132 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003133 1 \
3134 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003135 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003136 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003137 -c "X509 - Certificate verification failed"
3138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003139run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003140 "$P_SRV crt_file=data_files/server5-badsign.crt \
3141 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003142 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003143 0 \
3144 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003145 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003146 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003147 -C "X509 - Certificate verification failed"
3148
Hanno Beckere6706e62017-05-15 16:05:15 +01003149run_test "Authentication: server goodcert, client optional, no trusted CA" \
3150 "$P_SRV" \
3151 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3152 0 \
3153 -c "x509_verify_cert() returned" \
3154 -c "! The certificate is not correctly signed by the trusted CA" \
3155 -c "! Certificate verification flags"\
3156 -C "! mbedtls_ssl_handshake returned" \
3157 -C "X509 - Certificate verification failed" \
3158 -C "SSL - No CA Chain is set, but required to operate"
3159
3160run_test "Authentication: server goodcert, client required, no trusted CA" \
3161 "$P_SRV" \
3162 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3163 1 \
3164 -c "x509_verify_cert() returned" \
3165 -c "! The certificate is not correctly signed by the trusted CA" \
3166 -c "! Certificate verification flags"\
3167 -c "! mbedtls_ssl_handshake returned" \
3168 -c "SSL - No CA Chain is set, but required to operate"
3169
3170# The purpose of the next two tests is to test the client's behaviour when receiving a server
3171# certificate with an unsupported elliptic curve. This should usually not happen because
3172# the client informs the server about the supported curves - it does, though, in the
3173# corner case of a static ECDH suite, because the server doesn't check the curve on that
3174# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3175# different means to have the server ignoring the client's supported curve list.
3176
3177requires_config_enabled MBEDTLS_ECP_C
3178run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3179 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3180 crt_file=data_files/server5.ku-ka.crt" \
3181 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3182 1 \
3183 -c "bad certificate (EC key curve)"\
3184 -c "! Certificate verification flags"\
3185 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3186
3187requires_config_enabled MBEDTLS_ECP_C
3188run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3189 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3190 crt_file=data_files/server5.ku-ka.crt" \
3191 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3192 1 \
3193 -c "bad certificate (EC key curve)"\
3194 -c "! Certificate verification flags"\
3195 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003197run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003198 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003199 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003200 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003201 0 \
3202 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003203 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003204 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003205 -C "X509 - Certificate verification failed"
3206
Simon Butcher99000142016-10-13 17:21:01 +01003207run_test "Authentication: client SHA256, server required" \
3208 "$P_SRV auth_mode=required" \
3209 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3210 key_file=data_files/server6.key \
3211 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3212 0 \
3213 -c "Supported Signature Algorithm found: 4," \
3214 -c "Supported Signature Algorithm found: 5,"
3215
3216run_test "Authentication: client SHA384, server required" \
3217 "$P_SRV auth_mode=required" \
3218 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3219 key_file=data_files/server6.key \
3220 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3221 0 \
3222 -c "Supported Signature Algorithm found: 4," \
3223 -c "Supported Signature Algorithm found: 5,"
3224
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003225requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3226run_test "Authentication: client has no cert, server required (SSLv3)" \
3227 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3228 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3229 key_file=data_files/server5.key" \
3230 1 \
3231 -S "skip write certificate request" \
3232 -C "skip parse certificate request" \
3233 -c "got a certificate request" \
3234 -c "got no certificate to send" \
3235 -S "x509_verify_cert() returned" \
3236 -s "client has no certificate" \
3237 -s "! mbedtls_ssl_handshake returned" \
3238 -c "! mbedtls_ssl_handshake returned" \
3239 -s "No client certification received from the client, but required by the authentication mode"
3240
3241run_test "Authentication: client has no cert, server required (TLS)" \
3242 "$P_SRV debug_level=3 auth_mode=required" \
3243 "$P_CLI debug_level=3 crt_file=none \
3244 key_file=data_files/server5.key" \
3245 1 \
3246 -S "skip write certificate request" \
3247 -C "skip parse certificate request" \
3248 -c "got a certificate request" \
3249 -c "= write certificate$" \
3250 -C "skip write certificate$" \
3251 -S "x509_verify_cert() returned" \
3252 -s "client has no certificate" \
3253 -s "! mbedtls_ssl_handshake returned" \
3254 -c "! mbedtls_ssl_handshake returned" \
3255 -s "No client certification received from the client, but required by the authentication mode"
3256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003257run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003258 "$P_SRV debug_level=3 auth_mode=required" \
3259 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003260 key_file=data_files/server5.key" \
3261 1 \
3262 -S "skip write certificate request" \
3263 -C "skip parse certificate request" \
3264 -c "got a certificate request" \
3265 -C "skip write certificate" \
3266 -C "skip write certificate verify" \
3267 -S "skip parse certificate verify" \
3268 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003269 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003270 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003271 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003272 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003273 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003274# We don't check that the client receives the alert because it might
3275# detect that its write end of the connection is closed and abort
3276# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003277
Janos Follath89baba22017-04-10 14:34:35 +01003278run_test "Authentication: client cert not trusted, server required" \
3279 "$P_SRV debug_level=3 auth_mode=required" \
3280 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3281 key_file=data_files/server5.key" \
3282 1 \
3283 -S "skip write certificate request" \
3284 -C "skip parse certificate request" \
3285 -c "got a certificate request" \
3286 -C "skip write certificate" \
3287 -C "skip write certificate verify" \
3288 -S "skip parse certificate verify" \
3289 -s "x509_verify_cert() returned" \
3290 -s "! The certificate is not correctly signed by the trusted CA" \
3291 -s "! mbedtls_ssl_handshake returned" \
3292 -c "! mbedtls_ssl_handshake returned" \
3293 -s "X509 - Certificate verification failed"
3294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003295run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003296 "$P_SRV debug_level=3 auth_mode=optional" \
3297 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003298 key_file=data_files/server5.key" \
3299 0 \
3300 -S "skip write certificate request" \
3301 -C "skip parse certificate request" \
3302 -c "got a certificate request" \
3303 -C "skip write certificate" \
3304 -C "skip write certificate verify" \
3305 -S "skip parse certificate verify" \
3306 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003307 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003308 -S "! mbedtls_ssl_handshake returned" \
3309 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003310 -S "X509 - Certificate verification failed"
3311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003312run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003313 "$P_SRV debug_level=3 auth_mode=none" \
3314 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003315 key_file=data_files/server5.key" \
3316 0 \
3317 -s "skip write certificate request" \
3318 -C "skip parse certificate request" \
3319 -c "got no certificate request" \
3320 -c "skip write certificate" \
3321 -c "skip write certificate verify" \
3322 -s "skip parse certificate verify" \
3323 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003324 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003325 -S "! mbedtls_ssl_handshake returned" \
3326 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003327 -S "X509 - Certificate verification failed"
3328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003329run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003330 "$P_SRV debug_level=3 auth_mode=optional" \
3331 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003332 0 \
3333 -S "skip write certificate request" \
3334 -C "skip parse certificate request" \
3335 -c "got a certificate request" \
3336 -C "skip write certificate$" \
3337 -C "got no certificate to send" \
3338 -S "SSLv3 client has no certificate" \
3339 -c "skip write certificate verify" \
3340 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003341 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003342 -S "! mbedtls_ssl_handshake returned" \
3343 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003344 -S "X509 - Certificate verification failed"
3345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003346run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003347 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003348 "$O_CLI" \
3349 0 \
3350 -S "skip write certificate request" \
3351 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003352 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003353 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003354 -S "X509 - Certificate verification failed"
3355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003356run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003357 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003358 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003359 0 \
3360 -C "skip parse certificate request" \
3361 -c "got a certificate request" \
3362 -C "skip write certificate$" \
3363 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003364 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003365
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003366run_test "Authentication: client no cert, openssl server required" \
3367 "$O_SRV -Verify 10" \
3368 "$P_CLI debug_level=3 crt_file=none key_file=none" \
3369 1 \
3370 -C "skip parse certificate request" \
3371 -c "got a certificate request" \
3372 -C "skip write certificate$" \
3373 -c "skip write certificate verify" \
3374 -c "! mbedtls_ssl_handshake returned"
3375
Janos Follathe2681a42016-03-07 15:57:05 +00003376requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003377run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003378 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003379 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003380 0 \
3381 -S "skip write certificate request" \
3382 -C "skip parse certificate request" \
3383 -c "got a certificate request" \
3384 -C "skip write certificate$" \
3385 -c "skip write certificate verify" \
3386 -c "got no certificate to send" \
3387 -s "SSLv3 client has no certificate" \
3388 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003389 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003390 -S "! mbedtls_ssl_handshake returned" \
3391 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003392 -S "X509 - Certificate verification failed"
3393
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02003394# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
3395# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003396
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003397MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01003398MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003399
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003400if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01003401 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003402 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003403 printf "test value of ${MAX_IM_CA}. \n"
3404 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003405 printf "The tests assume this value and if it changes, the tests in this\n"
3406 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003407 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003408
3409 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003410fi
3411
Angus Grattonc4dd0732018-04-11 16:28:39 +10003412requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003413run_test "Authentication: server max_int chain, client default" \
3414 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
3415 key_file=data_files/dir-maxpath/09.key" \
3416 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
3417 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01003418 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003419
Angus Grattonc4dd0732018-04-11 16:28:39 +10003420requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003421run_test "Authentication: server max_int+1 chain, client default" \
3422 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3423 key_file=data_files/dir-maxpath/10.key" \
3424 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
3425 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01003426 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003427
Angus Grattonc4dd0732018-04-11 16:28:39 +10003428requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003429run_test "Authentication: server max_int+1 chain, client optional" \
3430 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3431 key_file=data_files/dir-maxpath/10.key" \
3432 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
3433 auth_mode=optional" \
3434 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01003435 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003436
Angus Grattonc4dd0732018-04-11 16:28:39 +10003437requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003438run_test "Authentication: server max_int+1 chain, client none" \
3439 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3440 key_file=data_files/dir-maxpath/10.key" \
3441 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
3442 auth_mode=none" \
3443 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01003444 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003445
Angus Grattonc4dd0732018-04-11 16:28:39 +10003446requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003447run_test "Authentication: client max_int+1 chain, server default" \
3448 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
3449 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
3450 key_file=data_files/dir-maxpath/10.key" \
3451 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01003452 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003453
Angus Grattonc4dd0732018-04-11 16:28:39 +10003454requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003455run_test "Authentication: client max_int+1 chain, server optional" \
3456 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
3457 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
3458 key_file=data_files/dir-maxpath/10.key" \
3459 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01003460 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003461
Angus Grattonc4dd0732018-04-11 16:28:39 +10003462requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003463run_test "Authentication: client max_int+1 chain, server required" \
3464 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
3465 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
3466 key_file=data_files/dir-maxpath/10.key" \
3467 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01003468 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003469
Angus Grattonc4dd0732018-04-11 16:28:39 +10003470requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003471run_test "Authentication: client max_int chain, server required" \
3472 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
3473 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
3474 key_file=data_files/dir-maxpath/09.key" \
3475 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01003476 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003477
Janos Follath89baba22017-04-10 14:34:35 +01003478# Tests for CA list in CertificateRequest messages
3479
3480run_test "Authentication: send CA list in CertificateRequest (default)" \
3481 "$P_SRV debug_level=3 auth_mode=required" \
3482 "$P_CLI crt_file=data_files/server6.crt \
3483 key_file=data_files/server6.key" \
3484 0 \
3485 -s "requested DN"
3486
3487run_test "Authentication: do not send CA list in CertificateRequest" \
3488 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
3489 "$P_CLI crt_file=data_files/server6.crt \
3490 key_file=data_files/server6.key" \
3491 0 \
3492 -S "requested DN"
3493
3494run_test "Authentication: send CA list in CertificateRequest, client self signed" \
3495 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
3496 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3497 key_file=data_files/server5.key" \
3498 1 \
3499 -S "requested DN" \
3500 -s "x509_verify_cert() returned" \
3501 -s "! The certificate is not correctly signed by the trusted CA" \
3502 -s "! mbedtls_ssl_handshake returned" \
3503 -c "! mbedtls_ssl_handshake returned" \
3504 -s "X509 - Certificate verification failed"
3505
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03003506# Tests for auth_mode, using CA callback, these are duplicated from the authentication tests
3507# When updating these tests, modify the matching authentication tests accordingly
Hanno Becker746aaf32019-03-28 15:25:23 +00003508
3509requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3510run_test "Authentication, CA callback: server badcert, client required" \
3511 "$P_SRV crt_file=data_files/server5-badsign.crt \
3512 key_file=data_files/server5.key" \
3513 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required" \
3514 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003515 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003516 -c "x509_verify_cert() returned" \
3517 -c "! The certificate is not correctly signed by the trusted CA" \
3518 -c "! mbedtls_ssl_handshake returned" \
3519 -c "X509 - Certificate verification failed"
3520
3521requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3522run_test "Authentication, CA callback: server badcert, client optional" \
3523 "$P_SRV crt_file=data_files/server5-badsign.crt \
3524 key_file=data_files/server5.key" \
3525 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional" \
3526 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003527 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003528 -c "x509_verify_cert() returned" \
3529 -c "! The certificate is not correctly signed by the trusted CA" \
3530 -C "! mbedtls_ssl_handshake returned" \
3531 -C "X509 - Certificate verification failed"
3532
3533# The purpose of the next two tests is to test the client's behaviour when receiving a server
3534# certificate with an unsupported elliptic curve. This should usually not happen because
3535# the client informs the server about the supported curves - it does, though, in the
3536# corner case of a static ECDH suite, because the server doesn't check the curve on that
3537# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3538# different means to have the server ignoring the client's supported curve list.
3539
3540requires_config_enabled MBEDTLS_ECP_C
3541requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3542run_test "Authentication, CA callback: server ECDH p256v1, client required, p256v1 unsupported" \
3543 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3544 crt_file=data_files/server5.ku-ka.crt" \
3545 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required curves=secp521r1" \
3546 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003547 -c "use CA callback for X.509 CRT verification" \
3548 -c "bad certificate (EC key curve)" \
3549 -c "! Certificate verification flags" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003550 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3551
3552requires_config_enabled MBEDTLS_ECP_C
3553requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3554run_test "Authentication, CA callback: server ECDH p256v1, client optional, p256v1 unsupported" \
3555 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3556 crt_file=data_files/server5.ku-ka.crt" \
3557 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional curves=secp521r1" \
3558 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003559 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003560 -c "bad certificate (EC key curve)"\
3561 -c "! Certificate verification flags"\
3562 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3563
3564requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3565run_test "Authentication, CA callback: client SHA256, server required" \
3566 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
3567 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3568 key_file=data_files/server6.key \
3569 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3570 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003571 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003572 -c "Supported Signature Algorithm found: 4," \
3573 -c "Supported Signature Algorithm found: 5,"
3574
3575requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3576run_test "Authentication, CA callback: client SHA384, server required" \
3577 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
3578 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3579 key_file=data_files/server6.key \
3580 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3581 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003582 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003583 -c "Supported Signature Algorithm found: 4," \
3584 -c "Supported Signature Algorithm found: 5,"
3585
3586requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3587run_test "Authentication, CA callback: client badcert, server required" \
3588 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
3589 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
3590 key_file=data_files/server5.key" \
3591 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003592 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003593 -S "skip write certificate request" \
3594 -C "skip parse certificate request" \
3595 -c "got a certificate request" \
3596 -C "skip write certificate" \
3597 -C "skip write certificate verify" \
3598 -S "skip parse certificate verify" \
3599 -s "x509_verify_cert() returned" \
3600 -s "! The certificate is not correctly signed by the trusted CA" \
3601 -s "! mbedtls_ssl_handshake returned" \
3602 -s "send alert level=2 message=48" \
3603 -c "! mbedtls_ssl_handshake returned" \
3604 -s "X509 - Certificate verification failed"
3605# We don't check that the client receives the alert because it might
3606# detect that its write end of the connection is closed and abort
3607# before reading the alert message.
3608
3609requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3610run_test "Authentication, CA callback: client cert not trusted, server required" \
3611 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
3612 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3613 key_file=data_files/server5.key" \
3614 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003615 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003616 -S "skip write certificate request" \
3617 -C "skip parse certificate request" \
3618 -c "got a certificate request" \
3619 -C "skip write certificate" \
3620 -C "skip write certificate verify" \
3621 -S "skip parse certificate verify" \
3622 -s "x509_verify_cert() returned" \
3623 -s "! The certificate is not correctly signed by the trusted CA" \
3624 -s "! mbedtls_ssl_handshake returned" \
3625 -c "! mbedtls_ssl_handshake returned" \
3626 -s "X509 - Certificate verification failed"
3627
3628requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3629run_test "Authentication, CA callback: client badcert, server optional" \
3630 "$P_SRV ca_callback=1 debug_level=3 auth_mode=optional" \
3631 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
3632 key_file=data_files/server5.key" \
3633 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003634 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003635 -S "skip write certificate request" \
3636 -C "skip parse certificate request" \
3637 -c "got a certificate request" \
3638 -C "skip write certificate" \
3639 -C "skip write certificate verify" \
3640 -S "skip parse certificate verify" \
3641 -s "x509_verify_cert() returned" \
3642 -s "! The certificate is not correctly signed by the trusted CA" \
3643 -S "! mbedtls_ssl_handshake returned" \
3644 -C "! mbedtls_ssl_handshake returned" \
3645 -S "X509 - Certificate verification failed"
3646
3647requires_full_size_output_buffer
3648requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3649run_test "Authentication, CA callback: server max_int chain, client default" \
3650 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
3651 key_file=data_files/dir-maxpath/09.key" \
3652 "$P_CLI ca_callback=1 debug_level=3 server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
3653 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003654 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003655 -C "X509 - A fatal error occurred"
3656
3657requires_full_size_output_buffer
3658requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3659run_test "Authentication, CA callback: server max_int+1 chain, client default" \
3660 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3661 key_file=data_files/dir-maxpath/10.key" \
3662 "$P_CLI debug_level=3 ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
3663 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003664 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003665 -c "X509 - A fatal error occurred"
3666
3667requires_full_size_output_buffer
3668requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3669run_test "Authentication, CA callback: server max_int+1 chain, client optional" \
3670 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3671 key_file=data_files/dir-maxpath/10.key" \
3672 "$P_CLI ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
3673 debug_level=3 auth_mode=optional" \
3674 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003675 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003676 -c "X509 - A fatal error occurred"
3677
3678requires_full_size_output_buffer
3679requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3680run_test "Authentication, CA callback: client max_int+1 chain, server optional" \
3681 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
3682 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
3683 key_file=data_files/dir-maxpath/10.key" \
3684 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003685 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003686 -s "X509 - A fatal error occurred"
3687
3688requires_full_size_output_buffer
3689requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3690run_test "Authentication, CA callback: client max_int+1 chain, server required" \
3691 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
3692 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
3693 key_file=data_files/dir-maxpath/10.key" \
3694 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003695 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003696 -s "X509 - A fatal error occurred"
3697
3698requires_full_size_output_buffer
3699requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
3700run_test "Authentication, CA callback: client max_int chain, server required" \
3701 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
3702 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
3703 key_file=data_files/dir-maxpath/09.key" \
3704 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01003705 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00003706 -S "X509 - A fatal error occurred"
3707
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01003708# Tests for certificate selection based on SHA verson
3709
3710run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
3711 "$P_SRV crt_file=data_files/server5.crt \
3712 key_file=data_files/server5.key \
3713 crt_file2=data_files/server5-sha1.crt \
3714 key_file2=data_files/server5.key" \
3715 "$P_CLI force_version=tls1_2" \
3716 0 \
3717 -c "signed using.*ECDSA with SHA256" \
3718 -C "signed using.*ECDSA with SHA1"
3719
3720run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
3721 "$P_SRV crt_file=data_files/server5.crt \
3722 key_file=data_files/server5.key \
3723 crt_file2=data_files/server5-sha1.crt \
3724 key_file2=data_files/server5.key" \
3725 "$P_CLI force_version=tls1_1" \
3726 0 \
3727 -C "signed using.*ECDSA with SHA256" \
3728 -c "signed using.*ECDSA with SHA1"
3729
3730run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
3731 "$P_SRV crt_file=data_files/server5.crt \
3732 key_file=data_files/server5.key \
3733 crt_file2=data_files/server5-sha1.crt \
3734 key_file2=data_files/server5.key" \
3735 "$P_CLI force_version=tls1" \
3736 0 \
3737 -C "signed using.*ECDSA with SHA256" \
3738 -c "signed using.*ECDSA with SHA1"
3739
3740run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
3741 "$P_SRV crt_file=data_files/server5.crt \
3742 key_file=data_files/server5.key \
3743 crt_file2=data_files/server6.crt \
3744 key_file2=data_files/server6.key" \
3745 "$P_CLI force_version=tls1_1" \
3746 0 \
3747 -c "serial number.*09" \
3748 -c "signed using.*ECDSA with SHA256" \
3749 -C "signed using.*ECDSA with SHA1"
3750
3751run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
3752 "$P_SRV crt_file=data_files/server6.crt \
3753 key_file=data_files/server6.key \
3754 crt_file2=data_files/server5.crt \
3755 key_file2=data_files/server5.key" \
3756 "$P_CLI force_version=tls1_1" \
3757 0 \
3758 -c "serial number.*0A" \
3759 -c "signed using.*ECDSA with SHA256" \
3760 -C "signed using.*ECDSA with SHA1"
3761
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003762# tests for SNI
3763
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003764run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003765 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003766 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003767 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003768 0 \
3769 -S "parse ServerName extension" \
3770 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3771 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003773run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003774 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003775 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003776 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 +02003777 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003778 0 \
3779 -s "parse ServerName extension" \
3780 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3781 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003783run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003784 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003785 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003786 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 +02003787 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003788 0 \
3789 -s "parse ServerName extension" \
3790 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3791 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003793run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003794 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003795 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003796 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 +02003797 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003798 1 \
3799 -s "parse ServerName extension" \
3800 -s "ssl_sni_wrapper() returned" \
3801 -s "mbedtls_ssl_handshake returned" \
3802 -c "mbedtls_ssl_handshake returned" \
3803 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003804
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003805run_test "SNI: client auth no override: optional" \
3806 "$P_SRV debug_level=3 auth_mode=optional \
3807 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3808 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3809 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003810 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003811 -S "skip write certificate request" \
3812 -C "skip parse certificate request" \
3813 -c "got a certificate request" \
3814 -C "skip write certificate" \
3815 -C "skip write certificate verify" \
3816 -S "skip parse certificate verify"
3817
3818run_test "SNI: client auth override: none -> optional" \
3819 "$P_SRV debug_level=3 auth_mode=none \
3820 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3821 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3822 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003823 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003824 -S "skip write certificate request" \
3825 -C "skip parse certificate request" \
3826 -c "got a certificate request" \
3827 -C "skip write certificate" \
3828 -C "skip write certificate verify" \
3829 -S "skip parse certificate verify"
3830
3831run_test "SNI: client auth override: optional -> none" \
3832 "$P_SRV debug_level=3 auth_mode=optional \
3833 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3834 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3835 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003836 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003837 -s "skip write certificate request" \
3838 -C "skip parse certificate request" \
3839 -c "got no certificate request" \
3840 -c "skip write certificate" \
3841 -c "skip write certificate verify" \
3842 -s "skip parse certificate verify"
3843
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003844run_test "SNI: CA no override" \
3845 "$P_SRV debug_level=3 auth_mode=optional \
3846 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3847 ca_file=data_files/test-ca.crt \
3848 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3849 "$P_CLI debug_level=3 server_name=localhost \
3850 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3851 1 \
3852 -S "skip write certificate request" \
3853 -C "skip parse certificate request" \
3854 -c "got a certificate request" \
3855 -C "skip write certificate" \
3856 -C "skip write certificate verify" \
3857 -S "skip parse certificate verify" \
3858 -s "x509_verify_cert() returned" \
3859 -s "! The certificate is not correctly signed by the trusted CA" \
3860 -S "The certificate has been revoked (is on a CRL)"
3861
3862run_test "SNI: CA override" \
3863 "$P_SRV debug_level=3 auth_mode=optional \
3864 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3865 ca_file=data_files/test-ca.crt \
3866 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3867 "$P_CLI debug_level=3 server_name=localhost \
3868 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3869 0 \
3870 -S "skip write certificate request" \
3871 -C "skip parse certificate request" \
3872 -c "got a certificate request" \
3873 -C "skip write certificate" \
3874 -C "skip write certificate verify" \
3875 -S "skip parse certificate verify" \
3876 -S "x509_verify_cert() returned" \
3877 -S "! The certificate is not correctly signed by the trusted CA" \
3878 -S "The certificate has been revoked (is on a CRL)"
3879
3880run_test "SNI: CA override with CRL" \
3881 "$P_SRV debug_level=3 auth_mode=optional \
3882 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3883 ca_file=data_files/test-ca.crt \
3884 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3885 "$P_CLI debug_level=3 server_name=localhost \
3886 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3887 1 \
3888 -S "skip write certificate request" \
3889 -C "skip parse certificate request" \
3890 -c "got a certificate request" \
3891 -C "skip write certificate" \
3892 -C "skip write certificate verify" \
3893 -S "skip parse certificate verify" \
3894 -s "x509_verify_cert() returned" \
3895 -S "! The certificate is not correctly signed by the trusted CA" \
3896 -s "The certificate has been revoked (is on a CRL)"
3897
Andres AG1a834452016-12-07 10:01:30 +00003898# Tests for SNI and DTLS
3899
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003900run_test "SNI: DTLS, no SNI callback" \
3901 "$P_SRV debug_level=3 dtls=1 \
3902 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3903 "$P_CLI server_name=localhost dtls=1" \
3904 0 \
3905 -S "parse ServerName extension" \
3906 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3907 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3908
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003909run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003910 "$P_SRV debug_level=3 dtls=1 \
3911 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3912 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3913 "$P_CLI server_name=localhost dtls=1" \
3914 0 \
3915 -s "parse ServerName extension" \
3916 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3917 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3918
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003919run_test "SNI: DTLS, matching cert 2" \
3920 "$P_SRV debug_level=3 dtls=1 \
3921 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3922 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3923 "$P_CLI server_name=polarssl.example dtls=1" \
3924 0 \
3925 -s "parse ServerName extension" \
3926 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3927 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3928
3929run_test "SNI: DTLS, no matching cert" \
3930 "$P_SRV debug_level=3 dtls=1 \
3931 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3932 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3933 "$P_CLI server_name=nonesuch.example dtls=1" \
3934 1 \
3935 -s "parse ServerName extension" \
3936 -s "ssl_sni_wrapper() returned" \
3937 -s "mbedtls_ssl_handshake returned" \
3938 -c "mbedtls_ssl_handshake returned" \
3939 -c "SSL - A fatal alert message was received from our peer"
3940
3941run_test "SNI: DTLS, client auth no override: optional" \
3942 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3943 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3944 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3945 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3946 0 \
3947 -S "skip write certificate request" \
3948 -C "skip parse certificate request" \
3949 -c "got a certificate request" \
3950 -C "skip write certificate" \
3951 -C "skip write certificate verify" \
3952 -S "skip parse certificate verify"
3953
3954run_test "SNI: DTLS, client auth override: none -> optional" \
3955 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3956 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3957 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3958 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3959 0 \
3960 -S "skip write certificate request" \
3961 -C "skip parse certificate request" \
3962 -c "got a certificate request" \
3963 -C "skip write certificate" \
3964 -C "skip write certificate verify" \
3965 -S "skip parse certificate verify"
3966
3967run_test "SNI: DTLS, client auth override: optional -> none" \
3968 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3969 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3970 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3971 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3972 0 \
3973 -s "skip write certificate request" \
3974 -C "skip parse certificate request" \
3975 -c "got no certificate request" \
3976 -c "skip write certificate" \
3977 -c "skip write certificate verify" \
3978 -s "skip parse certificate verify"
3979
3980run_test "SNI: DTLS, CA no override" \
3981 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3982 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3983 ca_file=data_files/test-ca.crt \
3984 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3985 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3986 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3987 1 \
3988 -S "skip write certificate request" \
3989 -C "skip parse certificate request" \
3990 -c "got a certificate request" \
3991 -C "skip write certificate" \
3992 -C "skip write certificate verify" \
3993 -S "skip parse certificate verify" \
3994 -s "x509_verify_cert() returned" \
3995 -s "! The certificate is not correctly signed by the trusted CA" \
3996 -S "The certificate has been revoked (is on a CRL)"
3997
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003998run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003999 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4000 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4001 ca_file=data_files/test-ca.crt \
4002 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4003 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4004 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4005 0 \
4006 -S "skip write certificate request" \
4007 -C "skip parse certificate request" \
4008 -c "got a certificate request" \
4009 -C "skip write certificate" \
4010 -C "skip write certificate verify" \
4011 -S "skip parse certificate verify" \
4012 -S "x509_verify_cert() returned" \
4013 -S "! The certificate is not correctly signed by the trusted CA" \
4014 -S "The certificate has been revoked (is on a CRL)"
4015
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004016run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004017 "$P_SRV debug_level=3 auth_mode=optional \
4018 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4019 ca_file=data_files/test-ca.crt \
4020 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4021 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4022 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4023 1 \
4024 -S "skip write certificate request" \
4025 -C "skip parse certificate request" \
4026 -c "got a certificate request" \
4027 -C "skip write certificate" \
4028 -C "skip write certificate verify" \
4029 -S "skip parse certificate verify" \
4030 -s "x509_verify_cert() returned" \
4031 -S "! The certificate is not correctly signed by the trusted CA" \
4032 -s "The certificate has been revoked (is on a CRL)"
4033
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004034# Tests for non-blocking I/O: exercise a variety of handshake flows
4035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004036run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004037 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4038 "$P_CLI nbio=2 tickets=0" \
4039 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004040 -S "mbedtls_ssl_handshake returned" \
4041 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004042 -c "Read from server: .* bytes read"
4043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004044run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004045 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4046 "$P_CLI nbio=2 tickets=0" \
4047 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004048 -S "mbedtls_ssl_handshake returned" \
4049 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004050 -c "Read from server: .* bytes read"
4051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004052run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004053 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4054 "$P_CLI nbio=2 tickets=1" \
4055 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004056 -S "mbedtls_ssl_handshake returned" \
4057 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004058 -c "Read from server: .* bytes read"
4059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004060run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004061 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4062 "$P_CLI nbio=2 tickets=1" \
4063 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004064 -S "mbedtls_ssl_handshake returned" \
4065 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004066 -c "Read from server: .* bytes read"
4067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004068run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004069 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4070 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4071 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004072 -S "mbedtls_ssl_handshake returned" \
4073 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004074 -c "Read from server: .* bytes read"
4075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004076run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004077 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4078 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4079 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004080 -S "mbedtls_ssl_handshake returned" \
4081 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004082 -c "Read from server: .* bytes read"
4083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004084run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004085 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4086 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4087 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004088 -S "mbedtls_ssl_handshake returned" \
4089 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004090 -c "Read from server: .* bytes read"
4091
Hanno Becker00076712017-11-15 16:39:08 +00004092# Tests for event-driven I/O: exercise a variety of handshake flows
4093
4094run_test "Event-driven I/O: basic handshake" \
4095 "$P_SRV event=1 tickets=0 auth_mode=none" \
4096 "$P_CLI event=1 tickets=0" \
4097 0 \
4098 -S "mbedtls_ssl_handshake returned" \
4099 -C "mbedtls_ssl_handshake returned" \
4100 -c "Read from server: .* bytes read"
4101
4102run_test "Event-driven I/O: client auth" \
4103 "$P_SRV event=1 tickets=0 auth_mode=required" \
4104 "$P_CLI event=1 tickets=0" \
4105 0 \
4106 -S "mbedtls_ssl_handshake returned" \
4107 -C "mbedtls_ssl_handshake returned" \
4108 -c "Read from server: .* bytes read"
4109
4110run_test "Event-driven I/O: ticket" \
4111 "$P_SRV event=1 tickets=1 auth_mode=none" \
4112 "$P_CLI event=1 tickets=1" \
4113 0 \
4114 -S "mbedtls_ssl_handshake returned" \
4115 -C "mbedtls_ssl_handshake returned" \
4116 -c "Read from server: .* bytes read"
4117
4118run_test "Event-driven I/O: ticket + client auth" \
4119 "$P_SRV event=1 tickets=1 auth_mode=required" \
4120 "$P_CLI event=1 tickets=1" \
4121 0 \
4122 -S "mbedtls_ssl_handshake returned" \
4123 -C "mbedtls_ssl_handshake returned" \
4124 -c "Read from server: .* bytes read"
4125
4126run_test "Event-driven I/O: ticket + client auth + resume" \
4127 "$P_SRV event=1 tickets=1 auth_mode=required" \
4128 "$P_CLI event=1 tickets=1 reconnect=1" \
4129 0 \
4130 -S "mbedtls_ssl_handshake returned" \
4131 -C "mbedtls_ssl_handshake returned" \
4132 -c "Read from server: .* bytes read"
4133
4134run_test "Event-driven I/O: ticket + resume" \
4135 "$P_SRV event=1 tickets=1 auth_mode=none" \
4136 "$P_CLI event=1 tickets=1 reconnect=1" \
4137 0 \
4138 -S "mbedtls_ssl_handshake returned" \
4139 -C "mbedtls_ssl_handshake returned" \
4140 -c "Read from server: .* bytes read"
4141
4142run_test "Event-driven I/O: session-id resume" \
4143 "$P_SRV event=1 tickets=0 auth_mode=none" \
4144 "$P_CLI event=1 tickets=0 reconnect=1" \
4145 0 \
4146 -S "mbedtls_ssl_handshake returned" \
4147 -C "mbedtls_ssl_handshake returned" \
4148 -c "Read from server: .* bytes read"
4149
Hanno Becker6a33f592018-03-13 11:38:46 +00004150run_test "Event-driven I/O, DTLS: basic handshake" \
4151 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4152 "$P_CLI dtls=1 event=1 tickets=0" \
4153 0 \
4154 -c "Read from server: .* bytes read"
4155
4156run_test "Event-driven I/O, DTLS: client auth" \
4157 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4158 "$P_CLI dtls=1 event=1 tickets=0" \
4159 0 \
4160 -c "Read from server: .* bytes read"
4161
4162run_test "Event-driven I/O, DTLS: ticket" \
4163 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4164 "$P_CLI dtls=1 event=1 tickets=1" \
4165 0 \
4166 -c "Read from server: .* bytes read"
4167
4168run_test "Event-driven I/O, DTLS: ticket + client auth" \
4169 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4170 "$P_CLI dtls=1 event=1 tickets=1" \
4171 0 \
4172 -c "Read from server: .* bytes read"
4173
4174run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4175 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4176 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4177 0 \
4178 -c "Read from server: .* bytes read"
4179
4180run_test "Event-driven I/O, DTLS: ticket + resume" \
4181 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4182 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4183 0 \
4184 -c "Read from server: .* bytes read"
4185
4186run_test "Event-driven I/O, DTLS: session-id resume" \
4187 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4188 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4189 0 \
4190 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004191
4192# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4193# During session resumption, the client will send its ApplicationData record
4194# within the same datagram as the Finished messages. In this situation, the
4195# server MUST NOT idle on the underlying transport after handshake completion,
4196# because the ApplicationData request has already been queued internally.
4197run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004198 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004199 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4200 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4201 0 \
4202 -c "Read from server: .* bytes read"
4203
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004204# Tests for version negotiation
4205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004206run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004207 "$P_SRV" \
4208 "$P_CLI" \
4209 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004210 -S "mbedtls_ssl_handshake returned" \
4211 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004212 -s "Protocol is TLSv1.2" \
4213 -c "Protocol is TLSv1.2"
4214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004215run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004216 "$P_SRV" \
4217 "$P_CLI max_version=tls1_1" \
4218 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004219 -S "mbedtls_ssl_handshake returned" \
4220 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004221 -s "Protocol is TLSv1.1" \
4222 -c "Protocol is TLSv1.1"
4223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004224run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004225 "$P_SRV max_version=tls1_1" \
4226 "$P_CLI" \
4227 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004228 -S "mbedtls_ssl_handshake returned" \
4229 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004230 -s "Protocol is TLSv1.1" \
4231 -c "Protocol is TLSv1.1"
4232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004233run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004234 "$P_SRV max_version=tls1_1" \
4235 "$P_CLI max_version=tls1_1" \
4236 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004237 -S "mbedtls_ssl_handshake returned" \
4238 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004239 -s "Protocol is TLSv1.1" \
4240 -c "Protocol is TLSv1.1"
4241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004242run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004243 "$P_SRV min_version=tls1_1" \
4244 "$P_CLI max_version=tls1_1" \
4245 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004246 -S "mbedtls_ssl_handshake returned" \
4247 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004248 -s "Protocol is TLSv1.1" \
4249 -c "Protocol is TLSv1.1"
4250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004251run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004252 "$P_SRV max_version=tls1_1" \
4253 "$P_CLI min_version=tls1_1" \
4254 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004255 -S "mbedtls_ssl_handshake returned" \
4256 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004257 -s "Protocol is TLSv1.1" \
4258 -c "Protocol is TLSv1.1"
4259
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004260run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004261 "$P_SRV max_version=tls1_1" \
4262 "$P_CLI min_version=tls1_2" \
4263 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004264 -s "mbedtls_ssl_handshake returned" \
4265 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004266 -c "SSL - Handshake protocol not within min/max boundaries"
4267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004268run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004269 "$P_SRV min_version=tls1_2" \
4270 "$P_CLI max_version=tls1_1" \
4271 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004272 -s "mbedtls_ssl_handshake returned" \
4273 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004274 -s "SSL - Handshake protocol not within min/max boundaries"
4275
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004276# Tests for ALPN extension
4277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004278run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004279 "$P_SRV debug_level=3" \
4280 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004281 0 \
4282 -C "client hello, adding alpn extension" \
4283 -S "found alpn extension" \
4284 -C "got an alert message, type: \\[2:120]" \
4285 -S "server hello, adding alpn extension" \
4286 -C "found alpn extension " \
4287 -C "Application Layer Protocol is" \
4288 -S "Application Layer Protocol is"
4289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004290run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004291 "$P_SRV debug_level=3" \
4292 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004293 0 \
4294 -c "client hello, adding alpn extension" \
4295 -s "found alpn extension" \
4296 -C "got an alert message, type: \\[2:120]" \
4297 -S "server hello, adding alpn extension" \
4298 -C "found alpn extension " \
4299 -c "Application Layer Protocol is (none)" \
4300 -S "Application Layer Protocol is"
4301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004302run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004303 "$P_SRV debug_level=3 alpn=abc,1234" \
4304 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004305 0 \
4306 -C "client hello, adding alpn extension" \
4307 -S "found alpn extension" \
4308 -C "got an alert message, type: \\[2:120]" \
4309 -S "server hello, adding alpn extension" \
4310 -C "found alpn extension " \
4311 -C "Application Layer Protocol is" \
4312 -s "Application Layer Protocol is (none)"
4313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004314run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004315 "$P_SRV debug_level=3 alpn=abc,1234" \
4316 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004317 0 \
4318 -c "client hello, adding alpn extension" \
4319 -s "found alpn extension" \
4320 -C "got an alert message, type: \\[2:120]" \
4321 -s "server hello, adding alpn extension" \
4322 -c "found alpn extension" \
4323 -c "Application Layer Protocol is abc" \
4324 -s "Application Layer Protocol is abc"
4325
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004326run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004327 "$P_SRV debug_level=3 alpn=abc,1234" \
4328 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004329 0 \
4330 -c "client hello, adding alpn extension" \
4331 -s "found alpn extension" \
4332 -C "got an alert message, type: \\[2:120]" \
4333 -s "server hello, adding alpn extension" \
4334 -c "found alpn extension" \
4335 -c "Application Layer Protocol is abc" \
4336 -s "Application Layer Protocol is abc"
4337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004338run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004339 "$P_SRV debug_level=3 alpn=abc,1234" \
4340 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004341 0 \
4342 -c "client hello, adding alpn extension" \
4343 -s "found alpn extension" \
4344 -C "got an alert message, type: \\[2:120]" \
4345 -s "server hello, adding alpn extension" \
4346 -c "found alpn extension" \
4347 -c "Application Layer Protocol is 1234" \
4348 -s "Application Layer Protocol is 1234"
4349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004350run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004351 "$P_SRV debug_level=3 alpn=abc,123" \
4352 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004353 1 \
4354 -c "client hello, adding alpn extension" \
4355 -s "found alpn extension" \
4356 -c "got an alert message, type: \\[2:120]" \
4357 -S "server hello, adding alpn extension" \
4358 -C "found alpn extension" \
4359 -C "Application Layer Protocol is 1234" \
4360 -S "Application Layer Protocol is 1234"
4361
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02004362
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004363# Tests for keyUsage in leaf certificates, part 1:
4364# server-side certificate/suite selection
4365
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004366run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004367 "$P_SRV key_file=data_files/server2.key \
4368 crt_file=data_files/server2.ku-ds.crt" \
4369 "$P_CLI" \
4370 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02004371 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004372
4373
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004374run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004375 "$P_SRV key_file=data_files/server2.key \
4376 crt_file=data_files/server2.ku-ke.crt" \
4377 "$P_CLI" \
4378 0 \
4379 -c "Ciphersuite is TLS-RSA-WITH-"
4380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004381run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004382 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004383 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004384 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004385 1 \
4386 -C "Ciphersuite is "
4387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004388run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004389 "$P_SRV key_file=data_files/server5.key \
4390 crt_file=data_files/server5.ku-ds.crt" \
4391 "$P_CLI" \
4392 0 \
4393 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
4394
4395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004396run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004397 "$P_SRV key_file=data_files/server5.key \
4398 crt_file=data_files/server5.ku-ka.crt" \
4399 "$P_CLI" \
4400 0 \
4401 -c "Ciphersuite is TLS-ECDH-"
4402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004403run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004404 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004405 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004406 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004407 1 \
4408 -C "Ciphersuite is "
4409
4410# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004411# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004413run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004414 "$O_SRV -key data_files/server2.key \
4415 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004416 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004417 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4418 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004419 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004420 -C "Processing of the Certificate handshake message failed" \
4421 -c "Ciphersuite is TLS-"
4422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004423run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004424 "$O_SRV -key data_files/server2.key \
4425 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004426 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004427 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4428 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004429 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004430 -C "Processing of the Certificate handshake message failed" \
4431 -c "Ciphersuite is TLS-"
4432
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004433run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004434 "$O_SRV -key data_files/server2.key \
4435 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004436 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004437 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4438 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004439 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004440 -C "Processing of the Certificate handshake message failed" \
4441 -c "Ciphersuite is TLS-"
4442
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004443run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004444 "$O_SRV -key data_files/server2.key \
4445 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004446 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004447 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4448 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004449 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004450 -c "Processing of the Certificate handshake message failed" \
4451 -C "Ciphersuite is TLS-"
4452
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004453run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
4454 "$O_SRV -key data_files/server2.key \
4455 -cert data_files/server2.ku-ke.crt" \
4456 "$P_CLI debug_level=1 auth_mode=optional \
4457 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4458 0 \
4459 -c "bad certificate (usage extensions)" \
4460 -C "Processing of the Certificate handshake message failed" \
4461 -c "Ciphersuite is TLS-" \
4462 -c "! Usage does not match the keyUsage extension"
4463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004464run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004465 "$O_SRV -key data_files/server2.key \
4466 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004467 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004468 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4469 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004470 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004471 -C "Processing of the Certificate handshake message failed" \
4472 -c "Ciphersuite is TLS-"
4473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004474run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004475 "$O_SRV -key data_files/server2.key \
4476 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004477 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004478 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4479 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004480 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004481 -c "Processing of the Certificate handshake message failed" \
4482 -C "Ciphersuite is TLS-"
4483
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004484run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
4485 "$O_SRV -key data_files/server2.key \
4486 -cert data_files/server2.ku-ds.crt" \
4487 "$P_CLI debug_level=1 auth_mode=optional \
4488 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4489 0 \
4490 -c "bad certificate (usage extensions)" \
4491 -C "Processing of the Certificate handshake message failed" \
4492 -c "Ciphersuite is TLS-" \
4493 -c "! Usage does not match the keyUsage extension"
4494
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004495# Tests for keyUsage in leaf certificates, part 3:
4496# server-side checking of client cert
4497
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004498run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004499 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004500 "$O_CLI -key data_files/server2.key \
4501 -cert data_files/server2.ku-ds.crt" \
4502 0 \
4503 -S "bad certificate (usage extensions)" \
4504 -S "Processing of the Certificate handshake message failed"
4505
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004506run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004507 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004508 "$O_CLI -key data_files/server2.key \
4509 -cert data_files/server2.ku-ke.crt" \
4510 0 \
4511 -s "bad certificate (usage extensions)" \
4512 -S "Processing of the Certificate handshake message failed"
4513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004514run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004515 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004516 "$O_CLI -key data_files/server2.key \
4517 -cert data_files/server2.ku-ke.crt" \
4518 1 \
4519 -s "bad certificate (usage extensions)" \
4520 -s "Processing of the Certificate handshake message failed"
4521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004522run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004523 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004524 "$O_CLI -key data_files/server5.key \
4525 -cert data_files/server5.ku-ds.crt" \
4526 0 \
4527 -S "bad certificate (usage extensions)" \
4528 -S "Processing of the Certificate handshake message failed"
4529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004530run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004531 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004532 "$O_CLI -key data_files/server5.key \
4533 -cert data_files/server5.ku-ka.crt" \
4534 0 \
4535 -s "bad certificate (usage extensions)" \
4536 -S "Processing of the Certificate handshake message failed"
4537
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004538# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
4539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004540run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004541 "$P_SRV key_file=data_files/server5.key \
4542 crt_file=data_files/server5.eku-srv.crt" \
4543 "$P_CLI" \
4544 0
4545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004546run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004547 "$P_SRV key_file=data_files/server5.key \
4548 crt_file=data_files/server5.eku-srv.crt" \
4549 "$P_CLI" \
4550 0
4551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004552run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004553 "$P_SRV key_file=data_files/server5.key \
4554 crt_file=data_files/server5.eku-cs_any.crt" \
4555 "$P_CLI" \
4556 0
4557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004558run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02004559 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004560 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02004561 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004562 1
4563
4564# Tests for extendedKeyUsage, part 2: client-side checking of server cert
4565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004566run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004567 "$O_SRV -key data_files/server5.key \
4568 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004569 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004570 0 \
4571 -C "bad certificate (usage extensions)" \
4572 -C "Processing of the Certificate handshake message failed" \
4573 -c "Ciphersuite is TLS-"
4574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004575run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004576 "$O_SRV -key data_files/server5.key \
4577 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004578 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004579 0 \
4580 -C "bad certificate (usage extensions)" \
4581 -C "Processing of the Certificate handshake message failed" \
4582 -c "Ciphersuite is TLS-"
4583
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004584run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004585 "$O_SRV -key data_files/server5.key \
4586 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004587 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004588 0 \
4589 -C "bad certificate (usage extensions)" \
4590 -C "Processing of the Certificate handshake message failed" \
4591 -c "Ciphersuite is TLS-"
4592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004593run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004594 "$O_SRV -key data_files/server5.key \
4595 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004596 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004597 1 \
4598 -c "bad certificate (usage extensions)" \
4599 -c "Processing of the Certificate handshake message failed" \
4600 -C "Ciphersuite is TLS-"
4601
4602# Tests for extendedKeyUsage, part 3: server-side checking of client cert
4603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004604run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004605 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004606 "$O_CLI -key data_files/server5.key \
4607 -cert data_files/server5.eku-cli.crt" \
4608 0 \
4609 -S "bad certificate (usage extensions)" \
4610 -S "Processing of the Certificate handshake message failed"
4611
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004612run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004613 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004614 "$O_CLI -key data_files/server5.key \
4615 -cert data_files/server5.eku-srv_cli.crt" \
4616 0 \
4617 -S "bad certificate (usage extensions)" \
4618 -S "Processing of the Certificate handshake message failed"
4619
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004620run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004621 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004622 "$O_CLI -key data_files/server5.key \
4623 -cert data_files/server5.eku-cs_any.crt" \
4624 0 \
4625 -S "bad certificate (usage extensions)" \
4626 -S "Processing of the Certificate handshake message failed"
4627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004628run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004629 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004630 "$O_CLI -key data_files/server5.key \
4631 -cert data_files/server5.eku-cs.crt" \
4632 0 \
4633 -s "bad certificate (usage extensions)" \
4634 -S "Processing of the Certificate handshake message failed"
4635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004636run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004637 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004638 "$O_CLI -key data_files/server5.key \
4639 -cert data_files/server5.eku-cs.crt" \
4640 1 \
4641 -s "bad certificate (usage extensions)" \
4642 -s "Processing of the Certificate handshake message failed"
4643
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004644# Tests for DHM parameters loading
4645
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004646run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004647 "$P_SRV" \
4648 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4649 debug_level=3" \
4650 0 \
4651 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01004652 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004654run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004655 "$P_SRV dhm_file=data_files/dhparams.pem" \
4656 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4657 debug_level=3" \
4658 0 \
4659 -c "value of 'DHM: P ' (1024 bits)" \
4660 -c "value of 'DHM: G ' (2 bits)"
4661
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004662# Tests for DHM client-side size checking
4663
4664run_test "DHM size: server default, client default, OK" \
4665 "$P_SRV" \
4666 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4667 debug_level=1" \
4668 0 \
4669 -C "DHM prime too short:"
4670
4671run_test "DHM size: server default, client 2048, OK" \
4672 "$P_SRV" \
4673 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4674 debug_level=1 dhmlen=2048" \
4675 0 \
4676 -C "DHM prime too short:"
4677
4678run_test "DHM size: server 1024, client default, OK" \
4679 "$P_SRV dhm_file=data_files/dhparams.pem" \
4680 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4681 debug_level=1" \
4682 0 \
4683 -C "DHM prime too short:"
4684
4685run_test "DHM size: server 1000, client default, rejected" \
4686 "$P_SRV dhm_file=data_files/dh.1000.pem" \
4687 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4688 debug_level=1" \
4689 1 \
4690 -c "DHM prime too short:"
4691
4692run_test "DHM size: server default, client 2049, rejected" \
4693 "$P_SRV" \
4694 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4695 debug_level=1 dhmlen=2049" \
4696 1 \
4697 -c "DHM prime too short:"
4698
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004699# Tests for PSK callback
4700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004701run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004702 "$P_SRV psk=abc123 psk_identity=foo" \
4703 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4704 psk_identity=foo psk=abc123" \
4705 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004706 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004707 -S "SSL - Unknown identity received" \
4708 -S "SSL - Verification of the message MAC failed"
4709
Hanno Beckerf7027512018-10-23 15:27:39 +01004710requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4711run_test "PSK callback: opaque psk on client, no callback" \
4712 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
4713 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004714 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01004715 0 \
4716 -c "skip PMS generation for opaque PSK"\
4717 -S "skip PMS generation for opaque PSK"\
4718 -C "using extended master secret"\
4719 -S "using extended master secret"\
4720 -S "SSL - None of the common ciphersuites is usable" \
4721 -S "SSL - Unknown identity received" \
4722 -S "SSL - Verification of the message MAC failed"
4723
4724requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4725run_test "PSK callback: opaque psk on client, no callback, SHA-384" \
4726 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
4727 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004728 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01004729 0 \
4730 -c "skip PMS generation for opaque PSK"\
4731 -S "skip PMS generation for opaque PSK"\
4732 -C "using extended master secret"\
4733 -S "using extended master secret"\
4734 -S "SSL - None of the common ciphersuites is usable" \
4735 -S "SSL - Unknown identity received" \
4736 -S "SSL - Verification of the message MAC failed"
4737
4738requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4739run_test "PSK callback: opaque psk on client, no callback, EMS" \
4740 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
4741 "$P_CLI extended_ms=1 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004742 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01004743 0 \
4744 -c "skip PMS generation for opaque PSK"\
4745 -S "skip PMS generation for opaque PSK"\
4746 -c "using extended master secret"\
4747 -s "using extended master secret"\
4748 -S "SSL - None of the common ciphersuites is usable" \
4749 -S "SSL - Unknown identity received" \
4750 -S "SSL - Verification of the message MAC failed"
4751
4752requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4753run_test "PSK callback: opaque psk on client, no callback, SHA-384, EMS" \
4754 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
4755 "$P_CLI extended_ms=1 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004756 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01004757 0 \
4758 -c "skip PMS generation for opaque PSK"\
4759 -S "skip PMS generation for opaque PSK"\
4760 -c "using extended master secret"\
4761 -s "using extended master secret"\
4762 -S "SSL - None of the common ciphersuites is usable" \
4763 -S "SSL - Unknown identity received" \
4764 -S "SSL - Verification of the message MAC failed"
4765
Hanno Becker28c79dc2018-10-26 13:15:08 +01004766requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4767run_test "PSK callback: raw psk on client, static opaque on server, no callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004768 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01004769 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4770 psk_identity=foo psk=abc123" \
4771 0 \
4772 -C "skip PMS generation for opaque PSK"\
4773 -s "skip PMS generation for opaque PSK"\
4774 -C "using extended master secret"\
4775 -S "using extended master secret"\
4776 -S "SSL - None of the common ciphersuites is usable" \
4777 -S "SSL - Unknown identity received" \
4778 -S "SSL - Verification of the message MAC failed"
4779
4780requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4781run_test "PSK callback: raw psk on client, static opaque on server, no callback, SHA-384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004782 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01004783 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
4784 psk_identity=foo psk=abc123" \
4785 0 \
4786 -C "skip PMS generation for opaque PSK"\
4787 -s "skip PMS generation for opaque PSK"\
4788 -C "using extended master secret"\
4789 -S "using extended master secret"\
4790 -S "SSL - None of the common ciphersuites is usable" \
4791 -S "SSL - Unknown identity received" \
4792 -S "SSL - Verification of the message MAC failed"
4793
4794requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4795run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004796 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01004797 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
4798 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4799 psk_identity=foo psk=abc123 extended_ms=1" \
4800 0 \
4801 -c "using extended master secret"\
4802 -s "using extended master secret"\
4803 -C "skip PMS generation for opaque PSK"\
4804 -s "skip PMS generation for opaque PSK"\
4805 -S "SSL - None of the common ciphersuites is usable" \
4806 -S "SSL - Unknown identity received" \
4807 -S "SSL - Verification of the message MAC failed"
4808
4809requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4810run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS, SHA384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004811 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01004812 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
4813 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
4814 psk_identity=foo psk=abc123 extended_ms=1" \
4815 0 \
4816 -c "using extended master secret"\
4817 -s "using extended master secret"\
4818 -C "skip PMS generation for opaque PSK"\
4819 -s "skip PMS generation for opaque PSK"\
4820 -S "SSL - None of the common ciphersuites is usable" \
4821 -S "SSL - Unknown identity received" \
4822 -S "SSL - Verification of the message MAC failed"
4823
4824requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4825run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004826 "$P_SRV extended_ms=0 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01004827 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4828 psk_identity=def psk=beef" \
4829 0 \
4830 -C "skip PMS generation for opaque PSK"\
4831 -s "skip PMS generation for opaque PSK"\
4832 -C "using extended master secret"\
4833 -S "using extended master secret"\
4834 -S "SSL - None of the common ciphersuites is usable" \
4835 -S "SSL - Unknown identity received" \
4836 -S "SSL - Verification of the message MAC failed"
4837
4838requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4839run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, SHA-384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004840 "$P_SRV extended_ms=0 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01004841 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
4842 psk_identity=def psk=beef" \
4843 0 \
4844 -C "skip PMS generation for opaque PSK"\
4845 -s "skip PMS generation for opaque PSK"\
4846 -C "using extended master secret"\
4847 -S "using extended master secret"\
4848 -S "SSL - None of the common ciphersuites is usable" \
4849 -S "SSL - Unknown identity received" \
4850 -S "SSL - Verification of the message MAC failed"
4851
4852requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4853run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004854 "$P_SRV debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01004855 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
4856 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4857 psk_identity=abc psk=dead extended_ms=1" \
4858 0 \
4859 -c "using extended master secret"\
4860 -s "using extended master secret"\
4861 -C "skip PMS generation for opaque PSK"\
4862 -s "skip PMS generation for opaque PSK"\
4863 -S "SSL - None of the common ciphersuites is usable" \
4864 -S "SSL - Unknown identity received" \
4865 -S "SSL - Verification of the message MAC failed"
4866
4867requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4868run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS, SHA384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004869 "$P_SRV debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01004870 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
4871 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
4872 psk_identity=abc psk=dead extended_ms=1" \
4873 0 \
4874 -c "using extended master secret"\
4875 -s "using extended master secret"\
4876 -C "skip PMS generation for opaque PSK"\
4877 -s "skip PMS generation for opaque PSK"\
4878 -S "SSL - None of the common ciphersuites is usable" \
4879 -S "SSL - Unknown identity received" \
4880 -S "SSL - Verification of the message MAC failed"
4881
4882requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4883run_test "PSK callback: raw psk on client, mismatching static raw PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004884 "$P_SRV extended_ms=0 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01004885 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4886 psk_identity=def psk=beef" \
4887 0 \
4888 -C "skip PMS generation for opaque PSK"\
4889 -s "skip PMS generation for opaque PSK"\
4890 -C "using extended master secret"\
4891 -S "using extended master secret"\
4892 -S "SSL - None of the common ciphersuites is usable" \
4893 -S "SSL - Unknown identity received" \
4894 -S "SSL - Verification of the message MAC failed"
4895
4896requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4897run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004898 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01004899 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4900 psk_identity=def psk=beef" \
4901 0 \
4902 -C "skip PMS generation for opaque PSK"\
4903 -s "skip PMS generation for opaque PSK"\
4904 -C "using extended master secret"\
4905 -S "using extended master secret"\
4906 -S "SSL - None of the common ciphersuites is usable" \
4907 -S "SSL - Unknown identity received" \
4908 -S "SSL - Verification of the message MAC failed"
4909
4910requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4911run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, raw PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004912 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01004913 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4914 psk_identity=def psk=beef" \
4915 0 \
4916 -C "skip PMS generation for opaque PSK"\
4917 -C "using extended master secret"\
4918 -S "using extended master secret"\
4919 -S "SSL - None of the common ciphersuites is usable" \
4920 -S "SSL - Unknown identity received" \
4921 -S "SSL - Verification of the message MAC failed"
4922
4923requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4924run_test "PSK callback: raw psk on client, id-matching but wrong raw PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004925 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=def psk=abc123 debug_level=3 psk_list=abc,dead,def,beef min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01004926 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4927 psk_identity=def psk=beef" \
4928 0 \
4929 -C "skip PMS generation for opaque PSK"\
4930 -C "using extended master secret"\
4931 -S "using extended master secret"\
4932 -S "SSL - None of the common ciphersuites is usable" \
4933 -S "SSL - Unknown identity received" \
4934 -S "SSL - Verification of the message MAC failed"
4935
4936requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
4937run_test "PSK callback: raw psk on client, matching opaque PSK on server, wrong opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00004938 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=def psk=beef debug_level=3 psk_list=abc,dead,def,abc123 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01004939 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4940 psk_identity=def psk=beef" \
4941 1 \
4942 -s "SSL - Verification of the message MAC failed"
4943
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004944run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004945 "$P_SRV" \
4946 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4947 psk_identity=foo psk=abc123" \
4948 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004949 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004950 -S "SSL - Unknown identity received" \
4951 -S "SSL - Verification of the message MAC failed"
4952
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004953run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004954 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
4955 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4956 psk_identity=foo psk=abc123" \
4957 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004958 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004959 -s "SSL - Unknown identity received" \
4960 -S "SSL - Verification of the message MAC failed"
4961
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004962run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004963 "$P_SRV psk_list=abc,dead,def,beef" \
4964 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4965 psk_identity=abc psk=dead" \
4966 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004967 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004968 -S "SSL - Unknown identity received" \
4969 -S "SSL - Verification of the message MAC failed"
4970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004971run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004972 "$P_SRV psk_list=abc,dead,def,beef" \
4973 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4974 psk_identity=def psk=beef" \
4975 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004976 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004977 -S "SSL - Unknown identity received" \
4978 -S "SSL - Verification of the message MAC failed"
4979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004980run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004981 "$P_SRV psk_list=abc,dead,def,beef" \
4982 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4983 psk_identity=ghi psk=beef" \
4984 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004985 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004986 -s "SSL - Unknown identity received" \
4987 -S "SSL - Verification of the message MAC failed"
4988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004989run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004990 "$P_SRV psk_list=abc,dead,def,beef" \
4991 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4992 psk_identity=abc psk=beef" \
4993 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004994 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004995 -S "SSL - Unknown identity received" \
4996 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004997
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004998# Tests for EC J-PAKE
4999
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005000requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005001run_test "ECJPAKE: client not configured" \
5002 "$P_SRV debug_level=3" \
5003 "$P_CLI debug_level=3" \
5004 0 \
5005 -C "add ciphersuite: c0ff" \
5006 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005007 -S "found ecjpake kkpp extension" \
5008 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005009 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005010 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005011 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005012 -S "None of the common ciphersuites is usable"
5013
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005014requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005015run_test "ECJPAKE: server not configured" \
5016 "$P_SRV debug_level=3" \
5017 "$P_CLI debug_level=3 ecjpake_pw=bla \
5018 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5019 1 \
5020 -c "add ciphersuite: c0ff" \
5021 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005022 -s "found ecjpake kkpp extension" \
5023 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005024 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005025 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005026 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005027 -s "None of the common ciphersuites is usable"
5028
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005029requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005030run_test "ECJPAKE: working, TLS" \
5031 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5032 "$P_CLI debug_level=3 ecjpake_pw=bla \
5033 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005034 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005035 -c "add ciphersuite: c0ff" \
5036 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005037 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005038 -s "found ecjpake kkpp extension" \
5039 -S "skip ecjpake kkpp extension" \
5040 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005041 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005042 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005043 -S "None of the common ciphersuites is usable" \
5044 -S "SSL - Verification of the message MAC failed"
5045
Janos Follath74537a62016-09-02 13:45:28 +01005046server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005047requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005048run_test "ECJPAKE: password mismatch, TLS" \
5049 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5050 "$P_CLI debug_level=3 ecjpake_pw=bad \
5051 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5052 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005053 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005054 -s "SSL - Verification of the message MAC failed"
5055
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005056requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005057run_test "ECJPAKE: working, DTLS" \
5058 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5059 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5060 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5061 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005062 -c "re-using cached ecjpake parameters" \
5063 -S "SSL - Verification of the message MAC failed"
5064
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005065requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005066run_test "ECJPAKE: working, DTLS, no cookie" \
5067 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5068 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5069 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5070 0 \
5071 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005072 -S "SSL - Verification of the message MAC failed"
5073
Janos Follath74537a62016-09-02 13:45:28 +01005074server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005075requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005076run_test "ECJPAKE: password mismatch, DTLS" \
5077 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5078 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5079 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5080 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005081 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005082 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005083
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005084# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005085requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005086run_test "ECJPAKE: working, DTLS, nolog" \
5087 "$P_SRV dtls=1 ecjpake_pw=bla" \
5088 "$P_CLI dtls=1 ecjpake_pw=bla \
5089 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5090 0
5091
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005092# Tests for ciphersuites per version
5093
Janos Follathe2681a42016-03-07 15:57:05 +00005094requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005095requires_config_enabled MBEDTLS_CAMELLIA_C
5096requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005097run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005098 "$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 +02005099 "$P_CLI force_version=ssl3" \
5100 0 \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005101 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005102
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005103requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5104requires_config_enabled MBEDTLS_CAMELLIA_C
5105requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005106run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005107 "$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 +01005108 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005109 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005110 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005111
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005112requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5113requires_config_enabled MBEDTLS_CAMELLIA_C
5114requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005115run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005116 "$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 +02005117 "$P_CLI force_version=tls1_1" \
5118 0 \
5119 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5120
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005121requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5122requires_config_enabled MBEDTLS_CAMELLIA_C
5123requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005124run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005125 "$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 +02005126 "$P_CLI force_version=tls1_2" \
5127 0 \
5128 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5129
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005130# Test for ClientHello without extensions
5131
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005132requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005133run_test "ClientHello without extensions, SHA-1 allowed" \
Ron Eldor574ac572019-01-16 23:14:41 +02005134 "$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 +02005135 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005136 0 \
5137 -s "dumping 'client hello extensions' (0 bytes)"
5138
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005139requires_gnutls
5140run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
5141 "$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 +02005142 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005143 0 \
5144 -s "dumping 'client hello extensions' (0 bytes)"
5145
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005146# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005147
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005148run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005149 "$P_SRV" \
5150 "$P_CLI request_size=100" \
5151 0 \
5152 -s "Read from client: 100 bytes read$"
5153
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005154run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005155 "$P_SRV" \
5156 "$P_CLI request_size=500" \
5157 0 \
5158 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005159
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005160# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005161
Janos Follathe2681a42016-03-07 15:57:05 +00005162requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005163run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005164 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005165 "$P_CLI request_size=1 force_version=ssl3 \
5166 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5167 0 \
5168 -s "Read from client: 1 bytes read"
5169
Janos Follathe2681a42016-03-07 15:57:05 +00005170requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005171run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005172 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005173 "$P_CLI request_size=1 force_version=ssl3 \
5174 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5175 0 \
5176 -s "Read from client: 1 bytes read"
5177
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005178run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005179 "$P_SRV" \
5180 "$P_CLI request_size=1 force_version=tls1 \
5181 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5182 0 \
5183 -s "Read from client: 1 bytes read"
5184
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005185run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005186 "$P_SRV" \
5187 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5188 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5189 0 \
5190 -s "Read from client: 1 bytes read"
5191
Hanno Becker32c55012017-11-10 08:42:54 +00005192requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005193run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005194 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005195 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005196 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005197 0 \
5198 -s "Read from client: 1 bytes read"
5199
Hanno Becker32c55012017-11-10 08:42:54 +00005200requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005201run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005202 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005203 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005204 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005205 0 \
5206 -s "Read from client: 1 bytes read"
5207
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005208run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005209 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005210 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005211 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5212 0 \
5213 -s "Read from client: 1 bytes read"
5214
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005215run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005216 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5217 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005218 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005219 0 \
5220 -s "Read from client: 1 bytes read"
5221
5222requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005223run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005224 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005225 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005226 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005227 0 \
5228 -s "Read from client: 1 bytes read"
5229
Hanno Becker8501f982017-11-10 08:59:04 +00005230requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005231run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005232 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5233 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5234 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005235 0 \
5236 -s "Read from client: 1 bytes read"
5237
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005238run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005239 "$P_SRV" \
5240 "$P_CLI request_size=1 force_version=tls1_1 \
5241 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5242 0 \
5243 -s "Read from client: 1 bytes read"
5244
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005245run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005246 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005247 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005248 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005249 0 \
5250 -s "Read from client: 1 bytes read"
5251
5252requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005253run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005254 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005255 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005256 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005257 0 \
5258 -s "Read from client: 1 bytes read"
5259
5260requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005261run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005262 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005263 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005264 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005265 0 \
5266 -s "Read from client: 1 bytes read"
5267
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005268run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005269 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005270 "$P_CLI request_size=1 force_version=tls1_1 \
5271 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5272 0 \
5273 -s "Read from client: 1 bytes read"
5274
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005275run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005276 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005277 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005278 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005279 0 \
5280 -s "Read from client: 1 bytes read"
5281
Hanno Becker8501f982017-11-10 08:59:04 +00005282requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005283run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005284 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005285 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005286 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005287 0 \
5288 -s "Read from client: 1 bytes read"
5289
Hanno Becker32c55012017-11-10 08:42:54 +00005290requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005291run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005292 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005293 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005294 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005295 0 \
5296 -s "Read from client: 1 bytes read"
5297
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005298run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005299 "$P_SRV" \
5300 "$P_CLI request_size=1 force_version=tls1_2 \
5301 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5302 0 \
5303 -s "Read from client: 1 bytes read"
5304
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005305run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005306 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005307 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005308 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005309 0 \
5310 -s "Read from client: 1 bytes read"
5311
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005312run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005313 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005314 "$P_CLI request_size=1 force_version=tls1_2 \
5315 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005316 0 \
5317 -s "Read from client: 1 bytes read"
5318
Hanno Becker32c55012017-11-10 08:42:54 +00005319requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005320run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005321 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005322 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005323 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005324 0 \
5325 -s "Read from client: 1 bytes read"
5326
Hanno Becker8501f982017-11-10 08:59:04 +00005327requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005328run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005329 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005330 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005331 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005332 0 \
5333 -s "Read from client: 1 bytes read"
5334
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005335run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005336 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005337 "$P_CLI request_size=1 force_version=tls1_2 \
5338 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5339 0 \
5340 -s "Read from client: 1 bytes read"
5341
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005342run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005343 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005344 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005345 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005346 0 \
5347 -s "Read from client: 1 bytes read"
5348
Hanno Becker32c55012017-11-10 08:42:54 +00005349requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005350run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005351 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005352 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005353 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005354 0 \
5355 -s "Read from client: 1 bytes read"
5356
Hanno Becker8501f982017-11-10 08:59:04 +00005357requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005358run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005359 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005360 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005361 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005362 0 \
5363 -s "Read from client: 1 bytes read"
5364
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005365run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005366 "$P_SRV" \
5367 "$P_CLI request_size=1 force_version=tls1_2 \
5368 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5369 0 \
5370 -s "Read from client: 1 bytes read"
5371
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005372run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005373 "$P_SRV" \
5374 "$P_CLI request_size=1 force_version=tls1_2 \
5375 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5376 0 \
5377 -s "Read from client: 1 bytes read"
5378
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005379# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00005380
5381requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005382run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005383 "$P_SRV dtls=1 force_version=dtls1" \
5384 "$P_CLI dtls=1 request_size=1 \
5385 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5386 0 \
5387 -s "Read from client: 1 bytes read"
5388
5389requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005390run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00005391 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
5392 "$P_CLI dtls=1 request_size=1 \
5393 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5394 0 \
5395 -s "Read from client: 1 bytes read"
5396
5397requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5398requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005399run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005400 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
5401 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00005402 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5403 0 \
5404 -s "Read from client: 1 bytes read"
5405
5406requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5407requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005408run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005409 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005410 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005411 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005412 0 \
5413 -s "Read from client: 1 bytes read"
5414
5415requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005416run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00005417 "$P_SRV dtls=1 force_version=dtls1_2" \
5418 "$P_CLI dtls=1 request_size=1 \
5419 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5420 0 \
5421 -s "Read from client: 1 bytes read"
5422
5423requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005424run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005425 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005426 "$P_CLI dtls=1 request_size=1 \
5427 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5428 0 \
5429 -s "Read from client: 1 bytes read"
5430
5431requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5432requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005433run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005434 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005435 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005436 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005437 0 \
5438 -s "Read from client: 1 bytes read"
5439
5440requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5441requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005442run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005443 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005444 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005445 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005446 0 \
5447 -s "Read from client: 1 bytes read"
5448
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005449# Tests for small server packets
5450
5451requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5452run_test "Small server packet SSLv3 BlockCipher" \
5453 "$P_SRV response_size=1 min_version=ssl3" \
5454 "$P_CLI force_version=ssl3 \
5455 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5456 0 \
5457 -c "Read from server: 1 bytes read"
5458
5459requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5460run_test "Small server packet SSLv3 StreamCipher" \
5461 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5462 "$P_CLI force_version=ssl3 \
5463 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5464 0 \
5465 -c "Read from server: 1 bytes read"
5466
5467run_test "Small server packet TLS 1.0 BlockCipher" \
5468 "$P_SRV response_size=1" \
5469 "$P_CLI force_version=tls1 \
5470 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5471 0 \
5472 -c "Read from server: 1 bytes read"
5473
5474run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
5475 "$P_SRV response_size=1" \
5476 "$P_CLI force_version=tls1 etm=0 \
5477 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5478 0 \
5479 -c "Read from server: 1 bytes read"
5480
5481requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5482run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
5483 "$P_SRV response_size=1 trunc_hmac=1" \
5484 "$P_CLI force_version=tls1 \
5485 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5486 0 \
5487 -c "Read from server: 1 bytes read"
5488
5489requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5490run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
5491 "$P_SRV response_size=1 trunc_hmac=1" \
5492 "$P_CLI force_version=tls1 \
5493 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5494 0 \
5495 -c "Read from server: 1 bytes read"
5496
5497run_test "Small server packet TLS 1.0 StreamCipher" \
5498 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5499 "$P_CLI force_version=tls1 \
5500 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5501 0 \
5502 -c "Read from server: 1 bytes read"
5503
5504run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
5505 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5506 "$P_CLI force_version=tls1 \
5507 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5508 0 \
5509 -c "Read from server: 1 bytes read"
5510
5511requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5512run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
5513 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5514 "$P_CLI force_version=tls1 \
5515 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5516 0 \
5517 -c "Read from server: 1 bytes read"
5518
5519requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5520run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5521 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5522 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5523 trunc_hmac=1 etm=0" \
5524 0 \
5525 -c "Read from server: 1 bytes read"
5526
5527run_test "Small server packet TLS 1.1 BlockCipher" \
5528 "$P_SRV response_size=1" \
5529 "$P_CLI force_version=tls1_1 \
5530 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5531 0 \
5532 -c "Read from server: 1 bytes read"
5533
5534run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
5535 "$P_SRV response_size=1" \
5536 "$P_CLI force_version=tls1_1 \
5537 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5538 0 \
5539 -c "Read from server: 1 bytes read"
5540
5541requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5542run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
5543 "$P_SRV response_size=1 trunc_hmac=1" \
5544 "$P_CLI force_version=tls1_1 \
5545 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5546 0 \
5547 -c "Read from server: 1 bytes read"
5548
5549requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5550run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5551 "$P_SRV response_size=1 trunc_hmac=1" \
5552 "$P_CLI force_version=tls1_1 \
5553 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5554 0 \
5555 -c "Read from server: 1 bytes read"
5556
5557run_test "Small server packet TLS 1.1 StreamCipher" \
5558 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5559 "$P_CLI force_version=tls1_1 \
5560 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5561 0 \
5562 -c "Read from server: 1 bytes read"
5563
5564run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
5565 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5566 "$P_CLI force_version=tls1_1 \
5567 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5568 0 \
5569 -c "Read from server: 1 bytes read"
5570
5571requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5572run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
5573 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5574 "$P_CLI force_version=tls1_1 \
5575 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5576 0 \
5577 -c "Read from server: 1 bytes read"
5578
5579requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5580run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5581 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5582 "$P_CLI force_version=tls1_1 \
5583 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5584 0 \
5585 -c "Read from server: 1 bytes read"
5586
5587run_test "Small server packet TLS 1.2 BlockCipher" \
5588 "$P_SRV response_size=1" \
5589 "$P_CLI force_version=tls1_2 \
5590 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5591 0 \
5592 -c "Read from server: 1 bytes read"
5593
5594run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5595 "$P_SRV response_size=1" \
5596 "$P_CLI force_version=tls1_2 \
5597 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5598 0 \
5599 -c "Read from server: 1 bytes read"
5600
5601run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5602 "$P_SRV response_size=1" \
5603 "$P_CLI force_version=tls1_2 \
5604 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5605 0 \
5606 -c "Read from server: 1 bytes read"
5607
5608requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5609run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5610 "$P_SRV response_size=1 trunc_hmac=1" \
5611 "$P_CLI force_version=tls1_2 \
5612 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5613 0 \
5614 -c "Read from server: 1 bytes read"
5615
5616requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5617run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5618 "$P_SRV response_size=1 trunc_hmac=1" \
5619 "$P_CLI force_version=tls1_2 \
5620 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5621 0 \
5622 -c "Read from server: 1 bytes read"
5623
5624run_test "Small server packet TLS 1.2 StreamCipher" \
5625 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5626 "$P_CLI force_version=tls1_2 \
5627 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5628 0 \
5629 -c "Read from server: 1 bytes read"
5630
5631run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
5632 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5633 "$P_CLI force_version=tls1_2 \
5634 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5635 0 \
5636 -c "Read from server: 1 bytes read"
5637
5638requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5639run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
5640 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5641 "$P_CLI force_version=tls1_2 \
5642 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5643 0 \
5644 -c "Read from server: 1 bytes read"
5645
5646requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5647run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5648 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5649 "$P_CLI force_version=tls1_2 \
5650 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5651 0 \
5652 -c "Read from server: 1 bytes read"
5653
5654run_test "Small server packet TLS 1.2 AEAD" \
5655 "$P_SRV response_size=1" \
5656 "$P_CLI force_version=tls1_2 \
5657 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5658 0 \
5659 -c "Read from server: 1 bytes read"
5660
5661run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5662 "$P_SRV response_size=1" \
5663 "$P_CLI force_version=tls1_2 \
5664 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5665 0 \
5666 -c "Read from server: 1 bytes read"
5667
5668# Tests for small server packets in DTLS
5669
5670requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5671run_test "Small server packet DTLS 1.0" \
5672 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
5673 "$P_CLI dtls=1 \
5674 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5675 0 \
5676 -c "Read from server: 1 bytes read"
5677
5678requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5679run_test "Small server packet DTLS 1.0, without EtM" \
5680 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
5681 "$P_CLI dtls=1 \
5682 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5683 0 \
5684 -c "Read from server: 1 bytes read"
5685
5686requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5687requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5688run_test "Small server packet DTLS 1.0, truncated hmac" \
5689 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
5690 "$P_CLI dtls=1 trunc_hmac=1 \
5691 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5692 0 \
5693 -c "Read from server: 1 bytes read"
5694
5695requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5696requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5697run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
5698 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
5699 "$P_CLI dtls=1 \
5700 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5701 0 \
5702 -c "Read from server: 1 bytes read"
5703
5704requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5705run_test "Small server packet DTLS 1.2" \
5706 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
5707 "$P_CLI dtls=1 \
5708 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5709 0 \
5710 -c "Read from server: 1 bytes read"
5711
5712requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5713run_test "Small server packet DTLS 1.2, without EtM" \
5714 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5715 "$P_CLI dtls=1 \
5716 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5717 0 \
5718 -c "Read from server: 1 bytes read"
5719
5720requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5721requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5722run_test "Small server packet DTLS 1.2, truncated hmac" \
5723 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5724 "$P_CLI dtls=1 \
5725 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5726 0 \
5727 -c "Read from server: 1 bytes read"
5728
5729requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5730requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5731run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5732 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5733 "$P_CLI dtls=1 \
5734 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5735 0 \
5736 -c "Read from server: 1 bytes read"
5737
Janos Follath00efff72016-05-06 13:48:23 +01005738# A test for extensions in SSLv3
5739
5740requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5741run_test "SSLv3 with extensions, server side" \
5742 "$P_SRV min_version=ssl3 debug_level=3" \
5743 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
5744 0 \
5745 -S "dumping 'client hello extensions'" \
5746 -S "server hello, total extension length:"
5747
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005748# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005749
Angus Grattonc4dd0732018-04-11 16:28:39 +10005750# How many fragments do we expect to write $1 bytes?
5751fragments_for_write() {
5752 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
5753}
5754
Janos Follathe2681a42016-03-07 15:57:05 +00005755requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005756run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005757 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005758 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005759 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5760 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005761 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5762 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005763
Janos Follathe2681a42016-03-07 15:57:05 +00005764requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005765run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005766 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005767 "$P_CLI request_size=16384 force_version=ssl3 \
5768 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5769 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005770 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5771 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005772
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005773run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005774 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005775 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005776 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5777 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005778 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5779 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005780
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005781run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005782 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005783 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
5784 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5785 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005786 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005787
Hanno Becker32c55012017-11-10 08:42:54 +00005788requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005789run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005790 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005791 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005792 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005793 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005794 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5795 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005796
Hanno Becker32c55012017-11-10 08:42:54 +00005797requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005798run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005799 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005800 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005801 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005802 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005803 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005804
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005805run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005806 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005807 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005808 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5809 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005810 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005811
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005812run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005813 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5814 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005815 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005816 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005817 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005818
5819requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005820run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005821 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005822 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005823 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005824 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005825 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005826
Hanno Becker278fc7a2017-11-10 09:16:28 +00005827requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005828run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005829 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005830 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005831 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005832 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005833 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5834 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005835
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005836run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005837 "$P_SRV" \
5838 "$P_CLI request_size=16384 force_version=tls1_1 \
5839 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5840 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005841 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5842 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005843
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005844run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005845 "$P_SRV" \
5846 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
5847 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005848 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005849 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005850
Hanno Becker32c55012017-11-10 08:42:54 +00005851requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005852run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005853 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005854 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005855 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005856 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005857 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005858
Hanno Becker32c55012017-11-10 08:42:54 +00005859requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005860run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005861 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005862 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005863 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005864 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005865 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005866
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005867run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005868 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5869 "$P_CLI request_size=16384 force_version=tls1_1 \
5870 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5871 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005872 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5873 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005874
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005875run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005876 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005877 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005878 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005879 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005880 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5881 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005882
Hanno Becker278fc7a2017-11-10 09:16:28 +00005883requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005884run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005885 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005886 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005887 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005888 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005889 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005890
Hanno Becker278fc7a2017-11-10 09:16:28 +00005891requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005892run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005893 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005894 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005895 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005896 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005897 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5898 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005899
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005900run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005901 "$P_SRV" \
5902 "$P_CLI request_size=16384 force_version=tls1_2 \
5903 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5904 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005905 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5906 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005907
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005908run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005909 "$P_SRV" \
5910 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
5911 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5912 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005913 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005914
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005915run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005916 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005917 "$P_CLI request_size=16384 force_version=tls1_2 \
5918 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005919 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005920 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5921 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005922
Hanno Becker32c55012017-11-10 08:42:54 +00005923requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005924run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005925 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005926 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005927 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005928 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005929 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005930
Hanno Becker278fc7a2017-11-10 09:16:28 +00005931requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005932run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005933 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005934 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005935 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005936 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.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005941 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005942 "$P_CLI request_size=16384 force_version=tls1_2 \
5943 force_ciphersuite=TLS-RSA-WITH-RC4-128-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.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005949 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005950 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005951 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
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.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005957 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005958 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005959 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005960 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005961 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005962
Hanno Becker278fc7a2017-11-10 09:16:28 +00005963requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005964run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005965 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005966 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005967 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005968 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005969 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5970 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005971
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005972run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005973 "$P_SRV" \
5974 "$P_CLI request_size=16384 force_version=tls1_2 \
5975 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5976 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005977 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5978 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005979
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005980run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005981 "$P_SRV" \
5982 "$P_CLI request_size=16384 force_version=tls1_2 \
5983 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5984 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005985 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5986 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005987
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005988# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005989requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5990run_test "Large server packet SSLv3 StreamCipher" \
5991 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5992 "$P_CLI force_version=ssl3 \
5993 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5994 0 \
5995 -c "Read from server: 16384 bytes read"
5996
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04005997# Checking next 4 tests logs for 1n-1 split against BEAST too
5998requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5999run_test "Large server packet SSLv3 BlockCipher" \
6000 "$P_SRV response_size=16384 min_version=ssl3" \
6001 "$P_CLI force_version=ssl3 recsplit=0 \
6002 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6003 0 \
6004 -c "Read from server: 1 bytes read"\
6005 -c "16383 bytes read"\
6006 -C "Read from server: 16384 bytes read"
6007
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006008run_test "Large server packet TLS 1.0 BlockCipher" \
6009 "$P_SRV response_size=16384" \
6010 "$P_CLI force_version=tls1 recsplit=0 \
6011 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6012 0 \
6013 -c "Read from server: 1 bytes read"\
6014 -c "16383 bytes read"\
6015 -C "Read from server: 16384 bytes read"
6016
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006017run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6018 "$P_SRV response_size=16384" \
6019 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6020 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6021 0 \
6022 -c "Read from server: 1 bytes read"\
6023 -c "16383 bytes read"\
6024 -C "Read from server: 16384 bytes read"
6025
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006026requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6027run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6028 "$P_SRV response_size=16384" \
6029 "$P_CLI force_version=tls1 recsplit=0 \
6030 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6031 trunc_hmac=1" \
6032 0 \
6033 -c "Read from server: 1 bytes read"\
6034 -c "16383 bytes read"\
6035 -C "Read from server: 16384 bytes read"
6036
6037requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6038run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6039 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6040 "$P_CLI force_version=tls1 \
6041 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6042 trunc_hmac=1" \
6043 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006044 -s "16384 bytes written in 1 fragments" \
6045 -c "Read from server: 16384 bytes read"
6046
6047run_test "Large server packet TLS 1.0 StreamCipher" \
6048 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6049 "$P_CLI force_version=tls1 \
6050 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6051 0 \
6052 -s "16384 bytes written in 1 fragments" \
6053 -c "Read from server: 16384 bytes read"
6054
6055run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6056 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6057 "$P_CLI force_version=tls1 \
6058 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6059 0 \
6060 -s "16384 bytes written in 1 fragments" \
6061 -c "Read from server: 16384 bytes read"
6062
6063requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6064run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6065 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6066 "$P_CLI force_version=tls1 \
6067 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6068 0 \
6069 -s "16384 bytes written in 1 fragments" \
6070 -c "Read from server: 16384 bytes read"
6071
6072requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6073run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6074 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6075 "$P_CLI force_version=tls1 \
6076 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6077 0 \
6078 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006079 -c "Read from server: 16384 bytes read"
6080
6081run_test "Large server packet TLS 1.1 BlockCipher" \
6082 "$P_SRV response_size=16384" \
6083 "$P_CLI force_version=tls1_1 \
6084 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6085 0 \
6086 -c "Read from server: 16384 bytes read"
6087
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006088run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6089 "$P_SRV response_size=16384" \
6090 "$P_CLI force_version=tls1_1 etm=0 \
6091 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006092 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006093 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006094 -c "Read from server: 16384 bytes read"
6095
6096requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6097run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6098 "$P_SRV response_size=16384" \
6099 "$P_CLI force_version=tls1_1 \
6100 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6101 trunc_hmac=1" \
6102 0 \
6103 -c "Read from server: 16384 bytes read"
6104
6105requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006106run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6107 "$P_SRV response_size=16384 trunc_hmac=1" \
6108 "$P_CLI force_version=tls1_1 \
6109 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6110 0 \
6111 -s "16384 bytes written in 1 fragments" \
6112 -c "Read from server: 16384 bytes read"
6113
6114run_test "Large server packet TLS 1.1 StreamCipher" \
6115 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6116 "$P_CLI force_version=tls1_1 \
6117 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6118 0 \
6119 -c "Read from server: 16384 bytes read"
6120
6121run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6122 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6123 "$P_CLI force_version=tls1_1 \
6124 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6125 0 \
6126 -s "16384 bytes written in 1 fragments" \
6127 -c "Read from server: 16384 bytes read"
6128
6129requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006130run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6131 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6132 "$P_CLI force_version=tls1_1 \
6133 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6134 trunc_hmac=1" \
6135 0 \
6136 -c "Read from server: 16384 bytes read"
6137
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006138run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6139 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6140 "$P_CLI force_version=tls1_1 \
6141 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6142 0 \
6143 -s "16384 bytes written in 1 fragments" \
6144 -c "Read from server: 16384 bytes read"
6145
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006146run_test "Large server packet TLS 1.2 BlockCipher" \
6147 "$P_SRV response_size=16384" \
6148 "$P_CLI force_version=tls1_2 \
6149 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6150 0 \
6151 -c "Read from server: 16384 bytes read"
6152
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006153run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6154 "$P_SRV response_size=16384" \
6155 "$P_CLI force_version=tls1_2 etm=0 \
6156 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6157 0 \
6158 -s "16384 bytes written in 1 fragments" \
6159 -c "Read from server: 16384 bytes read"
6160
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006161run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6162 "$P_SRV response_size=16384" \
6163 "$P_CLI force_version=tls1_2 \
6164 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6165 0 \
6166 -c "Read from server: 16384 bytes read"
6167
6168requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6169run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6170 "$P_SRV response_size=16384" \
6171 "$P_CLI force_version=tls1_2 \
6172 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6173 trunc_hmac=1" \
6174 0 \
6175 -c "Read from server: 16384 bytes read"
6176
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006177run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6178 "$P_SRV response_size=16384 trunc_hmac=1" \
6179 "$P_CLI force_version=tls1_2 \
6180 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6181 0 \
6182 -s "16384 bytes written in 1 fragments" \
6183 -c "Read from server: 16384 bytes read"
6184
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006185run_test "Large server packet TLS 1.2 StreamCipher" \
6186 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6187 "$P_CLI force_version=tls1_2 \
6188 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6189 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006190 -s "16384 bytes written in 1 fragments" \
6191 -c "Read from server: 16384 bytes read"
6192
6193run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6194 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6195 "$P_CLI force_version=tls1_2 \
6196 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6197 0 \
6198 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006199 -c "Read from server: 16384 bytes read"
6200
6201requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6202run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6203 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6204 "$P_CLI force_version=tls1_2 \
6205 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6206 trunc_hmac=1" \
6207 0 \
6208 -c "Read from server: 16384 bytes read"
6209
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006210requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6211run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6212 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6213 "$P_CLI force_version=tls1_2 \
6214 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6215 0 \
6216 -s "16384 bytes written in 1 fragments" \
6217 -c "Read from server: 16384 bytes read"
6218
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006219run_test "Large server packet TLS 1.2 AEAD" \
6220 "$P_SRV response_size=16384" \
6221 "$P_CLI force_version=tls1_2 \
6222 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6223 0 \
6224 -c "Read from server: 16384 bytes read"
6225
6226run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6227 "$P_SRV response_size=16384" \
6228 "$P_CLI force_version=tls1_2 \
6229 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6230 0 \
6231 -c "Read from server: 16384 bytes read"
6232
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006233# Tests for restartable ECC
6234
6235requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6236run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006237 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006238 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006239 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006240 debug_level=1" \
6241 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006242 -C "x509_verify_cert.*4b00" \
6243 -C "mbedtls_pk_verify.*4b00" \
6244 -C "mbedtls_ecdh_make_public.*4b00" \
6245 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006246
6247requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6248run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006249 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006250 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006251 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006252 debug_level=1 ec_max_ops=0" \
6253 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006254 -C "x509_verify_cert.*4b00" \
6255 -C "mbedtls_pk_verify.*4b00" \
6256 -C "mbedtls_ecdh_make_public.*4b00" \
6257 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006258
6259requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6260run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006261 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006262 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006263 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006264 debug_level=1 ec_max_ops=65535" \
6265 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006266 -C "x509_verify_cert.*4b00" \
6267 -C "mbedtls_pk_verify.*4b00" \
6268 -C "mbedtls_ecdh_make_public.*4b00" \
6269 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006270
6271requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6272run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006273 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006274 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006275 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006276 debug_level=1 ec_max_ops=1000" \
6277 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006278 -c "x509_verify_cert.*4b00" \
6279 -c "mbedtls_pk_verify.*4b00" \
6280 -c "mbedtls_ecdh_make_public.*4b00" \
6281 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006282
6283requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006284run_test "EC restart: TLS, max_ops=1000, badsign" \
6285 "$P_SRV auth_mode=required \
6286 crt_file=data_files/server5-badsign.crt \
6287 key_file=data_files/server5.key" \
6288 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6289 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6290 debug_level=1 ec_max_ops=1000" \
6291 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006292 -c "x509_verify_cert.*4b00" \
6293 -C "mbedtls_pk_verify.*4b00" \
6294 -C "mbedtls_ecdh_make_public.*4b00" \
6295 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006296 -c "! The certificate is not correctly signed by the trusted CA" \
6297 -c "! mbedtls_ssl_handshake returned" \
6298 -c "X509 - Certificate verification failed"
6299
6300requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6301run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
6302 "$P_SRV auth_mode=required \
6303 crt_file=data_files/server5-badsign.crt \
6304 key_file=data_files/server5.key" \
6305 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6306 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6307 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6308 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006309 -c "x509_verify_cert.*4b00" \
6310 -c "mbedtls_pk_verify.*4b00" \
6311 -c "mbedtls_ecdh_make_public.*4b00" \
6312 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006313 -c "! The certificate is not correctly signed by the trusted CA" \
6314 -C "! mbedtls_ssl_handshake returned" \
6315 -C "X509 - Certificate verification failed"
6316
6317requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6318run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
6319 "$P_SRV auth_mode=required \
6320 crt_file=data_files/server5-badsign.crt \
6321 key_file=data_files/server5.key" \
6322 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6323 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6324 debug_level=1 ec_max_ops=1000 auth_mode=none" \
6325 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006326 -C "x509_verify_cert.*4b00" \
6327 -c "mbedtls_pk_verify.*4b00" \
6328 -c "mbedtls_ecdh_make_public.*4b00" \
6329 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006330 -C "! The certificate is not correctly signed by the trusted CA" \
6331 -C "! mbedtls_ssl_handshake returned" \
6332 -C "X509 - Certificate verification failed"
6333
6334requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006335run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006336 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006337 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006338 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006339 dtls=1 debug_level=1 ec_max_ops=1000" \
6340 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006341 -c "x509_verify_cert.*4b00" \
6342 -c "mbedtls_pk_verify.*4b00" \
6343 -c "mbedtls_ecdh_make_public.*4b00" \
6344 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006345
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006346requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6347run_test "EC restart: TLS, max_ops=1000 no client auth" \
6348 "$P_SRV" \
6349 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6350 debug_level=1 ec_max_ops=1000" \
6351 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006352 -c "x509_verify_cert.*4b00" \
6353 -c "mbedtls_pk_verify.*4b00" \
6354 -c "mbedtls_ecdh_make_public.*4b00" \
6355 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006356
6357requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6358run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6359 "$P_SRV psk=abc123" \
6360 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6361 psk=abc123 debug_level=1 ec_max_ops=1000" \
6362 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006363 -C "x509_verify_cert.*4b00" \
6364 -C "mbedtls_pk_verify.*4b00" \
6365 -C "mbedtls_ecdh_make_public.*4b00" \
6366 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006367
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006368# Tests of asynchronous private key support in SSL
6369
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006370requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006371run_test "SSL async private: sign, delay=0" \
6372 "$P_SRV \
6373 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006374 "$P_CLI" \
6375 0 \
6376 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006377 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006378
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006379requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006380run_test "SSL async private: sign, delay=1" \
6381 "$P_SRV \
6382 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006383 "$P_CLI" \
6384 0 \
6385 -s "Async sign callback: using key slot " \
6386 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006387 -s "Async resume (slot [0-9]): sign done, status=0"
6388
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006389requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6390run_test "SSL async private: sign, delay=2" \
6391 "$P_SRV \
6392 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6393 "$P_CLI" \
6394 0 \
6395 -s "Async sign callback: using key slot " \
6396 -U "Async sign callback: using key slot " \
6397 -s "Async resume (slot [0-9]): call 1 more times." \
6398 -s "Async resume (slot [0-9]): call 0 more times." \
6399 -s "Async resume (slot [0-9]): sign done, status=0"
6400
Gilles Peskined3268832018-04-26 06:23:59 +02006401# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
6402# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
6403requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6404requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6405run_test "SSL async private: sign, RSA, TLS 1.1" \
6406 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
6407 async_operations=s async_private_delay1=0 async_private_delay2=0" \
6408 "$P_CLI force_version=tls1_1" \
6409 0 \
6410 -s "Async sign callback: using key slot " \
6411 -s "Async resume (slot [0-9]): sign done, status=0"
6412
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006413requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02006414run_test "SSL async private: sign, SNI" \
6415 "$P_SRV debug_level=3 \
6416 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6417 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6418 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6419 "$P_CLI server_name=polarssl.example" \
6420 0 \
6421 -s "Async sign callback: using key slot " \
6422 -s "Async resume (slot [0-9]): sign done, status=0" \
6423 -s "parse ServerName extension" \
6424 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6425 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6426
6427requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006428run_test "SSL async private: decrypt, delay=0" \
6429 "$P_SRV \
6430 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6431 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6432 0 \
6433 -s "Async decrypt callback: using key slot " \
6434 -s "Async resume (slot [0-9]): decrypt done, status=0"
6435
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006436requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006437run_test "SSL async private: decrypt, delay=1" \
6438 "$P_SRV \
6439 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6440 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6441 0 \
6442 -s "Async decrypt callback: using key slot " \
6443 -s "Async resume (slot [0-9]): call 0 more times." \
6444 -s "Async resume (slot [0-9]): decrypt done, status=0"
6445
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006446requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006447run_test "SSL async private: decrypt RSA-PSK, delay=0" \
6448 "$P_SRV psk=abc123 \
6449 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6450 "$P_CLI psk=abc123 \
6451 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6452 0 \
6453 -s "Async decrypt callback: using key slot " \
6454 -s "Async resume (slot [0-9]): decrypt done, status=0"
6455
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006456requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006457run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6458 "$P_SRV psk=abc123 \
6459 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6460 "$P_CLI psk=abc123 \
6461 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6462 0 \
6463 -s "Async decrypt callback: using key slot " \
6464 -s "Async resume (slot [0-9]): call 0 more times." \
6465 -s "Async resume (slot [0-9]): decrypt done, status=0"
6466
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006467requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006468run_test "SSL async private: sign callback not present" \
6469 "$P_SRV \
6470 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6471 "$P_CLI; [ \$? -eq 1 ] &&
6472 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6473 0 \
6474 -S "Async sign callback" \
6475 -s "! mbedtls_ssl_handshake returned" \
6476 -s "The own private key or pre-shared key is not set, but needed" \
6477 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6478 -s "Successful connection"
6479
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006480requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006481run_test "SSL async private: decrypt callback not present" \
6482 "$P_SRV debug_level=1 \
6483 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6484 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6485 [ \$? -eq 1 ] && $P_CLI" \
6486 0 \
6487 -S "Async decrypt callback" \
6488 -s "! mbedtls_ssl_handshake returned" \
6489 -s "got no RSA private key" \
6490 -s "Async resume (slot [0-9]): sign done, status=0" \
6491 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006492
6493# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006494requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006495run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006496 "$P_SRV \
6497 async_operations=s async_private_delay1=1 \
6498 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6499 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006500 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6501 0 \
6502 -s "Async sign callback: using key slot 0," \
6503 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006504 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006505
6506# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006507requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006508run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006509 "$P_SRV \
6510 async_operations=s async_private_delay2=1 \
6511 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6512 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006513 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6514 0 \
6515 -s "Async sign callback: using key slot 0," \
6516 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006517 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006518
6519# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006520requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006521run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006522 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006523 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006524 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6525 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006526 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6527 0 \
6528 -s "Async sign callback: using key slot 1," \
6529 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006530 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006531
6532# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006533requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006534run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006535 "$P_SRV \
6536 async_operations=s async_private_delay1=1 \
6537 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6538 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006539 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6540 0 \
6541 -s "Async sign callback: no key matches this certificate."
6542
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006543requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006544run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006545 "$P_SRV \
6546 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6547 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006548 "$P_CLI" \
6549 1 \
6550 -s "Async sign callback: injected error" \
6551 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006552 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006553 -s "! mbedtls_ssl_handshake returned"
6554
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006555requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006556run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006557 "$P_SRV \
6558 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6559 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006560 "$P_CLI" \
6561 1 \
6562 -s "Async sign callback: using key slot " \
6563 -S "Async resume" \
6564 -s "Async cancel"
6565
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006566requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006567run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006568 "$P_SRV \
6569 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6570 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006571 "$P_CLI" \
6572 1 \
6573 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006574 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006575 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006576 -s "! mbedtls_ssl_handshake returned"
6577
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006578requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006579run_test "SSL async private: decrypt, error in start" \
6580 "$P_SRV \
6581 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6582 async_private_error=1" \
6583 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6584 1 \
6585 -s "Async decrypt callback: injected error" \
6586 -S "Async resume" \
6587 -S "Async cancel" \
6588 -s "! mbedtls_ssl_handshake returned"
6589
6590requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6591run_test "SSL async private: decrypt, cancel after start" \
6592 "$P_SRV \
6593 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6594 async_private_error=2" \
6595 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6596 1 \
6597 -s "Async decrypt callback: using key slot " \
6598 -S "Async resume" \
6599 -s "Async cancel"
6600
6601requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6602run_test "SSL async private: decrypt, error in resume" \
6603 "$P_SRV \
6604 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6605 async_private_error=3" \
6606 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6607 1 \
6608 -s "Async decrypt callback: using key slot " \
6609 -s "Async resume callback: decrypt done but injected error" \
6610 -S "Async cancel" \
6611 -s "! mbedtls_ssl_handshake returned"
6612
6613requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006614run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006615 "$P_SRV \
6616 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6617 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006618 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6619 0 \
6620 -s "Async cancel" \
6621 -s "! mbedtls_ssl_handshake returned" \
6622 -s "Async resume" \
6623 -s "Successful connection"
6624
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006625requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006626run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006627 "$P_SRV \
6628 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6629 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006630 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6631 0 \
6632 -s "! mbedtls_ssl_handshake returned" \
6633 -s "Async resume" \
6634 -s "Successful connection"
6635
6636# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006637requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006638run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006639 "$P_SRV \
6640 async_operations=s async_private_delay1=1 async_private_error=-2 \
6641 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6642 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006643 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6644 [ \$? -eq 1 ] &&
6645 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6646 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006647 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006648 -S "Async resume" \
6649 -s "Async cancel" \
6650 -s "! mbedtls_ssl_handshake returned" \
6651 -s "Async sign callback: no key matches this certificate." \
6652 -s "Successful connection"
6653
6654# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006655requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006656run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006657 "$P_SRV \
6658 async_operations=s async_private_delay1=1 async_private_error=-3 \
6659 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6660 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006661 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6662 [ \$? -eq 1 ] &&
6663 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6664 0 \
6665 -s "Async resume" \
6666 -s "! mbedtls_ssl_handshake returned" \
6667 -s "Async sign callback: no key matches this certificate." \
6668 -s "Successful connection"
6669
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006670requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006671requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006672run_test "SSL async private: renegotiation: client-initiated; sign" \
6673 "$P_SRV \
6674 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006675 exchanges=2 renegotiation=1" \
6676 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6677 0 \
6678 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006679 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006680
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006681requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006682requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006683run_test "SSL async private: renegotiation: server-initiated; sign" \
6684 "$P_SRV \
6685 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006686 exchanges=2 renegotiation=1 renegotiate=1" \
6687 "$P_CLI exchanges=2 renegotiation=1" \
6688 0 \
6689 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006690 -s "Async resume (slot [0-9]): sign done, status=0"
6691
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006692requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006693requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6694run_test "SSL async private: renegotiation: client-initiated; decrypt" \
6695 "$P_SRV \
6696 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6697 exchanges=2 renegotiation=1" \
6698 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
6699 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6700 0 \
6701 -s "Async decrypt callback: using key slot " \
6702 -s "Async resume (slot [0-9]): decrypt done, status=0"
6703
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006704requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006705requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6706run_test "SSL async private: renegotiation: server-initiated; decrypt" \
6707 "$P_SRV \
6708 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6709 exchanges=2 renegotiation=1 renegotiate=1" \
6710 "$P_CLI exchanges=2 renegotiation=1 \
6711 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6712 0 \
6713 -s "Async decrypt callback: using key slot " \
6714 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006715
Ron Eldor58093c82018-06-28 13:22:05 +03006716# Tests for ECC extensions (rfc 4492)
6717
Ron Eldor643df7c2018-06-28 16:17:00 +03006718requires_config_enabled MBEDTLS_AES_C
6719requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6720requires_config_enabled MBEDTLS_SHA256_C
6721requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006722run_test "Force a non ECC ciphersuite in the client side" \
6723 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006724 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006725 0 \
6726 -C "client hello, adding supported_elliptic_curves extension" \
6727 -C "client hello, adding supported_point_formats extension" \
6728 -S "found supported elliptic curves extension" \
6729 -S "found supported point formats extension"
6730
Ron Eldor643df7c2018-06-28 16:17:00 +03006731requires_config_enabled MBEDTLS_AES_C
6732requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6733requires_config_enabled MBEDTLS_SHA256_C
6734requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006735run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006736 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006737 "$P_CLI debug_level=3" \
6738 0 \
6739 -C "found supported_point_formats extension" \
6740 -S "server hello, supported_point_formats extension"
6741
Ron Eldor643df7c2018-06-28 16:17:00 +03006742requires_config_enabled MBEDTLS_AES_C
6743requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6744requires_config_enabled MBEDTLS_SHA256_C
6745requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006746run_test "Force an ECC ciphersuite in the client side" \
6747 "$P_SRV debug_level=3" \
6748 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6749 0 \
6750 -c "client hello, adding supported_elliptic_curves extension" \
6751 -c "client hello, adding supported_point_formats extension" \
6752 -s "found supported elliptic curves extension" \
6753 -s "found supported point formats extension"
6754
Ron Eldor643df7c2018-06-28 16:17:00 +03006755requires_config_enabled MBEDTLS_AES_C
6756requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6757requires_config_enabled MBEDTLS_SHA256_C
6758requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006759run_test "Force an ECC ciphersuite in the server side" \
6760 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6761 "$P_CLI debug_level=3" \
6762 0 \
6763 -c "found supported_point_formats extension" \
6764 -s "server hello, supported_point_formats extension"
6765
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006766# Tests for DTLS HelloVerifyRequest
6767
6768run_test "DTLS cookie: enabled" \
6769 "$P_SRV dtls=1 debug_level=2" \
6770 "$P_CLI dtls=1 debug_level=2" \
6771 0 \
6772 -s "cookie verification failed" \
6773 -s "cookie verification passed" \
6774 -S "cookie verification skipped" \
6775 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006776 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006777 -S "SSL - The requested feature is not available"
6778
6779run_test "DTLS cookie: disabled" \
6780 "$P_SRV dtls=1 debug_level=2 cookies=0" \
6781 "$P_CLI dtls=1 debug_level=2" \
6782 0 \
6783 -S "cookie verification failed" \
6784 -S "cookie verification passed" \
6785 -s "cookie verification skipped" \
6786 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006787 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006788 -S "SSL - The requested feature is not available"
6789
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006790run_test "DTLS cookie: default (failing)" \
6791 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
6792 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
6793 1 \
6794 -s "cookie verification failed" \
6795 -S "cookie verification passed" \
6796 -S "cookie verification skipped" \
6797 -C "received hello verify request" \
6798 -S "hello verification requested" \
6799 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006800
6801requires_ipv6
6802run_test "DTLS cookie: enabled, IPv6" \
6803 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
6804 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
6805 0 \
6806 -s "cookie verification failed" \
6807 -s "cookie verification passed" \
6808 -S "cookie verification skipped" \
6809 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006810 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006811 -S "SSL - The requested feature is not available"
6812
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02006813run_test "DTLS cookie: enabled, nbio" \
6814 "$P_SRV dtls=1 nbio=2 debug_level=2" \
6815 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6816 0 \
6817 -s "cookie verification failed" \
6818 -s "cookie verification passed" \
6819 -S "cookie verification skipped" \
6820 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006821 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02006822 -S "SSL - The requested feature is not available"
6823
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006824# Tests for client reconnecting from the same port with DTLS
6825
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006826not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006827run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006828 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
6829 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006830 0 \
6831 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006832 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006833 -S "Client initiated reconnection from same port"
6834
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006835not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006836run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006837 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
6838 "$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 +02006839 0 \
6840 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006841 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006842 -s "Client initiated reconnection from same port"
6843
Paul Bakker362689d2016-05-13 10:33:25 +01006844not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
6845run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006846 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
6847 "$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 +02006848 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006849 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006850 -s "Client initiated reconnection from same port"
6851
Paul Bakker362689d2016-05-13 10:33:25 +01006852only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
6853run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
6854 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
6855 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
6856 0 \
6857 -S "The operation timed out" \
6858 -s "Client initiated reconnection from same port"
6859
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006860run_test "DTLS client reconnect from same port: no cookies" \
6861 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02006862 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
6863 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006864 -s "The operation timed out" \
6865 -S "Client initiated reconnection from same port"
6866
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006867# Tests for various cases of client authentication with DTLS
6868# (focused on handshake flows and message parsing)
6869
6870run_test "DTLS client auth: required" \
6871 "$P_SRV dtls=1 auth_mode=required" \
6872 "$P_CLI dtls=1" \
6873 0 \
6874 -s "Verifying peer X.509 certificate... ok"
6875
6876run_test "DTLS client auth: optional, client has no cert" \
6877 "$P_SRV dtls=1 auth_mode=optional" \
6878 "$P_CLI dtls=1 crt_file=none key_file=none" \
6879 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006880 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006881
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006882run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006883 "$P_SRV dtls=1 auth_mode=none" \
6884 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
6885 0 \
6886 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006887 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006888
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02006889run_test "DTLS wrong PSK: badmac alert" \
6890 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
6891 "$P_CLI dtls=1 psk=abc124" \
6892 1 \
6893 -s "SSL - Verification of the message MAC failed" \
6894 -c "SSL - A fatal alert message was received from our peer"
6895
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02006896# Tests for receiving fragmented handshake messages with DTLS
6897
6898requires_gnutls
6899run_test "DTLS reassembly: no fragmentation (gnutls server)" \
6900 "$G_SRV -u --mtu 2048 -a" \
6901 "$P_CLI dtls=1 debug_level=2" \
6902 0 \
6903 -C "found fragmented DTLS handshake message" \
6904 -C "error"
6905
6906requires_gnutls
6907run_test "DTLS reassembly: some fragmentation (gnutls server)" \
6908 "$G_SRV -u --mtu 512" \
6909 "$P_CLI dtls=1 debug_level=2" \
6910 0 \
6911 -c "found fragmented DTLS handshake message" \
6912 -C "error"
6913
6914requires_gnutls
6915run_test "DTLS reassembly: more fragmentation (gnutls server)" \
6916 "$G_SRV -u --mtu 128" \
6917 "$P_CLI dtls=1 debug_level=2" \
6918 0 \
6919 -c "found fragmented DTLS handshake message" \
6920 -C "error"
6921
6922requires_gnutls
6923run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
6924 "$G_SRV -u --mtu 128" \
6925 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6926 0 \
6927 -c "found fragmented DTLS handshake message" \
6928 -C "error"
6929
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006930requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006931requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006932run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
6933 "$G_SRV -u --mtu 256" \
6934 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
6935 0 \
6936 -c "found fragmented DTLS handshake message" \
6937 -c "client hello, adding renegotiation extension" \
6938 -c "found renegotiation extension" \
6939 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006940 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006941 -C "error" \
6942 -s "Extra-header:"
6943
6944requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006945requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006946run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
6947 "$G_SRV -u --mtu 256" \
6948 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
6949 0 \
6950 -c "found fragmented DTLS handshake message" \
6951 -c "client hello, adding renegotiation extension" \
6952 -c "found renegotiation extension" \
6953 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006954 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006955 -C "error" \
6956 -s "Extra-header:"
6957
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006958run_test "DTLS reassembly: no fragmentation (openssl server)" \
6959 "$O_SRV -dtls1 -mtu 2048" \
6960 "$P_CLI dtls=1 debug_level=2" \
6961 0 \
6962 -C "found fragmented DTLS handshake message" \
6963 -C "error"
6964
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006965run_test "DTLS reassembly: some fragmentation (openssl server)" \
6966 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006967 "$P_CLI dtls=1 debug_level=2" \
6968 0 \
6969 -c "found fragmented DTLS handshake message" \
6970 -C "error"
6971
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006972run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006973 "$O_SRV -dtls1 -mtu 256" \
6974 "$P_CLI dtls=1 debug_level=2" \
6975 0 \
6976 -c "found fragmented DTLS handshake message" \
6977 -C "error"
6978
6979run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
6980 "$O_SRV -dtls1 -mtu 256" \
6981 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6982 0 \
6983 -c "found fragmented DTLS handshake message" \
6984 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006985
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006986# Tests for sending fragmented handshake messages with DTLS
6987#
6988# Use client auth when we need the client to send large messages,
6989# and use large cert chains on both sides too (the long chains we have all use
6990# both RSA and ECDSA, but ideally we should have long chains with either).
6991# Sizes reached (UDP payload):
6992# - 2037B for server certificate
6993# - 1542B for client certificate
6994# - 1013B for newsessionticket
6995# - all others below 512B
6996# All those tests assume MAX_CONTENT_LEN is at least 2048
6997
6998requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6999requires_config_enabled MBEDTLS_RSA_C
7000requires_config_enabled MBEDTLS_ECDSA_C
7001requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7002run_test "DTLS fragmenting: none (for reference)" \
7003 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7004 crt_file=data_files/server7_int-ca.crt \
7005 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007006 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007007 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007008 "$P_CLI dtls=1 debug_level=2 \
7009 crt_file=data_files/server8_int-ca2.crt \
7010 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007011 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007012 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007013 0 \
7014 -S "found fragmented DTLS handshake message" \
7015 -C "found fragmented DTLS handshake message" \
7016 -C "error"
7017
7018requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7019requires_config_enabled MBEDTLS_RSA_C
7020requires_config_enabled MBEDTLS_ECDSA_C
7021requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007022run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007023 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7024 crt_file=data_files/server7_int-ca.crt \
7025 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007026 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007027 max_frag_len=1024" \
7028 "$P_CLI dtls=1 debug_level=2 \
7029 crt_file=data_files/server8_int-ca2.crt \
7030 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007031 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007032 max_frag_len=2048" \
7033 0 \
7034 -S "found fragmented DTLS handshake message" \
7035 -c "found fragmented DTLS handshake message" \
7036 -C "error"
7037
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007038# With the MFL extension, the server has no way of forcing
7039# the client to not exceed a certain MTU; hence, the following
7040# test can't be replicated with an MTU proxy such as the one
7041# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007042requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7043requires_config_enabled MBEDTLS_RSA_C
7044requires_config_enabled MBEDTLS_ECDSA_C
7045requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007046run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007047 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7048 crt_file=data_files/server7_int-ca.crt \
7049 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007050 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007051 max_frag_len=512" \
7052 "$P_CLI dtls=1 debug_level=2 \
7053 crt_file=data_files/server8_int-ca2.crt \
7054 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007055 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007056 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007057 0 \
7058 -S "found fragmented DTLS handshake message" \
7059 -c "found fragmented DTLS handshake message" \
7060 -C "error"
7061
7062requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7063requires_config_enabled MBEDTLS_RSA_C
7064requires_config_enabled MBEDTLS_ECDSA_C
7065requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007066run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007067 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7068 crt_file=data_files/server7_int-ca.crt \
7069 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007070 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007071 max_frag_len=2048" \
7072 "$P_CLI dtls=1 debug_level=2 \
7073 crt_file=data_files/server8_int-ca2.crt \
7074 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007075 hs_timeout=2500-60000 \
7076 max_frag_len=1024" \
7077 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007078 -S "found fragmented DTLS handshake message" \
7079 -c "found fragmented DTLS handshake message" \
7080 -C "error"
7081
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007082# While not required by the standard defining the MFL extension
7083# (according to which it only applies to records, not to datagrams),
7084# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7085# as otherwise there wouldn't be any means to communicate MTU restrictions
7086# to the peer.
7087# The next test checks that no datagrams significantly larger than the
7088# negotiated MFL are sent.
7089requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7090requires_config_enabled MBEDTLS_RSA_C
7091requires_config_enabled MBEDTLS_ECDSA_C
7092requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7093run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007094 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007095 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7096 crt_file=data_files/server7_int-ca.crt \
7097 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007098 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007099 max_frag_len=2048" \
7100 "$P_CLI dtls=1 debug_level=2 \
7101 crt_file=data_files/server8_int-ca2.crt \
7102 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007103 hs_timeout=2500-60000 \
7104 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007105 0 \
7106 -S "found fragmented DTLS handshake message" \
7107 -c "found fragmented DTLS handshake message" \
7108 -C "error"
7109
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007110requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7111requires_config_enabled MBEDTLS_RSA_C
7112requires_config_enabled MBEDTLS_ECDSA_C
7113requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007114run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007115 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7116 crt_file=data_files/server7_int-ca.crt \
7117 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007118 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007119 max_frag_len=2048" \
7120 "$P_CLI dtls=1 debug_level=2 \
7121 crt_file=data_files/server8_int-ca2.crt \
7122 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007123 hs_timeout=2500-60000 \
7124 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007125 0 \
7126 -s "found fragmented DTLS handshake message" \
7127 -c "found fragmented DTLS handshake message" \
7128 -C "error"
7129
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007130# While not required by the standard defining the MFL extension
7131# (according to which it only applies to records, not to datagrams),
7132# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7133# as otherwise there wouldn't be any means to communicate MTU restrictions
7134# to the peer.
7135# The next test checks that no datagrams significantly larger than the
7136# negotiated MFL are sent.
7137requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7138requires_config_enabled MBEDTLS_RSA_C
7139requires_config_enabled MBEDTLS_ECDSA_C
7140requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7141run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007142 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007143 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7144 crt_file=data_files/server7_int-ca.crt \
7145 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007146 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007147 max_frag_len=2048" \
7148 "$P_CLI dtls=1 debug_level=2 \
7149 crt_file=data_files/server8_int-ca2.crt \
7150 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007151 hs_timeout=2500-60000 \
7152 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007153 0 \
7154 -s "found fragmented DTLS handshake message" \
7155 -c "found fragmented DTLS handshake message" \
7156 -C "error"
7157
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007158requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7159requires_config_enabled MBEDTLS_RSA_C
7160requires_config_enabled MBEDTLS_ECDSA_C
7161run_test "DTLS fragmenting: none (for reference) (MTU)" \
7162 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7163 crt_file=data_files/server7_int-ca.crt \
7164 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007165 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007166 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007167 "$P_CLI dtls=1 debug_level=2 \
7168 crt_file=data_files/server8_int-ca2.crt \
7169 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007170 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007171 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007172 0 \
7173 -S "found fragmented DTLS handshake message" \
7174 -C "found fragmented DTLS handshake message" \
7175 -C "error"
7176
7177requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7178requires_config_enabled MBEDTLS_RSA_C
7179requires_config_enabled MBEDTLS_ECDSA_C
7180run_test "DTLS fragmenting: client (MTU)" \
7181 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7182 crt_file=data_files/server7_int-ca.crt \
7183 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007184 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007185 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007186 "$P_CLI dtls=1 debug_level=2 \
7187 crt_file=data_files/server8_int-ca2.crt \
7188 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007189 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007190 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007191 0 \
7192 -s "found fragmented DTLS handshake message" \
7193 -C "found fragmented DTLS handshake message" \
7194 -C "error"
7195
7196requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7197requires_config_enabled MBEDTLS_RSA_C
7198requires_config_enabled MBEDTLS_ECDSA_C
7199run_test "DTLS fragmenting: server (MTU)" \
7200 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7201 crt_file=data_files/server7_int-ca.crt \
7202 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007203 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007204 mtu=512" \
7205 "$P_CLI dtls=1 debug_level=2 \
7206 crt_file=data_files/server8_int-ca2.crt \
7207 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007208 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007209 mtu=2048" \
7210 0 \
7211 -S "found fragmented DTLS handshake message" \
7212 -c "found fragmented DTLS handshake message" \
7213 -C "error"
7214
7215requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7216requires_config_enabled MBEDTLS_RSA_C
7217requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007218run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007219 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007220 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7221 crt_file=data_files/server7_int-ca.crt \
7222 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007223 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007224 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007225 "$P_CLI dtls=1 debug_level=2 \
7226 crt_file=data_files/server8_int-ca2.crt \
7227 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007228 hs_timeout=2500-60000 \
7229 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007230 0 \
7231 -s "found fragmented DTLS handshake message" \
7232 -c "found fragmented DTLS handshake message" \
7233 -C "error"
7234
Andrzej Kurek77826052018-10-11 07:34:08 -04007235# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007236requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7237requires_config_enabled MBEDTLS_RSA_C
7238requires_config_enabled MBEDTLS_ECDSA_C
7239requires_config_enabled MBEDTLS_SHA256_C
7240requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7241requires_config_enabled MBEDTLS_AES_C
7242requires_config_enabled MBEDTLS_GCM_C
7243run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007244 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007245 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7246 crt_file=data_files/server7_int-ca.crt \
7247 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007248 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007249 mtu=512" \
7250 "$P_CLI dtls=1 debug_level=2 \
7251 crt_file=data_files/server8_int-ca2.crt \
7252 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007253 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7254 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007255 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007256 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007257 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007258 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007259 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007260
Andrzej Kurek7311c782018-10-11 06:49:41 -04007261# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007262# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007263# The ratio of max/min timeout should ideally equal 4 to accept two
7264# retransmissions, but in some cases (like both the server and client using
7265# fragmentation and auto-reduction) an extra retransmission might occur,
7266# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007267not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007268requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7269requires_config_enabled MBEDTLS_RSA_C
7270requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007271requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7272requires_config_enabled MBEDTLS_AES_C
7273requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007274run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7275 -p "$P_PXY mtu=508" \
7276 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7277 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007278 key_file=data_files/server7.key \
7279 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007280 "$P_CLI dtls=1 debug_level=2 \
7281 crt_file=data_files/server8_int-ca2.crt \
7282 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007283 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7284 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007285 0 \
7286 -s "found fragmented DTLS handshake message" \
7287 -c "found fragmented DTLS handshake message" \
7288 -C "error"
7289
Andrzej Kurek77826052018-10-11 07:34:08 -04007290# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01007291only_with_valgrind
7292requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7293requires_config_enabled MBEDTLS_RSA_C
7294requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007295requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7296requires_config_enabled MBEDTLS_AES_C
7297requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01007298run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7299 -p "$P_PXY mtu=508" \
7300 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7301 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007302 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01007303 hs_timeout=250-10000" \
7304 "$P_CLI dtls=1 debug_level=2 \
7305 crt_file=data_files/server8_int-ca2.crt \
7306 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007307 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01007308 hs_timeout=250-10000" \
7309 0 \
7310 -s "found fragmented DTLS handshake message" \
7311 -c "found fragmented DTLS handshake message" \
7312 -C "error"
7313
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007314# 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 +02007315# OTOH the client might resend if the server is to slow to reset after sending
7316# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007317not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007318requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7319requires_config_enabled MBEDTLS_RSA_C
7320requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007321run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007322 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007323 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7324 crt_file=data_files/server7_int-ca.crt \
7325 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007326 hs_timeout=10000-60000 \
7327 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007328 "$P_CLI dtls=1 debug_level=2 \
7329 crt_file=data_files/server8_int-ca2.crt \
7330 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007331 hs_timeout=10000-60000 \
7332 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007333 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007334 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007335 -s "found fragmented DTLS handshake message" \
7336 -c "found fragmented DTLS handshake message" \
7337 -C "error"
7338
Andrzej Kurek77826052018-10-11 07:34:08 -04007339# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007340# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
7341# OTOH the client might resend if the server is to slow to reset after sending
7342# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007343not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007344requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7345requires_config_enabled MBEDTLS_RSA_C
7346requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007347requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7348requires_config_enabled MBEDTLS_AES_C
7349requires_config_enabled MBEDTLS_GCM_C
7350run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007351 -p "$P_PXY mtu=512" \
7352 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7353 crt_file=data_files/server7_int-ca.crt \
7354 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007355 hs_timeout=10000-60000 \
7356 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007357 "$P_CLI dtls=1 debug_level=2 \
7358 crt_file=data_files/server8_int-ca2.crt \
7359 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007360 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7361 hs_timeout=10000-60000 \
7362 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007363 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007364 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007365 -s "found fragmented DTLS handshake message" \
7366 -c "found fragmented DTLS handshake message" \
7367 -C "error"
7368
Andrzej Kurek7311c782018-10-11 06:49:41 -04007369not_with_valgrind # spurious autoreduction due to timeout
7370requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7371requires_config_enabled MBEDTLS_RSA_C
7372requires_config_enabled MBEDTLS_ECDSA_C
7373run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007374 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007375 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7376 crt_file=data_files/server7_int-ca.crt \
7377 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007378 hs_timeout=10000-60000 \
7379 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007380 "$P_CLI dtls=1 debug_level=2 \
7381 crt_file=data_files/server8_int-ca2.crt \
7382 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007383 hs_timeout=10000-60000 \
7384 mtu=1024 nbio=2" \
7385 0 \
7386 -S "autoreduction" \
7387 -s "found fragmented DTLS handshake message" \
7388 -c "found fragmented DTLS handshake message" \
7389 -C "error"
7390
Andrzej Kurek77826052018-10-11 07:34:08 -04007391# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007392not_with_valgrind # spurious autoreduction due to timeout
7393requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7394requires_config_enabled MBEDTLS_RSA_C
7395requires_config_enabled MBEDTLS_ECDSA_C
7396requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7397requires_config_enabled MBEDTLS_AES_C
7398requires_config_enabled MBEDTLS_GCM_C
7399run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7400 -p "$P_PXY mtu=512" \
7401 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7402 crt_file=data_files/server7_int-ca.crt \
7403 key_file=data_files/server7.key \
7404 hs_timeout=10000-60000 \
7405 mtu=512 nbio=2" \
7406 "$P_CLI dtls=1 debug_level=2 \
7407 crt_file=data_files/server8_int-ca2.crt \
7408 key_file=data_files/server8.key \
7409 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7410 hs_timeout=10000-60000 \
7411 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007412 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007413 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007414 -s "found fragmented DTLS handshake message" \
7415 -c "found fragmented DTLS handshake message" \
7416 -C "error"
7417
Andrzej Kurek77826052018-10-11 07:34:08 -04007418# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007419# This ensures things still work after session_reset().
7420# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007421# Since we don't support reading fragmented ClientHello yet,
7422# up the MTU to 1450 (larger than ClientHello with session ticket,
7423# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007424# An autoreduction on the client-side might happen if the server is
7425# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007426# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007427# resumed listening, which would result in a spurious autoreduction.
7428not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007429requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7430requires_config_enabled MBEDTLS_RSA_C
7431requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007432requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7433requires_config_enabled MBEDTLS_AES_C
7434requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007435run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7436 -p "$P_PXY mtu=1450" \
7437 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7438 crt_file=data_files/server7_int-ca.crt \
7439 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007440 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007441 mtu=1450" \
7442 "$P_CLI dtls=1 debug_level=2 \
7443 crt_file=data_files/server8_int-ca2.crt \
7444 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007445 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007446 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007447 mtu=1450 reconnect=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007448 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007449 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007450 -s "found fragmented DTLS handshake message" \
7451 -c "found fragmented DTLS handshake message" \
7452 -C "error"
7453
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007454# An autoreduction on the client-side might happen if the server is
7455# slow to reset, therefore omitting '-C "autoreduction"' below.
7456not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007457requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7458requires_config_enabled MBEDTLS_RSA_C
7459requires_config_enabled MBEDTLS_ECDSA_C
7460requires_config_enabled MBEDTLS_SHA256_C
7461requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7462requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7463requires_config_enabled MBEDTLS_CHACHAPOLY_C
7464run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7465 -p "$P_PXY mtu=512" \
7466 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7467 crt_file=data_files/server7_int-ca.crt \
7468 key_file=data_files/server7.key \
7469 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007470 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007471 mtu=512" \
7472 "$P_CLI dtls=1 debug_level=2 \
7473 crt_file=data_files/server8_int-ca2.crt \
7474 key_file=data_files/server8.key \
7475 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007476 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007477 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007478 mtu=512" \
7479 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007480 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007481 -s "found fragmented DTLS handshake message" \
7482 -c "found fragmented DTLS handshake message" \
7483 -C "error"
7484
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007485# An autoreduction on the client-side might happen if the server is
7486# slow to reset, therefore omitting '-C "autoreduction"' below.
7487not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007488requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7489requires_config_enabled MBEDTLS_RSA_C
7490requires_config_enabled MBEDTLS_ECDSA_C
7491requires_config_enabled MBEDTLS_SHA256_C
7492requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7493requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7494requires_config_enabled MBEDTLS_AES_C
7495requires_config_enabled MBEDTLS_GCM_C
7496run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7497 -p "$P_PXY mtu=512" \
7498 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7499 crt_file=data_files/server7_int-ca.crt \
7500 key_file=data_files/server7.key \
7501 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007502 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007503 mtu=512" \
7504 "$P_CLI dtls=1 debug_level=2 \
7505 crt_file=data_files/server8_int-ca2.crt \
7506 key_file=data_files/server8.key \
7507 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007508 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007509 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007510 mtu=512" \
7511 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007512 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007513 -s "found fragmented DTLS handshake message" \
7514 -c "found fragmented DTLS handshake message" \
7515 -C "error"
7516
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007517# An autoreduction on the client-side might happen if the server is
7518# slow to reset, therefore omitting '-C "autoreduction"' below.
7519not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007520requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7521requires_config_enabled MBEDTLS_RSA_C
7522requires_config_enabled MBEDTLS_ECDSA_C
7523requires_config_enabled MBEDTLS_SHA256_C
7524requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7525requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7526requires_config_enabled MBEDTLS_AES_C
7527requires_config_enabled MBEDTLS_CCM_C
7528run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007529 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007530 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7531 crt_file=data_files/server7_int-ca.crt \
7532 key_file=data_files/server7.key \
7533 exchanges=2 renegotiation=1 \
7534 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007535 hs_timeout=10000-60000 \
7536 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007537 "$P_CLI dtls=1 debug_level=2 \
7538 crt_file=data_files/server8_int-ca2.crt \
7539 key_file=data_files/server8.key \
7540 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007541 hs_timeout=10000-60000 \
7542 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007543 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007544 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007545 -s "found fragmented DTLS handshake message" \
7546 -c "found fragmented DTLS handshake message" \
7547 -C "error"
7548
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007549# An autoreduction on the client-side might happen if the server is
7550# slow to reset, therefore omitting '-C "autoreduction"' below.
7551not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007552requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7553requires_config_enabled MBEDTLS_RSA_C
7554requires_config_enabled MBEDTLS_ECDSA_C
7555requires_config_enabled MBEDTLS_SHA256_C
7556requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7557requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7558requires_config_enabled MBEDTLS_AES_C
7559requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7560requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7561run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007562 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007563 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7564 crt_file=data_files/server7_int-ca.crt \
7565 key_file=data_files/server7.key \
7566 exchanges=2 renegotiation=1 \
7567 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007568 hs_timeout=10000-60000 \
7569 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007570 "$P_CLI dtls=1 debug_level=2 \
7571 crt_file=data_files/server8_int-ca2.crt \
7572 key_file=data_files/server8.key \
7573 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007574 hs_timeout=10000-60000 \
7575 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007576 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007577 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007578 -s "found fragmented DTLS handshake message" \
7579 -c "found fragmented DTLS handshake message" \
7580 -C "error"
7581
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007582# An autoreduction on the client-side might happen if the server is
7583# slow to reset, therefore omitting '-C "autoreduction"' below.
7584not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007585requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7586requires_config_enabled MBEDTLS_RSA_C
7587requires_config_enabled MBEDTLS_ECDSA_C
7588requires_config_enabled MBEDTLS_SHA256_C
7589requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7590requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7591requires_config_enabled MBEDTLS_AES_C
7592requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7593run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007594 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007595 "$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 \
7598 exchanges=2 renegotiation=1 \
7599 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007600 hs_timeout=10000-60000 \
7601 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007602 "$P_CLI dtls=1 debug_level=2 \
7603 crt_file=data_files/server8_int-ca2.crt \
7604 key_file=data_files/server8.key \
7605 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007606 hs_timeout=10000-60000 \
7607 mtu=1024" \
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 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007615requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7616requires_config_enabled MBEDTLS_RSA_C
7617requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007618requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7619requires_config_enabled MBEDTLS_AES_C
7620requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007621client_needs_more_time 2
7622run_test "DTLS fragmenting: proxy MTU + 3d" \
7623 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007624 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007625 crt_file=data_files/server7_int-ca.crt \
7626 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007627 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007628 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007629 crt_file=data_files/server8_int-ca2.crt \
7630 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007631 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007632 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007633 0 \
7634 -s "found fragmented DTLS handshake message" \
7635 -c "found fragmented DTLS handshake message" \
7636 -C "error"
7637
Andrzej Kurek77826052018-10-11 07:34:08 -04007638# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007639requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7640requires_config_enabled MBEDTLS_RSA_C
7641requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007642requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7643requires_config_enabled MBEDTLS_AES_C
7644requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007645client_needs_more_time 2
7646run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7647 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7648 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7649 crt_file=data_files/server7_int-ca.crt \
7650 key_file=data_files/server7.key \
7651 hs_timeout=250-10000 mtu=512 nbio=2" \
7652 "$P_CLI dtls=1 debug_level=2 \
7653 crt_file=data_files/server8_int-ca2.crt \
7654 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007655 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007656 hs_timeout=250-10000 mtu=512 nbio=2" \
7657 0 \
7658 -s "found fragmented DTLS handshake message" \
7659 -c "found fragmented DTLS handshake message" \
7660 -C "error"
7661
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007662# interop tests for DTLS fragmentating with reliable connection
7663#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007664# here and below we just want to test that the we fragment in a way that
7665# pleases other implementations, so we don't need the peer to fragment
7666requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7667requires_config_enabled MBEDTLS_RSA_C
7668requires_config_enabled MBEDTLS_ECDSA_C
7669requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007670requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007671run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
7672 "$G_SRV -u" \
7673 "$P_CLI dtls=1 debug_level=2 \
7674 crt_file=data_files/server8_int-ca2.crt \
7675 key_file=data_files/server8.key \
7676 mtu=512 force_version=dtls1_2" \
7677 0 \
7678 -c "fragmenting handshake message" \
7679 -C "error"
7680
7681requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7682requires_config_enabled MBEDTLS_RSA_C
7683requires_config_enabled MBEDTLS_ECDSA_C
7684requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007685requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007686run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
7687 "$G_SRV -u" \
7688 "$P_CLI dtls=1 debug_level=2 \
7689 crt_file=data_files/server8_int-ca2.crt \
7690 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007691 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007692 0 \
7693 -c "fragmenting handshake message" \
7694 -C "error"
7695
Hanno Beckerb9a00862018-08-28 10:20:22 +01007696# We use --insecure for the GnuTLS client because it expects
7697# the hostname / IP it connects to to be the name used in the
7698# certificate obtained from the server. Here, however, it
7699# connects to 127.0.0.1 while our test certificates use 'localhost'
7700# as the server name in the certificate. This will make the
7701# certifiate validation fail, but passing --insecure makes
7702# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007703requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7704requires_config_enabled MBEDTLS_RSA_C
7705requires_config_enabled MBEDTLS_ECDSA_C
7706requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007707requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007708requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007709run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007710 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007711 crt_file=data_files/server7_int-ca.crt \
7712 key_file=data_files/server7.key \
7713 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007714 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007715 0 \
7716 -s "fragmenting handshake message"
7717
Hanno Beckerb9a00862018-08-28 10:20:22 +01007718# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007719requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7720requires_config_enabled MBEDTLS_RSA_C
7721requires_config_enabled MBEDTLS_ECDSA_C
7722requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007723requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007724requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007725run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007726 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007727 crt_file=data_files/server7_int-ca.crt \
7728 key_file=data_files/server7.key \
7729 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007730 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007731 0 \
7732 -s "fragmenting handshake message"
7733
7734requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7735requires_config_enabled MBEDTLS_RSA_C
7736requires_config_enabled MBEDTLS_ECDSA_C
7737requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7738run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
7739 "$O_SRV -dtls1_2 -verify 10" \
7740 "$P_CLI dtls=1 debug_level=2 \
7741 crt_file=data_files/server8_int-ca2.crt \
7742 key_file=data_files/server8.key \
7743 mtu=512 force_version=dtls1_2" \
7744 0 \
7745 -c "fragmenting handshake message" \
7746 -C "error"
7747
7748requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7749requires_config_enabled MBEDTLS_RSA_C
7750requires_config_enabled MBEDTLS_ECDSA_C
7751requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7752run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
7753 "$O_SRV -dtls1 -verify 10" \
7754 "$P_CLI dtls=1 debug_level=2 \
7755 crt_file=data_files/server8_int-ca2.crt \
7756 key_file=data_files/server8.key \
7757 mtu=512 force_version=dtls1" \
7758 0 \
7759 -c "fragmenting handshake message" \
7760 -C "error"
7761
7762requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7763requires_config_enabled MBEDTLS_RSA_C
7764requires_config_enabled MBEDTLS_ECDSA_C
7765requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7766run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
7767 "$P_SRV dtls=1 debug_level=2 \
7768 crt_file=data_files/server7_int-ca.crt \
7769 key_file=data_files/server7.key \
7770 mtu=512 force_version=dtls1_2" \
7771 "$O_CLI -dtls1_2" \
7772 0 \
7773 -s "fragmenting handshake message"
7774
7775requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7776requires_config_enabled MBEDTLS_RSA_C
7777requires_config_enabled MBEDTLS_ECDSA_C
7778requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7779run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
7780 "$P_SRV dtls=1 debug_level=2 \
7781 crt_file=data_files/server7_int-ca.crt \
7782 key_file=data_files/server7.key \
7783 mtu=512 force_version=dtls1" \
7784 "$O_CLI -dtls1" \
7785 0 \
7786 -s "fragmenting handshake message"
7787
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007788# interop tests for DTLS fragmentating with unreliable connection
7789#
7790# again we just want to test that the we fragment in a way that
7791# pleases other implementations, so we don't need the peer to fragment
7792requires_gnutls_next
7793requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7794requires_config_enabled MBEDTLS_RSA_C
7795requires_config_enabled MBEDTLS_ECDSA_C
7796requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007797client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007798run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
7799 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7800 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007801 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007802 crt_file=data_files/server8_int-ca2.crt \
7803 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007804 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007805 0 \
7806 -c "fragmenting handshake message" \
7807 -C "error"
7808
7809requires_gnutls_next
7810requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7811requires_config_enabled MBEDTLS_RSA_C
7812requires_config_enabled MBEDTLS_ECDSA_C
7813requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007814client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007815run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
7816 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7817 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007818 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007819 crt_file=data_files/server8_int-ca2.crt \
7820 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007821 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007822 0 \
7823 -c "fragmenting handshake message" \
7824 -C "error"
7825
k-stachowiak17a38d32019-02-18 15:29:56 +01007826requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007827requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7828requires_config_enabled MBEDTLS_RSA_C
7829requires_config_enabled MBEDTLS_ECDSA_C
7830requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7831client_needs_more_time 4
7832run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
7833 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7834 "$P_SRV dtls=1 debug_level=2 \
7835 crt_file=data_files/server7_int-ca.crt \
7836 key_file=data_files/server7.key \
7837 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiak17a38d32019-02-18 15:29:56 +01007838 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007839 0 \
7840 -s "fragmenting handshake message"
7841
k-stachowiak17a38d32019-02-18 15:29:56 +01007842requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007843requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7844requires_config_enabled MBEDTLS_RSA_C
7845requires_config_enabled MBEDTLS_ECDSA_C
7846requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7847client_needs_more_time 4
7848run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
7849 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7850 "$P_SRV dtls=1 debug_level=2 \
7851 crt_file=data_files/server7_int-ca.crt \
7852 key_file=data_files/server7.key \
7853 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiak17a38d32019-02-18 15:29:56 +01007854 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007855 0 \
7856 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007857
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007858## Interop test with OpenSSL might trigger a bug in recent versions (including
7859## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007860## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007861## They should be re-enabled once a fixed version of OpenSSL is available
7862## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007863skip_next_test
7864requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7865requires_config_enabled MBEDTLS_RSA_C
7866requires_config_enabled MBEDTLS_ECDSA_C
7867requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7868client_needs_more_time 4
7869run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
7870 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7871 "$O_SRV -dtls1_2 -verify 10" \
7872 "$P_CLI dtls=1 debug_level=2 \
7873 crt_file=data_files/server8_int-ca2.crt \
7874 key_file=data_files/server8.key \
7875 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7876 0 \
7877 -c "fragmenting handshake message" \
7878 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007879
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007880skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007881requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7882requires_config_enabled MBEDTLS_RSA_C
7883requires_config_enabled MBEDTLS_ECDSA_C
7884requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007885client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007886run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
7887 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007888 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007889 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007890 crt_file=data_files/server8_int-ca2.crt \
7891 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007892 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007893 0 \
7894 -c "fragmenting handshake message" \
7895 -C "error"
7896
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007897skip_next_test
7898requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7899requires_config_enabled MBEDTLS_RSA_C
7900requires_config_enabled MBEDTLS_ECDSA_C
7901requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7902client_needs_more_time 4
7903run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
7904 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7905 "$P_SRV dtls=1 debug_level=2 \
7906 crt_file=data_files/server7_int-ca.crt \
7907 key_file=data_files/server7.key \
7908 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7909 "$O_CLI -dtls1_2" \
7910 0 \
7911 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007912
7913# -nbio is added to prevent s_client from blocking in case of duplicated
7914# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007915skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007916requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7917requires_config_enabled MBEDTLS_RSA_C
7918requires_config_enabled MBEDTLS_ECDSA_C
7919requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007920client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007921run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
7922 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007923 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007924 crt_file=data_files/server7_int-ca.crt \
7925 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007926 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007927 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007928 0 \
7929 -s "fragmenting handshake message"
7930
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007931# Tests for specific things with "unreliable" UDP connection
7932
7933not_with_valgrind # spurious resend due to timeout
7934run_test "DTLS proxy: reference" \
7935 -p "$P_PXY" \
7936 "$P_SRV dtls=1 debug_level=2" \
7937 "$P_CLI dtls=1 debug_level=2" \
7938 0 \
7939 -C "replayed record" \
7940 -S "replayed record" \
7941 -C "record from another epoch" \
7942 -S "record from another epoch" \
7943 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007944 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007945 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007946 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007947 -c "HTTP/1.0 200 OK"
7948
7949not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007950run_test "DTLS proxy: duplicate every packet" \
7951 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007952 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7953 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007954 0 \
7955 -c "replayed record" \
7956 -s "replayed record" \
7957 -c "record from another epoch" \
7958 -s "record from another epoch" \
7959 -S "resend" \
7960 -s "Extra-header:" \
7961 -c "HTTP/1.0 200 OK"
7962
7963run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
7964 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007965 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
7966 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007967 0 \
7968 -c "replayed record" \
7969 -S "replayed record" \
7970 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007971 -s "record from another epoch" \
7972 -c "resend" \
7973 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007974 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007975 -c "HTTP/1.0 200 OK"
7976
7977run_test "DTLS proxy: multiple records in same datagram" \
7978 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007979 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7980 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007981 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007982 -c "next record in same datagram" \
7983 -s "next record in same datagram"
7984
7985run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
7986 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007987 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7988 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007989 0 \
7990 -c "next record in same datagram" \
7991 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007992
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007993run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
7994 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007995 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
7996 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007997 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007998 -c "discarding invalid record (mac)" \
7999 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008000 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008001 -c "HTTP/1.0 200 OK" \
8002 -S "too many records with bad MAC" \
8003 -S "Verification of the message MAC failed"
8004
8005run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8006 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008007 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8008 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008009 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008010 -C "discarding invalid record (mac)" \
8011 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008012 -S "Extra-header:" \
8013 -C "HTTP/1.0 200 OK" \
8014 -s "too many records with bad MAC" \
8015 -s "Verification of the message MAC failed"
8016
8017run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8018 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008019 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8020 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008021 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008022 -c "discarding invalid record (mac)" \
8023 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008024 -s "Extra-header:" \
8025 -c "HTTP/1.0 200 OK" \
8026 -S "too many records with bad MAC" \
8027 -S "Verification of the message MAC failed"
8028
8029run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8030 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008031 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8032 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008033 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008034 -c "discarding invalid record (mac)" \
8035 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008036 -s "Extra-header:" \
8037 -c "HTTP/1.0 200 OK" \
8038 -s "too many records with bad MAC" \
8039 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008040
8041run_test "DTLS proxy: delay ChangeCipherSpec" \
8042 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008043 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8044 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008045 0 \
8046 -c "record from another epoch" \
8047 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008048 -s "Extra-header:" \
8049 -c "HTTP/1.0 200 OK"
8050
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008051# Tests for reordering support with DTLS
8052
Hanno Becker56cdfd12018-08-17 13:42:15 +01008053run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8054 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008055 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8056 hs_timeout=2500-60000" \
8057 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8058 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008059 0 \
8060 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008061 -c "Next handshake message has been buffered - load"\
8062 -S "Buffering HS message" \
8063 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008064 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008065 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008066 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008067 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008068
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008069run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8070 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008071 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8072 hs_timeout=2500-60000" \
8073 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8074 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008075 0 \
8076 -c "Buffering HS message" \
8077 -c "found fragmented DTLS handshake message"\
8078 -c "Next handshake message 1 not or only partially bufffered" \
8079 -c "Next handshake message has been buffered - load"\
8080 -S "Buffering HS message" \
8081 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008082 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008083 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008084 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008085 -S "Remember CCS message"
8086
Hanno Beckera1adcca2018-08-24 14:41:07 +01008087# The client buffers the ServerKeyExchange before receiving the fragmented
8088# Certificate message; at the time of writing, together these are aroudn 1200b
8089# in size, so that the bound below ensures that the certificate can be reassembled
8090# while keeping the ServerKeyExchange.
8091requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8092run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008093 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008094 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8095 hs_timeout=2500-60000" \
8096 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8097 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008098 0 \
8099 -c "Buffering HS message" \
8100 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008101 -C "attempt to make space by freeing buffered messages" \
8102 -S "Buffering HS message" \
8103 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008104 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008105 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008106 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008107 -S "Remember CCS message"
8108
8109# The size constraints ensure that the delayed certificate message can't
8110# be reassembled while keeping the ServerKeyExchange message, but it can
8111# when dropping it first.
8112requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8113requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8114run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8115 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008116 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8117 hs_timeout=2500-60000" \
8118 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8119 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008120 0 \
8121 -c "Buffering HS message" \
8122 -c "attempt to make space by freeing buffered future messages" \
8123 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008124 -S "Buffering HS message" \
8125 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008126 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008127 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008128 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008129 -S "Remember CCS message"
8130
Hanno Becker56cdfd12018-08-17 13:42:15 +01008131run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8132 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008133 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8134 hs_timeout=2500-60000" \
8135 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8136 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008137 0 \
8138 -C "Buffering HS message" \
8139 -C "Next handshake message has been buffered - load"\
8140 -s "Buffering HS message" \
8141 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008142 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008143 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008144 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008145 -S "Remember CCS message"
8146
8147run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8148 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008149 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8150 hs_timeout=2500-60000" \
8151 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8152 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008153 0 \
8154 -C "Buffering HS message" \
8155 -C "Next handshake message has been buffered - load"\
8156 -S "Buffering HS message" \
8157 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008158 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008159 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008160 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008161 -S "Remember CCS message"
8162
8163run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8164 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008165 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8166 hs_timeout=2500-60000" \
8167 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8168 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008169 0 \
8170 -C "Buffering HS message" \
8171 -C "Next handshake message has been buffered - load"\
8172 -S "Buffering HS message" \
8173 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008174 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008175 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008176 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008177 -s "Remember CCS message"
8178
Hanno Beckera1adcca2018-08-24 14:41:07 +01008179run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008180 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008181 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8182 hs_timeout=2500-60000" \
8183 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8184 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008185 0 \
8186 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008187 -s "Found buffered record from current epoch - load" \
8188 -c "Buffer record from epoch 1" \
8189 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008190
Hanno Beckera1adcca2018-08-24 14:41:07 +01008191# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8192# from the server are delayed, so that the encrypted Finished message
8193# is received and buffered. When the fragmented NewSessionTicket comes
8194# in afterwards, the encrypted Finished message must be freed in order
8195# to make space for the NewSessionTicket to be reassembled.
8196# This works only in very particular circumstances:
8197# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8198# of the NewSessionTicket, but small enough to also allow buffering of
8199# the encrypted Finished message.
8200# - The MTU setting on the server must be so small that the NewSessionTicket
8201# needs to be fragmented.
8202# - All messages sent by the server must be small enough to be either sent
8203# without fragmentation or be reassembled within the bounds of
8204# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8205# handshake, omitting CRTs.
8206requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
8207requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
8208run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8209 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
8210 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
8211 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8212 0 \
8213 -s "Buffer record from epoch 1" \
8214 -s "Found buffered record from current epoch - load" \
8215 -c "Buffer record from epoch 1" \
8216 -C "Found buffered record from current epoch - load" \
8217 -c "Enough space available after freeing future epoch record"
8218
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008219# Tests for "randomly unreliable connection": try a variety of flows and peers
8220
8221client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008222run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8223 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008224 "$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 +02008225 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008226 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008227 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8228 0 \
8229 -s "Extra-header:" \
8230 -c "HTTP/1.0 200 OK"
8231
Janos Follath74537a62016-09-02 13:45:28 +01008232client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008233run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8234 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008235 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8236 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008237 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8238 0 \
8239 -s "Extra-header:" \
8240 -c "HTTP/1.0 200 OK"
8241
Janos Follath74537a62016-09-02 13:45:28 +01008242client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008243run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8244 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008245 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8246 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008247 0 \
8248 -s "Extra-header:" \
8249 -c "HTTP/1.0 200 OK"
8250
Janos Follath74537a62016-09-02 13:45:28 +01008251client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008252run_test "DTLS proxy: 3d, FS, client auth" \
8253 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008254 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8255 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008256 0 \
8257 -s "Extra-header:" \
8258 -c "HTTP/1.0 200 OK"
8259
Janos Follath74537a62016-09-02 13:45:28 +01008260client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008261run_test "DTLS proxy: 3d, FS, ticket" \
8262 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008263 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8264 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008265 0 \
8266 -s "Extra-header:" \
8267 -c "HTTP/1.0 200 OK"
8268
Janos Follath74537a62016-09-02 13:45:28 +01008269client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008270run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8271 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008272 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8273 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008274 0 \
8275 -s "Extra-header:" \
8276 -c "HTTP/1.0 200 OK"
8277
Janos Follath74537a62016-09-02 13:45:28 +01008278client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008279run_test "DTLS proxy: 3d, max handshake, nbio" \
8280 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008281 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008282 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008283 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008284 0 \
8285 -s "Extra-header:" \
8286 -c "HTTP/1.0 200 OK"
8287
Janos Follath74537a62016-09-02 13:45:28 +01008288client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008289run_test "DTLS proxy: 3d, min handshake, resumption" \
8290 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008291 "$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 +02008292 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008293 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008294 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8295 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8296 0 \
8297 -s "a session has been resumed" \
8298 -c "a session has been resumed" \
8299 -s "Extra-header:" \
8300 -c "HTTP/1.0 200 OK"
8301
Janos Follath74537a62016-09-02 13:45:28 +01008302client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008303run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8304 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008305 "$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 +02008306 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008307 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008308 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8309 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8310 0 \
8311 -s "a session has been resumed" \
8312 -c "a session has been resumed" \
8313 -s "Extra-header:" \
8314 -c "HTTP/1.0 200 OK"
8315
Janos Follath74537a62016-09-02 13:45:28 +01008316client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008317requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008318run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008319 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008320 "$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 +02008321 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008322 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008323 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008324 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8325 0 \
8326 -c "=> renegotiate" \
8327 -s "=> renegotiate" \
8328 -s "Extra-header:" \
8329 -c "HTTP/1.0 200 OK"
8330
Janos Follath74537a62016-09-02 13:45:28 +01008331client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008332requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008333run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8334 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008335 "$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 +02008336 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008337 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008338 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008339 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8340 0 \
8341 -c "=> renegotiate" \
8342 -s "=> renegotiate" \
8343 -s "Extra-header:" \
8344 -c "HTTP/1.0 200 OK"
8345
Janos Follath74537a62016-09-02 13:45:28 +01008346client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008347requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008348run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008349 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008350 "$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 +02008351 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008352 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008353 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008354 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008355 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8356 0 \
8357 -c "=> renegotiate" \
8358 -s "=> renegotiate" \
8359 -s "Extra-header:" \
8360 -c "HTTP/1.0 200 OK"
8361
Janos Follath74537a62016-09-02 13:45:28 +01008362client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008363requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008364run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008365 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008366 "$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 +02008367 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008368 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008369 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008370 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008371 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8372 0 \
8373 -c "=> renegotiate" \
8374 -s "=> renegotiate" \
8375 -s "Extra-header:" \
8376 -c "HTTP/1.0 200 OK"
8377
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008378## Interop tests with OpenSSL might trigger a bug in recent versions (including
8379## all versions installed on the CI machines), reported here:
8380## Bug report: https://github.com/openssl/openssl/issues/6902
8381## They should be re-enabled once a fixed version of OpenSSL is available
8382## (this should happen in some 1.1.1_ release according to the ticket).
8383skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008384client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008385not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008386run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008387 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8388 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008389 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008390 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008391 -c "HTTP/1.0 200 OK"
8392
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008393skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008394client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008395not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008396run_test "DTLS proxy: 3d, openssl server, fragmentation" \
8397 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8398 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008399 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008400 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008401 -c "HTTP/1.0 200 OK"
8402
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008403skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008404client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008405not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008406run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8407 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8408 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008409 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008410 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008411 -c "HTTP/1.0 200 OK"
8412
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008413requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008414client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008415not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008416run_test "DTLS proxy: 3d, gnutls server" \
8417 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8418 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008419 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008420 0 \
8421 -s "Extra-header:" \
8422 -c "Extra-header:"
8423
k-stachowiak17a38d32019-02-18 15:29:56 +01008424requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008425client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008426not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008427run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
8428 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008429 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008430 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008431 0 \
8432 -s "Extra-header:" \
8433 -c "Extra-header:"
8434
k-stachowiak17a38d32019-02-18 15:29:56 +01008435requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008436client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008437not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008438run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8439 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008440 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008441 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008442 0 \
8443 -s "Extra-header:" \
8444 -c "Extra-header:"
8445
Ron Eldorf75e2522019-05-14 20:38:49 +03008446requires_config_enabled MBEDTLS_SSL_EXPORT_KEYS
8447run_test "export keys functionality" \
8448 "$P_SRV eap_tls=1 debug_level=3" \
8449 "$P_CLI eap_tls=1 debug_level=3" \
8450 0 \
8451 -s "exported maclen is " \
8452 -s "exported keylen is " \
8453 -s "exported ivlen is " \
8454 -c "exported maclen is " \
8455 -c "exported keylen is " \
8456 -c "exported ivlen is "
8457
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008458# Final report
8459
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008460echo "------------------------------------------------------------------------"
8461
8462if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008463 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008464else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008465 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008466fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008467PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008468echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008469
8470exit $FAILS