blob: 58defbfcc90be6593660192880bbbe9d983c6540 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Angus Grattonc4dd0732018-04-11 16:28:39 +100024if cd $( dirname $0 ); then :; else
25 echo "cd $( dirname $0 ) failed" >&2
26 exit 1
27fi
28
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010029# default values, can be overriden by the environment
30: ${P_SRV:=../programs/ssl/ssl_server2}
31: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020032: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010033: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020034: ${GNUTLS_CLI:=gnutls-cli}
35: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020036: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010037
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020038O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010039O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020040G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010041G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020042TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010043
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010044TESTS=0
45FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020046SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010047
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000048CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020049
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010050MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010051FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020052EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010053
Paul Bakkere20310a2016-05-10 11:18:17 +010054SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010055RUN_TEST_NUMBER=''
56
Paul Bakkeracaac852016-05-10 11:47:13 +010057PRESERVE_LOGS=0
58
Gilles Peskinef93c7d32017-04-14 17:55:28 +020059# Pick a "unique" server port in the range 10000-19999, and a proxy
60# port which is this plus 10000. Each port number may be independently
61# overridden by a command line option.
62SRV_PORT=$(($$ % 10000 + 10000))
63PXY_PORT=$((SRV_PORT + 10000))
64
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010065print_usage() {
66 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010067 printf " -h|--help\tPrint this help.\n"
68 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
70 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010071 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010072 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010073 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020074 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
75 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010076 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010077}
78
79get_options() {
80 while [ $# -gt 0 ]; do
81 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010082 -f|--filter)
83 shift; FILTER=$1
84 ;;
85 -e|--exclude)
86 shift; EXCLUDE=$1
87 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010088 -m|--memcheck)
89 MEMCHECK=1
90 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010091 -n|--number)
92 shift; RUN_TEST_NUMBER=$1
93 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010094 -s|--show-numbers)
95 SHOW_TEST_NUMBER=1
96 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010097 -p|--preserve-logs)
98 PRESERVE_LOGS=1
99 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200100 --port)
101 shift; SRV_PORT=$1
102 ;;
103 --proxy-port)
104 shift; PXY_PORT=$1
105 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100106 --seed)
107 shift; SEED="$1"
108 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100109 -h|--help)
110 print_usage
111 exit 0
112 ;;
113 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200114 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100115 print_usage
116 exit 1
117 ;;
118 esac
119 shift
120 done
121}
122
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100123# skip next test if the flag is not enabled in config.h
124requires_config_enabled() {
125 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
126 SKIP_NEXT="YES"
127 fi
128}
129
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200130# skip next test if the flag is enabled in config.h
131requires_config_disabled() {
132 if grep "^#define $1" $CONFIG_H > /dev/null; then
133 SKIP_NEXT="YES"
134 fi
135}
136
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200137# skip next test if OpenSSL doesn't support FALLBACK_SCSV
138requires_openssl_with_fallback_scsv() {
139 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
140 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
141 then
142 OPENSSL_HAS_FBSCSV="YES"
143 else
144 OPENSSL_HAS_FBSCSV="NO"
145 fi
146 fi
147 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
148 SKIP_NEXT="YES"
149 fi
150}
151
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200152# skip next test if GnuTLS isn't available
153requires_gnutls() {
154 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200155 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200156 GNUTLS_AVAILABLE="YES"
157 else
158 GNUTLS_AVAILABLE="NO"
159 fi
160 fi
161 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
162 SKIP_NEXT="YES"
163 fi
164}
165
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200166# skip next test if IPv6 isn't available on this host
167requires_ipv6() {
168 if [ -z "${HAS_IPV6:-}" ]; then
169 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
170 SRV_PID=$!
171 sleep 1
172 kill $SRV_PID >/dev/null 2>&1
173 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
174 HAS_IPV6="NO"
175 else
176 HAS_IPV6="YES"
177 fi
178 rm -r $SRV_OUT
179 fi
180
181 if [ "$HAS_IPV6" = "NO" ]; then
182 SKIP_NEXT="YES"
183 fi
184}
185
Angus Grattonc4dd0732018-04-11 16:28:39 +1000186# Calculate the input & output maximum content lengths set in the config
187MAX_CONTENT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
188MAX_IN_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
189MAX_OUT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
190
191if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
192 MAX_CONTENT_LEN="$MAX_IN_LEN"
193fi
194if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
195 MAX_CONTENT_LEN="$MAX_OUT_LEN"
196fi
197
198# skip the next test if the SSL output buffer is less than 16KB
199requires_full_size_output_buffer() {
200 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
201 SKIP_NEXT="YES"
202 fi
203}
204
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200205# skip the next test if valgrind is in use
206not_with_valgrind() {
207 if [ "$MEMCHECK" -gt 0 ]; then
208 SKIP_NEXT="YES"
209 fi
210}
211
Paul Bakker362689d2016-05-13 10:33:25 +0100212# skip the next test if valgrind is NOT in use
213only_with_valgrind() {
214 if [ "$MEMCHECK" -eq 0 ]; then
215 SKIP_NEXT="YES"
216 fi
217}
218
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200219# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100220client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200221 CLI_DELAY_FACTOR=$1
222}
223
Janos Follath74537a62016-09-02 13:45:28 +0100224# wait for the given seconds after the client finished in the next test
225server_needs_more_time() {
226 SRV_DELAY_SECONDS=$1
227}
228
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100229# print_name <name>
230print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100231 TESTS=$(( $TESTS + 1 ))
232 LINE=""
233
234 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
235 LINE="$TESTS "
236 fi
237
238 LINE="$LINE$1"
239 printf "$LINE "
240 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100241 for i in `seq 1 $LEN`; do printf '.'; done
242 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100243
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100244}
245
246# fail <message>
247fail() {
248 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100249 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100250
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200251 mv $SRV_OUT o-srv-${TESTS}.log
252 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200253 if [ -n "$PXY_CMD" ]; then
254 mv $PXY_OUT o-pxy-${TESTS}.log
255 fi
256 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100257
Azim Khan19d13732018-03-29 11:04:20 +0100258 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 +0200259 echo " ! server output:"
260 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200261 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200262 echo " ! client output:"
263 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200264 if [ -n "$PXY_CMD" ]; then
265 echo " ! ========================================================"
266 echo " ! proxy output:"
267 cat o-pxy-${TESTS}.log
268 fi
269 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200270 fi
271
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200272 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100273}
274
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100275# is_polar <cmd_line>
276is_polar() {
277 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
278}
279
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200280# openssl s_server doesn't have -www with DTLS
281check_osrv_dtls() {
282 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
283 NEEDS_INPUT=1
284 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
285 else
286 NEEDS_INPUT=0
287 fi
288}
289
290# provide input to commands that need it
291provide_input() {
292 if [ $NEEDS_INPUT -eq 0 ]; then
293 return
294 fi
295
296 while true; do
297 echo "HTTP/1.0 200 OK"
298 sleep 1
299 done
300}
301
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100302# has_mem_err <log_file_name>
303has_mem_err() {
304 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
305 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
306 then
307 return 1 # false: does not have errors
308 else
309 return 0 # true: has errors
310 fi
311}
312
Gilles Peskine418b5362017-12-14 18:58:42 +0100313# Wait for process $2 to be listening on port $1
314if type lsof >/dev/null 2>/dev/null; then
315 wait_server_start() {
316 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200317 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100318 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200319 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100320 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200321 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100322 # Make a tight loop, server normally takes less than 1s to start.
323 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
324 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
325 echo "SERVERSTART TIMEOUT"
326 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
327 break
328 fi
329 # Linux and *BSD support decimal arguments to sleep. On other
330 # OSes this may be a tight loop.
331 sleep 0.1 2>/dev/null || true
332 done
333 }
334else
Gilles Peskinea9312652018-06-29 15:48:13 +0200335 echo "Warning: lsof not available, wait_server_start = sleep"
Gilles Peskine418b5362017-12-14 18:58:42 +0100336 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200337 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100338 }
339fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200340
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100341# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100342# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100343# acceptable bounds
344check_server_hello_time() {
345 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100346 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100347 # Get the Unix timestamp for now
348 CUR_TIME=$(date +'%s')
349 THRESHOLD_IN_SECS=300
350
351 # Check if the ServerHello time was printed
352 if [ -z "$SERVER_HELLO_TIME" ]; then
353 return 1
354 fi
355
356 # Check the time in ServerHello is within acceptable bounds
357 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
358 # The time in ServerHello is at least 5 minutes before now
359 return 1
360 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100361 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100362 return 1
363 else
364 return 0
365 fi
366}
367
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200368# wait for client to terminate and set CLI_EXIT
369# must be called right after starting the client
370wait_client_done() {
371 CLI_PID=$!
372
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200373 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
374 CLI_DELAY_FACTOR=1
375
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200376 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200377 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200378
379 wait $CLI_PID
380 CLI_EXIT=$?
381
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200382 kill $DOG_PID >/dev/null 2>&1
383 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200384
385 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100386
387 sleep $SRV_DELAY_SECONDS
388 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200389}
390
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200391# check if the given command uses dtls and sets global variable DTLS
392detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200393 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200394 DTLS=1
395 else
396 DTLS=0
397 fi
398}
399
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200400# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100401# Options: -s pattern pattern that must be present in server output
402# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100403# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100404# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100405# -S pattern pattern that must be absent in server output
406# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100407# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100408# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100409run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100410 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200411 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100412
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100413 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
414 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200415 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100416 return
417 fi
418
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100419 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100420
Paul Bakkerb7584a52016-05-10 10:50:43 +0100421 # Do we only run numbered tests?
422 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
423 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
424 else
425 SKIP_NEXT="YES"
426 fi
427
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200428 # should we skip?
429 if [ "X$SKIP_NEXT" = "XYES" ]; then
430 SKIP_NEXT="NO"
431 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200432 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200433 return
434 fi
435
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200436 # does this test use a proxy?
437 if [ "X$1" = "X-p" ]; then
438 PXY_CMD="$2"
439 shift 2
440 else
441 PXY_CMD=""
442 fi
443
444 # get commands and client output
445 SRV_CMD="$1"
446 CLI_CMD="$2"
447 CLI_EXPECT="$3"
448 shift 3
449
450 # fix client port
451 if [ -n "$PXY_CMD" ]; then
452 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
453 else
454 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
455 fi
456
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200457 # update DTLS variable
458 detect_dtls "$SRV_CMD"
459
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100460 # prepend valgrind to our commands if active
461 if [ "$MEMCHECK" -gt 0 ]; then
462 if is_polar "$SRV_CMD"; then
463 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
464 fi
465 if is_polar "$CLI_CMD"; then
466 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
467 fi
468 fi
469
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200470 TIMES_LEFT=2
471 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200472 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200473
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200474 # run the commands
475 if [ -n "$PXY_CMD" ]; then
476 echo "$PXY_CMD" > $PXY_OUT
477 $PXY_CMD >> $PXY_OUT 2>&1 &
478 PXY_PID=$!
479 # assume proxy starts faster than server
480 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200481
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200482 check_osrv_dtls
483 echo "$SRV_CMD" > $SRV_OUT
484 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
485 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100486 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200487
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200488 echo "$CLI_CMD" > $CLI_OUT
489 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
490 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100491
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100492 sleep 0.05
493
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200494 # terminate the server (and the proxy)
495 kill $SRV_PID
496 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100497
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200498 if [ -n "$PXY_CMD" ]; then
499 kill $PXY_PID >/dev/null 2>&1
500 wait $PXY_PID
501 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100502
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200503 # retry only on timeouts
504 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
505 printf "RETRY "
506 else
507 TIMES_LEFT=0
508 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200509 done
510
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100511 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200512 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100513 # expected client exit to incorrectly succeed in case of catastrophic
514 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100515 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200516 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100517 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100518 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100519 return
520 fi
521 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100522 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200523 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100524 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100525 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100526 return
527 fi
528 fi
529
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100530 # check server exit code
531 if [ $? != 0 ]; then
532 fail "server fail"
533 return
534 fi
535
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100536 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100537 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
538 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100539 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200540 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100541 return
542 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100543
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100544 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200545 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100546 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100547 while [ $# -gt 0 ]
548 do
549 case $1 in
550 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100551 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 +0100552 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100553 return
554 fi
555 ;;
556
557 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100558 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 +0100559 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100560 return
561 fi
562 ;;
563
564 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100565 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 +0100566 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100567 return
568 fi
569 ;;
570
571 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100572 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 +0100573 fail "pattern '$2' MUST NOT be present in the Client output"
574 return
575 fi
576 ;;
577
578 # The filtering in the following two options (-u and -U) do the following
579 # - ignore valgrind output
580 # - filter out everything but lines right after the pattern occurances
581 # - keep one of each non-unique line
582 # - count how many lines remain
583 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
584 # if there were no duplicates.
585 "-U")
586 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
587 fail "lines following pattern '$2' must be unique in Server output"
588 return
589 fi
590 ;;
591
592 "-u")
593 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
594 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100595 return
596 fi
597 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100598 "-F")
599 if ! $2 "$SRV_OUT"; then
600 fail "function call to '$2' failed on Server output"
601 return
602 fi
603 ;;
604 "-f")
605 if ! $2 "$CLI_OUT"; then
606 fail "function call to '$2' failed on Client output"
607 return
608 fi
609 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100610
611 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200612 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100613 exit 1
614 esac
615 shift 2
616 done
617
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100618 # check valgrind's results
619 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200620 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100621 fail "Server has memory errors"
622 return
623 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200624 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100625 fail "Client has memory errors"
626 return
627 fi
628 fi
629
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100630 # if we're here, everything is ok
631 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100632 if [ "$PRESERVE_LOGS" -gt 0 ]; then
633 mv $SRV_OUT o-srv-${TESTS}.log
634 mv $CLI_OUT o-cli-${TESTS}.log
635 fi
636
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200637 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100638}
639
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100640cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200641 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200642 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
643 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
644 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
645 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100646 exit 1
647}
648
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100649#
650# MAIN
651#
652
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100653get_options "$@"
654
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100655# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100656P_SRV_BIN="${P_SRV%%[ ]*}"
657P_CLI_BIN="${P_CLI%%[ ]*}"
658P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100659if [ ! -x "$P_SRV_BIN" ]; then
660 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100661 exit 1
662fi
Hanno Becker17c04932017-10-10 14:44:53 +0100663if [ ! -x "$P_CLI_BIN" ]; then
664 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100665 exit 1
666fi
Hanno Becker17c04932017-10-10 14:44:53 +0100667if [ ! -x "$P_PXY_BIN" ]; then
668 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200669 exit 1
670fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100671if [ "$MEMCHECK" -gt 0 ]; then
672 if which valgrind >/dev/null 2>&1; then :; else
673 echo "Memcheck not possible. Valgrind not found"
674 exit 1
675 fi
676fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100677if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
678 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100679 exit 1
680fi
681
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200682# used by watchdog
683MAIN_PID="$$"
684
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100685# We use somewhat arbitrary delays for tests:
686# - how long do we wait for the server to start (when lsof not available)?
687# - how long do we allow for the client to finish?
688# (not to check performance, just to avoid waiting indefinitely)
689# Things are slower with valgrind, so give extra time here.
690#
691# Note: without lsof, there is a trade-off between the running time of this
692# script and the risk of spurious errors because we didn't wait long enough.
693# The watchdog delay on the other hand doesn't affect normal running time of
694# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200695if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100696 START_DELAY=6
697 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200698else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100699 START_DELAY=2
700 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200701fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100702
703# some particular tests need more time:
704# - for the client, we multiply the usual watchdog limit by a factor
705# - for the server, we sleep for a number of seconds after the client exits
706# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200707CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100708SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200709
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200710# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000711# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200712P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
713P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100714P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200715O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200716O_CLI="$O_CLI -connect localhost:+SRV_PORT"
717G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000718G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200719
Gilles Peskine62469d92017-05-10 10:13:59 +0200720# Allow SHA-1, because many of our test certificates use it
721P_SRV="$P_SRV allow_sha1=1"
722P_CLI="$P_CLI allow_sha1=1"
723
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200724# Also pick a unique name for intermediate files
725SRV_OUT="srv_out.$$"
726CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200727PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200728SESSION="session.$$"
729
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200730SKIP_NEXT="NO"
731
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100732trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100733
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200734# Basic test
735
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200736# Checks that:
737# - things work with all ciphersuites active (used with config-full in all.sh)
738# - the expected (highest security) parameters are selected
739# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200740run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200741 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200742 "$P_CLI" \
743 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200744 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200745 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200746 -s "client hello v3, signature_algorithm ext: 6" \
747 -s "ECDHE curve: secp521r1" \
748 -S "error" \
749 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200750
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000751run_test "Default, DTLS" \
752 "$P_SRV dtls=1" \
753 "$P_CLI dtls=1" \
754 0 \
755 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200756 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000757
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100758# Test current time in ServerHello
759requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200760run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100761 "$P_SRV debug_level=3" \
762 "$P_CLI debug_level=3" \
763 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100764 -f "check_server_hello_time" \
765 -F "check_server_hello_time"
766
Simon Butcher8e004102016-10-14 00:48:33 +0100767# Test for uniqueness of IVs in AEAD ciphersuites
768run_test "Unique IV in GCM" \
769 "$P_SRV exchanges=20 debug_level=4" \
770 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
771 0 \
772 -u "IV used" \
773 -U "IV used"
774
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100775# Tests for rc4 option
776
Simon Butchera410af52016-05-19 22:12:18 +0100777requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100778run_test "RC4: server disabled, client enabled" \
779 "$P_SRV" \
780 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
781 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100782 -s "SSL - The server has no ciphersuites in common"
783
Simon Butchera410af52016-05-19 22:12:18 +0100784requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100785run_test "RC4: server half, client enabled" \
786 "$P_SRV arc4=1" \
787 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
788 1 \
789 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100790
791run_test "RC4: server enabled, client disabled" \
792 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
793 "$P_CLI" \
794 1 \
795 -s "SSL - The server has no ciphersuites in common"
796
797run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100798 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100799 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
800 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100801 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100802 -S "SSL - The server has no ciphersuites in common"
803
Hanno Beckerd26bb202018-08-17 09:54:10 +0100804# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
805
806requires_gnutls
807requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
808run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
809 "$G_SRV"\
810 "$P_CLI force_version=tls1_1" \
811 0
812
813requires_gnutls
814requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
815run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
816 "$G_SRV"\
817 "$P_CLI force_version=tls1" \
818 0
819
Gilles Peskinebc70a182017-05-09 15:59:24 +0200820# Tests for SHA-1 support
821
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200822requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200823run_test "SHA-1 forbidden by default in server certificate" \
824 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
825 "$P_CLI debug_level=2 allow_sha1=0" \
826 1 \
827 -c "The certificate is signed with an unacceptable hash"
828
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200829requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
830run_test "SHA-1 forbidden by default in server certificate" \
831 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
832 "$P_CLI debug_level=2 allow_sha1=0" \
833 0
834
Gilles Peskinebc70a182017-05-09 15:59:24 +0200835run_test "SHA-1 explicitly allowed in server certificate" \
836 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
837 "$P_CLI allow_sha1=1" \
838 0
839
840run_test "SHA-256 allowed by default in server certificate" \
841 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
842 "$P_CLI allow_sha1=0" \
843 0
844
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200845requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200846run_test "SHA-1 forbidden by default in client certificate" \
847 "$P_SRV auth_mode=required allow_sha1=0" \
848 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
849 1 \
850 -s "The certificate is signed with an unacceptable hash"
851
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200852requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
853run_test "SHA-1 forbidden by default in client certificate" \
854 "$P_SRV auth_mode=required allow_sha1=0" \
855 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
856 0
857
Gilles Peskinebc70a182017-05-09 15:59:24 +0200858run_test "SHA-1 explicitly allowed in client certificate" \
859 "$P_SRV auth_mode=required allow_sha1=1" \
860 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
861 0
862
863run_test "SHA-256 allowed by default in client certificate" \
864 "$P_SRV auth_mode=required allow_sha1=0" \
865 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
866 0
867
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100868# Tests for Truncated HMAC extension
869
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100870run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200871 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100872 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100873 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000874 -s "dumping 'expected mac' (20 bytes)" \
875 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100876
Hanno Becker32c55012017-11-10 08:42:54 +0000877requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100878run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200879 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000880 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100881 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000882 -s "dumping 'expected mac' (20 bytes)" \
883 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100884
Hanno Becker32c55012017-11-10 08:42:54 +0000885requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100886run_test "Truncated HMAC: client enabled, server default" \
887 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000888 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100889 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000890 -s "dumping 'expected mac' (20 bytes)" \
891 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100892
Hanno Becker32c55012017-11-10 08:42:54 +0000893requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100894run_test "Truncated HMAC: client enabled, server disabled" \
895 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000896 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100897 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000898 -s "dumping 'expected mac' (20 bytes)" \
899 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100900
Hanno Becker32c55012017-11-10 08:42:54 +0000901requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000902run_test "Truncated HMAC: client disabled, server enabled" \
903 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000904 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000905 0 \
906 -s "dumping 'expected mac' (20 bytes)" \
907 -S "dumping 'expected mac' (10 bytes)"
908
909requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100910run_test "Truncated HMAC: client enabled, server enabled" \
911 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000912 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100913 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000914 -S "dumping 'expected mac' (20 bytes)" \
915 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100916
Hanno Becker4c4f4102017-11-10 09:16:05 +0000917run_test "Truncated HMAC, DTLS: client default, server default" \
918 "$P_SRV dtls=1 debug_level=4" \
919 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
920 0 \
921 -s "dumping 'expected mac' (20 bytes)" \
922 -S "dumping 'expected mac' (10 bytes)"
923
924requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
925run_test "Truncated HMAC, DTLS: client disabled, server default" \
926 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000927 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000928 0 \
929 -s "dumping 'expected mac' (20 bytes)" \
930 -S "dumping 'expected mac' (10 bytes)"
931
932requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
933run_test "Truncated HMAC, DTLS: client enabled, server default" \
934 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000935 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000936 0 \
937 -s "dumping 'expected mac' (20 bytes)" \
938 -S "dumping 'expected mac' (10 bytes)"
939
940requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
941run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
942 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000943 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000944 0 \
945 -s "dumping 'expected mac' (20 bytes)" \
946 -S "dumping 'expected mac' (10 bytes)"
947
948requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
949run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
950 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000951 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000952 0 \
953 -s "dumping 'expected mac' (20 bytes)" \
954 -S "dumping 'expected mac' (10 bytes)"
955
956requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
957run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
958 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000959 "$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 +0100960 0 \
961 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100962 -s "dumping 'expected mac' (10 bytes)"
963
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100964# Tests for Encrypt-then-MAC extension
965
966run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100967 "$P_SRV debug_level=3 \
968 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100969 "$P_CLI debug_level=3" \
970 0 \
971 -c "client hello, adding encrypt_then_mac extension" \
972 -s "found encrypt then mac extension" \
973 -s "server hello, adding encrypt then mac extension" \
974 -c "found encrypt_then_mac extension" \
975 -c "using encrypt then mac" \
976 -s "using encrypt then mac"
977
978run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100979 "$P_SRV debug_level=3 etm=0 \
980 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100981 "$P_CLI debug_level=3 etm=1" \
982 0 \
983 -c "client hello, adding encrypt_then_mac extension" \
984 -s "found encrypt then mac extension" \
985 -S "server hello, adding encrypt then mac extension" \
986 -C "found encrypt_then_mac extension" \
987 -C "using encrypt then mac" \
988 -S "using encrypt then mac"
989
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100990run_test "Encrypt then MAC: client enabled, aead cipher" \
991 "$P_SRV debug_level=3 etm=1 \
992 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
993 "$P_CLI debug_level=3 etm=1" \
994 0 \
995 -c "client hello, adding encrypt_then_mac extension" \
996 -s "found encrypt then mac extension" \
997 -S "server hello, adding encrypt then mac extension" \
998 -C "found encrypt_then_mac extension" \
999 -C "using encrypt then mac" \
1000 -S "using encrypt then mac"
1001
1002run_test "Encrypt then MAC: client enabled, stream cipher" \
1003 "$P_SRV debug_level=3 etm=1 \
1004 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001005 "$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 +01001006 0 \
1007 -c "client hello, adding encrypt_then_mac extension" \
1008 -s "found encrypt then mac extension" \
1009 -S "server hello, adding encrypt then mac extension" \
1010 -C "found encrypt_then_mac extension" \
1011 -C "using encrypt then mac" \
1012 -S "using encrypt then mac"
1013
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001014run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001015 "$P_SRV debug_level=3 etm=1 \
1016 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001017 "$P_CLI debug_level=3 etm=0" \
1018 0 \
1019 -C "client hello, adding encrypt_then_mac extension" \
1020 -S "found encrypt then mac extension" \
1021 -S "server hello, adding encrypt then mac extension" \
1022 -C "found encrypt_then_mac extension" \
1023 -C "using encrypt then mac" \
1024 -S "using encrypt then mac"
1025
Janos Follathe2681a42016-03-07 15:57:05 +00001026requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001027run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001028 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001029 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001030 "$P_CLI debug_level=3 force_version=ssl3" \
1031 0 \
1032 -C "client hello, adding encrypt_then_mac extension" \
1033 -S "found encrypt then mac extension" \
1034 -S "server hello, adding encrypt then mac extension" \
1035 -C "found encrypt_then_mac extension" \
1036 -C "using encrypt then mac" \
1037 -S "using encrypt then mac"
1038
Janos Follathe2681a42016-03-07 15:57:05 +00001039requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001040run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001041 "$P_SRV debug_level=3 force_version=ssl3 \
1042 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001043 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001044 0 \
1045 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001046 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001047 -S "server hello, adding encrypt then mac extension" \
1048 -C "found encrypt_then_mac extension" \
1049 -C "using encrypt then mac" \
1050 -S "using encrypt then mac"
1051
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001052# Tests for Extended Master Secret extension
1053
1054run_test "Extended Master Secret: default" \
1055 "$P_SRV debug_level=3" \
1056 "$P_CLI debug_level=3" \
1057 0 \
1058 -c "client hello, adding extended_master_secret extension" \
1059 -s "found extended master secret extension" \
1060 -s "server hello, adding extended master secret extension" \
1061 -c "found extended_master_secret extension" \
1062 -c "using extended master secret" \
1063 -s "using extended master secret"
1064
1065run_test "Extended Master Secret: client enabled, server disabled" \
1066 "$P_SRV debug_level=3 extended_ms=0" \
1067 "$P_CLI debug_level=3 extended_ms=1" \
1068 0 \
1069 -c "client hello, adding extended_master_secret extension" \
1070 -s "found extended master secret extension" \
1071 -S "server hello, adding extended master secret extension" \
1072 -C "found extended_master_secret extension" \
1073 -C "using extended master secret" \
1074 -S "using extended master secret"
1075
1076run_test "Extended Master Secret: client disabled, server enabled" \
1077 "$P_SRV debug_level=3 extended_ms=1" \
1078 "$P_CLI debug_level=3 extended_ms=0" \
1079 0 \
1080 -C "client hello, adding extended_master_secret extension" \
1081 -S "found extended master secret extension" \
1082 -S "server hello, adding extended master secret extension" \
1083 -C "found extended_master_secret extension" \
1084 -C "using extended master secret" \
1085 -S "using extended master secret"
1086
Janos Follathe2681a42016-03-07 15:57:05 +00001087requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001088run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001089 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001090 "$P_CLI debug_level=3 force_version=ssl3" \
1091 0 \
1092 -C "client hello, adding extended_master_secret extension" \
1093 -S "found extended master secret extension" \
1094 -S "server hello, adding extended master secret extension" \
1095 -C "found extended_master_secret extension" \
1096 -C "using extended master secret" \
1097 -S "using extended master secret"
1098
Janos Follathe2681a42016-03-07 15:57:05 +00001099requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001100run_test "Extended Master Secret: client enabled, server SSLv3" \
1101 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001102 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001103 0 \
1104 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001105 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001106 -S "server hello, adding extended master secret extension" \
1107 -C "found extended_master_secret extension" \
1108 -C "using extended master secret" \
1109 -S "using extended master secret"
1110
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001111# Tests for FALLBACK_SCSV
1112
1113run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001114 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001115 "$P_CLI debug_level=3 force_version=tls1_1" \
1116 0 \
1117 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001118 -S "received FALLBACK_SCSV" \
1119 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001120 -C "is a fatal alert message (msg 86)"
1121
1122run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001123 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001124 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1125 0 \
1126 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001127 -S "received FALLBACK_SCSV" \
1128 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001129 -C "is a fatal alert message (msg 86)"
1130
1131run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001132 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001133 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001134 1 \
1135 -c "adding FALLBACK_SCSV" \
1136 -s "received FALLBACK_SCSV" \
1137 -s "inapropriate fallback" \
1138 -c "is a fatal alert message (msg 86)"
1139
1140run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001141 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001142 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001143 0 \
1144 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001145 -s "received FALLBACK_SCSV" \
1146 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001147 -C "is a fatal alert message (msg 86)"
1148
1149requires_openssl_with_fallback_scsv
1150run_test "Fallback SCSV: default, openssl server" \
1151 "$O_SRV" \
1152 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1153 0 \
1154 -C "adding FALLBACK_SCSV" \
1155 -C "is a fatal alert message (msg 86)"
1156
1157requires_openssl_with_fallback_scsv
1158run_test "Fallback SCSV: enabled, openssl server" \
1159 "$O_SRV" \
1160 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1161 1 \
1162 -c "adding FALLBACK_SCSV" \
1163 -c "is a fatal alert message (msg 86)"
1164
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001165requires_openssl_with_fallback_scsv
1166run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001167 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001168 "$O_CLI -tls1_1" \
1169 0 \
1170 -S "received FALLBACK_SCSV" \
1171 -S "inapropriate fallback"
1172
1173requires_openssl_with_fallback_scsv
1174run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001175 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001176 "$O_CLI -tls1_1 -fallback_scsv" \
1177 1 \
1178 -s "received FALLBACK_SCSV" \
1179 -s "inapropriate fallback"
1180
1181requires_openssl_with_fallback_scsv
1182run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001183 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001184 "$O_CLI -fallback_scsv" \
1185 0 \
1186 -s "received FALLBACK_SCSV" \
1187 -S "inapropriate fallback"
1188
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001189# Test sending and receiving empty application data records
1190
1191run_test "Encrypt then MAC: empty application data record" \
1192 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1193 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1194 0 \
1195 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1196 -s "dumping 'input payload after decrypt' (0 bytes)" \
1197 -c "0 bytes written in 1 fragments"
1198
1199run_test "Default, no Encrypt then MAC: empty application data record" \
1200 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1201 "$P_CLI auth_mode=none etm=0 request_size=0" \
1202 0 \
1203 -s "dumping 'input payload after decrypt' (0 bytes)" \
1204 -c "0 bytes written in 1 fragments"
1205
1206run_test "Encrypt then MAC, DTLS: empty application data record" \
1207 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1208 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1209 0 \
1210 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1211 -s "dumping 'input payload after decrypt' (0 bytes)" \
1212 -c "0 bytes written in 1 fragments"
1213
1214run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
1215 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1216 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1217 0 \
1218 -s "dumping 'input payload after decrypt' (0 bytes)" \
1219 -c "0 bytes written in 1 fragments"
1220
Gilles Peskined50177f2017-05-16 17:53:03 +02001221## ClientHello generated with
1222## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1223## then manually twiddling the ciphersuite list.
1224## The ClientHello content is spelled out below as a hex string as
1225## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1226## The expected response is an inappropriate_fallback alert.
1227requires_openssl_with_fallback_scsv
1228run_test "Fallback SCSV: beginning of list" \
1229 "$P_SRV debug_level=2" \
1230 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1231 0 \
1232 -s "received FALLBACK_SCSV" \
1233 -s "inapropriate fallback"
1234
1235requires_openssl_with_fallback_scsv
1236run_test "Fallback SCSV: end of list" \
1237 "$P_SRV debug_level=2" \
1238 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1239 0 \
1240 -s "received FALLBACK_SCSV" \
1241 -s "inapropriate fallback"
1242
1243## Here the expected response is a valid ServerHello prefix, up to the random.
1244requires_openssl_with_fallback_scsv
1245run_test "Fallback SCSV: not in list" \
1246 "$P_SRV debug_level=2" \
1247 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1248 0 \
1249 -S "received FALLBACK_SCSV" \
1250 -S "inapropriate fallback"
1251
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001252# Tests for CBC 1/n-1 record splitting
1253
1254run_test "CBC Record splitting: TLS 1.2, no splitting" \
1255 "$P_SRV" \
1256 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1257 request_size=123 force_version=tls1_2" \
1258 0 \
1259 -s "Read from client: 123 bytes read" \
1260 -S "Read from client: 1 bytes read" \
1261 -S "122 bytes read"
1262
1263run_test "CBC Record splitting: TLS 1.1, no splitting" \
1264 "$P_SRV" \
1265 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1266 request_size=123 force_version=tls1_1" \
1267 0 \
1268 -s "Read from client: 123 bytes read" \
1269 -S "Read from client: 1 bytes read" \
1270 -S "122 bytes read"
1271
1272run_test "CBC Record splitting: TLS 1.0, splitting" \
1273 "$P_SRV" \
1274 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1275 request_size=123 force_version=tls1" \
1276 0 \
1277 -S "Read from client: 123 bytes read" \
1278 -s "Read from client: 1 bytes read" \
1279 -s "122 bytes read"
1280
Janos Follathe2681a42016-03-07 15:57:05 +00001281requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001282run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001283 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001284 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1285 request_size=123 force_version=ssl3" \
1286 0 \
1287 -S "Read from client: 123 bytes read" \
1288 -s "Read from client: 1 bytes read" \
1289 -s "122 bytes read"
1290
1291run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001292 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001293 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1294 request_size=123 force_version=tls1" \
1295 0 \
1296 -s "Read from client: 123 bytes read" \
1297 -S "Read from client: 1 bytes read" \
1298 -S "122 bytes read"
1299
1300run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1301 "$P_SRV" \
1302 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1303 request_size=123 force_version=tls1 recsplit=0" \
1304 0 \
1305 -s "Read from client: 123 bytes read" \
1306 -S "Read from client: 1 bytes read" \
1307 -S "122 bytes read"
1308
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001309run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1310 "$P_SRV nbio=2" \
1311 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1312 request_size=123 force_version=tls1" \
1313 0 \
1314 -S "Read from client: 123 bytes read" \
1315 -s "Read from client: 1 bytes read" \
1316 -s "122 bytes read"
1317
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001318# Tests for Session Tickets
1319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001320run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001321 "$P_SRV debug_level=3 tickets=1" \
1322 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001323 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001324 -c "client hello, adding session ticket extension" \
1325 -s "found session ticket extension" \
1326 -s "server hello, adding session ticket extension" \
1327 -c "found session_ticket extension" \
1328 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001329 -S "session successfully restored from cache" \
1330 -s "session successfully restored from ticket" \
1331 -s "a session has been resumed" \
1332 -c "a session has been resumed"
1333
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001334run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001335 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1336 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001337 0 \
1338 -c "client hello, adding session ticket extension" \
1339 -s "found session ticket extension" \
1340 -s "server hello, adding session ticket extension" \
1341 -c "found session_ticket extension" \
1342 -c "parse new session ticket" \
1343 -S "session successfully restored from cache" \
1344 -s "session successfully restored from ticket" \
1345 -s "a session has been resumed" \
1346 -c "a session has been resumed"
1347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001348run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001349 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1350 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001351 0 \
1352 -c "client hello, adding session ticket extension" \
1353 -s "found session ticket extension" \
1354 -s "server hello, adding session ticket extension" \
1355 -c "found session_ticket extension" \
1356 -c "parse new session ticket" \
1357 -S "session successfully restored from cache" \
1358 -S "session successfully restored from ticket" \
1359 -S "a session has been resumed" \
1360 -C "a session has been resumed"
1361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001362run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001363 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001365 0 \
1366 -c "client hello, adding session ticket extension" \
1367 -c "found session_ticket extension" \
1368 -c "parse new session ticket" \
1369 -c "a session has been resumed"
1370
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001371run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001372 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001373 "( $O_CLI -sess_out $SESSION; \
1374 $O_CLI -sess_in $SESSION; \
1375 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001376 0 \
1377 -s "found session ticket extension" \
1378 -s "server hello, adding session ticket extension" \
1379 -S "session successfully restored from cache" \
1380 -s "session successfully restored from ticket" \
1381 -s "a session has been resumed"
1382
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001383# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001385run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001386 "$P_SRV debug_level=3 tickets=0" \
1387 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001388 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001389 -c "client hello, adding session ticket extension" \
1390 -s "found session ticket extension" \
1391 -S "server hello, adding session ticket extension" \
1392 -C "found session_ticket extension" \
1393 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001394 -s "session successfully restored from cache" \
1395 -S "session successfully restored from ticket" \
1396 -s "a session has been resumed" \
1397 -c "a session has been resumed"
1398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001399run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001400 "$P_SRV debug_level=3 tickets=1" \
1401 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001402 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001403 -C "client hello, adding session ticket extension" \
1404 -S "found session ticket extension" \
1405 -S "server hello, adding session ticket extension" \
1406 -C "found session_ticket extension" \
1407 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001408 -s "session successfully restored from cache" \
1409 -S "session successfully restored from ticket" \
1410 -s "a session has been resumed" \
1411 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001413run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001414 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1415 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001416 0 \
1417 -S "session successfully restored from cache" \
1418 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001419 -S "a session has been resumed" \
1420 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001422run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001423 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1424 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001425 0 \
1426 -s "session successfully restored from cache" \
1427 -S "session successfully restored from ticket" \
1428 -s "a session has been resumed" \
1429 -c "a session has been resumed"
1430
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001431run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001432 "$P_SRV debug_level=3 tickets=0" \
1433 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001434 0 \
1435 -s "session successfully restored from cache" \
1436 -S "session successfully restored from ticket" \
1437 -s "a session has been resumed" \
1438 -c "a session has been resumed"
1439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001440run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001441 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1442 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001443 0 \
1444 -S "session successfully restored from cache" \
1445 -S "session successfully restored from ticket" \
1446 -S "a session has been resumed" \
1447 -C "a session has been resumed"
1448
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001449run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001450 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1451 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001452 0 \
1453 -s "session successfully restored from cache" \
1454 -S "session successfully restored from ticket" \
1455 -s "a session has been resumed" \
1456 -c "a session has been resumed"
1457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001458run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001459 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001460 "( $O_CLI -sess_out $SESSION; \
1461 $O_CLI -sess_in $SESSION; \
1462 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001463 0 \
1464 -s "found session ticket extension" \
1465 -S "server hello, adding session ticket extension" \
1466 -s "session successfully restored from cache" \
1467 -S "session successfully restored from ticket" \
1468 -s "a session has been resumed"
1469
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001470run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001471 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001472 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001473 0 \
1474 -C "found session_ticket extension" \
1475 -C "parse new session ticket" \
1476 -c "a session has been resumed"
1477
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001478# Tests for Max Fragment Length extension
1479
Angus Grattonc4dd0732018-04-11 16:28:39 +10001480if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
1481 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 +01001482 exit 1
1483fi
1484
Angus Grattonc4dd0732018-04-11 16:28:39 +10001485if [ $MAX_CONTENT_LEN -ne 16384 ]; then
1486 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
1487fi
1488
Hanno Becker4aed27e2017-09-18 15:00:34 +01001489requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001490run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001491 "$P_SRV debug_level=3" \
1492 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001493 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001494 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1495 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001496 -C "client hello, adding max_fragment_length extension" \
1497 -S "found max fragment length extension" \
1498 -S "server hello, max_fragment_length extension" \
1499 -C "found max_fragment_length extension"
1500
Hanno Becker4aed27e2017-09-18 15:00:34 +01001501requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001502run_test "Max fragment length: enabled, default, larger message" \
1503 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001504 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001505 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001506 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1507 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001508 -C "client hello, adding max_fragment_length extension" \
1509 -S "found max fragment length extension" \
1510 -S "server hello, max_fragment_length extension" \
1511 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001512 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1513 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001514 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001515
1516requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1517run_test "Max fragment length, DTLS: enabled, default, larger message" \
1518 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001519 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001520 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001521 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1522 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001523 -C "client hello, adding max_fragment_length extension" \
1524 -S "found max fragment length extension" \
1525 -S "server hello, max_fragment_length extension" \
1526 -C "found max_fragment_length extension" \
1527 -c "fragment larger than.*maximum "
1528
Angus Grattonc4dd0732018-04-11 16:28:39 +10001529# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1530# (session fragment length will be 16384 regardless of mbedtls
1531# content length configuration.)
1532
Hanno Beckerc5266962017-09-18 15:01:50 +01001533requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1534run_test "Max fragment length: disabled, larger message" \
1535 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001536 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001537 0 \
1538 -C "Maximum fragment length is 16384" \
1539 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001540 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1541 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001542 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001543
1544requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1545run_test "Max fragment length DTLS: disabled, larger message" \
1546 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001547 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001548 1 \
1549 -C "Maximum fragment length is 16384" \
1550 -S "Maximum fragment length is 16384" \
1551 -c "fragment larger than.*maximum "
1552
1553requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001554run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001555 "$P_SRV debug_level=3" \
1556 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001557 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001558 -c "Maximum fragment length is 4096" \
1559 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001560 -c "client hello, adding max_fragment_length extension" \
1561 -s "found max fragment length extension" \
1562 -s "server hello, max_fragment_length extension" \
1563 -c "found max_fragment_length extension"
1564
Hanno Becker4aed27e2017-09-18 15:00:34 +01001565requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001566run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001567 "$P_SRV debug_level=3 max_frag_len=4096" \
1568 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001569 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001570 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001571 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001572 -C "client hello, adding max_fragment_length extension" \
1573 -S "found max fragment length extension" \
1574 -S "server hello, max_fragment_length extension" \
1575 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001576
Hanno Becker4aed27e2017-09-18 15:00:34 +01001577requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001578requires_gnutls
1579run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001580 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001581 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001582 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001583 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001584 -c "client hello, adding max_fragment_length extension" \
1585 -c "found max_fragment_length extension"
1586
Hanno Becker4aed27e2017-09-18 15:00:34 +01001587requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001588run_test "Max fragment length: client, message just fits" \
1589 "$P_SRV debug_level=3" \
1590 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1591 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001592 -c "Maximum fragment length is 2048" \
1593 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001594 -c "client hello, adding max_fragment_length extension" \
1595 -s "found max fragment length extension" \
1596 -s "server hello, max_fragment_length extension" \
1597 -c "found max_fragment_length extension" \
1598 -c "2048 bytes written in 1 fragments" \
1599 -s "2048 bytes read"
1600
Hanno Becker4aed27e2017-09-18 15:00:34 +01001601requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001602run_test "Max fragment length: client, larger message" \
1603 "$P_SRV debug_level=3" \
1604 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1605 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001606 -c "Maximum fragment length is 2048" \
1607 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001608 -c "client hello, adding max_fragment_length extension" \
1609 -s "found max fragment length extension" \
1610 -s "server hello, max_fragment_length extension" \
1611 -c "found max_fragment_length extension" \
1612 -c "2345 bytes written in 2 fragments" \
1613 -s "2048 bytes read" \
1614 -s "297 bytes read"
1615
Hanno Becker4aed27e2017-09-18 15:00:34 +01001616requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001617run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001618 "$P_SRV debug_level=3 dtls=1" \
1619 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1620 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001621 -c "Maximum fragment length is 2048" \
1622 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001623 -c "client hello, adding max_fragment_length extension" \
1624 -s "found max fragment length extension" \
1625 -s "server hello, max_fragment_length extension" \
1626 -c "found max_fragment_length extension" \
1627 -c "fragment larger than.*maximum"
1628
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001629# Tests for renegotiation
1630
Hanno Becker6a243642017-10-12 15:18:45 +01001631# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001632run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001633 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001634 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001635 0 \
1636 -C "client hello, adding renegotiation extension" \
1637 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1638 -S "found renegotiation extension" \
1639 -s "server hello, secure renegotiation extension" \
1640 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001641 -C "=> renegotiate" \
1642 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001643 -S "write hello request"
1644
Hanno Becker6a243642017-10-12 15:18:45 +01001645requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001646run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001647 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001648 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001649 0 \
1650 -c "client hello, adding renegotiation extension" \
1651 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1652 -s "found renegotiation extension" \
1653 -s "server hello, secure renegotiation extension" \
1654 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001655 -c "=> renegotiate" \
1656 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001657 -S "write hello request"
1658
Hanno Becker6a243642017-10-12 15:18:45 +01001659requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001660run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001661 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001662 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001663 0 \
1664 -c "client hello, adding renegotiation extension" \
1665 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1666 -s "found renegotiation extension" \
1667 -s "server hello, secure renegotiation extension" \
1668 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001669 -c "=> renegotiate" \
1670 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001671 -s "write hello request"
1672
Janos Follathb0f148c2017-10-05 12:29:42 +01001673# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1674# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1675# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001676requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001677run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1678 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1679 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1680 0 \
1681 -c "client hello, adding renegotiation extension" \
1682 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1683 -s "found renegotiation extension" \
1684 -s "server hello, secure renegotiation extension" \
1685 -c "found renegotiation extension" \
1686 -c "=> renegotiate" \
1687 -s "=> renegotiate" \
1688 -S "write hello request" \
1689 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1690
1691# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1692# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1693# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001694requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001695run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1696 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1697 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1698 0 \
1699 -c "client hello, adding renegotiation extension" \
1700 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1701 -s "found renegotiation extension" \
1702 -s "server hello, secure renegotiation extension" \
1703 -c "found renegotiation extension" \
1704 -c "=> renegotiate" \
1705 -s "=> renegotiate" \
1706 -s "write hello request" \
1707 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1708
Hanno Becker6a243642017-10-12 15:18:45 +01001709requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001710run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001711 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001712 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001713 0 \
1714 -c "client hello, adding renegotiation extension" \
1715 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1716 -s "found renegotiation extension" \
1717 -s "server hello, secure renegotiation extension" \
1718 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001719 -c "=> renegotiate" \
1720 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001721 -s "write hello request"
1722
Hanno Becker6a243642017-10-12 15:18:45 +01001723requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001724run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001725 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001726 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001727 1 \
1728 -c "client hello, adding renegotiation extension" \
1729 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1730 -S "found renegotiation extension" \
1731 -s "server hello, secure renegotiation extension" \
1732 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001733 -c "=> renegotiate" \
1734 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001735 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001736 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001737 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001738
Hanno Becker6a243642017-10-12 15:18:45 +01001739requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001740run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001741 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001742 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001743 0 \
1744 -C "client hello, adding renegotiation extension" \
1745 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1746 -S "found renegotiation extension" \
1747 -s "server hello, secure renegotiation extension" \
1748 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001749 -C "=> renegotiate" \
1750 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001751 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001752 -S "SSL - An unexpected message was received from our peer" \
1753 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001754
Hanno Becker6a243642017-10-12 15:18:45 +01001755requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001756run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001757 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001758 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001759 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001760 0 \
1761 -C "client hello, adding renegotiation extension" \
1762 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1763 -S "found renegotiation extension" \
1764 -s "server hello, secure renegotiation extension" \
1765 -c "found renegotiation extension" \
1766 -C "=> renegotiate" \
1767 -S "=> renegotiate" \
1768 -s "write hello request" \
1769 -S "SSL - An unexpected message was received from our peer" \
1770 -S "failed"
1771
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001772# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001773requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001774run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001775 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001776 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001777 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001778 0 \
1779 -C "client hello, adding renegotiation extension" \
1780 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1781 -S "found renegotiation extension" \
1782 -s "server hello, secure renegotiation extension" \
1783 -c "found renegotiation extension" \
1784 -C "=> renegotiate" \
1785 -S "=> renegotiate" \
1786 -s "write hello request" \
1787 -S "SSL - An unexpected message was received from our peer" \
1788 -S "failed"
1789
Hanno Becker6a243642017-10-12 15:18:45 +01001790requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001791run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001792 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001793 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001794 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001795 0 \
1796 -C "client hello, adding renegotiation extension" \
1797 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1798 -S "found renegotiation extension" \
1799 -s "server hello, secure renegotiation extension" \
1800 -c "found renegotiation extension" \
1801 -C "=> renegotiate" \
1802 -S "=> renegotiate" \
1803 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001804 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001805
Hanno Becker6a243642017-10-12 15:18:45 +01001806requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001807run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001808 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001809 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001810 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001811 0 \
1812 -c "client hello, adding renegotiation extension" \
1813 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1814 -s "found renegotiation extension" \
1815 -s "server hello, secure renegotiation extension" \
1816 -c "found renegotiation extension" \
1817 -c "=> renegotiate" \
1818 -s "=> renegotiate" \
1819 -s "write hello request" \
1820 -S "SSL - An unexpected message was received from our peer" \
1821 -S "failed"
1822
Hanno Becker6a243642017-10-12 15:18:45 +01001823requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001824run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001825 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001826 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1827 0 \
1828 -C "client hello, adding renegotiation extension" \
1829 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1830 -S "found renegotiation extension" \
1831 -s "server hello, secure renegotiation extension" \
1832 -c "found renegotiation extension" \
1833 -S "record counter limit reached: renegotiate" \
1834 -C "=> renegotiate" \
1835 -S "=> renegotiate" \
1836 -S "write hello request" \
1837 -S "SSL - An unexpected message was received from our peer" \
1838 -S "failed"
1839
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001840# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001841requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001842run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001843 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001844 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001845 0 \
1846 -c "client hello, adding renegotiation extension" \
1847 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1848 -s "found renegotiation extension" \
1849 -s "server hello, secure renegotiation extension" \
1850 -c "found renegotiation extension" \
1851 -s "record counter limit reached: renegotiate" \
1852 -c "=> renegotiate" \
1853 -s "=> renegotiate" \
1854 -s "write hello request" \
1855 -S "SSL - An unexpected message was received from our peer" \
1856 -S "failed"
1857
Hanno Becker6a243642017-10-12 15:18:45 +01001858requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001859run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001860 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001861 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001862 0 \
1863 -c "client hello, adding renegotiation extension" \
1864 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1865 -s "found renegotiation extension" \
1866 -s "server hello, secure renegotiation extension" \
1867 -c "found renegotiation extension" \
1868 -s "record counter limit reached: renegotiate" \
1869 -c "=> renegotiate" \
1870 -s "=> renegotiate" \
1871 -s "write hello request" \
1872 -S "SSL - An unexpected message was received from our peer" \
1873 -S "failed"
1874
Hanno Becker6a243642017-10-12 15:18:45 +01001875requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001876run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001877 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001878 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1879 0 \
1880 -C "client hello, adding renegotiation extension" \
1881 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1882 -S "found renegotiation extension" \
1883 -s "server hello, secure renegotiation extension" \
1884 -c "found renegotiation extension" \
1885 -S "record counter limit reached: renegotiate" \
1886 -C "=> renegotiate" \
1887 -S "=> renegotiate" \
1888 -S "write hello request" \
1889 -S "SSL - An unexpected message was received from our peer" \
1890 -S "failed"
1891
Hanno Becker6a243642017-10-12 15:18:45 +01001892requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001893run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001894 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001895 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001896 0 \
1897 -c "client hello, adding renegotiation extension" \
1898 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1899 -s "found renegotiation extension" \
1900 -s "server hello, secure renegotiation extension" \
1901 -c "found renegotiation extension" \
1902 -c "=> renegotiate" \
1903 -s "=> renegotiate" \
1904 -S "write hello request"
1905
Hanno Becker6a243642017-10-12 15:18:45 +01001906requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001907run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001908 "$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 +02001909 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001910 0 \
1911 -c "client hello, adding renegotiation extension" \
1912 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1913 -s "found renegotiation extension" \
1914 -s "server hello, secure renegotiation extension" \
1915 -c "found renegotiation extension" \
1916 -c "=> renegotiate" \
1917 -s "=> renegotiate" \
1918 -s "write hello request"
1919
Hanno Becker6a243642017-10-12 15:18:45 +01001920requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001921run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001922 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001923 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001924 0 \
1925 -c "client hello, adding renegotiation extension" \
1926 -c "found renegotiation extension" \
1927 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001928 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001929 -C "error" \
1930 -c "HTTP/1.0 200 [Oo][Kk]"
1931
Paul Bakker539d9722015-02-08 16:18:35 +01001932requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001933requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001934run_test "Renegotiation: gnutls server strict, client-initiated" \
1935 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001936 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001937 0 \
1938 -c "client hello, adding renegotiation extension" \
1939 -c "found renegotiation extension" \
1940 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001941 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001942 -C "error" \
1943 -c "HTTP/1.0 200 [Oo][Kk]"
1944
Paul Bakker539d9722015-02-08 16:18:35 +01001945requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001946requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001947run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1948 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1949 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1950 1 \
1951 -c "client hello, adding renegotiation extension" \
1952 -C "found renegotiation extension" \
1953 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001954 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001955 -c "error" \
1956 -C "HTTP/1.0 200 [Oo][Kk]"
1957
Paul Bakker539d9722015-02-08 16:18:35 +01001958requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001959requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001960run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1961 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1962 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1963 allow_legacy=0" \
1964 1 \
1965 -c "client hello, adding renegotiation extension" \
1966 -C "found renegotiation extension" \
1967 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001968 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001969 -c "error" \
1970 -C "HTTP/1.0 200 [Oo][Kk]"
1971
Paul Bakker539d9722015-02-08 16:18:35 +01001972requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001973requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001974run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1975 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1976 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1977 allow_legacy=1" \
1978 0 \
1979 -c "client hello, adding renegotiation extension" \
1980 -C "found renegotiation extension" \
1981 -c "=> renegotiate" \
1982 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001983 -C "error" \
1984 -c "HTTP/1.0 200 [Oo][Kk]"
1985
Hanno Becker6a243642017-10-12 15:18:45 +01001986requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001987run_test "Renegotiation: DTLS, client-initiated" \
1988 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1989 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1990 0 \
1991 -c "client hello, adding renegotiation extension" \
1992 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1993 -s "found renegotiation extension" \
1994 -s "server hello, secure renegotiation extension" \
1995 -c "found renegotiation extension" \
1996 -c "=> renegotiate" \
1997 -s "=> renegotiate" \
1998 -S "write hello request"
1999
Hanno Becker6a243642017-10-12 15:18:45 +01002000requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002001run_test "Renegotiation: DTLS, server-initiated" \
2002 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002003 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2004 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002005 0 \
2006 -c "client hello, adding renegotiation extension" \
2007 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2008 -s "found renegotiation extension" \
2009 -s "server hello, secure renegotiation extension" \
2010 -c "found renegotiation extension" \
2011 -c "=> renegotiate" \
2012 -s "=> renegotiate" \
2013 -s "write hello request"
2014
Hanno Becker6a243642017-10-12 15:18:45 +01002015requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002016run_test "Renegotiation: DTLS, renego_period overflow" \
2017 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2018 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2019 0 \
2020 -c "client hello, adding renegotiation extension" \
2021 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2022 -s "found renegotiation extension" \
2023 -s "server hello, secure renegotiation extension" \
2024 -s "record counter limit reached: renegotiate" \
2025 -c "=> renegotiate" \
2026 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002027 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002028
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002029requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002030requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002031run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2032 "$G_SRV -u --mtu 4096" \
2033 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2034 0 \
2035 -c "client hello, adding renegotiation extension" \
2036 -c "found renegotiation extension" \
2037 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002038 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002039 -C "error" \
2040 -s "Extra-header:"
2041
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002042# Test for the "secure renegotation" extension only (no actual renegotiation)
2043
Paul Bakker539d9722015-02-08 16:18:35 +01002044requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002045run_test "Renego ext: gnutls server strict, client default" \
2046 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2047 "$P_CLI debug_level=3" \
2048 0 \
2049 -c "found renegotiation extension" \
2050 -C "error" \
2051 -c "HTTP/1.0 200 [Oo][Kk]"
2052
Paul Bakker539d9722015-02-08 16:18:35 +01002053requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002054run_test "Renego ext: gnutls server unsafe, client default" \
2055 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2056 "$P_CLI debug_level=3" \
2057 0 \
2058 -C "found renegotiation extension" \
2059 -C "error" \
2060 -c "HTTP/1.0 200 [Oo][Kk]"
2061
Paul Bakker539d9722015-02-08 16:18:35 +01002062requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002063run_test "Renego ext: gnutls server unsafe, client break legacy" \
2064 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2065 "$P_CLI debug_level=3 allow_legacy=-1" \
2066 1 \
2067 -C "found renegotiation extension" \
2068 -c "error" \
2069 -C "HTTP/1.0 200 [Oo][Kk]"
2070
Paul Bakker539d9722015-02-08 16:18:35 +01002071requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002072run_test "Renego ext: gnutls client strict, server default" \
2073 "$P_SRV debug_level=3" \
2074 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2075 0 \
2076 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2077 -s "server hello, secure renegotiation extension"
2078
Paul Bakker539d9722015-02-08 16:18:35 +01002079requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002080run_test "Renego ext: gnutls client unsafe, server default" \
2081 "$P_SRV debug_level=3" \
2082 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2083 0 \
2084 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2085 -S "server hello, secure renegotiation extension"
2086
Paul Bakker539d9722015-02-08 16:18:35 +01002087requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002088run_test "Renego ext: gnutls client unsafe, server break legacy" \
2089 "$P_SRV debug_level=3 allow_legacy=-1" \
2090 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2091 1 \
2092 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2093 -S "server hello, secure renegotiation extension"
2094
Janos Follath0b242342016-02-17 10:11:21 +00002095# Tests for silently dropping trailing extra bytes in .der certificates
2096
2097requires_gnutls
2098run_test "DER format: no trailing bytes" \
2099 "$P_SRV crt_file=data_files/server5-der0.crt \
2100 key_file=data_files/server5.key" \
2101 "$G_CLI " \
2102 0 \
2103 -c "Handshake was completed" \
2104
2105requires_gnutls
2106run_test "DER format: with a trailing zero byte" \
2107 "$P_SRV crt_file=data_files/server5-der1a.crt \
2108 key_file=data_files/server5.key" \
2109 "$G_CLI " \
2110 0 \
2111 -c "Handshake was completed" \
2112
2113requires_gnutls
2114run_test "DER format: with a trailing random byte" \
2115 "$P_SRV crt_file=data_files/server5-der1b.crt \
2116 key_file=data_files/server5.key" \
2117 "$G_CLI " \
2118 0 \
2119 -c "Handshake was completed" \
2120
2121requires_gnutls
2122run_test "DER format: with 2 trailing random bytes" \
2123 "$P_SRV crt_file=data_files/server5-der2.crt \
2124 key_file=data_files/server5.key" \
2125 "$G_CLI " \
2126 0 \
2127 -c "Handshake was completed" \
2128
2129requires_gnutls
2130run_test "DER format: with 4 trailing random bytes" \
2131 "$P_SRV crt_file=data_files/server5-der4.crt \
2132 key_file=data_files/server5.key" \
2133 "$G_CLI " \
2134 0 \
2135 -c "Handshake was completed" \
2136
2137requires_gnutls
2138run_test "DER format: with 8 trailing random bytes" \
2139 "$P_SRV crt_file=data_files/server5-der8.crt \
2140 key_file=data_files/server5.key" \
2141 "$G_CLI " \
2142 0 \
2143 -c "Handshake was completed" \
2144
2145requires_gnutls
2146run_test "DER format: with 9 trailing random bytes" \
2147 "$P_SRV crt_file=data_files/server5-der9.crt \
2148 key_file=data_files/server5.key" \
2149 "$G_CLI " \
2150 0 \
2151 -c "Handshake was completed" \
2152
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002153# Tests for auth_mode
2154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002155run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002156 "$P_SRV crt_file=data_files/server5-badsign.crt \
2157 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002158 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002159 1 \
2160 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002161 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002162 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002163 -c "X509 - Certificate verification failed"
2164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002165run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002166 "$P_SRV crt_file=data_files/server5-badsign.crt \
2167 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002168 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002169 0 \
2170 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002171 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002172 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002173 -C "X509 - Certificate verification failed"
2174
Hanno Beckere6706e62017-05-15 16:05:15 +01002175run_test "Authentication: server goodcert, client optional, no trusted CA" \
2176 "$P_SRV" \
2177 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2178 0 \
2179 -c "x509_verify_cert() returned" \
2180 -c "! The certificate is not correctly signed by the trusted CA" \
2181 -c "! Certificate verification flags"\
2182 -C "! mbedtls_ssl_handshake returned" \
2183 -C "X509 - Certificate verification failed" \
2184 -C "SSL - No CA Chain is set, but required to operate"
2185
2186run_test "Authentication: server goodcert, client required, no trusted CA" \
2187 "$P_SRV" \
2188 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2189 1 \
2190 -c "x509_verify_cert() returned" \
2191 -c "! The certificate is not correctly signed by the trusted CA" \
2192 -c "! Certificate verification flags"\
2193 -c "! mbedtls_ssl_handshake returned" \
2194 -c "SSL - No CA Chain is set, but required to operate"
2195
2196# The purpose of the next two tests is to test the client's behaviour when receiving a server
2197# certificate with an unsupported elliptic curve. This should usually not happen because
2198# the client informs the server about the supported curves - it does, though, in the
2199# corner case of a static ECDH suite, because the server doesn't check the curve on that
2200# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2201# different means to have the server ignoring the client's supported curve list.
2202
2203requires_config_enabled MBEDTLS_ECP_C
2204run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2205 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2206 crt_file=data_files/server5.ku-ka.crt" \
2207 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2208 1 \
2209 -c "bad certificate (EC key curve)"\
2210 -c "! Certificate verification flags"\
2211 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2212
2213requires_config_enabled MBEDTLS_ECP_C
2214run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2215 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2216 crt_file=data_files/server5.ku-ka.crt" \
2217 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2218 1 \
2219 -c "bad certificate (EC key curve)"\
2220 -c "! Certificate verification flags"\
2221 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002223run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002224 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002225 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002226 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002227 0 \
2228 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002229 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002230 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002231 -C "X509 - Certificate verification failed"
2232
Simon Butcher99000142016-10-13 17:21:01 +01002233run_test "Authentication: client SHA256, server required" \
2234 "$P_SRV auth_mode=required" \
2235 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2236 key_file=data_files/server6.key \
2237 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2238 0 \
2239 -c "Supported Signature Algorithm found: 4," \
2240 -c "Supported Signature Algorithm found: 5,"
2241
2242run_test "Authentication: client SHA384, server required" \
2243 "$P_SRV auth_mode=required" \
2244 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2245 key_file=data_files/server6.key \
2246 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2247 0 \
2248 -c "Supported Signature Algorithm found: 4," \
2249 -c "Supported Signature Algorithm found: 5,"
2250
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002251requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2252run_test "Authentication: client has no cert, server required (SSLv3)" \
2253 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2254 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2255 key_file=data_files/server5.key" \
2256 1 \
2257 -S "skip write certificate request" \
2258 -C "skip parse certificate request" \
2259 -c "got a certificate request" \
2260 -c "got no certificate to send" \
2261 -S "x509_verify_cert() returned" \
2262 -s "client has no certificate" \
2263 -s "! mbedtls_ssl_handshake returned" \
2264 -c "! mbedtls_ssl_handshake returned" \
2265 -s "No client certification received from the client, but required by the authentication mode"
2266
2267run_test "Authentication: client has no cert, server required (TLS)" \
2268 "$P_SRV debug_level=3 auth_mode=required" \
2269 "$P_CLI debug_level=3 crt_file=none \
2270 key_file=data_files/server5.key" \
2271 1 \
2272 -S "skip write certificate request" \
2273 -C "skip parse certificate request" \
2274 -c "got a certificate request" \
2275 -c "= write certificate$" \
2276 -C "skip write certificate$" \
2277 -S "x509_verify_cert() returned" \
2278 -s "client has no certificate" \
2279 -s "! mbedtls_ssl_handshake returned" \
2280 -c "! mbedtls_ssl_handshake returned" \
2281 -s "No client certification received from the client, but required by the authentication mode"
2282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002283run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002284 "$P_SRV debug_level=3 auth_mode=required" \
2285 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002286 key_file=data_files/server5.key" \
2287 1 \
2288 -S "skip write certificate request" \
2289 -C "skip parse certificate request" \
2290 -c "got a certificate request" \
2291 -C "skip write certificate" \
2292 -C "skip write certificate verify" \
2293 -S "skip parse certificate verify" \
2294 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002295 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002296 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002297 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002298 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002299 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002300# We don't check that the client receives the alert because it might
2301# detect that its write end of the connection is closed and abort
2302# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002303
Janos Follath89baba22017-04-10 14:34:35 +01002304run_test "Authentication: client cert not trusted, server required" \
2305 "$P_SRV debug_level=3 auth_mode=required" \
2306 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2307 key_file=data_files/server5.key" \
2308 1 \
2309 -S "skip write certificate request" \
2310 -C "skip parse certificate request" \
2311 -c "got a certificate request" \
2312 -C "skip write certificate" \
2313 -C "skip write certificate verify" \
2314 -S "skip parse certificate verify" \
2315 -s "x509_verify_cert() returned" \
2316 -s "! The certificate is not correctly signed by the trusted CA" \
2317 -s "! mbedtls_ssl_handshake returned" \
2318 -c "! mbedtls_ssl_handshake returned" \
2319 -s "X509 - Certificate verification failed"
2320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002321run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002322 "$P_SRV debug_level=3 auth_mode=optional" \
2323 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002324 key_file=data_files/server5.key" \
2325 0 \
2326 -S "skip write certificate request" \
2327 -C "skip parse certificate request" \
2328 -c "got a certificate request" \
2329 -C "skip write certificate" \
2330 -C "skip write certificate verify" \
2331 -S "skip parse certificate verify" \
2332 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002333 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002334 -S "! mbedtls_ssl_handshake returned" \
2335 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002336 -S "X509 - Certificate verification failed"
2337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002338run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002339 "$P_SRV debug_level=3 auth_mode=none" \
2340 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002341 key_file=data_files/server5.key" \
2342 0 \
2343 -s "skip write certificate request" \
2344 -C "skip parse certificate request" \
2345 -c "got no certificate request" \
2346 -c "skip write certificate" \
2347 -c "skip write certificate verify" \
2348 -s "skip parse certificate verify" \
2349 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002350 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002351 -S "! mbedtls_ssl_handshake returned" \
2352 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002353 -S "X509 - Certificate verification failed"
2354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002355run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002356 "$P_SRV debug_level=3 auth_mode=optional" \
2357 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002358 0 \
2359 -S "skip write certificate request" \
2360 -C "skip parse certificate request" \
2361 -c "got a certificate request" \
2362 -C "skip write certificate$" \
2363 -C "got no certificate to send" \
2364 -S "SSLv3 client has no certificate" \
2365 -c "skip write certificate verify" \
2366 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002367 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002368 -S "! mbedtls_ssl_handshake returned" \
2369 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002370 -S "X509 - Certificate verification failed"
2371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002372run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002373 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002374 "$O_CLI" \
2375 0 \
2376 -S "skip write certificate request" \
2377 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002378 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002379 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002380 -S "X509 - Certificate verification failed"
2381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002382run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002383 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002384 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002385 0 \
2386 -C "skip parse certificate request" \
2387 -c "got a certificate request" \
2388 -C "skip write certificate$" \
2389 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002390 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002391
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002392run_test "Authentication: client no cert, openssl server required" \
2393 "$O_SRV -Verify 10" \
2394 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2395 1 \
2396 -C "skip parse certificate request" \
2397 -c "got a certificate request" \
2398 -C "skip write certificate$" \
2399 -c "skip write certificate verify" \
2400 -c "! mbedtls_ssl_handshake returned"
2401
Janos Follathe2681a42016-03-07 15:57:05 +00002402requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002403run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002404 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002405 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002406 0 \
2407 -S "skip write certificate request" \
2408 -C "skip parse certificate request" \
2409 -c "got a certificate request" \
2410 -C "skip write certificate$" \
2411 -c "skip write certificate verify" \
2412 -c "got no certificate to send" \
2413 -s "SSLv3 client has no certificate" \
2414 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002415 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002416 -S "! mbedtls_ssl_handshake returned" \
2417 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002418 -S "X509 - Certificate verification failed"
2419
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002420# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2421# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002422
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002423MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002424MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002425
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002426if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002427 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002428 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002429 printf "test value of ${MAX_IM_CA}. \n"
2430 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002431 printf "The tests assume this value and if it changes, the tests in this\n"
2432 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002433 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002434
2435 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002436fi
2437
Angus Grattonc4dd0732018-04-11 16:28:39 +10002438requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002439run_test "Authentication: server max_int chain, client default" \
2440 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2441 key_file=data_files/dir-maxpath/09.key" \
2442 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2443 0 \
2444 -C "X509 - A fatal error occured"
2445
Angus Grattonc4dd0732018-04-11 16:28:39 +10002446requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002447run_test "Authentication: server max_int+1 chain, client default" \
2448 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2449 key_file=data_files/dir-maxpath/10.key" \
2450 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2451 1 \
2452 -c "X509 - A fatal error occured"
2453
Angus Grattonc4dd0732018-04-11 16:28:39 +10002454requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002455run_test "Authentication: server max_int+1 chain, client optional" \
2456 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2457 key_file=data_files/dir-maxpath/10.key" \
2458 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2459 auth_mode=optional" \
2460 1 \
2461 -c "X509 - A fatal error occured"
2462
Angus Grattonc4dd0732018-04-11 16:28:39 +10002463requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002464run_test "Authentication: server max_int+1 chain, client none" \
2465 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2466 key_file=data_files/dir-maxpath/10.key" \
2467 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2468 auth_mode=none" \
2469 0 \
2470 -C "X509 - A fatal error occured"
2471
Angus Grattonc4dd0732018-04-11 16:28:39 +10002472requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002473run_test "Authentication: client max_int+1 chain, server default" \
2474 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2475 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2476 key_file=data_files/dir-maxpath/10.key" \
2477 0 \
2478 -S "X509 - A fatal error occured"
2479
Angus Grattonc4dd0732018-04-11 16:28:39 +10002480requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002481run_test "Authentication: client max_int+1 chain, server optional" \
2482 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2483 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2484 key_file=data_files/dir-maxpath/10.key" \
2485 1 \
2486 -s "X509 - A fatal error occured"
2487
Angus Grattonc4dd0732018-04-11 16:28:39 +10002488requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002489run_test "Authentication: client max_int+1 chain, server required" \
2490 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2491 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2492 key_file=data_files/dir-maxpath/10.key" \
2493 1 \
2494 -s "X509 - A fatal error occured"
2495
Angus Grattonc4dd0732018-04-11 16:28:39 +10002496requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002497run_test "Authentication: client max_int chain, server required" \
2498 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2499 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2500 key_file=data_files/dir-maxpath/09.key" \
2501 0 \
2502 -S "X509 - A fatal error occured"
2503
Janos Follath89baba22017-04-10 14:34:35 +01002504# Tests for CA list in CertificateRequest messages
2505
2506run_test "Authentication: send CA list in CertificateRequest (default)" \
2507 "$P_SRV debug_level=3 auth_mode=required" \
2508 "$P_CLI crt_file=data_files/server6.crt \
2509 key_file=data_files/server6.key" \
2510 0 \
2511 -s "requested DN"
2512
2513run_test "Authentication: do not send CA list in CertificateRequest" \
2514 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2515 "$P_CLI crt_file=data_files/server6.crt \
2516 key_file=data_files/server6.key" \
2517 0 \
2518 -S "requested DN"
2519
2520run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2521 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2522 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2523 key_file=data_files/server5.key" \
2524 1 \
2525 -S "requested DN" \
2526 -s "x509_verify_cert() returned" \
2527 -s "! The certificate is not correctly signed by the trusted CA" \
2528 -s "! mbedtls_ssl_handshake returned" \
2529 -c "! mbedtls_ssl_handshake returned" \
2530 -s "X509 - Certificate verification failed"
2531
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002532# Tests for certificate selection based on SHA verson
2533
2534run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2535 "$P_SRV crt_file=data_files/server5.crt \
2536 key_file=data_files/server5.key \
2537 crt_file2=data_files/server5-sha1.crt \
2538 key_file2=data_files/server5.key" \
2539 "$P_CLI force_version=tls1_2" \
2540 0 \
2541 -c "signed using.*ECDSA with SHA256" \
2542 -C "signed using.*ECDSA with SHA1"
2543
2544run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2545 "$P_SRV crt_file=data_files/server5.crt \
2546 key_file=data_files/server5.key \
2547 crt_file2=data_files/server5-sha1.crt \
2548 key_file2=data_files/server5.key" \
2549 "$P_CLI force_version=tls1_1" \
2550 0 \
2551 -C "signed using.*ECDSA with SHA256" \
2552 -c "signed using.*ECDSA with SHA1"
2553
2554run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2555 "$P_SRV crt_file=data_files/server5.crt \
2556 key_file=data_files/server5.key \
2557 crt_file2=data_files/server5-sha1.crt \
2558 key_file2=data_files/server5.key" \
2559 "$P_CLI force_version=tls1" \
2560 0 \
2561 -C "signed using.*ECDSA with SHA256" \
2562 -c "signed using.*ECDSA with SHA1"
2563
2564run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2565 "$P_SRV crt_file=data_files/server5.crt \
2566 key_file=data_files/server5.key \
2567 crt_file2=data_files/server6.crt \
2568 key_file2=data_files/server6.key" \
2569 "$P_CLI force_version=tls1_1" \
2570 0 \
2571 -c "serial number.*09" \
2572 -c "signed using.*ECDSA with SHA256" \
2573 -C "signed using.*ECDSA with SHA1"
2574
2575run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2576 "$P_SRV crt_file=data_files/server6.crt \
2577 key_file=data_files/server6.key \
2578 crt_file2=data_files/server5.crt \
2579 key_file2=data_files/server5.key" \
2580 "$P_CLI force_version=tls1_1" \
2581 0 \
2582 -c "serial number.*0A" \
2583 -c "signed using.*ECDSA with SHA256" \
2584 -C "signed using.*ECDSA with SHA1"
2585
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002586# tests for SNI
2587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002588run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002589 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002590 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002591 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002592 0 \
2593 -S "parse ServerName extension" \
2594 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2595 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002597run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002598 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002599 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002600 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 +02002601 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002602 0 \
2603 -s "parse ServerName extension" \
2604 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2605 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002607run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002608 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002609 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002610 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 +02002611 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002612 0 \
2613 -s "parse ServerName extension" \
2614 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2615 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002617run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002618 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002619 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002620 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 +02002621 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002622 1 \
2623 -s "parse ServerName extension" \
2624 -s "ssl_sni_wrapper() returned" \
2625 -s "mbedtls_ssl_handshake returned" \
2626 -c "mbedtls_ssl_handshake returned" \
2627 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002628
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002629run_test "SNI: client auth no override: optional" \
2630 "$P_SRV debug_level=3 auth_mode=optional \
2631 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2632 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2633 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002634 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002635 -S "skip write certificate request" \
2636 -C "skip parse certificate request" \
2637 -c "got a certificate request" \
2638 -C "skip write certificate" \
2639 -C "skip write certificate verify" \
2640 -S "skip parse certificate verify"
2641
2642run_test "SNI: client auth override: none -> optional" \
2643 "$P_SRV debug_level=3 auth_mode=none \
2644 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2645 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2646 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002647 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002648 -S "skip write certificate request" \
2649 -C "skip parse certificate request" \
2650 -c "got a certificate request" \
2651 -C "skip write certificate" \
2652 -C "skip write certificate verify" \
2653 -S "skip parse certificate verify"
2654
2655run_test "SNI: client auth override: optional -> none" \
2656 "$P_SRV debug_level=3 auth_mode=optional \
2657 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2658 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2659 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002660 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002661 -s "skip write certificate request" \
2662 -C "skip parse certificate request" \
2663 -c "got no certificate request" \
2664 -c "skip write certificate" \
2665 -c "skip write certificate verify" \
2666 -s "skip parse certificate verify"
2667
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002668run_test "SNI: CA no override" \
2669 "$P_SRV debug_level=3 auth_mode=optional \
2670 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2671 ca_file=data_files/test-ca.crt \
2672 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2673 "$P_CLI debug_level=3 server_name=localhost \
2674 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2675 1 \
2676 -S "skip write certificate request" \
2677 -C "skip parse certificate request" \
2678 -c "got a certificate request" \
2679 -C "skip write certificate" \
2680 -C "skip write certificate verify" \
2681 -S "skip parse certificate verify" \
2682 -s "x509_verify_cert() returned" \
2683 -s "! The certificate is not correctly signed by the trusted CA" \
2684 -S "The certificate has been revoked (is on a CRL)"
2685
2686run_test "SNI: CA override" \
2687 "$P_SRV debug_level=3 auth_mode=optional \
2688 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2689 ca_file=data_files/test-ca.crt \
2690 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2691 "$P_CLI debug_level=3 server_name=localhost \
2692 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2693 0 \
2694 -S "skip write certificate request" \
2695 -C "skip parse certificate request" \
2696 -c "got a certificate request" \
2697 -C "skip write certificate" \
2698 -C "skip write certificate verify" \
2699 -S "skip parse certificate verify" \
2700 -S "x509_verify_cert() returned" \
2701 -S "! The certificate is not correctly signed by the trusted CA" \
2702 -S "The certificate has been revoked (is on a CRL)"
2703
2704run_test "SNI: CA override with CRL" \
2705 "$P_SRV debug_level=3 auth_mode=optional \
2706 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2707 ca_file=data_files/test-ca.crt \
2708 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2709 "$P_CLI debug_level=3 server_name=localhost \
2710 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2711 1 \
2712 -S "skip write certificate request" \
2713 -C "skip parse certificate request" \
2714 -c "got a certificate request" \
2715 -C "skip write certificate" \
2716 -C "skip write certificate verify" \
2717 -S "skip parse certificate verify" \
2718 -s "x509_verify_cert() returned" \
2719 -S "! The certificate is not correctly signed by the trusted CA" \
2720 -s "The certificate has been revoked (is on a CRL)"
2721
Andres AG1a834452016-12-07 10:01:30 +00002722# Tests for SNI and DTLS
2723
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002724run_test "SNI: DTLS, no SNI callback" \
2725 "$P_SRV debug_level=3 dtls=1 \
2726 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2727 "$P_CLI server_name=localhost dtls=1" \
2728 0 \
2729 -S "parse ServerName extension" \
2730 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2731 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2732
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002733run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00002734 "$P_SRV debug_level=3 dtls=1 \
2735 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2736 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2737 "$P_CLI server_name=localhost dtls=1" \
2738 0 \
2739 -s "parse ServerName extension" \
2740 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2741 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2742
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002743run_test "SNI: DTLS, matching cert 2" \
2744 "$P_SRV debug_level=3 dtls=1 \
2745 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2746 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2747 "$P_CLI server_name=polarssl.example dtls=1" \
2748 0 \
2749 -s "parse ServerName extension" \
2750 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2751 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2752
2753run_test "SNI: DTLS, no matching cert" \
2754 "$P_SRV debug_level=3 dtls=1 \
2755 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2756 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2757 "$P_CLI server_name=nonesuch.example dtls=1" \
2758 1 \
2759 -s "parse ServerName extension" \
2760 -s "ssl_sni_wrapper() returned" \
2761 -s "mbedtls_ssl_handshake returned" \
2762 -c "mbedtls_ssl_handshake returned" \
2763 -c "SSL - A fatal alert message was received from our peer"
2764
2765run_test "SNI: DTLS, client auth no override: optional" \
2766 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2767 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2768 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2769 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2770 0 \
2771 -S "skip write certificate request" \
2772 -C "skip parse certificate request" \
2773 -c "got a certificate request" \
2774 -C "skip write certificate" \
2775 -C "skip write certificate verify" \
2776 -S "skip parse certificate verify"
2777
2778run_test "SNI: DTLS, client auth override: none -> optional" \
2779 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2780 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2781 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2782 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2783 0 \
2784 -S "skip write certificate request" \
2785 -C "skip parse certificate request" \
2786 -c "got a certificate request" \
2787 -C "skip write certificate" \
2788 -C "skip write certificate verify" \
2789 -S "skip parse certificate verify"
2790
2791run_test "SNI: DTLS, client auth override: optional -> none" \
2792 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2793 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2794 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2795 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2796 0 \
2797 -s "skip write certificate request" \
2798 -C "skip parse certificate request" \
2799 -c "got no certificate request" \
2800 -c "skip write certificate" \
2801 -c "skip write certificate verify" \
2802 -s "skip parse certificate verify"
2803
2804run_test "SNI: DTLS, CA no override" \
2805 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2806 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2807 ca_file=data_files/test-ca.crt \
2808 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2809 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2810 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2811 1 \
2812 -S "skip write certificate request" \
2813 -C "skip parse certificate request" \
2814 -c "got a certificate request" \
2815 -C "skip write certificate" \
2816 -C "skip write certificate verify" \
2817 -S "skip parse certificate verify" \
2818 -s "x509_verify_cert() returned" \
2819 -s "! The certificate is not correctly signed by the trusted CA" \
2820 -S "The certificate has been revoked (is on a CRL)"
2821
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002822run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00002823 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2824 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2825 ca_file=data_files/test-ca.crt \
2826 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2827 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2828 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2829 0 \
2830 -S "skip write certificate request" \
2831 -C "skip parse certificate request" \
2832 -c "got a certificate request" \
2833 -C "skip write certificate" \
2834 -C "skip write certificate verify" \
2835 -S "skip parse certificate verify" \
2836 -S "x509_verify_cert() returned" \
2837 -S "! The certificate is not correctly signed by the trusted CA" \
2838 -S "The certificate has been revoked (is on a CRL)"
2839
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002840run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00002841 "$P_SRV debug_level=3 auth_mode=optional \
2842 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2843 ca_file=data_files/test-ca.crt \
2844 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2845 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2846 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2847 1 \
2848 -S "skip write certificate request" \
2849 -C "skip parse certificate request" \
2850 -c "got a certificate request" \
2851 -C "skip write certificate" \
2852 -C "skip write certificate verify" \
2853 -S "skip parse certificate verify" \
2854 -s "x509_verify_cert() returned" \
2855 -S "! The certificate is not correctly signed by the trusted CA" \
2856 -s "The certificate has been revoked (is on a CRL)"
2857
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002858# Tests for non-blocking I/O: exercise a variety of handshake flows
2859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002860run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002861 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2862 "$P_CLI nbio=2 tickets=0" \
2863 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002864 -S "mbedtls_ssl_handshake returned" \
2865 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002866 -c "Read from server: .* bytes read"
2867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002868run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002869 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2870 "$P_CLI nbio=2 tickets=0" \
2871 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002872 -S "mbedtls_ssl_handshake returned" \
2873 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002874 -c "Read from server: .* bytes read"
2875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002876run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002877 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2878 "$P_CLI nbio=2 tickets=1" \
2879 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002880 -S "mbedtls_ssl_handshake returned" \
2881 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002882 -c "Read from server: .* bytes read"
2883
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002884run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002885 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2886 "$P_CLI nbio=2 tickets=1" \
2887 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002888 -S "mbedtls_ssl_handshake returned" \
2889 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002890 -c "Read from server: .* bytes read"
2891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002892run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002893 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2894 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2895 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002896 -S "mbedtls_ssl_handshake returned" \
2897 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002898 -c "Read from server: .* bytes read"
2899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002900run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002901 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2902 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2903 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002904 -S "mbedtls_ssl_handshake returned" \
2905 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002906 -c "Read from server: .* bytes read"
2907
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002908run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002909 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2910 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2911 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002912 -S "mbedtls_ssl_handshake returned" \
2913 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002914 -c "Read from server: .* bytes read"
2915
Hanno Becker00076712017-11-15 16:39:08 +00002916# Tests for event-driven I/O: exercise a variety of handshake flows
2917
2918run_test "Event-driven I/O: basic handshake" \
2919 "$P_SRV event=1 tickets=0 auth_mode=none" \
2920 "$P_CLI event=1 tickets=0" \
2921 0 \
2922 -S "mbedtls_ssl_handshake returned" \
2923 -C "mbedtls_ssl_handshake returned" \
2924 -c "Read from server: .* bytes read"
2925
2926run_test "Event-driven I/O: client auth" \
2927 "$P_SRV event=1 tickets=0 auth_mode=required" \
2928 "$P_CLI event=1 tickets=0" \
2929 0 \
2930 -S "mbedtls_ssl_handshake returned" \
2931 -C "mbedtls_ssl_handshake returned" \
2932 -c "Read from server: .* bytes read"
2933
2934run_test "Event-driven I/O: ticket" \
2935 "$P_SRV event=1 tickets=1 auth_mode=none" \
2936 "$P_CLI event=1 tickets=1" \
2937 0 \
2938 -S "mbedtls_ssl_handshake returned" \
2939 -C "mbedtls_ssl_handshake returned" \
2940 -c "Read from server: .* bytes read"
2941
2942run_test "Event-driven I/O: ticket + client auth" \
2943 "$P_SRV event=1 tickets=1 auth_mode=required" \
2944 "$P_CLI event=1 tickets=1" \
2945 0 \
2946 -S "mbedtls_ssl_handshake returned" \
2947 -C "mbedtls_ssl_handshake returned" \
2948 -c "Read from server: .* bytes read"
2949
2950run_test "Event-driven I/O: ticket + client auth + resume" \
2951 "$P_SRV event=1 tickets=1 auth_mode=required" \
2952 "$P_CLI event=1 tickets=1 reconnect=1" \
2953 0 \
2954 -S "mbedtls_ssl_handshake returned" \
2955 -C "mbedtls_ssl_handshake returned" \
2956 -c "Read from server: .* bytes read"
2957
2958run_test "Event-driven I/O: ticket + resume" \
2959 "$P_SRV event=1 tickets=1 auth_mode=none" \
2960 "$P_CLI event=1 tickets=1 reconnect=1" \
2961 0 \
2962 -S "mbedtls_ssl_handshake returned" \
2963 -C "mbedtls_ssl_handshake returned" \
2964 -c "Read from server: .* bytes read"
2965
2966run_test "Event-driven I/O: session-id resume" \
2967 "$P_SRV event=1 tickets=0 auth_mode=none" \
2968 "$P_CLI event=1 tickets=0 reconnect=1" \
2969 0 \
2970 -S "mbedtls_ssl_handshake returned" \
2971 -C "mbedtls_ssl_handshake returned" \
2972 -c "Read from server: .* bytes read"
2973
Hanno Becker6a33f592018-03-13 11:38:46 +00002974run_test "Event-driven I/O, DTLS: basic handshake" \
2975 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2976 "$P_CLI dtls=1 event=1 tickets=0" \
2977 0 \
2978 -c "Read from server: .* bytes read"
2979
2980run_test "Event-driven I/O, DTLS: client auth" \
2981 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
2982 "$P_CLI dtls=1 event=1 tickets=0" \
2983 0 \
2984 -c "Read from server: .* bytes read"
2985
2986run_test "Event-driven I/O, DTLS: ticket" \
2987 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2988 "$P_CLI dtls=1 event=1 tickets=1" \
2989 0 \
2990 -c "Read from server: .* bytes read"
2991
2992run_test "Event-driven I/O, DTLS: ticket + client auth" \
2993 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2994 "$P_CLI dtls=1 event=1 tickets=1" \
2995 0 \
2996 -c "Read from server: .* bytes read"
2997
2998run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
2999 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3000 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
3001 0 \
3002 -c "Read from server: .* bytes read"
3003
3004run_test "Event-driven I/O, DTLS: ticket + resume" \
3005 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3006 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
3007 0 \
3008 -c "Read from server: .* bytes read"
3009
3010run_test "Event-driven I/O, DTLS: session-id resume" \
3011 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3012 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
3013 0 \
3014 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003015
3016# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3017# During session resumption, the client will send its ApplicationData record
3018# within the same datagram as the Finished messages. In this situation, the
3019# server MUST NOT idle on the underlying transport after handshake completion,
3020# because the ApplicationData request has already been queued internally.
3021run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003022 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003023 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3024 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
3025 0 \
3026 -c "Read from server: .* bytes read"
3027
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003028# Tests for version negotiation
3029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003030run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003031 "$P_SRV" \
3032 "$P_CLI" \
3033 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003034 -S "mbedtls_ssl_handshake returned" \
3035 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003036 -s "Protocol is TLSv1.2" \
3037 -c "Protocol is TLSv1.2"
3038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003039run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003040 "$P_SRV" \
3041 "$P_CLI max_version=tls1_1" \
3042 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003043 -S "mbedtls_ssl_handshake returned" \
3044 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003045 -s "Protocol is TLSv1.1" \
3046 -c "Protocol is TLSv1.1"
3047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003048run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003049 "$P_SRV max_version=tls1_1" \
3050 "$P_CLI" \
3051 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003052 -S "mbedtls_ssl_handshake returned" \
3053 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003054 -s "Protocol is TLSv1.1" \
3055 -c "Protocol is TLSv1.1"
3056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003057run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003058 "$P_SRV max_version=tls1_1" \
3059 "$P_CLI max_version=tls1_1" \
3060 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003061 -S "mbedtls_ssl_handshake returned" \
3062 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003063 -s "Protocol is TLSv1.1" \
3064 -c "Protocol is TLSv1.1"
3065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003066run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003067 "$P_SRV min_version=tls1_1" \
3068 "$P_CLI max_version=tls1_1" \
3069 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003070 -S "mbedtls_ssl_handshake returned" \
3071 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003072 -s "Protocol is TLSv1.1" \
3073 -c "Protocol is TLSv1.1"
3074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003075run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003076 "$P_SRV max_version=tls1_1" \
3077 "$P_CLI min_version=tls1_1" \
3078 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003079 -S "mbedtls_ssl_handshake returned" \
3080 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003081 -s "Protocol is TLSv1.1" \
3082 -c "Protocol is TLSv1.1"
3083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003084run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003085 "$P_SRV max_version=tls1_1" \
3086 "$P_CLI min_version=tls1_2" \
3087 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003088 -s "mbedtls_ssl_handshake returned" \
3089 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003090 -c "SSL - Handshake protocol not within min/max boundaries"
3091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003092run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003093 "$P_SRV min_version=tls1_2" \
3094 "$P_CLI max_version=tls1_1" \
3095 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003096 -s "mbedtls_ssl_handshake returned" \
3097 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003098 -s "SSL - Handshake protocol not within min/max boundaries"
3099
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003100# Tests for ALPN extension
3101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003102run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003103 "$P_SRV debug_level=3" \
3104 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003105 0 \
3106 -C "client hello, adding alpn extension" \
3107 -S "found alpn extension" \
3108 -C "got an alert message, type: \\[2:120]" \
3109 -S "server hello, adding alpn extension" \
3110 -C "found alpn extension " \
3111 -C "Application Layer Protocol is" \
3112 -S "Application Layer Protocol is"
3113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003114run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003115 "$P_SRV debug_level=3" \
3116 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003117 0 \
3118 -c "client hello, adding alpn extension" \
3119 -s "found alpn extension" \
3120 -C "got an alert message, type: \\[2:120]" \
3121 -S "server hello, adding alpn extension" \
3122 -C "found alpn extension " \
3123 -c "Application Layer Protocol is (none)" \
3124 -S "Application Layer Protocol is"
3125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003126run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003127 "$P_SRV debug_level=3 alpn=abc,1234" \
3128 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003129 0 \
3130 -C "client hello, adding alpn extension" \
3131 -S "found alpn extension" \
3132 -C "got an alert message, type: \\[2:120]" \
3133 -S "server hello, adding alpn extension" \
3134 -C "found alpn extension " \
3135 -C "Application Layer Protocol is" \
3136 -s "Application Layer Protocol is (none)"
3137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003138run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003139 "$P_SRV debug_level=3 alpn=abc,1234" \
3140 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003141 0 \
3142 -c "client hello, adding alpn extension" \
3143 -s "found alpn extension" \
3144 -C "got an alert message, type: \\[2:120]" \
3145 -s "server hello, adding alpn extension" \
3146 -c "found alpn extension" \
3147 -c "Application Layer Protocol is abc" \
3148 -s "Application Layer Protocol is abc"
3149
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003150run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003151 "$P_SRV debug_level=3 alpn=abc,1234" \
3152 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003153 0 \
3154 -c "client hello, adding alpn extension" \
3155 -s "found alpn extension" \
3156 -C "got an alert message, type: \\[2:120]" \
3157 -s "server hello, adding alpn extension" \
3158 -c "found alpn extension" \
3159 -c "Application Layer Protocol is abc" \
3160 -s "Application Layer Protocol is abc"
3161
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003162run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003163 "$P_SRV debug_level=3 alpn=abc,1234" \
3164 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003165 0 \
3166 -c "client hello, adding alpn extension" \
3167 -s "found alpn extension" \
3168 -C "got an alert message, type: \\[2:120]" \
3169 -s "server hello, adding alpn extension" \
3170 -c "found alpn extension" \
3171 -c "Application Layer Protocol is 1234" \
3172 -s "Application Layer Protocol is 1234"
3173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003174run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003175 "$P_SRV debug_level=3 alpn=abc,123" \
3176 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003177 1 \
3178 -c "client hello, adding alpn extension" \
3179 -s "found alpn extension" \
3180 -c "got an alert message, type: \\[2:120]" \
3181 -S "server hello, adding alpn extension" \
3182 -C "found alpn extension" \
3183 -C "Application Layer Protocol is 1234" \
3184 -S "Application Layer Protocol is 1234"
3185
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003186
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003187# Tests for keyUsage in leaf certificates, part 1:
3188# server-side certificate/suite selection
3189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003190run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003191 "$P_SRV key_file=data_files/server2.key \
3192 crt_file=data_files/server2.ku-ds.crt" \
3193 "$P_CLI" \
3194 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003195 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003196
3197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003198run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003199 "$P_SRV key_file=data_files/server2.key \
3200 crt_file=data_files/server2.ku-ke.crt" \
3201 "$P_CLI" \
3202 0 \
3203 -c "Ciphersuite is TLS-RSA-WITH-"
3204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003205run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003206 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003207 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003208 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003209 1 \
3210 -C "Ciphersuite is "
3211
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003212run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003213 "$P_SRV key_file=data_files/server5.key \
3214 crt_file=data_files/server5.ku-ds.crt" \
3215 "$P_CLI" \
3216 0 \
3217 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3218
3219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003220run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003221 "$P_SRV key_file=data_files/server5.key \
3222 crt_file=data_files/server5.ku-ka.crt" \
3223 "$P_CLI" \
3224 0 \
3225 -c "Ciphersuite is TLS-ECDH-"
3226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003227run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003228 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003229 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003230 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003231 1 \
3232 -C "Ciphersuite is "
3233
3234# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003235# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003236
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003237run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003238 "$O_SRV -key data_files/server2.key \
3239 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003240 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003241 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3242 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003243 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003244 -C "Processing of the Certificate handshake message failed" \
3245 -c "Ciphersuite is TLS-"
3246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003247run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003248 "$O_SRV -key data_files/server2.key \
3249 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003250 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003251 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3252 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003253 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003254 -C "Processing of the Certificate handshake message failed" \
3255 -c "Ciphersuite is TLS-"
3256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003257run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003258 "$O_SRV -key data_files/server2.key \
3259 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003260 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003261 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3262 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003263 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003264 -C "Processing of the Certificate handshake message failed" \
3265 -c "Ciphersuite is TLS-"
3266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003267run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003268 "$O_SRV -key data_files/server2.key \
3269 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003270 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003271 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3272 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003273 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003274 -c "Processing of the Certificate handshake message failed" \
3275 -C "Ciphersuite is TLS-"
3276
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003277run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3278 "$O_SRV -key data_files/server2.key \
3279 -cert data_files/server2.ku-ke.crt" \
3280 "$P_CLI debug_level=1 auth_mode=optional \
3281 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3282 0 \
3283 -c "bad certificate (usage extensions)" \
3284 -C "Processing of the Certificate handshake message failed" \
3285 -c "Ciphersuite is TLS-" \
3286 -c "! Usage does not match the keyUsage extension"
3287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003288run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003289 "$O_SRV -key data_files/server2.key \
3290 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003291 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003292 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3293 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003294 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003295 -C "Processing of the Certificate handshake message failed" \
3296 -c "Ciphersuite is TLS-"
3297
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003298run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003299 "$O_SRV -key data_files/server2.key \
3300 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003301 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003302 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3303 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003304 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003305 -c "Processing of the Certificate handshake message failed" \
3306 -C "Ciphersuite is TLS-"
3307
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003308run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3309 "$O_SRV -key data_files/server2.key \
3310 -cert data_files/server2.ku-ds.crt" \
3311 "$P_CLI debug_level=1 auth_mode=optional \
3312 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3313 0 \
3314 -c "bad certificate (usage extensions)" \
3315 -C "Processing of the Certificate handshake message failed" \
3316 -c "Ciphersuite is TLS-" \
3317 -c "! Usage does not match the keyUsage extension"
3318
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003319# Tests for keyUsage in leaf certificates, part 3:
3320# server-side checking of client cert
3321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003322run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003323 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003324 "$O_CLI -key data_files/server2.key \
3325 -cert data_files/server2.ku-ds.crt" \
3326 0 \
3327 -S "bad certificate (usage extensions)" \
3328 -S "Processing of the Certificate handshake message failed"
3329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003330run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003331 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003332 "$O_CLI -key data_files/server2.key \
3333 -cert data_files/server2.ku-ke.crt" \
3334 0 \
3335 -s "bad certificate (usage extensions)" \
3336 -S "Processing of the Certificate handshake message failed"
3337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003338run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003339 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003340 "$O_CLI -key data_files/server2.key \
3341 -cert data_files/server2.ku-ke.crt" \
3342 1 \
3343 -s "bad certificate (usage extensions)" \
3344 -s "Processing of the Certificate handshake message failed"
3345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003346run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003347 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003348 "$O_CLI -key data_files/server5.key \
3349 -cert data_files/server5.ku-ds.crt" \
3350 0 \
3351 -S "bad certificate (usage extensions)" \
3352 -S "Processing of the Certificate handshake message failed"
3353
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003354run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003355 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003356 "$O_CLI -key data_files/server5.key \
3357 -cert data_files/server5.ku-ka.crt" \
3358 0 \
3359 -s "bad certificate (usage extensions)" \
3360 -S "Processing of the Certificate handshake message failed"
3361
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003362# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003364run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003365 "$P_SRV key_file=data_files/server5.key \
3366 crt_file=data_files/server5.eku-srv.crt" \
3367 "$P_CLI" \
3368 0
3369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003370run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003371 "$P_SRV key_file=data_files/server5.key \
3372 crt_file=data_files/server5.eku-srv.crt" \
3373 "$P_CLI" \
3374 0
3375
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003376run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003377 "$P_SRV key_file=data_files/server5.key \
3378 crt_file=data_files/server5.eku-cs_any.crt" \
3379 "$P_CLI" \
3380 0
3381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003382run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003383 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003384 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003385 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003386 1
3387
3388# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003390run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003391 "$O_SRV -key data_files/server5.key \
3392 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003393 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003394 0 \
3395 -C "bad certificate (usage extensions)" \
3396 -C "Processing of the Certificate handshake message failed" \
3397 -c "Ciphersuite is TLS-"
3398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003399run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003400 "$O_SRV -key data_files/server5.key \
3401 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003402 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003403 0 \
3404 -C "bad certificate (usage extensions)" \
3405 -C "Processing of the Certificate handshake message failed" \
3406 -c "Ciphersuite is TLS-"
3407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003408run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003409 "$O_SRV -key data_files/server5.key \
3410 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003411 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003412 0 \
3413 -C "bad certificate (usage extensions)" \
3414 -C "Processing of the Certificate handshake message failed" \
3415 -c "Ciphersuite is TLS-"
3416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003417run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003418 "$O_SRV -key data_files/server5.key \
3419 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003420 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003421 1 \
3422 -c "bad certificate (usage extensions)" \
3423 -c "Processing of the Certificate handshake message failed" \
3424 -C "Ciphersuite is TLS-"
3425
3426# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3427
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003428run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003429 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003430 "$O_CLI -key data_files/server5.key \
3431 -cert data_files/server5.eku-cli.crt" \
3432 0 \
3433 -S "bad certificate (usage extensions)" \
3434 -S "Processing of the Certificate handshake message failed"
3435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003436run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003437 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003438 "$O_CLI -key data_files/server5.key \
3439 -cert data_files/server5.eku-srv_cli.crt" \
3440 0 \
3441 -S "bad certificate (usage extensions)" \
3442 -S "Processing of the Certificate handshake message failed"
3443
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003444run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003445 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003446 "$O_CLI -key data_files/server5.key \
3447 -cert data_files/server5.eku-cs_any.crt" \
3448 0 \
3449 -S "bad certificate (usage extensions)" \
3450 -S "Processing of the Certificate handshake message failed"
3451
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003452run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003453 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003454 "$O_CLI -key data_files/server5.key \
3455 -cert data_files/server5.eku-cs.crt" \
3456 0 \
3457 -s "bad certificate (usage extensions)" \
3458 -S "Processing of the Certificate handshake message failed"
3459
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003460run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003461 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003462 "$O_CLI -key data_files/server5.key \
3463 -cert data_files/server5.eku-cs.crt" \
3464 1 \
3465 -s "bad certificate (usage extensions)" \
3466 -s "Processing of the Certificate handshake message failed"
3467
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003468# Tests for DHM parameters loading
3469
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003470run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003471 "$P_SRV" \
3472 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3473 debug_level=3" \
3474 0 \
3475 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003476 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003478run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003479 "$P_SRV dhm_file=data_files/dhparams.pem" \
3480 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3481 debug_level=3" \
3482 0 \
3483 -c "value of 'DHM: P ' (1024 bits)" \
3484 -c "value of 'DHM: G ' (2 bits)"
3485
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003486# Tests for DHM client-side size checking
3487
3488run_test "DHM size: server default, client default, OK" \
3489 "$P_SRV" \
3490 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3491 debug_level=1" \
3492 0 \
3493 -C "DHM prime too short:"
3494
3495run_test "DHM size: server default, client 2048, OK" \
3496 "$P_SRV" \
3497 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3498 debug_level=1 dhmlen=2048" \
3499 0 \
3500 -C "DHM prime too short:"
3501
3502run_test "DHM size: server 1024, client default, OK" \
3503 "$P_SRV dhm_file=data_files/dhparams.pem" \
3504 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3505 debug_level=1" \
3506 0 \
3507 -C "DHM prime too short:"
3508
3509run_test "DHM size: server 1000, client default, rejected" \
3510 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3511 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3512 debug_level=1" \
3513 1 \
3514 -c "DHM prime too short:"
3515
3516run_test "DHM size: server default, client 2049, rejected" \
3517 "$P_SRV" \
3518 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3519 debug_level=1 dhmlen=2049" \
3520 1 \
3521 -c "DHM prime too short:"
3522
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003523# Tests for PSK callback
3524
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003525run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003526 "$P_SRV psk=abc123 psk_identity=foo" \
3527 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3528 psk_identity=foo psk=abc123" \
3529 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003530 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003531 -S "SSL - Unknown identity received" \
3532 -S "SSL - Verification of the message MAC failed"
3533
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003534run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003535 "$P_SRV" \
3536 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3537 psk_identity=foo psk=abc123" \
3538 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003539 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003540 -S "SSL - Unknown identity received" \
3541 -S "SSL - Verification of the message MAC failed"
3542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003543run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003544 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3545 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3546 psk_identity=foo psk=abc123" \
3547 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003548 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003549 -s "SSL - Unknown identity received" \
3550 -S "SSL - Verification of the message MAC failed"
3551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003552run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003553 "$P_SRV psk_list=abc,dead,def,beef" \
3554 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3555 psk_identity=abc psk=dead" \
3556 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003557 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003558 -S "SSL - Unknown identity received" \
3559 -S "SSL - Verification of the message MAC failed"
3560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003561run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003562 "$P_SRV psk_list=abc,dead,def,beef" \
3563 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3564 psk_identity=def psk=beef" \
3565 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003566 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003567 -S "SSL - Unknown identity received" \
3568 -S "SSL - Verification of the message MAC failed"
3569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003570run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003571 "$P_SRV psk_list=abc,dead,def,beef" \
3572 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3573 psk_identity=ghi psk=beef" \
3574 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003575 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003576 -s "SSL - Unknown identity received" \
3577 -S "SSL - Verification of the message MAC failed"
3578
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003579run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003580 "$P_SRV psk_list=abc,dead,def,beef" \
3581 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3582 psk_identity=abc psk=beef" \
3583 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003584 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003585 -S "SSL - Unknown identity received" \
3586 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003587
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003588# Tests for EC J-PAKE
3589
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003590requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003591run_test "ECJPAKE: client not configured" \
3592 "$P_SRV debug_level=3" \
3593 "$P_CLI debug_level=3" \
3594 0 \
3595 -C "add ciphersuite: c0ff" \
3596 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003597 -S "found ecjpake kkpp extension" \
3598 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003599 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003600 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003601 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003602 -S "None of the common ciphersuites is usable"
3603
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003604requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003605run_test "ECJPAKE: server not configured" \
3606 "$P_SRV debug_level=3" \
3607 "$P_CLI debug_level=3 ecjpake_pw=bla \
3608 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3609 1 \
3610 -c "add ciphersuite: c0ff" \
3611 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003612 -s "found ecjpake kkpp extension" \
3613 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003614 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003615 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003616 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003617 -s "None of the common ciphersuites is usable"
3618
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003619requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003620run_test "ECJPAKE: working, TLS" \
3621 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3622 "$P_CLI debug_level=3 ecjpake_pw=bla \
3623 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003624 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003625 -c "add ciphersuite: c0ff" \
3626 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003627 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003628 -s "found ecjpake kkpp extension" \
3629 -S "skip ecjpake kkpp extension" \
3630 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003631 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003632 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003633 -S "None of the common ciphersuites is usable" \
3634 -S "SSL - Verification of the message MAC failed"
3635
Janos Follath74537a62016-09-02 13:45:28 +01003636server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003637requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003638run_test "ECJPAKE: password mismatch, TLS" \
3639 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3640 "$P_CLI debug_level=3 ecjpake_pw=bad \
3641 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3642 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003643 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003644 -s "SSL - Verification of the message MAC failed"
3645
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003646requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003647run_test "ECJPAKE: working, DTLS" \
3648 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3649 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3650 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3651 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003652 -c "re-using cached ecjpake parameters" \
3653 -S "SSL - Verification of the message MAC failed"
3654
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003655requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003656run_test "ECJPAKE: working, DTLS, no cookie" \
3657 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3658 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3659 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3660 0 \
3661 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003662 -S "SSL - Verification of the message MAC failed"
3663
Janos Follath74537a62016-09-02 13:45:28 +01003664server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003665requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003666run_test "ECJPAKE: password mismatch, DTLS" \
3667 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3668 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3669 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3670 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003671 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003672 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003673
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003674# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003675requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003676run_test "ECJPAKE: working, DTLS, nolog" \
3677 "$P_SRV dtls=1 ecjpake_pw=bla" \
3678 "$P_CLI dtls=1 ecjpake_pw=bla \
3679 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3680 0
3681
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003682# Tests for ciphersuites per version
3683
Janos Follathe2681a42016-03-07 15:57:05 +00003684requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003685run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003686 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003687 "$P_CLI force_version=ssl3" \
3688 0 \
3689 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003691run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003692 "$P_SRV arc4=1 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01003693 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003694 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003695 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003697run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003698 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003699 "$P_CLI force_version=tls1_1" \
3700 0 \
3701 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003703run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003704 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003705 "$P_CLI force_version=tls1_2" \
3706 0 \
3707 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3708
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003709# Test for ClientHello without extensions
3710
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003711requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003712run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003713 "$P_SRV debug_level=3" \
3714 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3715 0 \
3716 -s "dumping 'client hello extensions' (0 bytes)"
3717
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003718requires_gnutls
3719run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3720 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3721 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3722 0 \
3723 -s "dumping 'client hello extensions' (0 bytes)"
3724
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003725# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003726
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003727run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003728 "$P_SRV" \
3729 "$P_CLI request_size=100" \
3730 0 \
3731 -s "Read from client: 100 bytes read$"
3732
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003733run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003734 "$P_SRV" \
3735 "$P_CLI request_size=500" \
3736 0 \
3737 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003738
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003739# Tests for small packets
3740
Janos Follathe2681a42016-03-07 15:57:05 +00003741requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003742run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003743 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003744 "$P_CLI request_size=1 force_version=ssl3 \
3745 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3746 0 \
3747 -s "Read from client: 1 bytes read"
3748
Janos Follathe2681a42016-03-07 15:57:05 +00003749requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003750run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003751 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003752 "$P_CLI request_size=1 force_version=ssl3 \
3753 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3754 0 \
3755 -s "Read from client: 1 bytes read"
3756
3757run_test "Small packet TLS 1.0 BlockCipher" \
3758 "$P_SRV" \
3759 "$P_CLI request_size=1 force_version=tls1 \
3760 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3761 0 \
3762 -s "Read from client: 1 bytes read"
3763
Hanno Becker8501f982017-11-10 08:59:04 +00003764run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003765 "$P_SRV" \
3766 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3767 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3768 0 \
3769 -s "Read from client: 1 bytes read"
3770
Hanno Becker32c55012017-11-10 08:42:54 +00003771requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003772run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003773 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003774 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003776 0 \
3777 -s "Read from client: 1 bytes read"
3778
Hanno Becker32c55012017-11-10 08:42:54 +00003779requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003780run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003781 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003782 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003783 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003784 0 \
3785 -s "Read from client: 1 bytes read"
3786
3787run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003788 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003789 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3791 0 \
3792 -s "Read from client: 1 bytes read"
3793
3794run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3795 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3796 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003797 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003798 0 \
3799 -s "Read from client: 1 bytes read"
3800
3801requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3802run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003803 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003804 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003805 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003806 0 \
3807 -s "Read from client: 1 bytes read"
3808
Hanno Becker8501f982017-11-10 08:59:04 +00003809requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3810run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003811 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3812 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3813 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003814 0 \
3815 -s "Read from client: 1 bytes read"
3816
3817run_test "Small packet TLS 1.1 BlockCipher" \
3818 "$P_SRV" \
3819 "$P_CLI request_size=1 force_version=tls1_1 \
3820 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3821 0 \
3822 -s "Read from client: 1 bytes read"
3823
Hanno Becker8501f982017-11-10 08:59:04 +00003824run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003825 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003826 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003827 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003828 0 \
3829 -s "Read from client: 1 bytes read"
3830
3831requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3832run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003833 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003834 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003835 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003836 0 \
3837 -s "Read from client: 1 bytes read"
3838
3839requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3840run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003841 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003842 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003843 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003844 0 \
3845 -s "Read from client: 1 bytes read"
3846
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003847run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003848 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003849 "$P_CLI request_size=1 force_version=tls1_1 \
3850 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3851 0 \
3852 -s "Read from client: 1 bytes read"
3853
Hanno Becker8501f982017-11-10 08:59:04 +00003854run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3855 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003856 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003857 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003858 0 \
3859 -s "Read from client: 1 bytes read"
3860
Hanno Becker8501f982017-11-10 08:59:04 +00003861requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3862run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003863 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003864 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003865 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003866 0 \
3867 -s "Read from client: 1 bytes read"
3868
Hanno Becker32c55012017-11-10 08:42:54 +00003869requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003870run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003871 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003872 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003873 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003874 0 \
3875 -s "Read from client: 1 bytes read"
3876
3877run_test "Small packet TLS 1.2 BlockCipher" \
3878 "$P_SRV" \
3879 "$P_CLI request_size=1 force_version=tls1_2 \
3880 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3881 0 \
3882 -s "Read from client: 1 bytes read"
3883
Hanno Becker8501f982017-11-10 08:59:04 +00003884run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003885 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003886 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003887 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003888 0 \
3889 -s "Read from client: 1 bytes read"
3890
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003891run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3892 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003893 "$P_CLI request_size=1 force_version=tls1_2 \
3894 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003895 0 \
3896 -s "Read from client: 1 bytes read"
3897
Hanno Becker32c55012017-11-10 08:42:54 +00003898requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003899run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003900 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003901 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003902 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003903 0 \
3904 -s "Read from client: 1 bytes read"
3905
Hanno Becker8501f982017-11-10 08:59:04 +00003906requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3907run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003908 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003909 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003910 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003911 0 \
3912 -s "Read from client: 1 bytes read"
3913
3914run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003915 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003916 "$P_CLI request_size=1 force_version=tls1_2 \
3917 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3918 0 \
3919 -s "Read from client: 1 bytes read"
3920
Hanno Becker8501f982017-11-10 08:59:04 +00003921run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003922 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003923 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003924 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003925 0 \
3926 -s "Read from client: 1 bytes read"
3927
Hanno Becker32c55012017-11-10 08:42:54 +00003928requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003929run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003930 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003931 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003932 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003933 0 \
3934 -s "Read from client: 1 bytes read"
3935
Hanno Becker8501f982017-11-10 08:59:04 +00003936requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3937run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003938 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003939 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003940 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003941 0 \
3942 -s "Read from client: 1 bytes read"
3943
3944run_test "Small packet TLS 1.2 AEAD" \
3945 "$P_SRV" \
3946 "$P_CLI request_size=1 force_version=tls1_2 \
3947 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3948 0 \
3949 -s "Read from client: 1 bytes read"
3950
3951run_test "Small packet TLS 1.2 AEAD shorter tag" \
3952 "$P_SRV" \
3953 "$P_CLI request_size=1 force_version=tls1_2 \
3954 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3955 0 \
3956 -s "Read from client: 1 bytes read"
3957
Hanno Beckere2148042017-11-10 08:59:18 +00003958# Tests for small packets in DTLS
3959
3960requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3961run_test "Small packet DTLS 1.0" \
3962 "$P_SRV dtls=1 force_version=dtls1" \
3963 "$P_CLI dtls=1 request_size=1 \
3964 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3965 0 \
3966 -s "Read from client: 1 bytes read"
3967
3968requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3969run_test "Small packet DTLS 1.0, without EtM" \
3970 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3971 "$P_CLI dtls=1 request_size=1 \
3972 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3973 0 \
3974 -s "Read from client: 1 bytes read"
3975
3976requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3977requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3978run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003979 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3980 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00003981 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3982 0 \
3983 -s "Read from client: 1 bytes read"
3984
3985requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3986requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3987run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003988 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003989 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003990 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003991 0 \
3992 -s "Read from client: 1 bytes read"
3993
3994requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3995run_test "Small packet DTLS 1.2" \
3996 "$P_SRV dtls=1 force_version=dtls1_2" \
3997 "$P_CLI dtls=1 request_size=1 \
3998 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3999 0 \
4000 -s "Read from client: 1 bytes read"
4001
4002requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4003run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004004 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004005 "$P_CLI dtls=1 request_size=1 \
4006 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4007 0 \
4008 -s "Read from client: 1 bytes read"
4009
4010requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4011requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4012run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004013 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004014 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004015 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004016 0 \
4017 -s "Read from client: 1 bytes read"
4018
4019requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4020requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4021run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004022 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004023 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004024 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004025 0 \
4026 -s "Read from client: 1 bytes read"
4027
Janos Follath00efff72016-05-06 13:48:23 +01004028# A test for extensions in SSLv3
4029
4030requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4031run_test "SSLv3 with extensions, server side" \
4032 "$P_SRV min_version=ssl3 debug_level=3" \
4033 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4034 0 \
4035 -S "dumping 'client hello extensions'" \
4036 -S "server hello, total extension length:"
4037
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004038# Test for large packets
4039
Angus Grattonc4dd0732018-04-11 16:28:39 +10004040# How many fragments do we expect to write $1 bytes?
4041fragments_for_write() {
4042 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4043}
4044
Janos Follathe2681a42016-03-07 15:57:05 +00004045requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004046run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004047 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004048 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004049 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4050 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004051 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4052 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004053
Janos Follathe2681a42016-03-07 15:57:05 +00004054requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004055run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004056 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004057 "$P_CLI request_size=16384 force_version=ssl3 \
4058 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4059 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004060 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4061 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004062
4063run_test "Large packet TLS 1.0 BlockCipher" \
4064 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004065 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004066 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4067 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004068 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4069 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004070
Hanno Becker278fc7a2017-11-10 09:16:28 +00004071run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004072 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004073 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4074 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4075 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004076 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004077
Hanno Becker32c55012017-11-10 08:42:54 +00004078requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004079run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004080 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004081 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004082 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004083 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004084 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4085 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004086
Hanno Becker32c55012017-11-10 08:42:54 +00004087requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004088run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004089 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004090 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004091 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004092 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004093 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004094
4095run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004096 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004097 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004098 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4099 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004100 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004101
4102run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
4103 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4104 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004105 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004106 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004107 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004108
4109requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4110run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004111 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004112 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004113 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004114 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004115 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004116
Hanno Becker278fc7a2017-11-10 09:16:28 +00004117requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4118run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004119 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004120 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004121 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004122 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004123 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4124 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004125
4126run_test "Large packet TLS 1.1 BlockCipher" \
4127 "$P_SRV" \
4128 "$P_CLI request_size=16384 force_version=tls1_1 \
4129 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4130 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004131 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4132 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004133
Hanno Becker278fc7a2017-11-10 09:16:28 +00004134run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
4135 "$P_SRV" \
4136 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4137 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004138 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004139 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004140
Hanno Becker32c55012017-11-10 08:42:54 +00004141requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004142run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004143 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004144 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004145 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004146 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004147 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004148
Hanno Becker32c55012017-11-10 08:42:54 +00004149requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004150run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004151 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004152 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004153 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004154 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004155 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004156
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004157run_test "Large packet TLS 1.1 StreamCipher" \
4158 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4159 "$P_CLI request_size=16384 force_version=tls1_1 \
4160 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4161 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004162 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4163 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004164
Hanno Becker278fc7a2017-11-10 09:16:28 +00004165run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
4166 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004167 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004168 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004169 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004170 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4171 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004172
Hanno Becker278fc7a2017-11-10 09:16:28 +00004173requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4174run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004175 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004176 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004177 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004178 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004179 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004180
Hanno Becker278fc7a2017-11-10 09:16:28 +00004181requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4182run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004183 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004184 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004185 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004186 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004187 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4188 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004189
4190run_test "Large packet TLS 1.2 BlockCipher" \
4191 "$P_SRV" \
4192 "$P_CLI request_size=16384 force_version=tls1_2 \
4193 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4194 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004195 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4196 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004197
Hanno Becker278fc7a2017-11-10 09:16:28 +00004198run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
4199 "$P_SRV" \
4200 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4201 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4202 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004203 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004204
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004205run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
4206 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004207 "$P_CLI request_size=16384 force_version=tls1_2 \
4208 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004209 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004210 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4211 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004212
Hanno Becker32c55012017-11-10 08:42:54 +00004213requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004214run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004215 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004216 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004217 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004218 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004219 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004220
Hanno Becker278fc7a2017-11-10 09:16:28 +00004221requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4222run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004223 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004224 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004225 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004226 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004227 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4228 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004229
4230run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004231 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004232 "$P_CLI request_size=16384 force_version=tls1_2 \
4233 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4234 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004235 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4236 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004237
Hanno Becker278fc7a2017-11-10 09:16:28 +00004238run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004239 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004240 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004241 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4242 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004243 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004244
Hanno Becker32c55012017-11-10 08:42:54 +00004245requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004246run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004247 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004248 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004249 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004250 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004251 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004252
Hanno Becker278fc7a2017-11-10 09:16:28 +00004253requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4254run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004255 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004256 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004257 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004258 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004259 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4260 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004261
4262run_test "Large packet TLS 1.2 AEAD" \
4263 "$P_SRV" \
4264 "$P_CLI request_size=16384 force_version=tls1_2 \
4265 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4266 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004267 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4268 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004269
4270run_test "Large packet TLS 1.2 AEAD shorter tag" \
4271 "$P_SRV" \
4272 "$P_CLI request_size=16384 force_version=tls1_2 \
4273 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4274 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004275 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4276 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004277
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004278# Tests of asynchronous private key support in SSL
4279
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004280requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004281run_test "SSL async private: sign, delay=0" \
4282 "$P_SRV \
4283 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004284 "$P_CLI" \
4285 0 \
4286 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004287 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004288
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004289requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004290run_test "SSL async private: sign, delay=1" \
4291 "$P_SRV \
4292 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004293 "$P_CLI" \
4294 0 \
4295 -s "Async sign callback: using key slot " \
4296 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004297 -s "Async resume (slot [0-9]): sign done, status=0"
4298
Gilles Peskine12d0cc12018-04-26 15:06:56 +02004299requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4300run_test "SSL async private: sign, delay=2" \
4301 "$P_SRV \
4302 async_operations=s async_private_delay1=2 async_private_delay2=2" \
4303 "$P_CLI" \
4304 0 \
4305 -s "Async sign callback: using key slot " \
4306 -U "Async sign callback: using key slot " \
4307 -s "Async resume (slot [0-9]): call 1 more times." \
4308 -s "Async resume (slot [0-9]): call 0 more times." \
4309 -s "Async resume (slot [0-9]): sign done, status=0"
4310
Gilles Peskined3268832018-04-26 06:23:59 +02004311# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
4312# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
4313requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4314requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4315run_test "SSL async private: sign, RSA, TLS 1.1" \
4316 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
4317 async_operations=s async_private_delay1=0 async_private_delay2=0" \
4318 "$P_CLI force_version=tls1_1" \
4319 0 \
4320 -s "Async sign callback: using key slot " \
4321 -s "Async resume (slot [0-9]): sign done, status=0"
4322
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004323requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02004324run_test "SSL async private: sign, SNI" \
4325 "$P_SRV debug_level=3 \
4326 async_operations=s async_private_delay1=0 async_private_delay2=0 \
4327 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4328 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4329 "$P_CLI server_name=polarssl.example" \
4330 0 \
4331 -s "Async sign callback: using key slot " \
4332 -s "Async resume (slot [0-9]): sign done, status=0" \
4333 -s "parse ServerName extension" \
4334 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4335 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4336
4337requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004338run_test "SSL async private: decrypt, delay=0" \
4339 "$P_SRV \
4340 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4341 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4342 0 \
4343 -s "Async decrypt callback: using key slot " \
4344 -s "Async resume (slot [0-9]): decrypt done, status=0"
4345
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004346requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004347run_test "SSL async private: decrypt, delay=1" \
4348 "$P_SRV \
4349 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4350 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4351 0 \
4352 -s "Async decrypt callback: using key slot " \
4353 -s "Async resume (slot [0-9]): call 0 more times." \
4354 -s "Async resume (slot [0-9]): decrypt done, status=0"
4355
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004356requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004357run_test "SSL async private: decrypt RSA-PSK, delay=0" \
4358 "$P_SRV psk=abc123 \
4359 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4360 "$P_CLI psk=abc123 \
4361 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4362 0 \
4363 -s "Async decrypt callback: using key slot " \
4364 -s "Async resume (slot [0-9]): decrypt done, status=0"
4365
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004366requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004367run_test "SSL async private: decrypt RSA-PSK, delay=1" \
4368 "$P_SRV psk=abc123 \
4369 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4370 "$P_CLI psk=abc123 \
4371 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4372 0 \
4373 -s "Async decrypt callback: using key slot " \
4374 -s "Async resume (slot [0-9]): call 0 more times." \
4375 -s "Async resume (slot [0-9]): decrypt done, status=0"
4376
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004377requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004378run_test "SSL async private: sign callback not present" \
4379 "$P_SRV \
4380 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4381 "$P_CLI; [ \$? -eq 1 ] &&
4382 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4383 0 \
4384 -S "Async sign callback" \
4385 -s "! mbedtls_ssl_handshake returned" \
4386 -s "The own private key or pre-shared key is not set, but needed" \
4387 -s "Async resume (slot [0-9]): decrypt done, status=0" \
4388 -s "Successful connection"
4389
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004390requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004391run_test "SSL async private: decrypt callback not present" \
4392 "$P_SRV debug_level=1 \
4393 async_operations=s async_private_delay1=1 async_private_delay2=1" \
4394 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
4395 [ \$? -eq 1 ] && $P_CLI" \
4396 0 \
4397 -S "Async decrypt callback" \
4398 -s "! mbedtls_ssl_handshake returned" \
4399 -s "got no RSA private key" \
4400 -s "Async resume (slot [0-9]): sign done, status=0" \
4401 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004402
4403# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004404requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004405run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004406 "$P_SRV \
4407 async_operations=s async_private_delay1=1 \
4408 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4409 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004410 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4411 0 \
4412 -s "Async sign callback: using key slot 0," \
4413 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004414 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004415
4416# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004417requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004418run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004419 "$P_SRV \
4420 async_operations=s async_private_delay2=1 \
4421 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4422 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004423 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4424 0 \
4425 -s "Async sign callback: using key slot 0," \
4426 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004427 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004428
4429# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004430requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02004431run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004432 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02004433 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004434 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4435 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004436 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4437 0 \
4438 -s "Async sign callback: using key slot 1," \
4439 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004440 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004441
4442# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004443requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004444run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004445 "$P_SRV \
4446 async_operations=s async_private_delay1=1 \
4447 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4448 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004449 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4450 0 \
4451 -s "Async sign callback: no key matches this certificate."
4452
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004453requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004454run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004455 "$P_SRV \
4456 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4457 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004458 "$P_CLI" \
4459 1 \
4460 -s "Async sign callback: injected error" \
4461 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004462 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004463 -s "! mbedtls_ssl_handshake returned"
4464
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004465requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004466run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004467 "$P_SRV \
4468 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4469 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004470 "$P_CLI" \
4471 1 \
4472 -s "Async sign callback: using key slot " \
4473 -S "Async resume" \
4474 -s "Async cancel"
4475
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004476requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004477run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004478 "$P_SRV \
4479 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4480 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004481 "$P_CLI" \
4482 1 \
4483 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004484 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004485 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004486 -s "! mbedtls_ssl_handshake returned"
4487
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004488requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004489run_test "SSL async private: decrypt, error in start" \
4490 "$P_SRV \
4491 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4492 async_private_error=1" \
4493 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4494 1 \
4495 -s "Async decrypt callback: injected error" \
4496 -S "Async resume" \
4497 -S "Async cancel" \
4498 -s "! mbedtls_ssl_handshake returned"
4499
4500requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4501run_test "SSL async private: decrypt, cancel after start" \
4502 "$P_SRV \
4503 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4504 async_private_error=2" \
4505 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4506 1 \
4507 -s "Async decrypt callback: using key slot " \
4508 -S "Async resume" \
4509 -s "Async cancel"
4510
4511requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4512run_test "SSL async private: decrypt, error in resume" \
4513 "$P_SRV \
4514 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4515 async_private_error=3" \
4516 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4517 1 \
4518 -s "Async decrypt callback: using key slot " \
4519 -s "Async resume callback: decrypt done but injected error" \
4520 -S "Async cancel" \
4521 -s "! mbedtls_ssl_handshake returned"
4522
4523requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004524run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004525 "$P_SRV \
4526 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4527 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004528 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4529 0 \
4530 -s "Async cancel" \
4531 -s "! mbedtls_ssl_handshake returned" \
4532 -s "Async resume" \
4533 -s "Successful connection"
4534
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004535requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004536run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004537 "$P_SRV \
4538 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4539 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004540 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4541 0 \
4542 -s "! mbedtls_ssl_handshake returned" \
4543 -s "Async resume" \
4544 -s "Successful connection"
4545
4546# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004547requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004548run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004549 "$P_SRV \
4550 async_operations=s async_private_delay1=1 async_private_error=-2 \
4551 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4552 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004553 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
4554 [ \$? -eq 1 ] &&
4555 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4556 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02004557 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004558 -S "Async resume" \
4559 -s "Async cancel" \
4560 -s "! mbedtls_ssl_handshake returned" \
4561 -s "Async sign callback: no key matches this certificate." \
4562 -s "Successful connection"
4563
4564# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004565requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02004566run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004567 "$P_SRV \
4568 async_operations=s async_private_delay1=1 async_private_error=-3 \
4569 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4570 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004571 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
4572 [ \$? -eq 1 ] &&
4573 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4574 0 \
4575 -s "Async resume" \
4576 -s "! mbedtls_ssl_handshake returned" \
4577 -s "Async sign callback: no key matches this certificate." \
4578 -s "Successful connection"
4579
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004580requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004581requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004582run_test "SSL async private: renegotiation: client-initiated; sign" \
4583 "$P_SRV \
4584 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004585 exchanges=2 renegotiation=1" \
4586 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
4587 0 \
4588 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004589 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004590
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004591requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004592requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004593run_test "SSL async private: renegotiation: server-initiated; sign" \
4594 "$P_SRV \
4595 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004596 exchanges=2 renegotiation=1 renegotiate=1" \
4597 "$P_CLI exchanges=2 renegotiation=1" \
4598 0 \
4599 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004600 -s "Async resume (slot [0-9]): sign done, status=0"
4601
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004602requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004603requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
4604run_test "SSL async private: renegotiation: client-initiated; decrypt" \
4605 "$P_SRV \
4606 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4607 exchanges=2 renegotiation=1" \
4608 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
4609 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4610 0 \
4611 -s "Async decrypt callback: using key slot " \
4612 -s "Async resume (slot [0-9]): decrypt done, status=0"
4613
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004614requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004615requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
4616run_test "SSL async private: renegotiation: server-initiated; decrypt" \
4617 "$P_SRV \
4618 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4619 exchanges=2 renegotiation=1 renegotiate=1" \
4620 "$P_CLI exchanges=2 renegotiation=1 \
4621 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4622 0 \
4623 -s "Async decrypt callback: using key slot " \
4624 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004625
Ron Eldor58093c82018-06-28 13:22:05 +03004626# Tests for ECC extensions (rfc 4492)
4627
Ron Eldor643df7c2018-06-28 16:17:00 +03004628requires_config_enabled MBEDTLS_AES_C
4629requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4630requires_config_enabled MBEDTLS_SHA256_C
4631requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03004632run_test "Force a non ECC ciphersuite in the client side" \
4633 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03004634 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03004635 0 \
4636 -C "client hello, adding supported_elliptic_curves extension" \
4637 -C "client hello, adding supported_point_formats extension" \
4638 -S "found supported elliptic curves extension" \
4639 -S "found supported point formats extension"
4640
Ron Eldor643df7c2018-06-28 16:17:00 +03004641requires_config_enabled MBEDTLS_AES_C
4642requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4643requires_config_enabled MBEDTLS_SHA256_C
4644requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03004645run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03004646 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03004647 "$P_CLI debug_level=3" \
4648 0 \
4649 -C "found supported_point_formats extension" \
4650 -S "server hello, supported_point_formats extension"
4651
Ron Eldor643df7c2018-06-28 16:17:00 +03004652requires_config_enabled MBEDTLS_AES_C
4653requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4654requires_config_enabled MBEDTLS_SHA256_C
4655requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03004656run_test "Force an ECC ciphersuite in the client side" \
4657 "$P_SRV debug_level=3" \
4658 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4659 0 \
4660 -c "client hello, adding supported_elliptic_curves extension" \
4661 -c "client hello, adding supported_point_formats extension" \
4662 -s "found supported elliptic curves extension" \
4663 -s "found supported point formats extension"
4664
Ron Eldor643df7c2018-06-28 16:17:00 +03004665requires_config_enabled MBEDTLS_AES_C
4666requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4667requires_config_enabled MBEDTLS_SHA256_C
4668requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03004669run_test "Force an ECC ciphersuite in the server side" \
4670 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4671 "$P_CLI debug_level=3" \
4672 0 \
4673 -c "found supported_point_formats extension" \
4674 -s "server hello, supported_point_formats extension"
4675
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004676# Tests for DTLS HelloVerifyRequest
4677
4678run_test "DTLS cookie: enabled" \
4679 "$P_SRV dtls=1 debug_level=2" \
4680 "$P_CLI dtls=1 debug_level=2" \
4681 0 \
4682 -s "cookie verification failed" \
4683 -s "cookie verification passed" \
4684 -S "cookie verification skipped" \
4685 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004686 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004687 -S "SSL - The requested feature is not available"
4688
4689run_test "DTLS cookie: disabled" \
4690 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4691 "$P_CLI dtls=1 debug_level=2" \
4692 0 \
4693 -S "cookie verification failed" \
4694 -S "cookie verification passed" \
4695 -s "cookie verification skipped" \
4696 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004697 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004698 -S "SSL - The requested feature is not available"
4699
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004700run_test "DTLS cookie: default (failing)" \
4701 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4702 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4703 1 \
4704 -s "cookie verification failed" \
4705 -S "cookie verification passed" \
4706 -S "cookie verification skipped" \
4707 -C "received hello verify request" \
4708 -S "hello verification requested" \
4709 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004710
4711requires_ipv6
4712run_test "DTLS cookie: enabled, IPv6" \
4713 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4714 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4715 0 \
4716 -s "cookie verification failed" \
4717 -s "cookie verification passed" \
4718 -S "cookie verification skipped" \
4719 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004720 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004721 -S "SSL - The requested feature is not available"
4722
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004723run_test "DTLS cookie: enabled, nbio" \
4724 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4725 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4726 0 \
4727 -s "cookie verification failed" \
4728 -s "cookie verification passed" \
4729 -S "cookie verification skipped" \
4730 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004731 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004732 -S "SSL - The requested feature is not available"
4733
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004734# Tests for client reconnecting from the same port with DTLS
4735
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004736not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004737run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004738 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4739 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004740 0 \
4741 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004742 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004743 -S "Client initiated reconnection from same port"
4744
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004745not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004746run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004747 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4748 "$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 +02004749 0 \
4750 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004751 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004752 -s "Client initiated reconnection from same port"
4753
Paul Bakker362689d2016-05-13 10:33:25 +01004754not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4755run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004756 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4757 "$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 +02004758 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004759 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004760 -s "Client initiated reconnection from same port"
4761
Paul Bakker362689d2016-05-13 10:33:25 +01004762only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4763run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4764 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4765 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4766 0 \
4767 -S "The operation timed out" \
4768 -s "Client initiated reconnection from same port"
4769
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004770run_test "DTLS client reconnect from same port: no cookies" \
4771 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02004772 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
4773 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004774 -s "The operation timed out" \
4775 -S "Client initiated reconnection from same port"
4776
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004777# Tests for various cases of client authentication with DTLS
4778# (focused on handshake flows and message parsing)
4779
4780run_test "DTLS client auth: required" \
4781 "$P_SRV dtls=1 auth_mode=required" \
4782 "$P_CLI dtls=1" \
4783 0 \
4784 -s "Verifying peer X.509 certificate... ok"
4785
4786run_test "DTLS client auth: optional, client has no cert" \
4787 "$P_SRV dtls=1 auth_mode=optional" \
4788 "$P_CLI dtls=1 crt_file=none key_file=none" \
4789 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004790 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004791
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004792run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004793 "$P_SRV dtls=1 auth_mode=none" \
4794 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
4795 0 \
4796 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004797 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004798
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02004799run_test "DTLS wrong PSK: badmac alert" \
4800 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
4801 "$P_CLI dtls=1 psk=abc124" \
4802 1 \
4803 -s "SSL - Verification of the message MAC failed" \
4804 -c "SSL - A fatal alert message was received from our peer"
4805
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02004806# Tests for receiving fragmented handshake messages with DTLS
4807
4808requires_gnutls
4809run_test "DTLS reassembly: no fragmentation (gnutls server)" \
4810 "$G_SRV -u --mtu 2048 -a" \
4811 "$P_CLI dtls=1 debug_level=2" \
4812 0 \
4813 -C "found fragmented DTLS handshake message" \
4814 -C "error"
4815
4816requires_gnutls
4817run_test "DTLS reassembly: some fragmentation (gnutls server)" \
4818 "$G_SRV -u --mtu 512" \
4819 "$P_CLI dtls=1 debug_level=2" \
4820 0 \
4821 -c "found fragmented DTLS handshake message" \
4822 -C "error"
4823
4824requires_gnutls
4825run_test "DTLS reassembly: more fragmentation (gnutls server)" \
4826 "$G_SRV -u --mtu 128" \
4827 "$P_CLI dtls=1 debug_level=2" \
4828 0 \
4829 -c "found fragmented DTLS handshake message" \
4830 -C "error"
4831
4832requires_gnutls
4833run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
4834 "$G_SRV -u --mtu 128" \
4835 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4836 0 \
4837 -c "found fragmented DTLS handshake message" \
4838 -C "error"
4839
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004840requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004841requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004842run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
4843 "$G_SRV -u --mtu 256" \
4844 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4845 0 \
4846 -c "found fragmented DTLS handshake message" \
4847 -c "client hello, adding renegotiation extension" \
4848 -c "found renegotiation extension" \
4849 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004850 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004851 -C "error" \
4852 -s "Extra-header:"
4853
4854requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004855requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004856run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4857 "$G_SRV -u --mtu 256" \
4858 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4859 0 \
4860 -c "found fragmented DTLS handshake message" \
4861 -c "client hello, adding renegotiation extension" \
4862 -c "found renegotiation extension" \
4863 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004864 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004865 -C "error" \
4866 -s "Extra-header:"
4867
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004868run_test "DTLS reassembly: no fragmentation (openssl server)" \
4869 "$O_SRV -dtls1 -mtu 2048" \
4870 "$P_CLI dtls=1 debug_level=2" \
4871 0 \
4872 -C "found fragmented DTLS handshake message" \
4873 -C "error"
4874
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004875run_test "DTLS reassembly: some fragmentation (openssl server)" \
4876 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004877 "$P_CLI dtls=1 debug_level=2" \
4878 0 \
4879 -c "found fragmented DTLS handshake message" \
4880 -C "error"
4881
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004882run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004883 "$O_SRV -dtls1 -mtu 256" \
4884 "$P_CLI dtls=1 debug_level=2" \
4885 0 \
4886 -c "found fragmented DTLS handshake message" \
4887 -C "error"
4888
4889run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4890 "$O_SRV -dtls1 -mtu 256" \
4891 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4892 0 \
4893 -c "found fragmented DTLS handshake message" \
4894 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004895
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004896# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004897
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004898not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004899run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004900 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004901 "$P_SRV dtls=1 debug_level=2" \
4902 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004903 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004904 -C "replayed record" \
4905 -S "replayed record" \
4906 -C "record from another epoch" \
4907 -S "record from another epoch" \
4908 -C "discarding invalid record" \
4909 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004910 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004911 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004912 -c "HTTP/1.0 200 OK"
4913
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004914not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004915run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004916 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004917 "$P_SRV dtls=1 debug_level=2" \
4918 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004919 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004920 -c "replayed record" \
4921 -s "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01004922 -c "record from another epoch" \
4923 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004924 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004925 -s "Extra-header:" \
4926 -c "HTTP/1.0 200 OK"
4927
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004928run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4929 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004930 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4931 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004932 0 \
4933 -c "replayed record" \
4934 -S "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01004935 -c "record from another epoch" \
4936 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004937 -c "resend" \
4938 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004939 -s "Extra-header:" \
4940 -c "HTTP/1.0 200 OK"
4941
Hanno Becker72a4f032017-11-15 16:39:20 +00004942run_test "DTLS proxy: multiple records in same datagram" \
Hanno Becker8d832182018-03-15 10:14:19 +00004943 -p "$P_PXY pack=50" \
Hanno Becker72a4f032017-11-15 16:39:20 +00004944 "$P_SRV dtls=1 debug_level=2" \
4945 "$P_CLI dtls=1 debug_level=2" \
4946 0 \
4947 -c "next record in same datagram" \
4948 -s "next record in same datagram"
4949
4950run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
Hanno Becker8d832182018-03-15 10:14:19 +00004951 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker72a4f032017-11-15 16:39:20 +00004952 "$P_SRV dtls=1 debug_level=2" \
4953 "$P_CLI dtls=1 debug_level=2" \
4954 0 \
4955 -c "next record in same datagram" \
4956 -s "next record in same datagram"
4957
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004958run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004959 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004960 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004961 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004962 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004963 -c "discarding invalid record (mac)" \
4964 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004965 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004966 -c "HTTP/1.0 200 OK" \
4967 -S "too many records with bad MAC" \
4968 -S "Verification of the message MAC failed"
4969
4970run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4971 -p "$P_PXY bad_ad=1" \
4972 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4973 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4974 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004975 -C "discarding invalid record (mac)" \
4976 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004977 -S "Extra-header:" \
4978 -C "HTTP/1.0 200 OK" \
4979 -s "too many records with bad MAC" \
4980 -s "Verification of the message MAC failed"
4981
4982run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4983 -p "$P_PXY bad_ad=1" \
4984 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4985 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4986 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004987 -c "discarding invalid record (mac)" \
4988 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004989 -s "Extra-header:" \
4990 -c "HTTP/1.0 200 OK" \
4991 -S "too many records with bad MAC" \
4992 -S "Verification of the message MAC failed"
4993
4994run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4995 -p "$P_PXY bad_ad=1" \
4996 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4997 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4998 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004999 -c "discarding invalid record (mac)" \
5000 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005001 -s "Extra-header:" \
5002 -c "HTTP/1.0 200 OK" \
5003 -s "too many records with bad MAC" \
5004 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005005
5006run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005007 -p "$P_PXY delay_ccs=1" \
5008 "$P_SRV dtls=1 debug_level=1" \
5009 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005010 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005011 -c "record from another epoch" \
5012 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005013 -s "Extra-header:" \
5014 -c "HTTP/1.0 200 OK"
5015
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005016# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005017
Janos Follath74537a62016-09-02 13:45:28 +01005018client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005019run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005020 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005021 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5022 psk=abc123" \
5023 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005024 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5025 0 \
5026 -s "Extra-header:" \
5027 -c "HTTP/1.0 200 OK"
5028
Janos Follath74537a62016-09-02 13:45:28 +01005029client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005030run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
5031 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005032 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
5033 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005034 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5035 0 \
5036 -s "Extra-header:" \
5037 -c "HTTP/1.0 200 OK"
5038
Janos Follath74537a62016-09-02 13:45:28 +01005039client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005040run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
5041 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005042 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
5043 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005044 0 \
5045 -s "Extra-header:" \
5046 -c "HTTP/1.0 200 OK"
5047
Janos Follath74537a62016-09-02 13:45:28 +01005048client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005049run_test "DTLS proxy: 3d, FS, client auth" \
5050 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005051 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
5052 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005053 0 \
5054 -s "Extra-header:" \
5055 -c "HTTP/1.0 200 OK"
5056
Janos Follath74537a62016-09-02 13:45:28 +01005057client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005058run_test "DTLS proxy: 3d, FS, ticket" \
5059 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005060 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
5061 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005062 0 \
5063 -s "Extra-header:" \
5064 -c "HTTP/1.0 200 OK"
5065
Janos Follath74537a62016-09-02 13:45:28 +01005066client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005067run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
5068 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005069 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
5070 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005071 0 \
5072 -s "Extra-header:" \
5073 -c "HTTP/1.0 200 OK"
5074
Janos Follath74537a62016-09-02 13:45:28 +01005075client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005076run_test "DTLS proxy: 3d, max handshake, nbio" \
5077 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005078 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
5079 auth_mode=required" \
5080 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005081 0 \
5082 -s "Extra-header:" \
5083 -c "HTTP/1.0 200 OK"
5084
Janos Follath74537a62016-09-02 13:45:28 +01005085client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005086run_test "DTLS proxy: 3d, min handshake, resumption" \
5087 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5088 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5089 psk=abc123 debug_level=3" \
5090 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5091 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5092 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5093 0 \
5094 -s "a session has been resumed" \
5095 -c "a session has been resumed" \
5096 -s "Extra-header:" \
5097 -c "HTTP/1.0 200 OK"
5098
Janos Follath74537a62016-09-02 13:45:28 +01005099client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005100run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
5101 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5102 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5103 psk=abc123 debug_level=3 nbio=2" \
5104 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5105 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
5106 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
5107 0 \
5108 -s "a session has been resumed" \
5109 -c "a session has been resumed" \
5110 -s "Extra-header:" \
5111 -c "HTTP/1.0 200 OK"
5112
Janos Follath74537a62016-09-02 13:45:28 +01005113client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005114requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005115run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005116 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005117 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5118 psk=abc123 renegotiation=1 debug_level=2" \
5119 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5120 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005121 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5122 0 \
5123 -c "=> renegotiate" \
5124 -s "=> renegotiate" \
5125 -s "Extra-header:" \
5126 -c "HTTP/1.0 200 OK"
5127
Janos Follath74537a62016-09-02 13:45:28 +01005128client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005129requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005130run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
5131 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005132 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
5133 psk=abc123 renegotiation=1 debug_level=2" \
5134 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
5135 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005136 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5137 0 \
5138 -c "=> renegotiate" \
5139 -s "=> renegotiate" \
5140 -s "Extra-header:" \
5141 -c "HTTP/1.0 200 OK"
5142
Janos Follath74537a62016-09-02 13:45:28 +01005143client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005144requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005145run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005146 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005147 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005148 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005149 debug_level=2" \
5150 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005151 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005152 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5153 0 \
5154 -c "=> renegotiate" \
5155 -s "=> renegotiate" \
5156 -s "Extra-header:" \
5157 -c "HTTP/1.0 200 OK"
5158
Janos Follath74537a62016-09-02 13:45:28 +01005159client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005160requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005161run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005162 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005163 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005164 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005165 debug_level=2 nbio=2" \
5166 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005167 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005168 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5169 0 \
5170 -c "=> renegotiate" \
5171 -s "=> renegotiate" \
5172 -s "Extra-header:" \
5173 -c "HTTP/1.0 200 OK"
5174
Janos Follath74537a62016-09-02 13:45:28 +01005175client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005176not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005177run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005178 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5179 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005180 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005181 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005182 -c "HTTP/1.0 200 OK"
5183
Janos Follath74537a62016-09-02 13:45:28 +01005184client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005185not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005186run_test "DTLS proxy: 3d, openssl server, fragmentation" \
5187 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5188 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005189 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005190 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005191 -c "HTTP/1.0 200 OK"
5192
Janos Follath74537a62016-09-02 13:45:28 +01005193client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005194not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005195run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
5196 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5197 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00005198 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005199 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005200 -c "HTTP/1.0 200 OK"
5201
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005202requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005203client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005204not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005205run_test "DTLS proxy: 3d, gnutls server" \
5206 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5207 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005208 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005209 0 \
5210 -s "Extra-header:" \
5211 -c "Extra-header:"
5212
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005213requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005214client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005215not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005216run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
5217 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5218 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005219 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005220 0 \
5221 -s "Extra-header:" \
5222 -c "Extra-header:"
5223
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005224requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005225client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005226not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005227run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
5228 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5229 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02005230 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005231 0 \
5232 -s "Extra-header:" \
5233 -c "Extra-header:"
5234
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01005235# Final report
5236
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005237echo "------------------------------------------------------------------------"
5238
5239if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005240 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005241else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005242 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005243fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02005244PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02005245echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005246
5247exit $FAILS