blob: cf2c168755bf696760f7246289227720c33fe653 [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
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020031: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020033O_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 +010034O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020035G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010036G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020037TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010038
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010039TESTS=0
40FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020041SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010042
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020044
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020047EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048
Paul Bakkere20310a2016-05-10 11:18:17 +010049SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010050RUN_TEST_NUMBER=''
51
Paul Bakkeracaac852016-05-10 11:47:13 +010052PRESERVE_LOGS=0
53
Gilles Peskinef93c7d32017-04-14 17:55:28 +020054# Pick a "unique" server port in the range 10000-19999, and a proxy
55# port which is this plus 10000. Each port number may be independently
56# overridden by a command line option.
57SRV_PORT=$(($$ % 10000 + 10000))
58PXY_PORT=$((SRV_PORT + 10000))
59
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010060print_usage() {
61 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010062 printf " -h|--help\tPrint this help.\n"
63 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020064 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
65 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010066 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010067 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010068 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
70 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010071 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072}
73
74get_options() {
75 while [ $# -gt 0 ]; do
76 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077 -f|--filter)
78 shift; FILTER=$1
79 ;;
80 -e|--exclude)
81 shift; EXCLUDE=$1
82 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010083 -m|--memcheck)
84 MEMCHECK=1
85 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010086 -n|--number)
87 shift; RUN_TEST_NUMBER=$1
88 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010089 -s|--show-numbers)
90 SHOW_TEST_NUMBER=1
91 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010092 -p|--preserve-logs)
93 PRESERVE_LOGS=1
94 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 --port)
96 shift; SRV_PORT=$1
97 ;;
98 --proxy-port)
99 shift; PXY_PORT=$1
100 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100101 --seed)
102 shift; SEED="$1"
103 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104 -h|--help)
105 print_usage
106 exit 0
107 ;;
108 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200109 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 print_usage
111 exit 1
112 ;;
113 esac
114 shift
115 done
116}
117
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100118# skip next test if the flag is not enabled in config.h
119requires_config_enabled() {
120 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
121 SKIP_NEXT="YES"
122 fi
123}
124
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200125# skip next test if the flag is enabled in config.h
126requires_config_disabled() {
127 if grep "^#define $1" $CONFIG_H > /dev/null; then
128 SKIP_NEXT="YES"
129 fi
130}
131
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200132# skip next test if OpenSSL doesn't support FALLBACK_SCSV
133requires_openssl_with_fallback_scsv() {
134 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
135 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
136 then
137 OPENSSL_HAS_FBSCSV="YES"
138 else
139 OPENSSL_HAS_FBSCSV="NO"
140 fi
141 fi
142 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
143 SKIP_NEXT="YES"
144 fi
145}
146
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200147# skip next test if GnuTLS isn't available
148requires_gnutls() {
149 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200150 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151 GNUTLS_AVAILABLE="YES"
152 else
153 GNUTLS_AVAILABLE="NO"
154 fi
155 fi
156 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200161# skip next test if IPv6 isn't available on this host
162requires_ipv6() {
163 if [ -z "${HAS_IPV6:-}" ]; then
164 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
165 SRV_PID=$!
166 sleep 1
167 kill $SRV_PID >/dev/null 2>&1
168 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
169 HAS_IPV6="NO"
170 else
171 HAS_IPV6="YES"
172 fi
173 rm -r $SRV_OUT
174 fi
175
176 if [ "$HAS_IPV6" = "NO" ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200181# skip the next test if valgrind is in use
182not_with_valgrind() {
183 if [ "$MEMCHECK" -gt 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Paul Bakker362689d2016-05-13 10:33:25 +0100188# skip the next test if valgrind is NOT in use
189only_with_valgrind() {
190 if [ "$MEMCHECK" -eq 0 ]; then
191 SKIP_NEXT="YES"
192 fi
193}
194
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200195# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100196client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200197 CLI_DELAY_FACTOR=$1
198}
199
Janos Follath74537a62016-09-02 13:45:28 +0100200# wait for the given seconds after the client finished in the next test
201server_needs_more_time() {
202 SRV_DELAY_SECONDS=$1
203}
204
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100205# print_name <name>
206print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100207 TESTS=$(( $TESTS + 1 ))
208 LINE=""
209
210 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
211 LINE="$TESTS "
212 fi
213
214 LINE="$LINE$1"
215 printf "$LINE "
216 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100217 for i in `seq 1 $LEN`; do printf '.'; done
218 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100220}
221
222# fail <message>
223fail() {
224 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100225 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200227 mv $SRV_OUT o-srv-${TESTS}.log
228 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200229 if [ -n "$PXY_CMD" ]; then
230 mv $PXY_OUT o-pxy-${TESTS}.log
231 fi
232 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100233
Azim Khan19d13732018-03-29 11:04:20 +0100234 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 +0200235 echo " ! server output:"
236 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200237 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200238 echo " ! client output:"
239 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200240 if [ -n "$PXY_CMD" ]; then
241 echo " ! ========================================================"
242 echo " ! proxy output:"
243 cat o-pxy-${TESTS}.log
244 fi
245 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200246 fi
247
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200248 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249}
250
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100251# is_polar <cmd_line>
252is_polar() {
253 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
254}
255
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200256# openssl s_server doesn't have -www with DTLS
257check_osrv_dtls() {
258 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
259 NEEDS_INPUT=1
260 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
261 else
262 NEEDS_INPUT=0
263 fi
264}
265
266# provide input to commands that need it
267provide_input() {
268 if [ $NEEDS_INPUT -eq 0 ]; then
269 return
270 fi
271
272 while true; do
273 echo "HTTP/1.0 200 OK"
274 sleep 1
275 done
276}
277
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100278# has_mem_err <log_file_name>
279has_mem_err() {
280 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
281 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
282 then
283 return 1 # false: does not have errors
284 else
285 return 0 # true: has errors
286 fi
287}
288
Gilles Peskine418b5362017-12-14 18:58:42 +0100289# Wait for process $2 to be listening on port $1
290if type lsof >/dev/null 2>/dev/null; then
291 wait_server_start() {
292 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200293 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100294 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200295 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100296 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200297 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100298 # Make a tight loop, server normally takes less than 1s to start.
299 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
300 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
301 echo "SERVERSTART TIMEOUT"
302 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
303 break
304 fi
305 # Linux and *BSD support decimal arguments to sleep. On other
306 # OSes this may be a tight loop.
307 sleep 0.1 2>/dev/null || true
308 done
309 }
310else
Gilles Peskine3c9e2b52018-01-08 12:38:15 +0100311 echo "Warning: lsof not available, wait_server_start = sleep $START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100312 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200313 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100314 }
315fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200316
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100317# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100318# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100319# acceptable bounds
320check_server_hello_time() {
321 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100322 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100323 # Get the Unix timestamp for now
324 CUR_TIME=$(date +'%s')
325 THRESHOLD_IN_SECS=300
326
327 # Check if the ServerHello time was printed
328 if [ -z "$SERVER_HELLO_TIME" ]; then
329 return 1
330 fi
331
332 # Check the time in ServerHello is within acceptable bounds
333 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
334 # The time in ServerHello is at least 5 minutes before now
335 return 1
336 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100337 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100338 return 1
339 else
340 return 0
341 fi
342}
343
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200344# wait for client to terminate and set CLI_EXIT
345# must be called right after starting the client
346wait_client_done() {
347 CLI_PID=$!
348
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200349 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
350 CLI_DELAY_FACTOR=1
351
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200352 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200353 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200354
355 wait $CLI_PID
356 CLI_EXIT=$?
357
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200358 kill $DOG_PID >/dev/null 2>&1
359 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200360
361 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100362
363 sleep $SRV_DELAY_SECONDS
364 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200365}
366
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200367# check if the given command uses dtls and sets global variable DTLS
368detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200369 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200370 DTLS=1
371 else
372 DTLS=0
373 fi
374}
375
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200376# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100377# Options: -s pattern pattern that must be present in server output
378# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100379# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100380# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100381# -S pattern pattern that must be absent in server output
382# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100383# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100384# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100385run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100386 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200387 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100388
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100389 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
390 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200391 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100392 return
393 fi
394
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100396
Paul Bakkerb7584a52016-05-10 10:50:43 +0100397 # Do we only run numbered tests?
398 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
399 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
400 else
401 SKIP_NEXT="YES"
402 fi
403
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200404 # should we skip?
405 if [ "X$SKIP_NEXT" = "XYES" ]; then
406 SKIP_NEXT="NO"
407 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200408 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200409 return
410 fi
411
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200412 # does this test use a proxy?
413 if [ "X$1" = "X-p" ]; then
414 PXY_CMD="$2"
415 shift 2
416 else
417 PXY_CMD=""
418 fi
419
420 # get commands and client output
421 SRV_CMD="$1"
422 CLI_CMD="$2"
423 CLI_EXPECT="$3"
424 shift 3
425
426 # fix client port
427 if [ -n "$PXY_CMD" ]; then
428 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
429 else
430 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
431 fi
432
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200433 # update DTLS variable
434 detect_dtls "$SRV_CMD"
435
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100436 # prepend valgrind to our commands if active
437 if [ "$MEMCHECK" -gt 0 ]; then
438 if is_polar "$SRV_CMD"; then
439 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
440 fi
441 if is_polar "$CLI_CMD"; then
442 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
443 fi
444 fi
445
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200446 TIMES_LEFT=2
447 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200448 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200449
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200450 # run the commands
451 if [ -n "$PXY_CMD" ]; then
452 echo "$PXY_CMD" > $PXY_OUT
453 $PXY_CMD >> $PXY_OUT 2>&1 &
454 PXY_PID=$!
455 # assume proxy starts faster than server
456 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200457
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200458 check_osrv_dtls
459 echo "$SRV_CMD" > $SRV_OUT
460 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
461 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100462 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200463
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200464 echo "$CLI_CMD" > $CLI_OUT
465 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
466 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100467
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100468 sleep 0.05
469
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200470 # terminate the server (and the proxy)
471 kill $SRV_PID
472 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100473
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200474 if [ -n "$PXY_CMD" ]; then
475 kill $PXY_PID >/dev/null 2>&1
476 wait $PXY_PID
477 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100478
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200479 # retry only on timeouts
480 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
481 printf "RETRY "
482 else
483 TIMES_LEFT=0
484 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200485 done
486
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100487 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200488 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100489 # expected client exit to incorrectly succeed in case of catastrophic
490 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100491 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200492 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100493 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100494 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100495 return
496 fi
497 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100498 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200499 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100500 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100501 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100502 return
503 fi
504 fi
505
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100506 # check server exit code
507 if [ $? != 0 ]; then
508 fail "server fail"
509 return
510 fi
511
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100512 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100513 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
514 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100515 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200516 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100517 return
518 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100519
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100520 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200521 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100522 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100523 while [ $# -gt 0 ]
524 do
525 case $1 in
526 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100527 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 +0100528 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100529 return
530 fi
531 ;;
532
533 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100534 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 +0100535 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100536 return
537 fi
538 ;;
539
540 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100541 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 +0100542 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100543 return
544 fi
545 ;;
546
547 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100548 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 +0100549 fail "pattern '$2' MUST NOT be present in the Client output"
550 return
551 fi
552 ;;
553
554 # The filtering in the following two options (-u and -U) do the following
555 # - ignore valgrind output
556 # - filter out everything but lines right after the pattern occurances
557 # - keep one of each non-unique line
558 # - count how many lines remain
559 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
560 # if there were no duplicates.
561 "-U")
562 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
563 fail "lines following pattern '$2' must be unique in Server output"
564 return
565 fi
566 ;;
567
568 "-u")
569 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
570 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100571 return
572 fi
573 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100574 "-F")
575 if ! $2 "$SRV_OUT"; then
576 fail "function call to '$2' failed on Server output"
577 return
578 fi
579 ;;
580 "-f")
581 if ! $2 "$CLI_OUT"; then
582 fail "function call to '$2' failed on Client output"
583 return
584 fi
585 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100586
587 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200588 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100589 exit 1
590 esac
591 shift 2
592 done
593
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100594 # check valgrind's results
595 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200596 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100597 fail "Server has memory errors"
598 return
599 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200600 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100601 fail "Client has memory errors"
602 return
603 fi
604 fi
605
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100606 # if we're here, everything is ok
607 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100608 if [ "$PRESERVE_LOGS" -gt 0 ]; then
609 mv $SRV_OUT o-srv-${TESTS}.log
610 mv $CLI_OUT o-cli-${TESTS}.log
611 fi
612
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200613 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100614}
615
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100616cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200617 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200618 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
619 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
620 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
621 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100622 exit 1
623}
624
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100625#
626# MAIN
627#
628
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000629if cd $( dirname $0 ); then :; else
630 echo "cd $( dirname $0 ) failed" >&2
631 exit 1
632fi
633
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100634get_options "$@"
635
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100636# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100637P_SRV_BIN="${P_SRV%%[ ]*}"
638P_CLI_BIN="${P_CLI%%[ ]*}"
639P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100640if [ ! -x "$P_SRV_BIN" ]; then
641 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100642 exit 1
643fi
Hanno Becker17c04932017-10-10 14:44:53 +0100644if [ ! -x "$P_CLI_BIN" ]; then
645 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100646 exit 1
647fi
Hanno Becker17c04932017-10-10 14:44:53 +0100648if [ ! -x "$P_PXY_BIN" ]; then
649 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200650 exit 1
651fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100652if [ "$MEMCHECK" -gt 0 ]; then
653 if which valgrind >/dev/null 2>&1; then :; else
654 echo "Memcheck not possible. Valgrind not found"
655 exit 1
656 fi
657fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100658if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
659 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100660 exit 1
661fi
662
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200663# used by watchdog
664MAIN_PID="$$"
665
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100666# We use somewhat arbitrary delays for tests:
667# - how long do we wait for the server to start (when lsof not available)?
668# - how long do we allow for the client to finish?
669# (not to check performance, just to avoid waiting indefinitely)
670# Things are slower with valgrind, so give extra time here.
671#
672# Note: without lsof, there is a trade-off between the running time of this
673# script and the risk of spurious errors because we didn't wait long enough.
674# The watchdog delay on the other hand doesn't affect normal running time of
675# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200676if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100677 START_DELAY=6
678 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200679else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100680 START_DELAY=2
681 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200682fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100683
684# some particular tests need more time:
685# - for the client, we multiply the usual watchdog limit by a factor
686# - for the server, we sleep for a number of seconds after the client exits
687# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200688CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100689SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200690
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200691# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000692# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200693P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
694P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100695P_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 +0200696O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200697O_CLI="$O_CLI -connect localhost:+SRV_PORT"
698G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000699G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200700
Gilles Peskine62469d92017-05-10 10:13:59 +0200701# Allow SHA-1, because many of our test certificates use it
702P_SRV="$P_SRV allow_sha1=1"
703P_CLI="$P_CLI allow_sha1=1"
704
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200705# Also pick a unique name for intermediate files
706SRV_OUT="srv_out.$$"
707CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200708PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200709SESSION="session.$$"
710
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200711SKIP_NEXT="NO"
712
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100713trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100714
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200715# Basic test
716
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200717# Checks that:
718# - things work with all ciphersuites active (used with config-full in all.sh)
719# - the expected (highest security) parameters are selected
720# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200721run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200722 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200723 "$P_CLI" \
724 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200725 -s "Protocol is TLSv1.2" \
726 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
727 -s "client hello v3, signature_algorithm ext: 6" \
728 -s "ECDHE curve: secp521r1" \
729 -S "error" \
730 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200731
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000732run_test "Default, DTLS" \
733 "$P_SRV dtls=1" \
734 "$P_CLI dtls=1" \
735 0 \
736 -s "Protocol is DTLSv1.2" \
737 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
738
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100739# Test current time in ServerHello
740requires_config_enabled MBEDTLS_HAVE_TIME
741run_test "Default, ServerHello contains gmt_unix_time" \
742 "$P_SRV debug_level=3" \
743 "$P_CLI debug_level=3" \
744 0 \
745 -s "Protocol is TLSv1.2" \
746 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
747 -s "client hello v3, signature_algorithm ext: 6" \
748 -s "ECDHE curve: secp521r1" \
749 -S "error" \
750 -C "error" \
751 -f "check_server_hello_time" \
752 -F "check_server_hello_time"
753
Simon Butcher8e004102016-10-14 00:48:33 +0100754# Test for uniqueness of IVs in AEAD ciphersuites
755run_test "Unique IV in GCM" \
756 "$P_SRV exchanges=20 debug_level=4" \
757 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
758 0 \
759 -u "IV used" \
760 -U "IV used"
761
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100762# Tests for rc4 option
763
Simon Butchera410af52016-05-19 22:12:18 +0100764requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100765run_test "RC4: server disabled, client enabled" \
766 "$P_SRV" \
767 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
768 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100769 -s "SSL - The server has no ciphersuites in common"
770
Simon Butchera410af52016-05-19 22:12:18 +0100771requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100772run_test "RC4: server half, client enabled" \
773 "$P_SRV arc4=1" \
774 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
775 1 \
776 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100777
778run_test "RC4: server enabled, client disabled" \
779 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
780 "$P_CLI" \
781 1 \
782 -s "SSL - The server has no ciphersuites in common"
783
784run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100785 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100786 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
787 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100788 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100789 -S "SSL - The server has no ciphersuites in common"
790
Gilles Peskinebc70a182017-05-09 15:59:24 +0200791# Tests for SHA-1 support
792
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200793requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200794run_test "SHA-1 forbidden by default in server certificate" \
795 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
796 "$P_CLI debug_level=2 allow_sha1=0" \
797 1 \
798 -c "The certificate is signed with an unacceptable hash"
799
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200800requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
801run_test "SHA-1 forbidden by default in server certificate" \
802 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
803 "$P_CLI debug_level=2 allow_sha1=0" \
804 0
805
Gilles Peskinebc70a182017-05-09 15:59:24 +0200806run_test "SHA-1 explicitly allowed in server certificate" \
807 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
808 "$P_CLI allow_sha1=1" \
809 0
810
811run_test "SHA-256 allowed by default in server certificate" \
812 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
813 "$P_CLI allow_sha1=0" \
814 0
815
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200816requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200817run_test "SHA-1 forbidden by default in client certificate" \
818 "$P_SRV auth_mode=required allow_sha1=0" \
819 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
820 1 \
821 -s "The certificate is signed with an unacceptable hash"
822
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200823requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
824run_test "SHA-1 forbidden by default in client certificate" \
825 "$P_SRV auth_mode=required allow_sha1=0" \
826 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
827 0
828
Gilles Peskinebc70a182017-05-09 15:59:24 +0200829run_test "SHA-1 explicitly allowed in client certificate" \
830 "$P_SRV auth_mode=required allow_sha1=1" \
831 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
832 0
833
834run_test "SHA-256 allowed by default in client certificate" \
835 "$P_SRV auth_mode=required allow_sha1=0" \
836 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
837 0
838
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100839# Tests for Truncated HMAC extension
840
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100841run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200842 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100843 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100844 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000845 -s "dumping 'expected mac' (20 bytes)" \
846 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100847
Hanno Becker32c55012017-11-10 08:42:54 +0000848requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100849run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200850 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000851 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100852 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000853 -s "dumping 'expected mac' (20 bytes)" \
854 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100855
Hanno Becker32c55012017-11-10 08:42:54 +0000856requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100857run_test "Truncated HMAC: client enabled, server default" \
858 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000859 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100860 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000861 -s "dumping 'expected mac' (20 bytes)" \
862 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100863
Hanno Becker32c55012017-11-10 08:42:54 +0000864requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100865run_test "Truncated HMAC: client enabled, server disabled" \
866 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000867 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100868 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000869 -s "dumping 'expected mac' (20 bytes)" \
870 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100871
Hanno Becker32c55012017-11-10 08:42:54 +0000872requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000873run_test "Truncated HMAC: client disabled, server enabled" \
874 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000875 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000876 0 \
877 -s "dumping 'expected mac' (20 bytes)" \
878 -S "dumping 'expected mac' (10 bytes)"
879
880requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100881run_test "Truncated HMAC: client enabled, server enabled" \
882 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000883 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100884 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000885 -S "dumping 'expected mac' (20 bytes)" \
886 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100887
Hanno Becker4c4f4102017-11-10 09:16:05 +0000888run_test "Truncated HMAC, DTLS: client default, server default" \
889 "$P_SRV dtls=1 debug_level=4" \
890 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
891 0 \
892 -s "dumping 'expected mac' (20 bytes)" \
893 -S "dumping 'expected mac' (10 bytes)"
894
895requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
896run_test "Truncated HMAC, DTLS: client disabled, server default" \
897 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000898 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000899 0 \
900 -s "dumping 'expected mac' (20 bytes)" \
901 -S "dumping 'expected mac' (10 bytes)"
902
903requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
904run_test "Truncated HMAC, DTLS: client enabled, server default" \
905 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000906 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000907 0 \
908 -s "dumping 'expected mac' (20 bytes)" \
909 -S "dumping 'expected mac' (10 bytes)"
910
911requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
912run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
913 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000914 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000915 0 \
916 -s "dumping 'expected mac' (20 bytes)" \
917 -S "dumping 'expected mac' (10 bytes)"
918
919requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
920run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
921 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000922 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000923 0 \
924 -s "dumping 'expected mac' (20 bytes)" \
925 -S "dumping 'expected mac' (10 bytes)"
926
927requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
928run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
929 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000930 "$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 +0100931 0 \
932 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100933 -s "dumping 'expected mac' (10 bytes)"
934
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100935# Tests for Encrypt-then-MAC extension
936
937run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100938 "$P_SRV debug_level=3 \
939 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100940 "$P_CLI debug_level=3" \
941 0 \
942 -c "client hello, adding encrypt_then_mac extension" \
943 -s "found encrypt then mac extension" \
944 -s "server hello, adding encrypt then mac extension" \
945 -c "found encrypt_then_mac extension" \
946 -c "using encrypt then mac" \
947 -s "using encrypt then mac"
948
949run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100950 "$P_SRV debug_level=3 etm=0 \
951 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100952 "$P_CLI debug_level=3 etm=1" \
953 0 \
954 -c "client hello, adding encrypt_then_mac extension" \
955 -s "found encrypt then mac extension" \
956 -S "server hello, adding encrypt then mac extension" \
957 -C "found encrypt_then_mac extension" \
958 -C "using encrypt then mac" \
959 -S "using encrypt then mac"
960
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100961run_test "Encrypt then MAC: client enabled, aead cipher" \
962 "$P_SRV debug_level=3 etm=1 \
963 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
964 "$P_CLI debug_level=3 etm=1" \
965 0 \
966 -c "client hello, adding encrypt_then_mac extension" \
967 -s "found encrypt then mac extension" \
968 -S "server hello, adding encrypt then mac extension" \
969 -C "found encrypt_then_mac extension" \
970 -C "using encrypt then mac" \
971 -S "using encrypt then mac"
972
973run_test "Encrypt then MAC: client enabled, stream cipher" \
974 "$P_SRV debug_level=3 etm=1 \
975 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100976 "$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 +0100977 0 \
978 -c "client hello, adding encrypt_then_mac extension" \
979 -s "found encrypt then mac extension" \
980 -S "server hello, adding encrypt then mac extension" \
981 -C "found encrypt_then_mac extension" \
982 -C "using encrypt then mac" \
983 -S "using encrypt then mac"
984
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100985run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100986 "$P_SRV debug_level=3 etm=1 \
987 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100988 "$P_CLI debug_level=3 etm=0" \
989 0 \
990 -C "client hello, adding encrypt_then_mac extension" \
991 -S "found encrypt then mac extension" \
992 -S "server hello, adding encrypt then mac extension" \
993 -C "found encrypt_then_mac extension" \
994 -C "using encrypt then mac" \
995 -S "using encrypt then mac"
996
Janos Follathe2681a42016-03-07 15:57:05 +0000997requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100998run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100999 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001000 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001001 "$P_CLI debug_level=3 force_version=ssl3" \
1002 0 \
1003 -C "client hello, adding encrypt_then_mac extension" \
1004 -S "found encrypt then mac extension" \
1005 -S "server hello, adding encrypt then mac extension" \
1006 -C "found encrypt_then_mac extension" \
1007 -C "using encrypt then mac" \
1008 -S "using encrypt then mac"
1009
Janos Follathe2681a42016-03-07 15:57:05 +00001010requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001011run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001012 "$P_SRV debug_level=3 force_version=ssl3 \
1013 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001014 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001015 0 \
1016 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001017 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001018 -S "server hello, adding encrypt then mac extension" \
1019 -C "found encrypt_then_mac extension" \
1020 -C "using encrypt then mac" \
1021 -S "using encrypt then mac"
1022
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001023# Tests for Extended Master Secret extension
1024
1025run_test "Extended Master Secret: default" \
1026 "$P_SRV debug_level=3" \
1027 "$P_CLI debug_level=3" \
1028 0 \
1029 -c "client hello, adding extended_master_secret extension" \
1030 -s "found extended master secret extension" \
1031 -s "server hello, adding extended master secret extension" \
1032 -c "found extended_master_secret extension" \
1033 -c "using extended master secret" \
1034 -s "using extended master secret"
1035
1036run_test "Extended Master Secret: client enabled, server disabled" \
1037 "$P_SRV debug_level=3 extended_ms=0" \
1038 "$P_CLI debug_level=3 extended_ms=1" \
1039 0 \
1040 -c "client hello, adding extended_master_secret extension" \
1041 -s "found extended master secret extension" \
1042 -S "server hello, adding extended master secret extension" \
1043 -C "found extended_master_secret extension" \
1044 -C "using extended master secret" \
1045 -S "using extended master secret"
1046
1047run_test "Extended Master Secret: client disabled, server enabled" \
1048 "$P_SRV debug_level=3 extended_ms=1" \
1049 "$P_CLI debug_level=3 extended_ms=0" \
1050 0 \
1051 -C "client hello, adding extended_master_secret extension" \
1052 -S "found extended master secret extension" \
1053 -S "server hello, adding extended master secret extension" \
1054 -C "found extended_master_secret extension" \
1055 -C "using extended master secret" \
1056 -S "using extended master secret"
1057
Janos Follathe2681a42016-03-07 15:57:05 +00001058requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001059run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001060 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001061 "$P_CLI debug_level=3 force_version=ssl3" \
1062 0 \
1063 -C "client hello, adding extended_master_secret extension" \
1064 -S "found extended master secret extension" \
1065 -S "server hello, adding extended master secret extension" \
1066 -C "found extended_master_secret extension" \
1067 -C "using extended master secret" \
1068 -S "using extended master secret"
1069
Janos Follathe2681a42016-03-07 15:57:05 +00001070requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001071run_test "Extended Master Secret: client enabled, server SSLv3" \
1072 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001073 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001074 0 \
1075 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001076 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001077 -S "server hello, adding extended master secret extension" \
1078 -C "found extended_master_secret extension" \
1079 -C "using extended master secret" \
1080 -S "using extended master secret"
1081
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001082# Tests for FALLBACK_SCSV
1083
1084run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001085 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001086 "$P_CLI debug_level=3 force_version=tls1_1" \
1087 0 \
1088 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001089 -S "received FALLBACK_SCSV" \
1090 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001091 -C "is a fatal alert message (msg 86)"
1092
1093run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001094 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001095 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1096 0 \
1097 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001098 -S "received FALLBACK_SCSV" \
1099 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001100 -C "is a fatal alert message (msg 86)"
1101
1102run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001103 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001104 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001105 1 \
1106 -c "adding FALLBACK_SCSV" \
1107 -s "received FALLBACK_SCSV" \
1108 -s "inapropriate fallback" \
1109 -c "is a fatal alert message (msg 86)"
1110
1111run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001112 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001113 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001114 0 \
1115 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001116 -s "received FALLBACK_SCSV" \
1117 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001118 -C "is a fatal alert message (msg 86)"
1119
1120requires_openssl_with_fallback_scsv
1121run_test "Fallback SCSV: default, openssl server" \
1122 "$O_SRV" \
1123 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1124 0 \
1125 -C "adding FALLBACK_SCSV" \
1126 -C "is a fatal alert message (msg 86)"
1127
1128requires_openssl_with_fallback_scsv
1129run_test "Fallback SCSV: enabled, openssl server" \
1130 "$O_SRV" \
1131 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1132 1 \
1133 -c "adding FALLBACK_SCSV" \
1134 -c "is a fatal alert message (msg 86)"
1135
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001136requires_openssl_with_fallback_scsv
1137run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001138 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001139 "$O_CLI -tls1_1" \
1140 0 \
1141 -S "received FALLBACK_SCSV" \
1142 -S "inapropriate fallback"
1143
1144requires_openssl_with_fallback_scsv
1145run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001146 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001147 "$O_CLI -tls1_1 -fallback_scsv" \
1148 1 \
1149 -s "received FALLBACK_SCSV" \
1150 -s "inapropriate fallback"
1151
1152requires_openssl_with_fallback_scsv
1153run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001154 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001155 "$O_CLI -fallback_scsv" \
1156 0 \
1157 -s "received FALLBACK_SCSV" \
1158 -S "inapropriate fallback"
1159
Gilles Peskined50177f2017-05-16 17:53:03 +02001160## ClientHello generated with
1161## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1162## then manually twiddling the ciphersuite list.
1163## The ClientHello content is spelled out below as a hex string as
1164## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1165## The expected response is an inappropriate_fallback alert.
1166requires_openssl_with_fallback_scsv
1167run_test "Fallback SCSV: beginning of list" \
1168 "$P_SRV debug_level=2" \
1169 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1170 0 \
1171 -s "received FALLBACK_SCSV" \
1172 -s "inapropriate fallback"
1173
1174requires_openssl_with_fallback_scsv
1175run_test "Fallback SCSV: end of list" \
1176 "$P_SRV debug_level=2" \
1177 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1178 0 \
1179 -s "received FALLBACK_SCSV" \
1180 -s "inapropriate fallback"
1181
1182## Here the expected response is a valid ServerHello prefix, up to the random.
1183requires_openssl_with_fallback_scsv
1184run_test "Fallback SCSV: not in list" \
1185 "$P_SRV debug_level=2" \
1186 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1187 0 \
1188 -S "received FALLBACK_SCSV" \
1189 -S "inapropriate fallback"
1190
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001191# Tests for CBC 1/n-1 record splitting
1192
1193run_test "CBC Record splitting: TLS 1.2, no splitting" \
1194 "$P_SRV" \
1195 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1196 request_size=123 force_version=tls1_2" \
1197 0 \
1198 -s "Read from client: 123 bytes read" \
1199 -S "Read from client: 1 bytes read" \
1200 -S "122 bytes read"
1201
1202run_test "CBC Record splitting: TLS 1.1, no splitting" \
1203 "$P_SRV" \
1204 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1205 request_size=123 force_version=tls1_1" \
1206 0 \
1207 -s "Read from client: 123 bytes read" \
1208 -S "Read from client: 1 bytes read" \
1209 -S "122 bytes read"
1210
1211run_test "CBC Record splitting: TLS 1.0, splitting" \
1212 "$P_SRV" \
1213 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1214 request_size=123 force_version=tls1" \
1215 0 \
1216 -S "Read from client: 123 bytes read" \
1217 -s "Read from client: 1 bytes read" \
1218 -s "122 bytes read"
1219
Janos Follathe2681a42016-03-07 15:57:05 +00001220requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001221run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001222 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001223 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1224 request_size=123 force_version=ssl3" \
1225 0 \
1226 -S "Read from client: 123 bytes read" \
1227 -s "Read from client: 1 bytes read" \
1228 -s "122 bytes read"
1229
1230run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001231 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001232 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1233 request_size=123 force_version=tls1" \
1234 0 \
1235 -s "Read from client: 123 bytes read" \
1236 -S "Read from client: 1 bytes read" \
1237 -S "122 bytes read"
1238
1239run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1240 "$P_SRV" \
1241 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1242 request_size=123 force_version=tls1 recsplit=0" \
1243 0 \
1244 -s "Read from client: 123 bytes read" \
1245 -S "Read from client: 1 bytes read" \
1246 -S "122 bytes read"
1247
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001248run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1249 "$P_SRV nbio=2" \
1250 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1251 request_size=123 force_version=tls1" \
1252 0 \
1253 -S "Read from client: 123 bytes read" \
1254 -s "Read from client: 1 bytes read" \
1255 -s "122 bytes read"
1256
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001257# Tests for Session Tickets
1258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001259run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001260 "$P_SRV debug_level=3 tickets=1" \
1261 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001262 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001263 -c "client hello, adding session ticket extension" \
1264 -s "found session ticket extension" \
1265 -s "server hello, adding session ticket extension" \
1266 -c "found session_ticket extension" \
1267 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001268 -S "session successfully restored from cache" \
1269 -s "session successfully restored from ticket" \
1270 -s "a session has been resumed" \
1271 -c "a session has been resumed"
1272
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001273run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001274 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1275 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001276 0 \
1277 -c "client hello, adding session ticket extension" \
1278 -s "found session ticket extension" \
1279 -s "server hello, adding session ticket extension" \
1280 -c "found session_ticket extension" \
1281 -c "parse new session ticket" \
1282 -S "session successfully restored from cache" \
1283 -s "session successfully restored from ticket" \
1284 -s "a session has been resumed" \
1285 -c "a session has been resumed"
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1289 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001290 0 \
1291 -c "client hello, adding session ticket extension" \
1292 -s "found session ticket extension" \
1293 -s "server hello, adding session ticket extension" \
1294 -c "found session_ticket extension" \
1295 -c "parse new session ticket" \
1296 -S "session successfully restored from cache" \
1297 -S "session successfully restored from ticket" \
1298 -S "a session has been resumed" \
1299 -C "a session has been resumed"
1300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001301run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001302 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001303 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001304 0 \
1305 -c "client hello, adding session ticket extension" \
1306 -c "found session_ticket extension" \
1307 -c "parse new session ticket" \
1308 -c "a session has been resumed"
1309
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001310run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001311 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001312 "( $O_CLI -sess_out $SESSION; \
1313 $O_CLI -sess_in $SESSION; \
1314 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001315 0 \
1316 -s "found session ticket extension" \
1317 -s "server hello, adding session ticket extension" \
1318 -S "session successfully restored from cache" \
1319 -s "session successfully restored from ticket" \
1320 -s "a session has been resumed"
1321
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001322# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001324run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001325 "$P_SRV debug_level=3 tickets=0" \
1326 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001327 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001328 -c "client hello, adding session ticket extension" \
1329 -s "found session ticket extension" \
1330 -S "server hello, adding session ticket extension" \
1331 -C "found session_ticket extension" \
1332 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001333 -s "session successfully restored from cache" \
1334 -S "session successfully restored from ticket" \
1335 -s "a session has been resumed" \
1336 -c "a session has been resumed"
1337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001338run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001339 "$P_SRV debug_level=3 tickets=1" \
1340 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001341 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001342 -C "client hello, adding session ticket extension" \
1343 -S "found session ticket extension" \
1344 -S "server hello, adding session ticket extension" \
1345 -C "found session_ticket extension" \
1346 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001347 -s "session successfully restored from cache" \
1348 -S "session successfully restored from ticket" \
1349 -s "a session has been resumed" \
1350 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001352run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001353 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1354 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001355 0 \
1356 -S "session successfully restored from cache" \
1357 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001358 -S "a session has been resumed" \
1359 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001361run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001362 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1363 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001364 0 \
1365 -s "session successfully restored from cache" \
1366 -S "session successfully restored from ticket" \
1367 -s "a session has been resumed" \
1368 -c "a session has been resumed"
1369
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001370run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001371 "$P_SRV debug_level=3 tickets=0" \
1372 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001373 0 \
1374 -s "session successfully restored from cache" \
1375 -S "session successfully restored from ticket" \
1376 -s "a session has been resumed" \
1377 -c "a session has been resumed"
1378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001379run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001380 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1381 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001382 0 \
1383 -S "session successfully restored from cache" \
1384 -S "session successfully restored from ticket" \
1385 -S "a session has been resumed" \
1386 -C "a session has been resumed"
1387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001388run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001389 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1390 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001391 0 \
1392 -s "session successfully restored from cache" \
1393 -S "session successfully restored from ticket" \
1394 -s "a session has been resumed" \
1395 -c "a session has been resumed"
1396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001397run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001398 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001399 "( $O_CLI -sess_out $SESSION; \
1400 $O_CLI -sess_in $SESSION; \
1401 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001402 0 \
1403 -s "found session ticket extension" \
1404 -S "server hello, adding session ticket extension" \
1405 -s "session successfully restored from cache" \
1406 -S "session successfully restored from ticket" \
1407 -s "a session has been resumed"
1408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001409run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001410 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001411 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001412 0 \
1413 -C "found session_ticket extension" \
1414 -C "parse new session ticket" \
1415 -c "a session has been resumed"
1416
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001417# Tests for Max Fragment Length extension
1418
Hanno Becker6428f8d2017-09-22 16:58:50 +01001419MAX_CONTENT_LEN_EXPECT='16384'
1420MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1421
1422if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1423 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1424 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1425 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1426 printf "\n"
1427 printf "The tests assume this value and if it changes, the tests in this\n"
1428 printf "script should also be adjusted.\n"
1429 printf "\n"
1430
1431 exit 1
1432fi
1433
Hanno Becker4aed27e2017-09-18 15:00:34 +01001434requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001435run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001436 "$P_SRV debug_level=3" \
1437 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001438 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001439 -c "Maximum fragment length is 16384" \
1440 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001441 -C "client hello, adding max_fragment_length extension" \
1442 -S "found max fragment length extension" \
1443 -S "server hello, max_fragment_length extension" \
1444 -C "found max_fragment_length extension"
1445
Hanno Becker4aed27e2017-09-18 15:00:34 +01001446requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001447run_test "Max fragment length: enabled, default, larger message" \
1448 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001449 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001450 0 \
1451 -c "Maximum fragment length is 16384" \
1452 -s "Maximum fragment length is 16384" \
1453 -C "client hello, adding max_fragment_length extension" \
1454 -S "found max fragment length extension" \
1455 -S "server hello, max_fragment_length extension" \
1456 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001457 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001458 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001459 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001460
1461requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1462run_test "Max fragment length, DTLS: enabled, default, larger message" \
1463 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001464 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001465 1 \
1466 -c "Maximum fragment length is 16384" \
1467 -s "Maximum fragment length is 16384" \
1468 -C "client hello, adding max_fragment_length extension" \
1469 -S "found max fragment length extension" \
1470 -S "server hello, max_fragment_length extension" \
1471 -C "found max_fragment_length extension" \
1472 -c "fragment larger than.*maximum "
1473
1474requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1475run_test "Max fragment length: disabled, larger message" \
1476 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001477 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001478 0 \
1479 -C "Maximum fragment length is 16384" \
1480 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001481 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001482 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001483 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001484
1485requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1486run_test "Max fragment length DTLS: disabled, larger message" \
1487 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001488 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001489 1 \
1490 -C "Maximum fragment length is 16384" \
1491 -S "Maximum fragment length is 16384" \
1492 -c "fragment larger than.*maximum "
1493
1494requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001495run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001496 "$P_SRV debug_level=3" \
1497 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001498 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001499 -c "Maximum fragment length is 4096" \
1500 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001501 -c "client hello, adding max_fragment_length extension" \
1502 -s "found max fragment length extension" \
1503 -s "server hello, max_fragment_length extension" \
1504 -c "found max_fragment_length extension"
1505
Hanno Becker4aed27e2017-09-18 15:00:34 +01001506requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001508 "$P_SRV debug_level=3 max_frag_len=4096" \
1509 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001510 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001511 -c "Maximum fragment length is 16384" \
1512 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001513 -C "client hello, adding max_fragment_length extension" \
1514 -S "found max fragment length extension" \
1515 -S "server hello, max_fragment_length extension" \
1516 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001517
Hanno Becker4aed27e2017-09-18 15:00:34 +01001518requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001519requires_gnutls
1520run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001521 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001522 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001523 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001524 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001525 -c "client hello, adding max_fragment_length extension" \
1526 -c "found max_fragment_length extension"
1527
Hanno Becker4aed27e2017-09-18 15:00:34 +01001528requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001529run_test "Max fragment length: client, message just fits" \
1530 "$P_SRV debug_level=3" \
1531 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1532 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001533 -c "Maximum fragment length is 2048" \
1534 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001535 -c "client hello, adding max_fragment_length extension" \
1536 -s "found max fragment length extension" \
1537 -s "server hello, max_fragment_length extension" \
1538 -c "found max_fragment_length extension" \
1539 -c "2048 bytes written in 1 fragments" \
1540 -s "2048 bytes read"
1541
Hanno Becker4aed27e2017-09-18 15:00:34 +01001542requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001543run_test "Max fragment length: client, larger message" \
1544 "$P_SRV debug_level=3" \
1545 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1546 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001547 -c "Maximum fragment length is 2048" \
1548 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001549 -c "client hello, adding max_fragment_length extension" \
1550 -s "found max fragment length extension" \
1551 -s "server hello, max_fragment_length extension" \
1552 -c "found max_fragment_length extension" \
1553 -c "2345 bytes written in 2 fragments" \
1554 -s "2048 bytes read" \
1555 -s "297 bytes read"
1556
Hanno Becker4aed27e2017-09-18 15:00:34 +01001557requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001558run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001559 "$P_SRV debug_level=3 dtls=1" \
1560 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1561 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001562 -c "Maximum fragment length is 2048" \
1563 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001564 -c "client hello, adding max_fragment_length extension" \
1565 -s "found max fragment length extension" \
1566 -s "server hello, max_fragment_length extension" \
1567 -c "found max_fragment_length extension" \
1568 -c "fragment larger than.*maximum"
1569
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001570# Tests for renegotiation
1571
Hanno Becker6a243642017-10-12 15:18:45 +01001572# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001573run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001574 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001575 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001576 0 \
1577 -C "client hello, adding renegotiation extension" \
1578 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1579 -S "found renegotiation extension" \
1580 -s "server hello, secure renegotiation extension" \
1581 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001582 -C "=> renegotiate" \
1583 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001584 -S "write hello request"
1585
Hanno Becker6a243642017-10-12 15:18:45 +01001586requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001587run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001588 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001589 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001590 0 \
1591 -c "client hello, adding renegotiation extension" \
1592 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1593 -s "found renegotiation extension" \
1594 -s "server hello, secure renegotiation extension" \
1595 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001596 -c "=> renegotiate" \
1597 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001598 -S "write hello request"
1599
Hanno Becker6a243642017-10-12 15:18:45 +01001600requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001601run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001602 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001603 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001604 0 \
1605 -c "client hello, adding renegotiation extension" \
1606 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1607 -s "found renegotiation extension" \
1608 -s "server hello, secure renegotiation extension" \
1609 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001610 -c "=> renegotiate" \
1611 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001612 -s "write hello request"
1613
Janos Follathb0f148c2017-10-05 12:29:42 +01001614# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1615# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1616# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001617requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001618run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1619 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1620 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1621 0 \
1622 -c "client hello, adding renegotiation extension" \
1623 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1624 -s "found renegotiation extension" \
1625 -s "server hello, secure renegotiation extension" \
1626 -c "found renegotiation extension" \
1627 -c "=> renegotiate" \
1628 -s "=> renegotiate" \
1629 -S "write hello request" \
1630 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1631
1632# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1633# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1634# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001635requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001636run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1637 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1638 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1639 0 \
1640 -c "client hello, adding renegotiation extension" \
1641 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1642 -s "found renegotiation extension" \
1643 -s "server hello, secure renegotiation extension" \
1644 -c "found renegotiation extension" \
1645 -c "=> renegotiate" \
1646 -s "=> renegotiate" \
1647 -s "write hello request" \
1648 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1649
Hanno Becker6a243642017-10-12 15:18:45 +01001650requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001651run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001652 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001653 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001654 0 \
1655 -c "client hello, adding renegotiation extension" \
1656 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1657 -s "found renegotiation extension" \
1658 -s "server hello, secure renegotiation extension" \
1659 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001660 -c "=> renegotiate" \
1661 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001662 -s "write hello request"
1663
Hanno Becker6a243642017-10-12 15:18:45 +01001664requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001665run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001666 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001667 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001668 1 \
1669 -c "client hello, adding renegotiation extension" \
1670 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1671 -S "found renegotiation extension" \
1672 -s "server hello, secure renegotiation extension" \
1673 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001674 -c "=> renegotiate" \
1675 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001676 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001677 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001678 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001679
Hanno Becker6a243642017-10-12 15:18:45 +01001680requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001681run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001682 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001683 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001684 0 \
1685 -C "client hello, adding renegotiation extension" \
1686 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1687 -S "found renegotiation extension" \
1688 -s "server hello, secure renegotiation extension" \
1689 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001690 -C "=> renegotiate" \
1691 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001692 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001693 -S "SSL - An unexpected message was received from our peer" \
1694 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001695
Hanno Becker6a243642017-10-12 15:18:45 +01001696requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001697run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001698 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001699 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001700 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001701 0 \
1702 -C "client hello, adding renegotiation extension" \
1703 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1704 -S "found renegotiation extension" \
1705 -s "server hello, secure renegotiation extension" \
1706 -c "found renegotiation extension" \
1707 -C "=> renegotiate" \
1708 -S "=> renegotiate" \
1709 -s "write hello request" \
1710 -S "SSL - An unexpected message was received from our peer" \
1711 -S "failed"
1712
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001713# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001714requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001715run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001716 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001717 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001718 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001719 0 \
1720 -C "client hello, adding renegotiation extension" \
1721 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1722 -S "found renegotiation extension" \
1723 -s "server hello, secure renegotiation extension" \
1724 -c "found renegotiation extension" \
1725 -C "=> renegotiate" \
1726 -S "=> renegotiate" \
1727 -s "write hello request" \
1728 -S "SSL - An unexpected message was received from our peer" \
1729 -S "failed"
1730
Hanno Becker6a243642017-10-12 15:18:45 +01001731requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001732run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001733 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001734 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001735 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001736 0 \
1737 -C "client hello, adding renegotiation extension" \
1738 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1739 -S "found renegotiation extension" \
1740 -s "server hello, secure renegotiation extension" \
1741 -c "found renegotiation extension" \
1742 -C "=> renegotiate" \
1743 -S "=> renegotiate" \
1744 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001745 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001746
Hanno Becker6a243642017-10-12 15:18:45 +01001747requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001748run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001749 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001750 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001751 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001752 0 \
1753 -c "client hello, adding renegotiation extension" \
1754 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1755 -s "found renegotiation extension" \
1756 -s "server hello, secure renegotiation extension" \
1757 -c "found renegotiation extension" \
1758 -c "=> renegotiate" \
1759 -s "=> renegotiate" \
1760 -s "write hello request" \
1761 -S "SSL - An unexpected message was received from our peer" \
1762 -S "failed"
1763
Hanno Becker6a243642017-10-12 15:18:45 +01001764requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001765run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001766 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001767 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1768 0 \
1769 -C "client hello, adding renegotiation extension" \
1770 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1771 -S "found renegotiation extension" \
1772 -s "server hello, secure renegotiation extension" \
1773 -c "found renegotiation extension" \
1774 -S "record counter limit reached: renegotiate" \
1775 -C "=> renegotiate" \
1776 -S "=> renegotiate" \
1777 -S "write hello request" \
1778 -S "SSL - An unexpected message was received from our peer" \
1779 -S "failed"
1780
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001781# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001782requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001783run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001784 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001785 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001786 0 \
1787 -c "client hello, adding renegotiation extension" \
1788 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1789 -s "found renegotiation extension" \
1790 -s "server hello, secure renegotiation extension" \
1791 -c "found renegotiation extension" \
1792 -s "record counter limit reached: renegotiate" \
1793 -c "=> renegotiate" \
1794 -s "=> renegotiate" \
1795 -s "write hello request" \
1796 -S "SSL - An unexpected message was received from our peer" \
1797 -S "failed"
1798
Hanno Becker6a243642017-10-12 15:18:45 +01001799requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001800run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001801 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001802 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001803 0 \
1804 -c "client hello, adding renegotiation extension" \
1805 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1806 -s "found renegotiation extension" \
1807 -s "server hello, secure renegotiation extension" \
1808 -c "found renegotiation extension" \
1809 -s "record counter limit reached: renegotiate" \
1810 -c "=> renegotiate" \
1811 -s "=> renegotiate" \
1812 -s "write hello request" \
1813 -S "SSL - An unexpected message was received from our peer" \
1814 -S "failed"
1815
Hanno Becker6a243642017-10-12 15:18:45 +01001816requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001817run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001818 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001819 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1820 0 \
1821 -C "client hello, adding renegotiation extension" \
1822 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1823 -S "found renegotiation extension" \
1824 -s "server hello, secure renegotiation extension" \
1825 -c "found renegotiation extension" \
1826 -S "record counter limit reached: renegotiate" \
1827 -C "=> renegotiate" \
1828 -S "=> renegotiate" \
1829 -S "write hello request" \
1830 -S "SSL - An unexpected message was received from our peer" \
1831 -S "failed"
1832
Hanno Becker6a243642017-10-12 15:18:45 +01001833requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001834run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001835 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001836 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001837 0 \
1838 -c "client hello, adding renegotiation extension" \
1839 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1840 -s "found renegotiation extension" \
1841 -s "server hello, secure renegotiation extension" \
1842 -c "found renegotiation extension" \
1843 -c "=> renegotiate" \
1844 -s "=> renegotiate" \
1845 -S "write hello request"
1846
Hanno Becker6a243642017-10-12 15:18:45 +01001847requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001848run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001849 "$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 +02001850 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001851 0 \
1852 -c "client hello, adding renegotiation extension" \
1853 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1854 -s "found renegotiation extension" \
1855 -s "server hello, secure renegotiation extension" \
1856 -c "found renegotiation extension" \
1857 -c "=> renegotiate" \
1858 -s "=> renegotiate" \
1859 -s "write hello request"
1860
Hanno Becker6a243642017-10-12 15:18:45 +01001861requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001862run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001863 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001864 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001865 0 \
1866 -c "client hello, adding renegotiation extension" \
1867 -c "found renegotiation extension" \
1868 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001869 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001870 -C "error" \
1871 -c "HTTP/1.0 200 [Oo][Kk]"
1872
Paul Bakker539d9722015-02-08 16:18:35 +01001873requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001874requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001875run_test "Renegotiation: gnutls server strict, client-initiated" \
1876 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001877 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001878 0 \
1879 -c "client hello, adding renegotiation extension" \
1880 -c "found renegotiation extension" \
1881 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001882 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001883 -C "error" \
1884 -c "HTTP/1.0 200 [Oo][Kk]"
1885
Paul Bakker539d9722015-02-08 16:18:35 +01001886requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001887requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001888run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1889 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1890 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1891 1 \
1892 -c "client hello, adding renegotiation extension" \
1893 -C "found renegotiation extension" \
1894 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001895 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001896 -c "error" \
1897 -C "HTTP/1.0 200 [Oo][Kk]"
1898
Paul Bakker539d9722015-02-08 16:18:35 +01001899requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001900requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001901run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1902 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1903 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1904 allow_legacy=0" \
1905 1 \
1906 -c "client hello, adding renegotiation extension" \
1907 -C "found renegotiation extension" \
1908 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001909 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001910 -c "error" \
1911 -C "HTTP/1.0 200 [Oo][Kk]"
1912
Paul Bakker539d9722015-02-08 16:18:35 +01001913requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001914requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001915run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1916 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1917 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1918 allow_legacy=1" \
1919 0 \
1920 -c "client hello, adding renegotiation extension" \
1921 -C "found renegotiation extension" \
1922 -c "=> renegotiate" \
1923 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001924 -C "error" \
1925 -c "HTTP/1.0 200 [Oo][Kk]"
1926
Hanno Becker6a243642017-10-12 15:18:45 +01001927requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001928run_test "Renegotiation: DTLS, client-initiated" \
1929 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1930 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1931 0 \
1932 -c "client hello, adding renegotiation extension" \
1933 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1934 -s "found renegotiation extension" \
1935 -s "server hello, secure renegotiation extension" \
1936 -c "found renegotiation extension" \
1937 -c "=> renegotiate" \
1938 -s "=> renegotiate" \
1939 -S "write hello request"
1940
Hanno Becker6a243642017-10-12 15:18:45 +01001941requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001942run_test "Renegotiation: DTLS, server-initiated" \
1943 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001944 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1945 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001946 0 \
1947 -c "client hello, adding renegotiation extension" \
1948 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1949 -s "found renegotiation extension" \
1950 -s "server hello, secure renegotiation extension" \
1951 -c "found renegotiation extension" \
1952 -c "=> renegotiate" \
1953 -s "=> renegotiate" \
1954 -s "write hello request"
1955
Hanno Becker6a243642017-10-12 15:18:45 +01001956requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00001957run_test "Renegotiation: DTLS, renego_period overflow" \
1958 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1959 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1960 0 \
1961 -c "client hello, adding renegotiation extension" \
1962 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1963 -s "found renegotiation extension" \
1964 -s "server hello, secure renegotiation extension" \
1965 -s "record counter limit reached: renegotiate" \
1966 -c "=> renegotiate" \
1967 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01001968 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00001969
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001970requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001971requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001972run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1973 "$G_SRV -u --mtu 4096" \
1974 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1975 0 \
1976 -c "client hello, adding renegotiation extension" \
1977 -c "found renegotiation extension" \
1978 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001979 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001980 -C "error" \
1981 -s "Extra-header:"
1982
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001983# Test for the "secure renegotation" extension only (no actual renegotiation)
1984
Paul Bakker539d9722015-02-08 16:18:35 +01001985requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001986run_test "Renego ext: gnutls server strict, client default" \
1987 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1988 "$P_CLI debug_level=3" \
1989 0 \
1990 -c "found renegotiation extension" \
1991 -C "error" \
1992 -c "HTTP/1.0 200 [Oo][Kk]"
1993
Paul Bakker539d9722015-02-08 16:18:35 +01001994requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001995run_test "Renego ext: gnutls server unsafe, client default" \
1996 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1997 "$P_CLI debug_level=3" \
1998 0 \
1999 -C "found renegotiation extension" \
2000 -C "error" \
2001 -c "HTTP/1.0 200 [Oo][Kk]"
2002
Paul Bakker539d9722015-02-08 16:18:35 +01002003requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002004run_test "Renego ext: gnutls server unsafe, client break legacy" \
2005 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2006 "$P_CLI debug_level=3 allow_legacy=-1" \
2007 1 \
2008 -C "found renegotiation extension" \
2009 -c "error" \
2010 -C "HTTP/1.0 200 [Oo][Kk]"
2011
Paul Bakker539d9722015-02-08 16:18:35 +01002012requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002013run_test "Renego ext: gnutls client strict, server default" \
2014 "$P_SRV debug_level=3" \
2015 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2016 0 \
2017 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2018 -s "server hello, secure renegotiation extension"
2019
Paul Bakker539d9722015-02-08 16:18:35 +01002020requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002021run_test "Renego ext: gnutls client unsafe, server default" \
2022 "$P_SRV debug_level=3" \
2023 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2024 0 \
2025 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2026 -S "server hello, secure renegotiation extension"
2027
Paul Bakker539d9722015-02-08 16:18:35 +01002028requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002029run_test "Renego ext: gnutls client unsafe, server break legacy" \
2030 "$P_SRV debug_level=3 allow_legacy=-1" \
2031 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2032 1 \
2033 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2034 -S "server hello, secure renegotiation extension"
2035
Janos Follath0b242342016-02-17 10:11:21 +00002036# Tests for silently dropping trailing extra bytes in .der certificates
2037
2038requires_gnutls
2039run_test "DER format: no trailing bytes" \
2040 "$P_SRV crt_file=data_files/server5-der0.crt \
2041 key_file=data_files/server5.key" \
2042 "$G_CLI " \
2043 0 \
2044 -c "Handshake was completed" \
2045
2046requires_gnutls
2047run_test "DER format: with a trailing zero byte" \
2048 "$P_SRV crt_file=data_files/server5-der1a.crt \
2049 key_file=data_files/server5.key" \
2050 "$G_CLI " \
2051 0 \
2052 -c "Handshake was completed" \
2053
2054requires_gnutls
2055run_test "DER format: with a trailing random byte" \
2056 "$P_SRV crt_file=data_files/server5-der1b.crt \
2057 key_file=data_files/server5.key" \
2058 "$G_CLI " \
2059 0 \
2060 -c "Handshake was completed" \
2061
2062requires_gnutls
2063run_test "DER format: with 2 trailing random bytes" \
2064 "$P_SRV crt_file=data_files/server5-der2.crt \
2065 key_file=data_files/server5.key" \
2066 "$G_CLI " \
2067 0 \
2068 -c "Handshake was completed" \
2069
2070requires_gnutls
2071run_test "DER format: with 4 trailing random bytes" \
2072 "$P_SRV crt_file=data_files/server5-der4.crt \
2073 key_file=data_files/server5.key" \
2074 "$G_CLI " \
2075 0 \
2076 -c "Handshake was completed" \
2077
2078requires_gnutls
2079run_test "DER format: with 8 trailing random bytes" \
2080 "$P_SRV crt_file=data_files/server5-der8.crt \
2081 key_file=data_files/server5.key" \
2082 "$G_CLI " \
2083 0 \
2084 -c "Handshake was completed" \
2085
2086requires_gnutls
2087run_test "DER format: with 9 trailing random bytes" \
2088 "$P_SRV crt_file=data_files/server5-der9.crt \
2089 key_file=data_files/server5.key" \
2090 "$G_CLI " \
2091 0 \
2092 -c "Handshake was completed" \
2093
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002094# Tests for auth_mode
2095
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002096run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002097 "$P_SRV crt_file=data_files/server5-badsign.crt \
2098 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002099 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002100 1 \
2101 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002102 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002103 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002104 -c "X509 - Certificate verification failed"
2105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002106run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002107 "$P_SRV crt_file=data_files/server5-badsign.crt \
2108 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002109 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002110 0 \
2111 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002112 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002113 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002114 -C "X509 - Certificate verification failed"
2115
Hanno Beckere6706e62017-05-15 16:05:15 +01002116run_test "Authentication: server goodcert, client optional, no trusted CA" \
2117 "$P_SRV" \
2118 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2119 0 \
2120 -c "x509_verify_cert() returned" \
2121 -c "! The certificate is not correctly signed by the trusted CA" \
2122 -c "! Certificate verification flags"\
2123 -C "! mbedtls_ssl_handshake returned" \
2124 -C "X509 - Certificate verification failed" \
2125 -C "SSL - No CA Chain is set, but required to operate"
2126
2127run_test "Authentication: server goodcert, client required, no trusted CA" \
2128 "$P_SRV" \
2129 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2130 1 \
2131 -c "x509_verify_cert() returned" \
2132 -c "! The certificate is not correctly signed by the trusted CA" \
2133 -c "! Certificate verification flags"\
2134 -c "! mbedtls_ssl_handshake returned" \
2135 -c "SSL - No CA Chain is set, but required to operate"
2136
2137# The purpose of the next two tests is to test the client's behaviour when receiving a server
2138# certificate with an unsupported elliptic curve. This should usually not happen because
2139# the client informs the server about the supported curves - it does, though, in the
2140# corner case of a static ECDH suite, because the server doesn't check the curve on that
2141# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2142# different means to have the server ignoring the client's supported curve list.
2143
2144requires_config_enabled MBEDTLS_ECP_C
2145run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2146 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2147 crt_file=data_files/server5.ku-ka.crt" \
2148 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2149 1 \
2150 -c "bad certificate (EC key curve)"\
2151 -c "! Certificate verification flags"\
2152 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2153
2154requires_config_enabled MBEDTLS_ECP_C
2155run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2156 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2157 crt_file=data_files/server5.ku-ka.crt" \
2158 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2159 1 \
2160 -c "bad certificate (EC key curve)"\
2161 -c "! Certificate verification flags"\
2162 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002164run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002165 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002166 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002167 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002168 0 \
2169 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002170 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002171 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002172 -C "X509 - Certificate verification failed"
2173
Simon Butcher99000142016-10-13 17:21:01 +01002174run_test "Authentication: client SHA256, server required" \
2175 "$P_SRV auth_mode=required" \
2176 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2177 key_file=data_files/server6.key \
2178 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2179 0 \
2180 -c "Supported Signature Algorithm found: 4," \
2181 -c "Supported Signature Algorithm found: 5,"
2182
2183run_test "Authentication: client SHA384, server required" \
2184 "$P_SRV auth_mode=required" \
2185 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2186 key_file=data_files/server6.key \
2187 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2188 0 \
2189 -c "Supported Signature Algorithm found: 4," \
2190 -c "Supported Signature Algorithm found: 5,"
2191
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002192requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2193run_test "Authentication: client has no cert, server required (SSLv3)" \
2194 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2195 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2196 key_file=data_files/server5.key" \
2197 1 \
2198 -S "skip write certificate request" \
2199 -C "skip parse certificate request" \
2200 -c "got a certificate request" \
2201 -c "got no certificate to send" \
2202 -S "x509_verify_cert() returned" \
2203 -s "client has no certificate" \
2204 -s "! mbedtls_ssl_handshake returned" \
2205 -c "! mbedtls_ssl_handshake returned" \
2206 -s "No client certification received from the client, but required by the authentication mode"
2207
2208run_test "Authentication: client has no cert, server required (TLS)" \
2209 "$P_SRV debug_level=3 auth_mode=required" \
2210 "$P_CLI debug_level=3 crt_file=none \
2211 key_file=data_files/server5.key" \
2212 1 \
2213 -S "skip write certificate request" \
2214 -C "skip parse certificate request" \
2215 -c "got a certificate request" \
2216 -c "= write certificate$" \
2217 -C "skip write certificate$" \
2218 -S "x509_verify_cert() returned" \
2219 -s "client has no certificate" \
2220 -s "! mbedtls_ssl_handshake returned" \
2221 -c "! mbedtls_ssl_handshake returned" \
2222 -s "No client certification received from the client, but required by the authentication mode"
2223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002224run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002225 "$P_SRV debug_level=3 auth_mode=required" \
2226 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002227 key_file=data_files/server5.key" \
2228 1 \
2229 -S "skip write certificate request" \
2230 -C "skip parse certificate request" \
2231 -c "got a certificate request" \
2232 -C "skip write certificate" \
2233 -C "skip write certificate verify" \
2234 -S "skip parse certificate verify" \
2235 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002236 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002237 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002238 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002239 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002240 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002241# We don't check that the client receives the alert because it might
2242# detect that its write end of the connection is closed and abort
2243# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002244
Janos Follath89baba22017-04-10 14:34:35 +01002245run_test "Authentication: client cert not trusted, server required" \
2246 "$P_SRV debug_level=3 auth_mode=required" \
2247 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2248 key_file=data_files/server5.key" \
2249 1 \
2250 -S "skip write certificate request" \
2251 -C "skip parse certificate request" \
2252 -c "got a certificate request" \
2253 -C "skip write certificate" \
2254 -C "skip write certificate verify" \
2255 -S "skip parse certificate verify" \
2256 -s "x509_verify_cert() returned" \
2257 -s "! The certificate is not correctly signed by the trusted CA" \
2258 -s "! mbedtls_ssl_handshake returned" \
2259 -c "! mbedtls_ssl_handshake returned" \
2260 -s "X509 - Certificate verification failed"
2261
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002262run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002263 "$P_SRV debug_level=3 auth_mode=optional" \
2264 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002265 key_file=data_files/server5.key" \
2266 0 \
2267 -S "skip write certificate request" \
2268 -C "skip parse certificate request" \
2269 -c "got a certificate request" \
2270 -C "skip write certificate" \
2271 -C "skip write certificate verify" \
2272 -S "skip parse certificate verify" \
2273 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002274 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002275 -S "! mbedtls_ssl_handshake returned" \
2276 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002277 -S "X509 - Certificate verification failed"
2278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002279run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002280 "$P_SRV debug_level=3 auth_mode=none" \
2281 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002282 key_file=data_files/server5.key" \
2283 0 \
2284 -s "skip write certificate request" \
2285 -C "skip parse certificate request" \
2286 -c "got no certificate request" \
2287 -c "skip write certificate" \
2288 -c "skip write certificate verify" \
2289 -s "skip parse certificate verify" \
2290 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002291 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002292 -S "! mbedtls_ssl_handshake returned" \
2293 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002294 -S "X509 - Certificate verification failed"
2295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002296run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002297 "$P_SRV debug_level=3 auth_mode=optional" \
2298 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002299 0 \
2300 -S "skip write certificate request" \
2301 -C "skip parse certificate request" \
2302 -c "got a certificate request" \
2303 -C "skip write certificate$" \
2304 -C "got no certificate to send" \
2305 -S "SSLv3 client has no certificate" \
2306 -c "skip write certificate verify" \
2307 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002308 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002309 -S "! mbedtls_ssl_handshake returned" \
2310 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002311 -S "X509 - Certificate verification failed"
2312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002313run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002314 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002315 "$O_CLI" \
2316 0 \
2317 -S "skip write certificate request" \
2318 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002319 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002320 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002321 -S "X509 - Certificate verification failed"
2322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002323run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002324 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002325 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002326 0 \
2327 -C "skip parse certificate request" \
2328 -c "got a certificate request" \
2329 -C "skip write certificate$" \
2330 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002331 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002332
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002333run_test "Authentication: client no cert, openssl server required" \
2334 "$O_SRV -Verify 10" \
2335 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2336 1 \
2337 -C "skip parse certificate request" \
2338 -c "got a certificate request" \
2339 -C "skip write certificate$" \
2340 -c "skip write certificate verify" \
2341 -c "! mbedtls_ssl_handshake returned"
2342
Janos Follathe2681a42016-03-07 15:57:05 +00002343requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002344run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002345 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002346 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002347 0 \
2348 -S "skip write certificate request" \
2349 -C "skip parse certificate request" \
2350 -c "got a certificate request" \
2351 -C "skip write certificate$" \
2352 -c "skip write certificate verify" \
2353 -c "got no certificate to send" \
2354 -s "SSLv3 client has no certificate" \
2355 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002356 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002357 -S "! mbedtls_ssl_handshake returned" \
2358 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002359 -S "X509 - Certificate verification failed"
2360
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002361# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2362# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002363
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002364MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002365MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002366
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002367if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002368 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002369 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002370 printf "test value of ${MAX_IM_CA}. \n"
2371 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002372 printf "The tests assume this value and if it changes, the tests in this\n"
2373 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002374 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002375
2376 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002377fi
2378
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002379run_test "Authentication: server max_int chain, client default" \
2380 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2381 key_file=data_files/dir-maxpath/09.key" \
2382 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2383 0 \
2384 -C "X509 - A fatal error occured"
2385
2386run_test "Authentication: server max_int+1 chain, client default" \
2387 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2388 key_file=data_files/dir-maxpath/10.key" \
2389 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2390 1 \
2391 -c "X509 - A fatal error occured"
2392
2393run_test "Authentication: server max_int+1 chain, client optional" \
2394 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2395 key_file=data_files/dir-maxpath/10.key" \
2396 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2397 auth_mode=optional" \
2398 1 \
2399 -c "X509 - A fatal error occured"
2400
2401run_test "Authentication: server max_int+1 chain, client none" \
2402 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2403 key_file=data_files/dir-maxpath/10.key" \
2404 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2405 auth_mode=none" \
2406 0 \
2407 -C "X509 - A fatal error occured"
2408
2409run_test "Authentication: client max_int+1 chain, server default" \
2410 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2411 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2412 key_file=data_files/dir-maxpath/10.key" \
2413 0 \
2414 -S "X509 - A fatal error occured"
2415
2416run_test "Authentication: client max_int+1 chain, server optional" \
2417 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2418 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2419 key_file=data_files/dir-maxpath/10.key" \
2420 1 \
2421 -s "X509 - A fatal error occured"
2422
2423run_test "Authentication: client max_int+1 chain, server required" \
2424 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2425 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2426 key_file=data_files/dir-maxpath/10.key" \
2427 1 \
2428 -s "X509 - A fatal error occured"
2429
2430run_test "Authentication: client max_int chain, server required" \
2431 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2432 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2433 key_file=data_files/dir-maxpath/09.key" \
2434 0 \
2435 -S "X509 - A fatal error occured"
2436
Janos Follath89baba22017-04-10 14:34:35 +01002437# Tests for CA list in CertificateRequest messages
2438
2439run_test "Authentication: send CA list in CertificateRequest (default)" \
2440 "$P_SRV debug_level=3 auth_mode=required" \
2441 "$P_CLI crt_file=data_files/server6.crt \
2442 key_file=data_files/server6.key" \
2443 0 \
2444 -s "requested DN"
2445
2446run_test "Authentication: do not send CA list in CertificateRequest" \
2447 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2448 "$P_CLI crt_file=data_files/server6.crt \
2449 key_file=data_files/server6.key" \
2450 0 \
2451 -S "requested DN"
2452
2453run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2454 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2455 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2456 key_file=data_files/server5.key" \
2457 1 \
2458 -S "requested DN" \
2459 -s "x509_verify_cert() returned" \
2460 -s "! The certificate is not correctly signed by the trusted CA" \
2461 -s "! mbedtls_ssl_handshake returned" \
2462 -c "! mbedtls_ssl_handshake returned" \
2463 -s "X509 - Certificate verification failed"
2464
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002465# Tests for certificate selection based on SHA verson
2466
2467run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2468 "$P_SRV crt_file=data_files/server5.crt \
2469 key_file=data_files/server5.key \
2470 crt_file2=data_files/server5-sha1.crt \
2471 key_file2=data_files/server5.key" \
2472 "$P_CLI force_version=tls1_2" \
2473 0 \
2474 -c "signed using.*ECDSA with SHA256" \
2475 -C "signed using.*ECDSA with SHA1"
2476
2477run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2478 "$P_SRV crt_file=data_files/server5.crt \
2479 key_file=data_files/server5.key \
2480 crt_file2=data_files/server5-sha1.crt \
2481 key_file2=data_files/server5.key" \
2482 "$P_CLI force_version=tls1_1" \
2483 0 \
2484 -C "signed using.*ECDSA with SHA256" \
2485 -c "signed using.*ECDSA with SHA1"
2486
2487run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2488 "$P_SRV crt_file=data_files/server5.crt \
2489 key_file=data_files/server5.key \
2490 crt_file2=data_files/server5-sha1.crt \
2491 key_file2=data_files/server5.key" \
2492 "$P_CLI force_version=tls1" \
2493 0 \
2494 -C "signed using.*ECDSA with SHA256" \
2495 -c "signed using.*ECDSA with SHA1"
2496
2497run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2498 "$P_SRV crt_file=data_files/server5.crt \
2499 key_file=data_files/server5.key \
2500 crt_file2=data_files/server6.crt \
2501 key_file2=data_files/server6.key" \
2502 "$P_CLI force_version=tls1_1" \
2503 0 \
2504 -c "serial number.*09" \
2505 -c "signed using.*ECDSA with SHA256" \
2506 -C "signed using.*ECDSA with SHA1"
2507
2508run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2509 "$P_SRV crt_file=data_files/server6.crt \
2510 key_file=data_files/server6.key \
2511 crt_file2=data_files/server5.crt \
2512 key_file2=data_files/server5.key" \
2513 "$P_CLI force_version=tls1_1" \
2514 0 \
2515 -c "serial number.*0A" \
2516 -c "signed using.*ECDSA with SHA256" \
2517 -C "signed using.*ECDSA with SHA1"
2518
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002519# tests for SNI
2520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002521run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002522 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002523 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002524 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002525 0 \
2526 -S "parse ServerName extension" \
2527 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2528 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002530run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002531 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002532 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002533 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 +02002534 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002535 0 \
2536 -s "parse ServerName extension" \
2537 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2538 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002540run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002541 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002542 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002543 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 +02002544 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002545 0 \
2546 -s "parse ServerName extension" \
2547 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2548 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002550run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002551 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002552 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002553 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 +02002554 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002555 1 \
2556 -s "parse ServerName extension" \
2557 -s "ssl_sni_wrapper() returned" \
2558 -s "mbedtls_ssl_handshake returned" \
2559 -c "mbedtls_ssl_handshake returned" \
2560 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002561
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002562run_test "SNI: client auth no override: optional" \
2563 "$P_SRV debug_level=3 auth_mode=optional \
2564 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2565 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2566 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002567 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002568 -S "skip write certificate request" \
2569 -C "skip parse certificate request" \
2570 -c "got a certificate request" \
2571 -C "skip write certificate" \
2572 -C "skip write certificate verify" \
2573 -S "skip parse certificate verify"
2574
2575run_test "SNI: client auth override: none -> optional" \
2576 "$P_SRV debug_level=3 auth_mode=none \
2577 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2578 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2579 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002580 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002581 -S "skip write certificate request" \
2582 -C "skip parse certificate request" \
2583 -c "got a certificate request" \
2584 -C "skip write certificate" \
2585 -C "skip write certificate verify" \
2586 -S "skip parse certificate verify"
2587
2588run_test "SNI: client auth override: optional -> none" \
2589 "$P_SRV debug_level=3 auth_mode=optional \
2590 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2591 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2592 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002593 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002594 -s "skip write certificate request" \
2595 -C "skip parse certificate request" \
2596 -c "got no certificate request" \
2597 -c "skip write certificate" \
2598 -c "skip write certificate verify" \
2599 -s "skip parse certificate verify"
2600
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002601run_test "SNI: CA no override" \
2602 "$P_SRV debug_level=3 auth_mode=optional \
2603 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2604 ca_file=data_files/test-ca.crt \
2605 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2606 "$P_CLI debug_level=3 server_name=localhost \
2607 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2608 1 \
2609 -S "skip write certificate request" \
2610 -C "skip parse certificate request" \
2611 -c "got a certificate request" \
2612 -C "skip write certificate" \
2613 -C "skip write certificate verify" \
2614 -S "skip parse certificate verify" \
2615 -s "x509_verify_cert() returned" \
2616 -s "! The certificate is not correctly signed by the trusted CA" \
2617 -S "The certificate has been revoked (is on a CRL)"
2618
2619run_test "SNI: CA override" \
2620 "$P_SRV debug_level=3 auth_mode=optional \
2621 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2622 ca_file=data_files/test-ca.crt \
2623 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2624 "$P_CLI debug_level=3 server_name=localhost \
2625 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2626 0 \
2627 -S "skip write certificate request" \
2628 -C "skip parse certificate request" \
2629 -c "got a certificate request" \
2630 -C "skip write certificate" \
2631 -C "skip write certificate verify" \
2632 -S "skip parse certificate verify" \
2633 -S "x509_verify_cert() returned" \
2634 -S "! The certificate is not correctly signed by the trusted CA" \
2635 -S "The certificate has been revoked (is on a CRL)"
2636
2637run_test "SNI: CA override with CRL" \
2638 "$P_SRV debug_level=3 auth_mode=optional \
2639 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2640 ca_file=data_files/test-ca.crt \
2641 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2642 "$P_CLI debug_level=3 server_name=localhost \
2643 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2644 1 \
2645 -S "skip write certificate request" \
2646 -C "skip parse certificate request" \
2647 -c "got a certificate request" \
2648 -C "skip write certificate" \
2649 -C "skip write certificate verify" \
2650 -S "skip parse certificate verify" \
2651 -s "x509_verify_cert() returned" \
2652 -S "! The certificate is not correctly signed by the trusted CA" \
2653 -s "The certificate has been revoked (is on a CRL)"
2654
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002655# Tests for non-blocking I/O: exercise a variety of handshake flows
2656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002657run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002658 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2659 "$P_CLI nbio=2 tickets=0" \
2660 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002661 -S "mbedtls_ssl_handshake returned" \
2662 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002663 -c "Read from server: .* bytes read"
2664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002665run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002666 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2667 "$P_CLI nbio=2 tickets=0" \
2668 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002669 -S "mbedtls_ssl_handshake returned" \
2670 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002671 -c "Read from server: .* bytes read"
2672
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002673run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002674 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2675 "$P_CLI nbio=2 tickets=1" \
2676 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002677 -S "mbedtls_ssl_handshake returned" \
2678 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002679 -c "Read from server: .* bytes read"
2680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002681run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002682 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2683 "$P_CLI nbio=2 tickets=1" \
2684 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002685 -S "mbedtls_ssl_handshake returned" \
2686 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002687 -c "Read from server: .* bytes read"
2688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002689run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002690 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2691 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2692 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002693 -S "mbedtls_ssl_handshake returned" \
2694 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002695 -c "Read from server: .* bytes read"
2696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002697run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002698 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2699 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2700 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002701 -S "mbedtls_ssl_handshake returned" \
2702 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002703 -c "Read from server: .* bytes read"
2704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002705run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002706 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2707 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2708 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002709 -S "mbedtls_ssl_handshake returned" \
2710 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002711 -c "Read from server: .* bytes read"
2712
Hanno Becker00076712017-11-15 16:39:08 +00002713# Tests for event-driven I/O: exercise a variety of handshake flows
2714
2715run_test "Event-driven I/O: basic handshake" \
2716 "$P_SRV event=1 tickets=0 auth_mode=none" \
2717 "$P_CLI event=1 tickets=0" \
2718 0 \
2719 -S "mbedtls_ssl_handshake returned" \
2720 -C "mbedtls_ssl_handshake returned" \
2721 -c "Read from server: .* bytes read"
2722
2723run_test "Event-driven I/O: client auth" \
2724 "$P_SRV event=1 tickets=0 auth_mode=required" \
2725 "$P_CLI event=1 tickets=0" \
2726 0 \
2727 -S "mbedtls_ssl_handshake returned" \
2728 -C "mbedtls_ssl_handshake returned" \
2729 -c "Read from server: .* bytes read"
2730
2731run_test "Event-driven I/O: ticket" \
2732 "$P_SRV event=1 tickets=1 auth_mode=none" \
2733 "$P_CLI event=1 tickets=1" \
2734 0 \
2735 -S "mbedtls_ssl_handshake returned" \
2736 -C "mbedtls_ssl_handshake returned" \
2737 -c "Read from server: .* bytes read"
2738
2739run_test "Event-driven I/O: ticket + client auth" \
2740 "$P_SRV event=1 tickets=1 auth_mode=required" \
2741 "$P_CLI event=1 tickets=1" \
2742 0 \
2743 -S "mbedtls_ssl_handshake returned" \
2744 -C "mbedtls_ssl_handshake returned" \
2745 -c "Read from server: .* bytes read"
2746
2747run_test "Event-driven I/O: ticket + client auth + resume" \
2748 "$P_SRV event=1 tickets=1 auth_mode=required" \
2749 "$P_CLI event=1 tickets=1 reconnect=1" \
2750 0 \
2751 -S "mbedtls_ssl_handshake returned" \
2752 -C "mbedtls_ssl_handshake returned" \
2753 -c "Read from server: .* bytes read"
2754
2755run_test "Event-driven I/O: ticket + resume" \
2756 "$P_SRV event=1 tickets=1 auth_mode=none" \
2757 "$P_CLI event=1 tickets=1 reconnect=1" \
2758 0 \
2759 -S "mbedtls_ssl_handshake returned" \
2760 -C "mbedtls_ssl_handshake returned" \
2761 -c "Read from server: .* bytes read"
2762
2763run_test "Event-driven I/O: session-id resume" \
2764 "$P_SRV event=1 tickets=0 auth_mode=none" \
2765 "$P_CLI event=1 tickets=0 reconnect=1" \
2766 0 \
2767 -S "mbedtls_ssl_handshake returned" \
2768 -C "mbedtls_ssl_handshake returned" \
2769 -c "Read from server: .* bytes read"
2770
Hanno Becker6a33f592018-03-13 11:38:46 +00002771run_test "Event-driven I/O, DTLS: basic handshake" \
2772 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2773 "$P_CLI dtls=1 event=1 tickets=0" \
2774 0 \
2775 -c "Read from server: .* bytes read"
2776
2777run_test "Event-driven I/O, DTLS: client auth" \
2778 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
2779 "$P_CLI dtls=1 event=1 tickets=0" \
2780 0 \
2781 -c "Read from server: .* bytes read"
2782
2783run_test "Event-driven I/O, DTLS: ticket" \
2784 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2785 "$P_CLI dtls=1 event=1 tickets=1" \
2786 0 \
2787 -c "Read from server: .* bytes read"
2788
2789run_test "Event-driven I/O, DTLS: ticket + client auth" \
2790 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2791 "$P_CLI dtls=1 event=1 tickets=1" \
2792 0 \
2793 -c "Read from server: .* bytes read"
2794
2795run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
2796 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2797 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2798 0 \
2799 -c "Read from server: .* bytes read"
2800
2801run_test "Event-driven I/O, DTLS: ticket + resume" \
2802 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2803 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2804 0 \
2805 -c "Read from server: .* bytes read"
2806
2807run_test "Event-driven I/O, DTLS: session-id resume" \
2808 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2809 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
2810 0 \
2811 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00002812
2813# This test demonstrates the need for the mbedtls_ssl_check_pending function.
2814# During session resumption, the client will send its ApplicationData record
2815# within the same datagram as the Finished messages. In this situation, the
2816# server MUST NOT idle on the underlying transport after handshake completion,
2817# because the ApplicationData request has already been queued internally.
2818run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00002819 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00002820 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
2821 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
2822 0 \
2823 -c "Read from server: .* bytes read"
2824
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002825# Tests for version negotiation
2826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002827run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002828 "$P_SRV" \
2829 "$P_CLI" \
2830 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002831 -S "mbedtls_ssl_handshake returned" \
2832 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002833 -s "Protocol is TLSv1.2" \
2834 -c "Protocol is TLSv1.2"
2835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002836run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002837 "$P_SRV" \
2838 "$P_CLI max_version=tls1_1" \
2839 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002840 -S "mbedtls_ssl_handshake returned" \
2841 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002842 -s "Protocol is TLSv1.1" \
2843 -c "Protocol is TLSv1.1"
2844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002845run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002846 "$P_SRV max_version=tls1_1" \
2847 "$P_CLI" \
2848 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002849 -S "mbedtls_ssl_handshake returned" \
2850 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002851 -s "Protocol is TLSv1.1" \
2852 -c "Protocol is TLSv1.1"
2853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002854run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002855 "$P_SRV max_version=tls1_1" \
2856 "$P_CLI max_version=tls1_1" \
2857 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002858 -S "mbedtls_ssl_handshake returned" \
2859 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002860 -s "Protocol is TLSv1.1" \
2861 -c "Protocol is TLSv1.1"
2862
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002863run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002864 "$P_SRV min_version=tls1_1" \
2865 "$P_CLI max_version=tls1_1" \
2866 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002867 -S "mbedtls_ssl_handshake returned" \
2868 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002869 -s "Protocol is TLSv1.1" \
2870 -c "Protocol is TLSv1.1"
2871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002872run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002873 "$P_SRV max_version=tls1_1" \
2874 "$P_CLI min_version=tls1_1" \
2875 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002876 -S "mbedtls_ssl_handshake returned" \
2877 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002878 -s "Protocol is TLSv1.1" \
2879 -c "Protocol is TLSv1.1"
2880
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002881run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002882 "$P_SRV max_version=tls1_1" \
2883 "$P_CLI min_version=tls1_2" \
2884 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002885 -s "mbedtls_ssl_handshake returned" \
2886 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002887 -c "SSL - Handshake protocol not within min/max boundaries"
2888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002889run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002890 "$P_SRV min_version=tls1_2" \
2891 "$P_CLI max_version=tls1_1" \
2892 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002893 -s "mbedtls_ssl_handshake returned" \
2894 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002895 -s "SSL - Handshake protocol not within min/max boundaries"
2896
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002897# Tests for ALPN extension
2898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002899run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002900 "$P_SRV debug_level=3" \
2901 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002902 0 \
2903 -C "client hello, adding alpn extension" \
2904 -S "found alpn extension" \
2905 -C "got an alert message, type: \\[2:120]" \
2906 -S "server hello, adding alpn extension" \
2907 -C "found alpn extension " \
2908 -C "Application Layer Protocol is" \
2909 -S "Application Layer Protocol is"
2910
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002911run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002912 "$P_SRV debug_level=3" \
2913 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002914 0 \
2915 -c "client hello, adding alpn extension" \
2916 -s "found alpn extension" \
2917 -C "got an alert message, type: \\[2:120]" \
2918 -S "server hello, adding alpn extension" \
2919 -C "found alpn extension " \
2920 -c "Application Layer Protocol is (none)" \
2921 -S "Application Layer Protocol is"
2922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002923run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002924 "$P_SRV debug_level=3 alpn=abc,1234" \
2925 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002926 0 \
2927 -C "client hello, adding alpn extension" \
2928 -S "found alpn extension" \
2929 -C "got an alert message, type: \\[2:120]" \
2930 -S "server hello, adding alpn extension" \
2931 -C "found alpn extension " \
2932 -C "Application Layer Protocol is" \
2933 -s "Application Layer Protocol is (none)"
2934
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002935run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002936 "$P_SRV debug_level=3 alpn=abc,1234" \
2937 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002938 0 \
2939 -c "client hello, adding alpn extension" \
2940 -s "found alpn extension" \
2941 -C "got an alert message, type: \\[2:120]" \
2942 -s "server hello, adding alpn extension" \
2943 -c "found alpn extension" \
2944 -c "Application Layer Protocol is abc" \
2945 -s "Application Layer Protocol is abc"
2946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002947run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002948 "$P_SRV debug_level=3 alpn=abc,1234" \
2949 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002950 0 \
2951 -c "client hello, adding alpn extension" \
2952 -s "found alpn extension" \
2953 -C "got an alert message, type: \\[2:120]" \
2954 -s "server hello, adding alpn extension" \
2955 -c "found alpn extension" \
2956 -c "Application Layer Protocol is abc" \
2957 -s "Application Layer Protocol is abc"
2958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002959run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002960 "$P_SRV debug_level=3 alpn=abc,1234" \
2961 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002962 0 \
2963 -c "client hello, adding alpn extension" \
2964 -s "found alpn extension" \
2965 -C "got an alert message, type: \\[2:120]" \
2966 -s "server hello, adding alpn extension" \
2967 -c "found alpn extension" \
2968 -c "Application Layer Protocol is 1234" \
2969 -s "Application Layer Protocol is 1234"
2970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002971run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002972 "$P_SRV debug_level=3 alpn=abc,123" \
2973 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002974 1 \
2975 -c "client hello, adding alpn extension" \
2976 -s "found alpn extension" \
2977 -c "got an alert message, type: \\[2:120]" \
2978 -S "server hello, adding alpn extension" \
2979 -C "found alpn extension" \
2980 -C "Application Layer Protocol is 1234" \
2981 -S "Application Layer Protocol is 1234"
2982
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002983
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002984# Tests for keyUsage in leaf certificates, part 1:
2985# server-side certificate/suite selection
2986
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002987run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002988 "$P_SRV key_file=data_files/server2.key \
2989 crt_file=data_files/server2.ku-ds.crt" \
2990 "$P_CLI" \
2991 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002992 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002993
2994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002995run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002996 "$P_SRV key_file=data_files/server2.key \
2997 crt_file=data_files/server2.ku-ke.crt" \
2998 "$P_CLI" \
2999 0 \
3000 -c "Ciphersuite is TLS-RSA-WITH-"
3001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003002run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003003 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003004 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003005 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003006 1 \
3007 -C "Ciphersuite is "
3008
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003009run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003010 "$P_SRV key_file=data_files/server5.key \
3011 crt_file=data_files/server5.ku-ds.crt" \
3012 "$P_CLI" \
3013 0 \
3014 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3015
3016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003017run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003018 "$P_SRV key_file=data_files/server5.key \
3019 crt_file=data_files/server5.ku-ka.crt" \
3020 "$P_CLI" \
3021 0 \
3022 -c "Ciphersuite is TLS-ECDH-"
3023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003024run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003025 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003026 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003027 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003028 1 \
3029 -C "Ciphersuite is "
3030
3031# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003032# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003034run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003035 "$O_SRV -key data_files/server2.key \
3036 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003037 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003038 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3039 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003040 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003041 -C "Processing of the Certificate handshake message failed" \
3042 -c "Ciphersuite is TLS-"
3043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003044run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003045 "$O_SRV -key data_files/server2.key \
3046 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003047 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003048 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3049 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003050 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003051 -C "Processing of the Certificate handshake message failed" \
3052 -c "Ciphersuite is TLS-"
3053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003054run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003055 "$O_SRV -key data_files/server2.key \
3056 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003057 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003058 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3059 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003060 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003061 -C "Processing of the Certificate handshake message failed" \
3062 -c "Ciphersuite is TLS-"
3063
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003064run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003065 "$O_SRV -key data_files/server2.key \
3066 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003067 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003068 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3069 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003070 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003071 -c "Processing of the Certificate handshake message failed" \
3072 -C "Ciphersuite is TLS-"
3073
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003074run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3075 "$O_SRV -key data_files/server2.key \
3076 -cert data_files/server2.ku-ke.crt" \
3077 "$P_CLI debug_level=1 auth_mode=optional \
3078 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3079 0 \
3080 -c "bad certificate (usage extensions)" \
3081 -C "Processing of the Certificate handshake message failed" \
3082 -c "Ciphersuite is TLS-" \
3083 -c "! Usage does not match the keyUsage extension"
3084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003085run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003086 "$O_SRV -key data_files/server2.key \
3087 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003088 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003089 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3090 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003091 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003092 -C "Processing of the Certificate handshake message failed" \
3093 -c "Ciphersuite is TLS-"
3094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003095run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003096 "$O_SRV -key data_files/server2.key \
3097 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003098 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003099 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3100 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003101 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003102 -c "Processing of the Certificate handshake message failed" \
3103 -C "Ciphersuite is TLS-"
3104
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003105run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3106 "$O_SRV -key data_files/server2.key \
3107 -cert data_files/server2.ku-ds.crt" \
3108 "$P_CLI debug_level=1 auth_mode=optional \
3109 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3110 0 \
3111 -c "bad certificate (usage extensions)" \
3112 -C "Processing of the Certificate handshake message failed" \
3113 -c "Ciphersuite is TLS-" \
3114 -c "! Usage does not match the keyUsage extension"
3115
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003116# Tests for keyUsage in leaf certificates, part 3:
3117# server-side checking of client cert
3118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003119run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003120 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003121 "$O_CLI -key data_files/server2.key \
3122 -cert data_files/server2.ku-ds.crt" \
3123 0 \
3124 -S "bad certificate (usage extensions)" \
3125 -S "Processing of the Certificate handshake message failed"
3126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003127run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003128 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003129 "$O_CLI -key data_files/server2.key \
3130 -cert data_files/server2.ku-ke.crt" \
3131 0 \
3132 -s "bad certificate (usage extensions)" \
3133 -S "Processing of the Certificate handshake message failed"
3134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003135run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003136 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003137 "$O_CLI -key data_files/server2.key \
3138 -cert data_files/server2.ku-ke.crt" \
3139 1 \
3140 -s "bad certificate (usage extensions)" \
3141 -s "Processing of the Certificate handshake message failed"
3142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003143run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003144 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003145 "$O_CLI -key data_files/server5.key \
3146 -cert data_files/server5.ku-ds.crt" \
3147 0 \
3148 -S "bad certificate (usage extensions)" \
3149 -S "Processing of the Certificate handshake message failed"
3150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003151run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003152 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003153 "$O_CLI -key data_files/server5.key \
3154 -cert data_files/server5.ku-ka.crt" \
3155 0 \
3156 -s "bad certificate (usage extensions)" \
3157 -S "Processing of the Certificate handshake message failed"
3158
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003159# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003161run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003162 "$P_SRV key_file=data_files/server5.key \
3163 crt_file=data_files/server5.eku-srv.crt" \
3164 "$P_CLI" \
3165 0
3166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003167run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003168 "$P_SRV key_file=data_files/server5.key \
3169 crt_file=data_files/server5.eku-srv.crt" \
3170 "$P_CLI" \
3171 0
3172
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003173run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003174 "$P_SRV key_file=data_files/server5.key \
3175 crt_file=data_files/server5.eku-cs_any.crt" \
3176 "$P_CLI" \
3177 0
3178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003179run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003180 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003181 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003182 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003183 1
3184
3185# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003187run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003188 "$O_SRV -key data_files/server5.key \
3189 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003190 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003191 0 \
3192 -C "bad certificate (usage extensions)" \
3193 -C "Processing of the Certificate handshake message failed" \
3194 -c "Ciphersuite is TLS-"
3195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003196run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003197 "$O_SRV -key data_files/server5.key \
3198 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003199 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003200 0 \
3201 -C "bad certificate (usage extensions)" \
3202 -C "Processing of the Certificate handshake message failed" \
3203 -c "Ciphersuite is TLS-"
3204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003205run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003206 "$O_SRV -key data_files/server5.key \
3207 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003208 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003209 0 \
3210 -C "bad certificate (usage extensions)" \
3211 -C "Processing of the Certificate handshake message failed" \
3212 -c "Ciphersuite is TLS-"
3213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003214run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003215 "$O_SRV -key data_files/server5.key \
3216 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003217 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003218 1 \
3219 -c "bad certificate (usage extensions)" \
3220 -c "Processing of the Certificate handshake message failed" \
3221 -C "Ciphersuite is TLS-"
3222
3223# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003225run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003226 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003227 "$O_CLI -key data_files/server5.key \
3228 -cert data_files/server5.eku-cli.crt" \
3229 0 \
3230 -S "bad certificate (usage extensions)" \
3231 -S "Processing of the Certificate handshake message failed"
3232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003233run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003234 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003235 "$O_CLI -key data_files/server5.key \
3236 -cert data_files/server5.eku-srv_cli.crt" \
3237 0 \
3238 -S "bad certificate (usage extensions)" \
3239 -S "Processing of the Certificate handshake message failed"
3240
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003241run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003242 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003243 "$O_CLI -key data_files/server5.key \
3244 -cert data_files/server5.eku-cs_any.crt" \
3245 0 \
3246 -S "bad certificate (usage extensions)" \
3247 -S "Processing of the Certificate handshake message failed"
3248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003249run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003250 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003251 "$O_CLI -key data_files/server5.key \
3252 -cert data_files/server5.eku-cs.crt" \
3253 0 \
3254 -s "bad certificate (usage extensions)" \
3255 -S "Processing of the Certificate handshake message failed"
3256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003257run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003258 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003259 "$O_CLI -key data_files/server5.key \
3260 -cert data_files/server5.eku-cs.crt" \
3261 1 \
3262 -s "bad certificate (usage extensions)" \
3263 -s "Processing of the Certificate handshake message failed"
3264
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003265# Tests for DHM parameters loading
3266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003267run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003268 "$P_SRV" \
3269 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3270 debug_level=3" \
3271 0 \
3272 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003273 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003275run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003276 "$P_SRV dhm_file=data_files/dhparams.pem" \
3277 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3278 debug_level=3" \
3279 0 \
3280 -c "value of 'DHM: P ' (1024 bits)" \
3281 -c "value of 'DHM: G ' (2 bits)"
3282
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003283# Tests for DHM client-side size checking
3284
3285run_test "DHM size: server default, client default, OK" \
3286 "$P_SRV" \
3287 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3288 debug_level=1" \
3289 0 \
3290 -C "DHM prime too short:"
3291
3292run_test "DHM size: server default, client 2048, OK" \
3293 "$P_SRV" \
3294 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3295 debug_level=1 dhmlen=2048" \
3296 0 \
3297 -C "DHM prime too short:"
3298
3299run_test "DHM size: server 1024, client default, OK" \
3300 "$P_SRV dhm_file=data_files/dhparams.pem" \
3301 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3302 debug_level=1" \
3303 0 \
3304 -C "DHM prime too short:"
3305
3306run_test "DHM size: server 1000, client default, rejected" \
3307 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3308 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3309 debug_level=1" \
3310 1 \
3311 -c "DHM prime too short:"
3312
3313run_test "DHM size: server default, client 2049, rejected" \
3314 "$P_SRV" \
3315 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3316 debug_level=1 dhmlen=2049" \
3317 1 \
3318 -c "DHM prime too short:"
3319
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003320# Tests for PSK callback
3321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003322run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003323 "$P_SRV psk=abc123 psk_identity=foo" \
3324 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3325 psk_identity=foo psk=abc123" \
3326 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003327 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003328 -S "SSL - Unknown identity received" \
3329 -S "SSL - Verification of the message MAC failed"
3330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003331run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003332 "$P_SRV" \
3333 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3334 psk_identity=foo psk=abc123" \
3335 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003336 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003337 -S "SSL - Unknown identity received" \
3338 -S "SSL - Verification of the message MAC failed"
3339
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003340run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003341 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3342 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3343 psk_identity=foo psk=abc123" \
3344 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003345 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003346 -s "SSL - Unknown identity received" \
3347 -S "SSL - Verification of the message MAC failed"
3348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003349run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003350 "$P_SRV psk_list=abc,dead,def,beef" \
3351 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3352 psk_identity=abc psk=dead" \
3353 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003354 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003355 -S "SSL - Unknown identity received" \
3356 -S "SSL - Verification of the message MAC failed"
3357
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003358run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003359 "$P_SRV psk_list=abc,dead,def,beef" \
3360 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3361 psk_identity=def psk=beef" \
3362 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003363 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003364 -S "SSL - Unknown identity received" \
3365 -S "SSL - Verification of the message MAC failed"
3366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003367run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003368 "$P_SRV psk_list=abc,dead,def,beef" \
3369 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3370 psk_identity=ghi psk=beef" \
3371 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003372 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003373 -s "SSL - Unknown identity received" \
3374 -S "SSL - Verification of the message MAC failed"
3375
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003376run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003377 "$P_SRV psk_list=abc,dead,def,beef" \
3378 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3379 psk_identity=abc psk=beef" \
3380 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003381 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003382 -S "SSL - Unknown identity received" \
3383 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003384
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003385# Tests for EC J-PAKE
3386
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003387requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003388run_test "ECJPAKE: client not configured" \
3389 "$P_SRV debug_level=3" \
3390 "$P_CLI debug_level=3" \
3391 0 \
3392 -C "add ciphersuite: c0ff" \
3393 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003394 -S "found ecjpake kkpp extension" \
3395 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003396 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003397 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003398 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003399 -S "None of the common ciphersuites is usable"
3400
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003401requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003402run_test "ECJPAKE: server not configured" \
3403 "$P_SRV debug_level=3" \
3404 "$P_CLI debug_level=3 ecjpake_pw=bla \
3405 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3406 1 \
3407 -c "add ciphersuite: c0ff" \
3408 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003409 -s "found ecjpake kkpp extension" \
3410 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003411 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003412 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003413 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003414 -s "None of the common ciphersuites is usable"
3415
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003416requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003417run_test "ECJPAKE: working, TLS" \
3418 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3419 "$P_CLI debug_level=3 ecjpake_pw=bla \
3420 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003421 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003422 -c "add ciphersuite: c0ff" \
3423 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003424 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003425 -s "found ecjpake kkpp extension" \
3426 -S "skip ecjpake kkpp extension" \
3427 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003428 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003429 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003430 -S "None of the common ciphersuites is usable" \
3431 -S "SSL - Verification of the message MAC failed"
3432
Janos Follath74537a62016-09-02 13:45:28 +01003433server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003434requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003435run_test "ECJPAKE: password mismatch, TLS" \
3436 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3437 "$P_CLI debug_level=3 ecjpake_pw=bad \
3438 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3439 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003440 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003441 -s "SSL - Verification of the message MAC failed"
3442
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003443requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003444run_test "ECJPAKE: working, DTLS" \
3445 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3446 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3447 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3448 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003449 -c "re-using cached ecjpake parameters" \
3450 -S "SSL - Verification of the message MAC failed"
3451
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003452requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003453run_test "ECJPAKE: working, DTLS, no cookie" \
3454 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3455 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3456 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3457 0 \
3458 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003459 -S "SSL - Verification of the message MAC failed"
3460
Janos Follath74537a62016-09-02 13:45:28 +01003461server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003462requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003463run_test "ECJPAKE: password mismatch, DTLS" \
3464 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3465 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3466 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3467 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003468 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003469 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003470
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003471# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003472requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003473run_test "ECJPAKE: working, DTLS, nolog" \
3474 "$P_SRV dtls=1 ecjpake_pw=bla" \
3475 "$P_CLI dtls=1 ecjpake_pw=bla \
3476 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3477 0
3478
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003479# Tests for ciphersuites per version
3480
Janos Follathe2681a42016-03-07 15:57:05 +00003481requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003482run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003483 "$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 +02003484 "$P_CLI force_version=ssl3" \
3485 0 \
3486 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003488run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003489 "$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 +01003490 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003491 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003492 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003494run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003495 "$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 +02003496 "$P_CLI force_version=tls1_1" \
3497 0 \
3498 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3499
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003500run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003501 "$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 +02003502 "$P_CLI force_version=tls1_2" \
3503 0 \
3504 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3505
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003506# Test for ClientHello without extensions
3507
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003508requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003509run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003510 "$P_SRV debug_level=3" \
3511 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3512 0 \
3513 -s "dumping 'client hello extensions' (0 bytes)"
3514
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003515requires_gnutls
3516run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3517 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3518 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3519 0 \
3520 -s "dumping 'client hello extensions' (0 bytes)"
3521
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003522# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003523
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003524run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003525 "$P_SRV" \
3526 "$P_CLI request_size=100" \
3527 0 \
3528 -s "Read from client: 100 bytes read$"
3529
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003530run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003531 "$P_SRV" \
3532 "$P_CLI request_size=500" \
3533 0 \
3534 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003535
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003536# Tests for small packets
3537
Janos Follathe2681a42016-03-07 15:57:05 +00003538requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003539run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003540 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003541 "$P_CLI request_size=1 force_version=ssl3 \
3542 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3543 0 \
3544 -s "Read from client: 1 bytes read"
3545
Janos Follathe2681a42016-03-07 15:57:05 +00003546requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003547run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003548 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003549 "$P_CLI request_size=1 force_version=ssl3 \
3550 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3551 0 \
3552 -s "Read from client: 1 bytes read"
3553
3554run_test "Small packet TLS 1.0 BlockCipher" \
3555 "$P_SRV" \
3556 "$P_CLI request_size=1 force_version=tls1 \
3557 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3558 0 \
3559 -s "Read from client: 1 bytes read"
3560
Hanno Becker8501f982017-11-10 08:59:04 +00003561run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003562 "$P_SRV" \
3563 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3564 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3565 0 \
3566 -s "Read from client: 1 bytes read"
3567
Hanno Becker32c55012017-11-10 08:42:54 +00003568requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003569run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003570 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003571 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003572 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003573 0 \
3574 -s "Read from client: 1 bytes read"
3575
Hanno Becker32c55012017-11-10 08:42:54 +00003576requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003577run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003578 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003579 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003580 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003581 0 \
3582 -s "Read from client: 1 bytes read"
3583
3584run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003585 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003586 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003587 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3588 0 \
3589 -s "Read from client: 1 bytes read"
3590
3591run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3592 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3593 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003594 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003595 0 \
3596 -s "Read from client: 1 bytes read"
3597
3598requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3599run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003600 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003601 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003602 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003603 0 \
3604 -s "Read from client: 1 bytes read"
3605
Hanno Becker8501f982017-11-10 08:59:04 +00003606requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3607run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003608 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3609 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3610 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003611 0 \
3612 -s "Read from client: 1 bytes read"
3613
3614run_test "Small packet TLS 1.1 BlockCipher" \
3615 "$P_SRV" \
3616 "$P_CLI request_size=1 force_version=tls1_1 \
3617 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3618 0 \
3619 -s "Read from client: 1 bytes read"
3620
Hanno Becker8501f982017-11-10 08:59:04 +00003621run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003622 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003623 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003624 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003625 0 \
3626 -s "Read from client: 1 bytes read"
3627
3628requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3629run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003630 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003631 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003632 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003633 0 \
3634 -s "Read from client: 1 bytes read"
3635
3636requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3637run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003638 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003639 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003640 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003641 0 \
3642 -s "Read from client: 1 bytes read"
3643
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003644run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003645 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003646 "$P_CLI request_size=1 force_version=tls1_1 \
3647 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3648 0 \
3649 -s "Read from client: 1 bytes read"
3650
Hanno Becker8501f982017-11-10 08:59:04 +00003651run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3652 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003653 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003654 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003655 0 \
3656 -s "Read from client: 1 bytes read"
3657
Hanno Becker8501f982017-11-10 08:59:04 +00003658requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3659run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003660 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003661 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003662 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003663 0 \
3664 -s "Read from client: 1 bytes read"
3665
Hanno Becker32c55012017-11-10 08:42:54 +00003666requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003667run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003668 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003669 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003670 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003671 0 \
3672 -s "Read from client: 1 bytes read"
3673
3674run_test "Small packet TLS 1.2 BlockCipher" \
3675 "$P_SRV" \
3676 "$P_CLI request_size=1 force_version=tls1_2 \
3677 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3678 0 \
3679 -s "Read from client: 1 bytes read"
3680
Hanno Becker8501f982017-11-10 08:59:04 +00003681run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003682 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003683 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003684 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003685 0 \
3686 -s "Read from client: 1 bytes read"
3687
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003688run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3689 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003690 "$P_CLI request_size=1 force_version=tls1_2 \
3691 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003692 0 \
3693 -s "Read from client: 1 bytes read"
3694
Hanno Becker32c55012017-11-10 08:42:54 +00003695requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003696run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003697 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003698 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003699 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003700 0 \
3701 -s "Read from client: 1 bytes read"
3702
Hanno Becker8501f982017-11-10 08:59:04 +00003703requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3704run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003705 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003706 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003707 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003708 0 \
3709 -s "Read from client: 1 bytes read"
3710
3711run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003712 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003713 "$P_CLI request_size=1 force_version=tls1_2 \
3714 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3715 0 \
3716 -s "Read from client: 1 bytes read"
3717
Hanno Becker8501f982017-11-10 08:59:04 +00003718run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003719 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003720 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003721 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003722 0 \
3723 -s "Read from client: 1 bytes read"
3724
Hanno Becker32c55012017-11-10 08:42:54 +00003725requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker8501f982017-11-10 08:59:04 +00003726run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003727 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003728 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003729 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003730 0 \
3731 -s "Read from client: 1 bytes read"
3732
Hanno Becker8501f982017-11-10 08:59:04 +00003733requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3734run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003735 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003736 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003737 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003738 0 \
3739 -s "Read from client: 1 bytes read"
3740
3741run_test "Small packet TLS 1.2 AEAD" \
3742 "$P_SRV" \
3743 "$P_CLI request_size=1 force_version=tls1_2 \
3744 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3745 0 \
3746 -s "Read from client: 1 bytes read"
3747
3748run_test "Small packet TLS 1.2 AEAD shorter tag" \
3749 "$P_SRV" \
3750 "$P_CLI request_size=1 force_version=tls1_2 \
3751 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3752 0 \
3753 -s "Read from client: 1 bytes read"
3754
Hanno Beckere2148042017-11-10 08:59:18 +00003755# Tests for small packets in DTLS
3756
3757requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3758run_test "Small packet DTLS 1.0" \
3759 "$P_SRV dtls=1 force_version=dtls1" \
3760 "$P_CLI dtls=1 request_size=1 \
3761 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3762 0 \
3763 -s "Read from client: 1 bytes read"
3764
3765requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3766run_test "Small packet DTLS 1.0, without EtM" \
3767 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3768 "$P_CLI dtls=1 request_size=1 \
3769 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3770 0 \
3771 -s "Read from client: 1 bytes read"
3772
3773requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3774requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3775run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003776 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3777 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00003778 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3779 0 \
3780 -s "Read from client: 1 bytes read"
3781
3782requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3783requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3784run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003785 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003786 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003787 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003788 0 \
3789 -s "Read from client: 1 bytes read"
3790
3791requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3792run_test "Small packet DTLS 1.2" \
3793 "$P_SRV dtls=1 force_version=dtls1_2" \
3794 "$P_CLI dtls=1 request_size=1 \
3795 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3796 0 \
3797 -s "Read from client: 1 bytes read"
3798
3799requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3800run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003801 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003802 "$P_CLI dtls=1 request_size=1 \
3803 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3804 0 \
3805 -s "Read from client: 1 bytes read"
3806
3807requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3808requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3809run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003810 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003811 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003812 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00003813 0 \
3814 -s "Read from client: 1 bytes read"
3815
3816requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3817requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3818run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003819 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00003820 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003821 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00003822 0 \
3823 -s "Read from client: 1 bytes read"
3824
Janos Follath00efff72016-05-06 13:48:23 +01003825# A test for extensions in SSLv3
3826
3827requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3828run_test "SSLv3 with extensions, server side" \
3829 "$P_SRV min_version=ssl3 debug_level=3" \
3830 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3831 0 \
3832 -S "dumping 'client hello extensions'" \
3833 -S "server hello, total extension length:"
3834
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003835# Test for large packets
3836
Janos Follathe2681a42016-03-07 15:57:05 +00003837requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003838run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003839 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003840 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003841 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3842 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003843 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003844 -s "Read from client: 16384 bytes read"
3845
Janos Follathe2681a42016-03-07 15:57:05 +00003846requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003847run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003848 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003849 "$P_CLI request_size=16384 force_version=ssl3 \
3850 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3851 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003852 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003853 -s "Read from client: 16384 bytes read"
3854
3855run_test "Large packet TLS 1.0 BlockCipher" \
3856 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003857 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003858 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3859 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003860 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003861 -s "Read from client: 16384 bytes read"
3862
Hanno Becker278fc7a2017-11-10 09:16:28 +00003863run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003864 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003865 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3866 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3867 0 \
3868 -s "Read from client: 16384 bytes read"
3869
Hanno Becker32c55012017-11-10 08:42:54 +00003870requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003871run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003872 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003873 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003874 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003875 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003876 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003877 -s "Read from client: 16384 bytes read"
3878
Hanno Becker32c55012017-11-10 08:42:54 +00003879requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003880run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003881 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003882 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003883 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003884 0 \
3885 -s "Read from client: 16384 bytes read"
3886
3887run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003888 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003889 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003890 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3891 0 \
3892 -s "Read from client: 16384 bytes read"
3893
3894run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3895 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3896 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003897 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003898 0 \
3899 -s "Read from client: 16384 bytes read"
3900
3901requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3902run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003903 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003904 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003905 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003906 0 \
3907 -s "Read from client: 16384 bytes read"
3908
Hanno Becker278fc7a2017-11-10 09:16:28 +00003909requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3910run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003911 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003912 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003913 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003914 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003915 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003916 -s "Read from client: 16384 bytes read"
3917
3918run_test "Large packet TLS 1.1 BlockCipher" \
3919 "$P_SRV" \
3920 "$P_CLI request_size=16384 force_version=tls1_1 \
3921 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3922 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003923 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003924 -s "Read from client: 16384 bytes read"
3925
Hanno Becker278fc7a2017-11-10 09:16:28 +00003926run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3927 "$P_SRV" \
3928 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3929 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003930 0 \
3931 -s "Read from client: 16384 bytes read"
3932
Hanno Becker32c55012017-11-10 08:42:54 +00003933requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003934run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003935 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003936 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003937 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003938 0 \
3939 -s "Read from client: 16384 bytes read"
3940
Hanno Becker32c55012017-11-10 08:42:54 +00003941requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00003942run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003943 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003944 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003945 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003946 0 \
3947 -s "Read from client: 16384 bytes read"
3948
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003949run_test "Large packet TLS 1.1 StreamCipher" \
3950 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3951 "$P_CLI request_size=16384 force_version=tls1_1 \
3952 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3953 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003954 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003955 -s "Read from client: 16384 bytes read"
3956
Hanno Becker278fc7a2017-11-10 09:16:28 +00003957run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
3958 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003959 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003960 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003961 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003962 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003963 -s "Read from client: 16384 bytes read"
3964
Hanno Becker278fc7a2017-11-10 09:16:28 +00003965requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3966run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003967 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003968 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003969 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003970 0 \
3971 -s "Read from client: 16384 bytes read"
3972
Hanno Becker278fc7a2017-11-10 09:16:28 +00003973requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3974run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003975 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00003976 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003977 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003978 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003979 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003980 -s "Read from client: 16384 bytes read"
3981
3982run_test "Large packet TLS 1.2 BlockCipher" \
3983 "$P_SRV" \
3984 "$P_CLI request_size=16384 force_version=tls1_2 \
3985 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3986 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003987 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003988 -s "Read from client: 16384 bytes read"
3989
Hanno Becker278fc7a2017-11-10 09:16:28 +00003990run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
3991 "$P_SRV" \
3992 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
3993 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3994 0 \
3995 -s "Read from client: 16384 bytes read"
3996
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003997run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3998 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003999 "$P_CLI request_size=16384 force_version=tls1_2 \
4000 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004001 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004002 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004003 -s "Read from client: 16384 bytes read"
4004
Hanno Becker32c55012017-11-10 08:42:54 +00004005requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004006run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004007 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004008 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004009 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004010 0 \
4011 -s "Read from client: 16384 bytes read"
4012
Hanno Becker278fc7a2017-11-10 09:16:28 +00004013requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4014run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004015 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004016 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004017 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004018 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004019 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004020 -s "Read from client: 16384 bytes read"
4021
4022run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004023 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004024 "$P_CLI request_size=16384 force_version=tls1_2 \
4025 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4026 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004027 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004028 -s "Read from client: 16384 bytes read"
4029
Hanno Becker278fc7a2017-11-10 09:16:28 +00004030run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004031 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004032 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004033 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4034 0 \
4035 -s "Read from client: 16384 bytes read"
4036
Hanno Becker32c55012017-11-10 08:42:54 +00004037requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker278fc7a2017-11-10 09:16:28 +00004038run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004039 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004040 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004041 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004042 0 \
4043 -s "Read from client: 16384 bytes read"
4044
Hanno Becker278fc7a2017-11-10 09:16:28 +00004045requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4046run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004047 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004048 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004049 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004050 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004051 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004052 -s "Read from client: 16384 bytes read"
4053
4054run_test "Large packet TLS 1.2 AEAD" \
4055 "$P_SRV" \
4056 "$P_CLI request_size=16384 force_version=tls1_2 \
4057 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4058 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004059 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004060 -s "Read from client: 16384 bytes read"
4061
4062run_test "Large packet TLS 1.2 AEAD shorter tag" \
4063 "$P_SRV" \
4064 "$P_CLI request_size=16384 force_version=tls1_2 \
4065 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4066 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004067 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004068 -s "Read from client: 16384 bytes read"
4069
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004070# Tests of asynchronous private key support in SSL
4071
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004072requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004073run_test "SSL async private: sign, delay=0" \
4074 "$P_SRV \
4075 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004076 "$P_CLI" \
4077 0 \
4078 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004079 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004080
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004081requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004082run_test "SSL async private: sign, delay=1" \
4083 "$P_SRV \
4084 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004085 "$P_CLI" \
4086 0 \
4087 -s "Async sign callback: using key slot " \
4088 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004089 -s "Async resume (slot [0-9]): sign done, status=0"
4090
Gilles Peskine12d0cc12018-04-26 15:06:56 +02004091requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4092run_test "SSL async private: sign, delay=2" \
4093 "$P_SRV \
4094 async_operations=s async_private_delay1=2 async_private_delay2=2" \
4095 "$P_CLI" \
4096 0 \
4097 -s "Async sign callback: using key slot " \
4098 -U "Async sign callback: using key slot " \
4099 -s "Async resume (slot [0-9]): call 1 more times." \
4100 -s "Async resume (slot [0-9]): call 0 more times." \
4101 -s "Async resume (slot [0-9]): sign done, status=0"
4102
Gilles Peskined3268832018-04-26 06:23:59 +02004103# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
4104# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
4105requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
4106requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4107run_test "SSL async private: sign, RSA, TLS 1.1" \
4108 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
4109 async_operations=s async_private_delay1=0 async_private_delay2=0" \
4110 "$P_CLI force_version=tls1_1" \
4111 0 \
4112 -s "Async sign callback: using key slot " \
4113 -s "Async resume (slot [0-9]): sign done, status=0"
4114
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004115requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004116run_test "SSL async private: decrypt, delay=0" \
4117 "$P_SRV \
4118 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4119 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4120 0 \
4121 -s "Async decrypt callback: using key slot " \
4122 -s "Async resume (slot [0-9]): decrypt done, status=0"
4123
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004124requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004125run_test "SSL async private: decrypt, delay=1" \
4126 "$P_SRV \
4127 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4128 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4129 0 \
4130 -s "Async decrypt callback: using key slot " \
4131 -s "Async resume (slot [0-9]): call 0 more times." \
4132 -s "Async resume (slot [0-9]): decrypt done, status=0"
4133
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004134requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004135run_test "SSL async private: decrypt RSA-PSK, delay=0" \
4136 "$P_SRV psk=abc123 \
4137 async_operations=d async_private_delay1=0 async_private_delay2=0" \
4138 "$P_CLI psk=abc123 \
4139 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4140 0 \
4141 -s "Async decrypt callback: using key slot " \
4142 -s "Async resume (slot [0-9]): decrypt done, status=0"
4143
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004144requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004145run_test "SSL async private: decrypt RSA-PSK, delay=1" \
4146 "$P_SRV psk=abc123 \
4147 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4148 "$P_CLI psk=abc123 \
4149 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
4150 0 \
4151 -s "Async decrypt callback: using key slot " \
4152 -s "Async resume (slot [0-9]): call 0 more times." \
4153 -s "Async resume (slot [0-9]): decrypt done, status=0"
4154
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004155requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004156run_test "SSL async private: sign callback not present" \
4157 "$P_SRV \
4158 async_operations=d async_private_delay1=1 async_private_delay2=1" \
4159 "$P_CLI; [ \$? -eq 1 ] &&
4160 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4161 0 \
4162 -S "Async sign callback" \
4163 -s "! mbedtls_ssl_handshake returned" \
4164 -s "The own private key or pre-shared key is not set, but needed" \
4165 -s "Async resume (slot [0-9]): decrypt done, status=0" \
4166 -s "Successful connection"
4167
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004168requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004169run_test "SSL async private: decrypt callback not present" \
4170 "$P_SRV debug_level=1 \
4171 async_operations=s async_private_delay1=1 async_private_delay2=1" \
4172 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
4173 [ \$? -eq 1 ] && $P_CLI" \
4174 0 \
4175 -S "Async decrypt callback" \
4176 -s "! mbedtls_ssl_handshake returned" \
4177 -s "got no RSA private key" \
4178 -s "Async resume (slot [0-9]): sign done, status=0" \
4179 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004180
4181# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004182requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004183run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004184 "$P_SRV \
4185 async_operations=s async_private_delay1=1 \
4186 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4187 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004188 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4189 0 \
4190 -s "Async sign callback: using key slot 0," \
4191 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004192 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004193
4194# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004195requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004196run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004197 "$P_SRV \
4198 async_operations=s async_private_delay2=1 \
4199 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4200 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004201 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4202 0 \
4203 -s "Async sign callback: using key slot 0," \
4204 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004205 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004206
4207# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004208requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02004209run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004210 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02004211 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004212 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4213 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004214 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4215 0 \
4216 -s "Async sign callback: using key slot 1," \
4217 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004218 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004219
4220# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004221requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004222run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004223 "$P_SRV \
4224 async_operations=s async_private_delay1=1 \
4225 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4226 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004227 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4228 0 \
4229 -s "Async sign callback: no key matches this certificate."
4230
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004231requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004232run_test "SSL async private: error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004233 "$P_SRV \
4234 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4235 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004236 "$P_CLI" \
4237 1 \
4238 -s "Async sign callback: injected error" \
4239 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004240 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004241 -s "! mbedtls_ssl_handshake returned"
4242
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004243requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004244run_test "SSL async private: cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004245 "$P_SRV \
4246 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4247 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004248 "$P_CLI" \
4249 1 \
4250 -s "Async sign callback: using key slot " \
4251 -S "Async resume" \
4252 -s "Async cancel"
4253
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004254requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004255run_test "SSL async private: error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004256 "$P_SRV \
4257 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4258 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004259 "$P_CLI" \
4260 1 \
4261 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004262 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004263 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004264 -s "! mbedtls_ssl_handshake returned"
4265
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004266requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004267run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004268 "$P_SRV \
4269 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4270 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004271 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4272 0 \
4273 -s "Async cancel" \
4274 -s "! mbedtls_ssl_handshake returned" \
4275 -s "Async resume" \
4276 -s "Successful connection"
4277
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004278requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004279run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004280 "$P_SRV \
4281 async_operations=s async_private_delay1=1 async_private_delay2=1 \
4282 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004283 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
4284 0 \
4285 -s "! mbedtls_ssl_handshake returned" \
4286 -s "Async resume" \
4287 -s "Successful connection"
4288
4289# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004290requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004291run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004292 "$P_SRV \
4293 async_operations=s async_private_delay1=1 async_private_error=-2 \
4294 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4295 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004296 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
4297 [ \$? -eq 1 ] &&
4298 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4299 0 \
Gilles Peskine37289cd2018-04-27 11:50:14 +02004300 -s "Async sign callback: using key slot 0"
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004301 -S "Async resume" \
4302 -s "Async cancel" \
4303 -s "! mbedtls_ssl_handshake returned" \
4304 -s "Async sign callback: no key matches this certificate." \
4305 -s "Successful connection"
4306
4307# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004308requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004309run_test "SSL async private: error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004310 "$P_SRV \
4311 async_operations=s async_private_delay1=1 async_private_error=-3 \
4312 key_file=data_files/server5.key crt_file=data_files/server5.crt \
4313 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01004314 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
4315 [ \$? -eq 1 ] &&
4316 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
4317 0 \
4318 -s "Async resume" \
4319 -s "! mbedtls_ssl_handshake returned" \
4320 -s "Async sign callback: no key matches this certificate." \
4321 -s "Successful connection"
4322
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004323requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004324requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004325run_test "SSL async private: renegotiation: client-initiated; sign" \
4326 "$P_SRV \
4327 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004328 exchanges=2 renegotiation=1" \
4329 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
4330 0 \
4331 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004332 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004333
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004334requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004335requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004336run_test "SSL async private: renegotiation: server-initiated; sign" \
4337 "$P_SRV \
4338 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004339 exchanges=2 renegotiation=1 renegotiate=1" \
4340 "$P_CLI exchanges=2 renegotiation=1" \
4341 0 \
4342 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004343 -s "Async resume (slot [0-9]): sign done, status=0"
4344
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004345requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004346requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
4347run_test "SSL async private: renegotiation: client-initiated; decrypt" \
4348 "$P_SRV \
4349 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4350 exchanges=2 renegotiation=1" \
4351 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
4352 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4353 0 \
4354 -s "Async decrypt callback: using key slot " \
4355 -s "Async resume (slot [0-9]): decrypt done, status=0"
4356
Gilles Peskineb74a1c72018-04-24 13:09:22 +02004357requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01004358requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
4359run_test "SSL async private: renegotiation: server-initiated; decrypt" \
4360 "$P_SRV \
4361 async_operations=d async_private_delay1=1 async_private_delay2=1 \
4362 exchanges=2 renegotiation=1 renegotiate=1" \
4363 "$P_CLI exchanges=2 renegotiation=1 \
4364 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4365 0 \
4366 -s "Async decrypt callback: using key slot " \
4367 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01004368
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004369# Tests for DTLS HelloVerifyRequest
4370
4371run_test "DTLS cookie: enabled" \
4372 "$P_SRV dtls=1 debug_level=2" \
4373 "$P_CLI dtls=1 debug_level=2" \
4374 0 \
4375 -s "cookie verification failed" \
4376 -s "cookie verification passed" \
4377 -S "cookie verification skipped" \
4378 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004379 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004380 -S "SSL - The requested feature is not available"
4381
4382run_test "DTLS cookie: disabled" \
4383 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4384 "$P_CLI dtls=1 debug_level=2" \
4385 0 \
4386 -S "cookie verification failed" \
4387 -S "cookie verification passed" \
4388 -s "cookie verification skipped" \
4389 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004390 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004391 -S "SSL - The requested feature is not available"
4392
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004393run_test "DTLS cookie: default (failing)" \
4394 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4395 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4396 1 \
4397 -s "cookie verification failed" \
4398 -S "cookie verification passed" \
4399 -S "cookie verification skipped" \
4400 -C "received hello verify request" \
4401 -S "hello verification requested" \
4402 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004403
4404requires_ipv6
4405run_test "DTLS cookie: enabled, IPv6" \
4406 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4407 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4408 0 \
4409 -s "cookie verification failed" \
4410 -s "cookie verification passed" \
4411 -S "cookie verification skipped" \
4412 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004413 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004414 -S "SSL - The requested feature is not available"
4415
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004416run_test "DTLS cookie: enabled, nbio" \
4417 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4418 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4419 0 \
4420 -s "cookie verification failed" \
4421 -s "cookie verification passed" \
4422 -S "cookie verification skipped" \
4423 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004424 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004425 -S "SSL - The requested feature is not available"
4426
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004427# Tests for client reconnecting from the same port with DTLS
4428
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004429not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004430run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004431 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4432 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004433 0 \
4434 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004435 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004436 -S "Client initiated reconnection from same port"
4437
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004438not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004439run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004440 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4441 "$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 +02004442 0 \
4443 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004444 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004445 -s "Client initiated reconnection from same port"
4446
Paul Bakker362689d2016-05-13 10:33:25 +01004447not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4448run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004449 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4450 "$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 +02004451 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004452 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004453 -s "Client initiated reconnection from same port"
4454
Paul Bakker362689d2016-05-13 10:33:25 +01004455only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
4456run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
4457 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
4458 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
4459 0 \
4460 -S "The operation timed out" \
4461 -s "Client initiated reconnection from same port"
4462
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004463run_test "DTLS client reconnect from same port: no cookies" \
4464 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02004465 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
4466 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004467 -s "The operation timed out" \
4468 -S "Client initiated reconnection from same port"
4469
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004470# Tests for various cases of client authentication with DTLS
4471# (focused on handshake flows and message parsing)
4472
4473run_test "DTLS client auth: required" \
4474 "$P_SRV dtls=1 auth_mode=required" \
4475 "$P_CLI dtls=1" \
4476 0 \
4477 -s "Verifying peer X.509 certificate... ok"
4478
4479run_test "DTLS client auth: optional, client has no cert" \
4480 "$P_SRV dtls=1 auth_mode=optional" \
4481 "$P_CLI dtls=1 crt_file=none key_file=none" \
4482 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004483 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004484
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004485run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004486 "$P_SRV dtls=1 auth_mode=none" \
4487 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
4488 0 \
4489 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004490 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02004491
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02004492run_test "DTLS wrong PSK: badmac alert" \
4493 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
4494 "$P_CLI dtls=1 psk=abc124" \
4495 1 \
4496 -s "SSL - Verification of the message MAC failed" \
4497 -c "SSL - A fatal alert message was received from our peer"
4498
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02004499# Tests for receiving fragmented handshake messages with DTLS
4500
4501requires_gnutls
4502run_test "DTLS reassembly: no fragmentation (gnutls server)" \
4503 "$G_SRV -u --mtu 2048 -a" \
4504 "$P_CLI dtls=1 debug_level=2" \
4505 0 \
4506 -C "found fragmented DTLS handshake message" \
4507 -C "error"
4508
4509requires_gnutls
4510run_test "DTLS reassembly: some fragmentation (gnutls server)" \
4511 "$G_SRV -u --mtu 512" \
4512 "$P_CLI dtls=1 debug_level=2" \
4513 0 \
4514 -c "found fragmented DTLS handshake message" \
4515 -C "error"
4516
4517requires_gnutls
4518run_test "DTLS reassembly: more fragmentation (gnutls server)" \
4519 "$G_SRV -u --mtu 128" \
4520 "$P_CLI dtls=1 debug_level=2" \
4521 0 \
4522 -c "found fragmented DTLS handshake message" \
4523 -C "error"
4524
4525requires_gnutls
4526run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
4527 "$G_SRV -u --mtu 128" \
4528 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4529 0 \
4530 -c "found fragmented DTLS handshake message" \
4531 -C "error"
4532
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004533requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004534requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004535run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
4536 "$G_SRV -u --mtu 256" \
4537 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4538 0 \
4539 -c "found fragmented DTLS handshake message" \
4540 -c "client hello, adding renegotiation extension" \
4541 -c "found renegotiation extension" \
4542 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004543 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004544 -C "error" \
4545 -s "Extra-header:"
4546
4547requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01004548requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004549run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4550 "$G_SRV -u --mtu 256" \
4551 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4552 0 \
4553 -c "found fragmented DTLS handshake message" \
4554 -c "client hello, adding renegotiation extension" \
4555 -c "found renegotiation extension" \
4556 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004557 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02004558 -C "error" \
4559 -s "Extra-header:"
4560
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004561run_test "DTLS reassembly: no fragmentation (openssl server)" \
4562 "$O_SRV -dtls1 -mtu 2048" \
4563 "$P_CLI dtls=1 debug_level=2" \
4564 0 \
4565 -C "found fragmented DTLS handshake message" \
4566 -C "error"
4567
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004568run_test "DTLS reassembly: some fragmentation (openssl server)" \
4569 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004570 "$P_CLI dtls=1 debug_level=2" \
4571 0 \
4572 -c "found fragmented DTLS handshake message" \
4573 -C "error"
4574
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004575run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004576 "$O_SRV -dtls1 -mtu 256" \
4577 "$P_CLI dtls=1 debug_level=2" \
4578 0 \
4579 -c "found fragmented DTLS handshake message" \
4580 -C "error"
4581
4582run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4583 "$O_SRV -dtls1 -mtu 256" \
4584 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4585 0 \
4586 -c "found fragmented DTLS handshake message" \
4587 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004588
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004589# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004590
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004591not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004592run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004593 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004594 "$P_SRV dtls=1 debug_level=2" \
4595 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004596 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004597 -C "replayed record" \
4598 -S "replayed record" \
4599 -C "record from another epoch" \
4600 -S "record from another epoch" \
4601 -C "discarding invalid record" \
4602 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004603 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004604 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004605 -c "HTTP/1.0 200 OK"
4606
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004607not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004608run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004609 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004610 "$P_SRV dtls=1 debug_level=2" \
4611 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004612 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004613 -c "replayed record" \
4614 -s "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01004615 -c "record from another epoch" \
4616 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004617 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004618 -s "Extra-header:" \
4619 -c "HTTP/1.0 200 OK"
4620
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004621run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4622 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004623 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4624 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004625 0 \
4626 -c "replayed record" \
4627 -S "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01004628 -c "record from another epoch" \
4629 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004630 -c "resend" \
4631 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004632 -s "Extra-header:" \
4633 -c "HTTP/1.0 200 OK"
4634
Hanno Becker72a4f032017-11-15 16:39:20 +00004635run_test "DTLS proxy: multiple records in same datagram" \
Hanno Becker8d832182018-03-15 10:14:19 +00004636 -p "$P_PXY pack=50" \
Hanno Becker72a4f032017-11-15 16:39:20 +00004637 "$P_SRV dtls=1 debug_level=2" \
4638 "$P_CLI dtls=1 debug_level=2" \
4639 0 \
4640 -c "next record in same datagram" \
4641 -s "next record in same datagram"
4642
4643run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
Hanno Becker8d832182018-03-15 10:14:19 +00004644 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker72a4f032017-11-15 16:39:20 +00004645 "$P_SRV dtls=1 debug_level=2" \
4646 "$P_CLI dtls=1 debug_level=2" \
4647 0 \
4648 -c "next record in same datagram" \
4649 -s "next record in same datagram"
4650
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004651run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004652 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004653 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004654 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004655 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004656 -c "discarding invalid record (mac)" \
4657 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004658 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004659 -c "HTTP/1.0 200 OK" \
4660 -S "too many records with bad MAC" \
4661 -S "Verification of the message MAC failed"
4662
4663run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4664 -p "$P_PXY bad_ad=1" \
4665 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4666 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4667 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004668 -C "discarding invalid record (mac)" \
4669 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004670 -S "Extra-header:" \
4671 -C "HTTP/1.0 200 OK" \
4672 -s "too many records with bad MAC" \
4673 -s "Verification of the message MAC failed"
4674
4675run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4676 -p "$P_PXY bad_ad=1" \
4677 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4678 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4679 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004680 -c "discarding invalid record (mac)" \
4681 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004682 -s "Extra-header:" \
4683 -c "HTTP/1.0 200 OK" \
4684 -S "too many records with bad MAC" \
4685 -S "Verification of the message MAC failed"
4686
4687run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4688 -p "$P_PXY bad_ad=1" \
4689 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4690 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4691 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004692 -c "discarding invalid record (mac)" \
4693 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004694 -s "Extra-header:" \
4695 -c "HTTP/1.0 200 OK" \
4696 -s "too many records with bad MAC" \
4697 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004698
4699run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004700 -p "$P_PXY delay_ccs=1" \
4701 "$P_SRV dtls=1 debug_level=1" \
4702 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004703 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004704 -c "record from another epoch" \
4705 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004706 -s "Extra-header:" \
4707 -c "HTTP/1.0 200 OK"
4708
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004709# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004710
Janos Follath74537a62016-09-02 13:45:28 +01004711client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004712run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004713 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004714 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4715 psk=abc123" \
4716 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004717 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4718 0 \
4719 -s "Extra-header:" \
4720 -c "HTTP/1.0 200 OK"
4721
Janos Follath74537a62016-09-02 13:45:28 +01004722client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004723run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4724 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004725 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4726 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004727 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4728 0 \
4729 -s "Extra-header:" \
4730 -c "HTTP/1.0 200 OK"
4731
Janos Follath74537a62016-09-02 13:45:28 +01004732client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004733run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4734 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004735 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4736 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004737 0 \
4738 -s "Extra-header:" \
4739 -c "HTTP/1.0 200 OK"
4740
Janos Follath74537a62016-09-02 13:45:28 +01004741client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004742run_test "DTLS proxy: 3d, FS, client auth" \
4743 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004744 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4745 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004746 0 \
4747 -s "Extra-header:" \
4748 -c "HTTP/1.0 200 OK"
4749
Janos Follath74537a62016-09-02 13:45:28 +01004750client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004751run_test "DTLS proxy: 3d, FS, ticket" \
4752 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004753 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4754 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004755 0 \
4756 -s "Extra-header:" \
4757 -c "HTTP/1.0 200 OK"
4758
Janos Follath74537a62016-09-02 13:45:28 +01004759client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004760run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4761 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004762 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4763 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004764 0 \
4765 -s "Extra-header:" \
4766 -c "HTTP/1.0 200 OK"
4767
Janos Follath74537a62016-09-02 13:45:28 +01004768client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004769run_test "DTLS proxy: 3d, max handshake, nbio" \
4770 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004771 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4772 auth_mode=required" \
4773 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004774 0 \
4775 -s "Extra-header:" \
4776 -c "HTTP/1.0 200 OK"
4777
Janos Follath74537a62016-09-02 13:45:28 +01004778client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004779run_test "DTLS proxy: 3d, min handshake, resumption" \
4780 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4781 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4782 psk=abc123 debug_level=3" \
4783 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4784 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4785 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4786 0 \
4787 -s "a session has been resumed" \
4788 -c "a session has been resumed" \
4789 -s "Extra-header:" \
4790 -c "HTTP/1.0 200 OK"
4791
Janos Follath74537a62016-09-02 13:45:28 +01004792client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004793run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4794 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4795 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4796 psk=abc123 debug_level=3 nbio=2" \
4797 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4798 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4799 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4800 0 \
4801 -s "a session has been resumed" \
4802 -c "a session has been resumed" \
4803 -s "Extra-header:" \
4804 -c "HTTP/1.0 200 OK"
4805
Janos Follath74537a62016-09-02 13:45:28 +01004806client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004807requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004808run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004809 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004810 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4811 psk=abc123 renegotiation=1 debug_level=2" \
4812 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4813 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004814 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4815 0 \
4816 -c "=> renegotiate" \
4817 -s "=> renegotiate" \
4818 -s "Extra-header:" \
4819 -c "HTTP/1.0 200 OK"
4820
Janos Follath74537a62016-09-02 13:45:28 +01004821client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004822requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004823run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4824 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004825 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4826 psk=abc123 renegotiation=1 debug_level=2" \
4827 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4828 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004829 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4830 0 \
4831 -c "=> renegotiate" \
4832 -s "=> renegotiate" \
4833 -s "Extra-header:" \
4834 -c "HTTP/1.0 200 OK"
4835
Janos Follath74537a62016-09-02 13:45:28 +01004836client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004837requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004838run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004839 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004840 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004841 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004842 debug_level=2" \
4843 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004844 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004845 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4846 0 \
4847 -c "=> renegotiate" \
4848 -s "=> renegotiate" \
4849 -s "Extra-header:" \
4850 -c "HTTP/1.0 200 OK"
4851
Janos Follath74537a62016-09-02 13:45:28 +01004852client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004853requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004854run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004855 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004856 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004857 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004858 debug_level=2 nbio=2" \
4859 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004860 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004861 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4862 0 \
4863 -c "=> renegotiate" \
4864 -s "=> renegotiate" \
4865 -s "Extra-header:" \
4866 -c "HTTP/1.0 200 OK"
4867
Janos Follath74537a62016-09-02 13:45:28 +01004868client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004869not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004870run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004871 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4872 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004873 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004874 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004875 -c "HTTP/1.0 200 OK"
4876
Janos Follath74537a62016-09-02 13:45:28 +01004877client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004878not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004879run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4880 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4881 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004882 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004883 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004884 -c "HTTP/1.0 200 OK"
4885
Janos Follath74537a62016-09-02 13:45:28 +01004886client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004887not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004888run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4889 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4890 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004891 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004892 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004893 -c "HTTP/1.0 200 OK"
4894
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004895requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004896client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004897not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004898run_test "DTLS proxy: 3d, gnutls server" \
4899 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4900 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004901 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004902 0 \
4903 -s "Extra-header:" \
4904 -c "Extra-header:"
4905
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004906requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004907client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004908not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004909run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4910 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4911 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004912 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004913 0 \
4914 -s "Extra-header:" \
4915 -c "Extra-header:"
4916
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004917requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004918client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004919not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004920run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4921 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4922 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004923 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004924 0 \
4925 -s "Extra-header:" \
4926 -c "Extra-header:"
4927
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004928# Final report
4929
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004930echo "------------------------------------------------------------------------"
4931
4932if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004933 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004934else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004935 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004936fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004937PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004938echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004939
4940exit $FAILS