blob: 6c336045da8ca35e171942bcb31668543b452cc6 [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
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
235 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
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200289# wait for server to start: two versions depending on lsof availability
290wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200291 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200292 START_TIME=$( date +%s )
293 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200294
295 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200296 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200297 while [ $DONE -eq 0 ]; do
298 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
299 then
300 DONE=1
301 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
302 echo "SERVERSTART TIMEOUT"
303 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
304 DONE=1
305 fi
306 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200307 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200308 while [ $DONE -eq 0 ]; do
309 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
310 then
311 DONE=1
312 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
313 echo "SERVERSTART TIMEOUT"
314 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
315 DONE=1
316 fi
317 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200318 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200319 else
320 sleep "$START_DELAY"
321 fi
322}
323
Andres Amaya Garciaac36e382017-09-06 15:44:01 +0100324# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia5987ef42017-09-14 12:41:29 +0100325# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciaac36e382017-09-06 15:44:01 +0100326# acceptable bounds
327check_server_hello_time() {
328 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garciaacdae0c2017-09-15 15:49:24 +0100329 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciaac36e382017-09-06 15:44:01 +0100330 # Get the Unix timestamp for now
331 CUR_TIME=$(date +'%s')
332 THRESHOLD_IN_SECS=300
333
334 # Check if the ServerHello time was printed
335 if [ -z "$SERVER_HELLO_TIME" ]; then
336 return 1
337 fi
338
339 # Check the time in ServerHello is within acceptable bounds
340 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
341 # The time in ServerHello is at least 5 minutes before now
342 return 1
343 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia5987ef42017-09-14 12:41:29 +0100344 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciaac36e382017-09-06 15:44:01 +0100345 return 1
346 else
347 return 0
348 fi
349}
350
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200351# wait for client to terminate and set CLI_EXIT
352# must be called right after starting the client
353wait_client_done() {
354 CLI_PID=$!
355
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200356 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
357 CLI_DELAY_FACTOR=1
358
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200359 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200360 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200361
362 wait $CLI_PID
363 CLI_EXIT=$?
364
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200365 kill $DOG_PID >/dev/null 2>&1
366 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200367
368 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100369
370 sleep $SRV_DELAY_SECONDS
371 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200372}
373
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200374# check if the given command uses dtls and sets global variable DTLS
375detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200376 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200377 DTLS=1
378 else
379 DTLS=0
380 fi
381}
382
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200383# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100384# Options: -s pattern pattern that must be present in server output
385# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100386# -u pattern lines after pattern must be unique in client output
Andres Amaya Garciaa46a58a2017-09-06 15:38:07 +0100387# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100388# -S pattern pattern that must be absent in server output
389# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100390# -U pattern lines after pattern must be unique in server output
Andres Amaya Garciaa46a58a2017-09-06 15:38:07 +0100391# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100392run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100393 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200394 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100396 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
397 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200398 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100399 return
400 fi
401
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100402 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100403
Paul Bakkerb7584a52016-05-10 10:50:43 +0100404 # Do we only run numbered tests?
405 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
406 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
407 else
408 SKIP_NEXT="YES"
409 fi
410
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200411 # should we skip?
412 if [ "X$SKIP_NEXT" = "XYES" ]; then
413 SKIP_NEXT="NO"
414 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200415 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200416 return
417 fi
418
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200419 # does this test use a proxy?
420 if [ "X$1" = "X-p" ]; then
421 PXY_CMD="$2"
422 shift 2
423 else
424 PXY_CMD=""
425 fi
426
427 # get commands and client output
428 SRV_CMD="$1"
429 CLI_CMD="$2"
430 CLI_EXPECT="$3"
431 shift 3
432
433 # fix client port
434 if [ -n "$PXY_CMD" ]; then
435 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
436 else
437 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
438 fi
439
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200440 # update DTLS variable
441 detect_dtls "$SRV_CMD"
442
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100443 # prepend valgrind to our commands if active
444 if [ "$MEMCHECK" -gt 0 ]; then
445 if is_polar "$SRV_CMD"; then
446 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
447 fi
448 if is_polar "$CLI_CMD"; then
449 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
450 fi
451 fi
452
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200453 TIMES_LEFT=2
454 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200455 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200456
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200457 # run the commands
458 if [ -n "$PXY_CMD" ]; then
459 echo "$PXY_CMD" > $PXY_OUT
460 $PXY_CMD >> $PXY_OUT 2>&1 &
461 PXY_PID=$!
462 # assume proxy starts faster than server
463 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200464
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200465 check_osrv_dtls
466 echo "$SRV_CMD" > $SRV_OUT
467 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
468 SRV_PID=$!
469 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200470
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200471 echo "$CLI_CMD" > $CLI_OUT
472 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
473 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100474
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200475 # terminate the server (and the proxy)
476 kill $SRV_PID
477 wait $SRV_PID
478 if [ -n "$PXY_CMD" ]; then
479 kill $PXY_PID >/dev/null 2>&1
480 wait $PXY_PID
481 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100482
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200483 # retry only on timeouts
484 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
485 printf "RETRY "
486 else
487 TIMES_LEFT=0
488 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200489 done
490
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100491 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200492 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100493 # expected client exit to incorrectly succeed in case of catastrophic
494 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100495 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200496 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100497 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100498 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100499 return
500 fi
501 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100502 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200503 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100504 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100505 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100506 return
507 fi
508 fi
509
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100510 # check server exit code
511 if [ $? != 0 ]; then
512 fail "server fail"
513 return
514 fi
515
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100516 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100517 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
518 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100519 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200520 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100521 return
522 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100523
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100524 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200525 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100526 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100527 while [ $# -gt 0 ]
528 do
529 case $1 in
530 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100531 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 +0100532 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100533 return
534 fi
535 ;;
536
537 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100538 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 +0100539 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100540 return
541 fi
542 ;;
543
544 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100545 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 +0100546 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100547 return
548 fi
549 ;;
550
551 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100552 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 +0100553 fail "pattern '$2' MUST NOT be present in the Client output"
554 return
555 fi
556 ;;
557
558 # The filtering in the following two options (-u and -U) do the following
559 # - ignore valgrind output
560 # - filter out everything but lines right after the pattern occurances
561 # - keep one of each non-unique line
562 # - count how many lines remain
563 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
564 # if there were no duplicates.
565 "-U")
566 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
567 fail "lines following pattern '$2' must be unique in Server output"
568 return
569 fi
570 ;;
571
572 "-u")
573 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
574 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100575 return
576 fi
577 ;;
Andres Amaya Garciaa46a58a2017-09-06 15:38:07 +0100578 "-F")
579 if ! $2 "$SRV_OUT"; then
580 fail "function call to '$2' failed on Server output"
581 return
582 fi
583 ;;
584 "-f")
585 if ! $2 "$CLI_OUT"; then
586 fail "function call to '$2' failed on Client output"
587 return
588 fi
589 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100590
591 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200592 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100593 exit 1
594 esac
595 shift 2
596 done
597
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100598 # check valgrind's results
599 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200600 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100601 fail "Server has memory errors"
602 return
603 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200604 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100605 fail "Client has memory errors"
606 return
607 fi
608 fi
609
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100610 # if we're here, everything is ok
611 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100612 if [ "$PRESERVE_LOGS" -gt 0 ]; then
613 mv $SRV_OUT o-srv-${TESTS}.log
614 mv $CLI_OUT o-cli-${TESTS}.log
615 fi
616
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200617 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100618}
619
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100620cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200621 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200622 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
623 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
624 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
625 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100626 exit 1
627}
628
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100629#
630# MAIN
631#
632
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000633if cd $( dirname $0 ); then :; else
634 echo "cd $( dirname $0 ) failed" >&2
635 exit 1
636fi
637
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100638get_options "$@"
639
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100640# sanity checks, avoid an avalanche of errors
641if [ ! -x "$P_SRV" ]; then
642 echo "Command '$P_SRV' is not an executable file"
643 exit 1
644fi
645if [ ! -x "$P_CLI" ]; then
646 echo "Command '$P_CLI' is not an executable file"
647 exit 1
648fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200649if [ ! -x "$P_PXY" ]; then
650 echo "Command '$P_PXY' is not an executable file"
651 exit 1
652fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100653if [ "$MEMCHECK" -gt 0 ]; then
654 if which valgrind >/dev/null 2>&1; then :; else
655 echo "Memcheck not possible. Valgrind not found"
656 exit 1
657 fi
658fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100659if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
660 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100661 exit 1
662fi
663
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200664# used by watchdog
665MAIN_PID="$$"
666
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200667# be more patient with valgrind
668if [ "$MEMCHECK" -gt 0 ]; then
669 START_DELAY=3
670 DOG_DELAY=30
671else
672 START_DELAY=1
673 DOG_DELAY=10
674fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200675CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100676SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200677
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200678# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000679# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200680P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
681P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100682P_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 +0200683O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200684O_CLI="$O_CLI -connect localhost:+SRV_PORT"
685G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000686G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200687
Gilles Peskine62469d92017-05-10 10:13:59 +0200688# Allow SHA-1, because many of our test certificates use it
689P_SRV="$P_SRV allow_sha1=1"
690P_CLI="$P_CLI allow_sha1=1"
691
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200692# Also pick a unique name for intermediate files
693SRV_OUT="srv_out.$$"
694CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200695PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200696SESSION="session.$$"
697
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200698SKIP_NEXT="NO"
699
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100700trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100701
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200702# Basic test
703
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200704# Checks that:
705# - things work with all ciphersuites active (used with config-full in all.sh)
706# - the expected (highest security) parameters are selected
707# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200708run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200709 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200710 "$P_CLI" \
711 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200712 -s "Protocol is TLSv1.2" \
713 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
714 -s "client hello v3, signature_algorithm ext: 6" \
715 -s "ECDHE curve: secp521r1" \
716 -S "error" \
717 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200718
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000719run_test "Default, DTLS" \
720 "$P_SRV dtls=1" \
721 "$P_CLI dtls=1" \
722 0 \
723 -s "Protocol is DTLSv1.2" \
724 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
725
Andres Amaya Garciaac36e382017-09-06 15:44:01 +0100726# Test current time in ServerHello
727requires_config_enabled MBEDTLS_HAVE_TIME
728run_test "Default, ServerHello contains gmt_unix_time" \
729 "$P_SRV debug_level=3" \
730 "$P_CLI debug_level=3" \
731 0 \
732 -s "Protocol is TLSv1.2" \
733 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
734 -s "client hello v3, signature_algorithm ext: 6" \
735 -s "ECDHE curve: secp521r1" \
736 -S "error" \
737 -C "error" \
738 -f "check_server_hello_time" \
739 -F "check_server_hello_time"
740
Simon Butcher8e004102016-10-14 00:48:33 +0100741# Test for uniqueness of IVs in AEAD ciphersuites
742run_test "Unique IV in GCM" \
743 "$P_SRV exchanges=20 debug_level=4" \
744 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
745 0 \
746 -u "IV used" \
747 -U "IV used"
748
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100749# Tests for rc4 option
750
Simon Butchera410af52016-05-19 22:12:18 +0100751requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100752run_test "RC4: server disabled, client enabled" \
753 "$P_SRV" \
754 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
755 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100756 -s "SSL - The server has no ciphersuites in common"
757
Simon Butchera410af52016-05-19 22:12:18 +0100758requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100759run_test "RC4: server half, client enabled" \
760 "$P_SRV arc4=1" \
761 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
762 1 \
763 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100764
765run_test "RC4: server enabled, client disabled" \
766 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
767 "$P_CLI" \
768 1 \
769 -s "SSL - The server has no ciphersuites in common"
770
771run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100772 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100773 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
774 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100775 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100776 -S "SSL - The server has no ciphersuites in common"
777
Gilles Peskinebc70a182017-05-09 15:59:24 +0200778# Tests for SHA-1 support
779
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200780requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200781run_test "SHA-1 forbidden by default in server certificate" \
782 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
783 "$P_CLI debug_level=2 allow_sha1=0" \
784 1 \
785 -c "The certificate is signed with an unacceptable hash"
786
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200787requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
788run_test "SHA-1 forbidden by default in server certificate" \
789 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
790 "$P_CLI debug_level=2 allow_sha1=0" \
791 0
792
Gilles Peskinebc70a182017-05-09 15:59:24 +0200793run_test "SHA-1 explicitly allowed in server certificate" \
794 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
795 "$P_CLI allow_sha1=1" \
796 0
797
798run_test "SHA-256 allowed by default in server certificate" \
799 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
800 "$P_CLI allow_sha1=0" \
801 0
802
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200803requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200804run_test "SHA-1 forbidden by default in client certificate" \
805 "$P_SRV auth_mode=required allow_sha1=0" \
806 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
807 1 \
808 -s "The certificate is signed with an unacceptable hash"
809
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200810requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
811run_test "SHA-1 forbidden by default in client certificate" \
812 "$P_SRV auth_mode=required allow_sha1=0" \
813 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
814 0
815
Gilles Peskinebc70a182017-05-09 15:59:24 +0200816run_test "SHA-1 explicitly allowed in client certificate" \
817 "$P_SRV auth_mode=required allow_sha1=1" \
818 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
819 0
820
821run_test "SHA-256 allowed by default in client certificate" \
822 "$P_SRV auth_mode=required allow_sha1=0" \
823 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
824 0
825
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100826# Tests for Truncated HMAC extension
827
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100828run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200829 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100830 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100831 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100832 -s "dumping 'computed mac' (20 bytes)" \
833 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100834
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100835run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200836 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100837 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
838 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100839 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100840 -s "dumping 'computed mac' (20 bytes)" \
841 -S "dumping 'computed mac' (10 bytes)"
842
843run_test "Truncated HMAC: client enabled, server default" \
844 "$P_SRV debug_level=4" \
845 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
846 trunc_hmac=1" \
847 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100848 -s "dumping 'computed mac' (20 bytes)" \
849 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100850
851run_test "Truncated HMAC: client enabled, server disabled" \
852 "$P_SRV debug_level=4 trunc_hmac=0" \
853 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
854 trunc_hmac=1" \
855 0 \
856 -s "dumping 'computed mac' (20 bytes)" \
857 -S "dumping 'computed mac' (10 bytes)"
858
859run_test "Truncated HMAC: client enabled, server enabled" \
860 "$P_SRV debug_level=4 trunc_hmac=1" \
861 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
862 trunc_hmac=1" \
863 0 \
864 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100865 -s "dumping 'computed mac' (10 bytes)"
866
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100867# Tests for Encrypt-then-MAC extension
868
869run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100870 "$P_SRV debug_level=3 \
871 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100872 "$P_CLI debug_level=3" \
873 0 \
874 -c "client hello, adding encrypt_then_mac extension" \
875 -s "found encrypt then mac extension" \
876 -s "server hello, adding encrypt then mac extension" \
877 -c "found encrypt_then_mac extension" \
878 -c "using encrypt then mac" \
879 -s "using encrypt then mac"
880
881run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100882 "$P_SRV debug_level=3 etm=0 \
883 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100884 "$P_CLI debug_level=3 etm=1" \
885 0 \
886 -c "client hello, adding encrypt_then_mac extension" \
887 -s "found encrypt then mac extension" \
888 -S "server hello, adding encrypt then mac extension" \
889 -C "found encrypt_then_mac extension" \
890 -C "using encrypt then mac" \
891 -S "using encrypt then mac"
892
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100893run_test "Encrypt then MAC: client enabled, aead cipher" \
894 "$P_SRV debug_level=3 etm=1 \
895 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
896 "$P_CLI debug_level=3 etm=1" \
897 0 \
898 -c "client hello, adding encrypt_then_mac extension" \
899 -s "found encrypt then mac extension" \
900 -S "server hello, adding encrypt then mac extension" \
901 -C "found encrypt_then_mac extension" \
902 -C "using encrypt then mac" \
903 -S "using encrypt then mac"
904
905run_test "Encrypt then MAC: client enabled, stream cipher" \
906 "$P_SRV debug_level=3 etm=1 \
907 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100908 "$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 +0100909 0 \
910 -c "client hello, adding encrypt_then_mac extension" \
911 -s "found encrypt then mac extension" \
912 -S "server hello, adding encrypt then mac extension" \
913 -C "found encrypt_then_mac extension" \
914 -C "using encrypt then mac" \
915 -S "using encrypt then mac"
916
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100917run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100918 "$P_SRV debug_level=3 etm=1 \
919 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100920 "$P_CLI debug_level=3 etm=0" \
921 0 \
922 -C "client hello, adding encrypt_then_mac extension" \
923 -S "found encrypt then mac extension" \
924 -S "server hello, adding encrypt then mac extension" \
925 -C "found encrypt_then_mac extension" \
926 -C "using encrypt then mac" \
927 -S "using encrypt then mac"
928
Janos Follathe2681a42016-03-07 15:57:05 +0000929requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100930run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100931 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100932 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100933 "$P_CLI debug_level=3 force_version=ssl3" \
934 0 \
935 -C "client hello, adding encrypt_then_mac extension" \
936 -S "found encrypt then mac extension" \
937 -S "server hello, adding encrypt then mac extension" \
938 -C "found encrypt_then_mac extension" \
939 -C "using encrypt then mac" \
940 -S "using encrypt then mac"
941
Janos Follathe2681a42016-03-07 15:57:05 +0000942requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100943run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100944 "$P_SRV debug_level=3 force_version=ssl3 \
945 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100946 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100947 0 \
948 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100949 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100950 -S "server hello, adding encrypt then mac extension" \
951 -C "found encrypt_then_mac extension" \
952 -C "using encrypt then mac" \
953 -S "using encrypt then mac"
954
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200955# Tests for Extended Master Secret extension
956
957run_test "Extended Master Secret: default" \
958 "$P_SRV debug_level=3" \
959 "$P_CLI debug_level=3" \
960 0 \
961 -c "client hello, adding extended_master_secret extension" \
962 -s "found extended master secret extension" \
963 -s "server hello, adding extended master secret extension" \
964 -c "found extended_master_secret extension" \
965 -c "using extended master secret" \
966 -s "using extended master secret"
967
968run_test "Extended Master Secret: client enabled, server disabled" \
969 "$P_SRV debug_level=3 extended_ms=0" \
970 "$P_CLI debug_level=3 extended_ms=1" \
971 0 \
972 -c "client hello, adding extended_master_secret extension" \
973 -s "found extended master secret extension" \
974 -S "server hello, adding extended master secret extension" \
975 -C "found extended_master_secret extension" \
976 -C "using extended master secret" \
977 -S "using extended master secret"
978
979run_test "Extended Master Secret: client disabled, server enabled" \
980 "$P_SRV debug_level=3 extended_ms=1" \
981 "$P_CLI debug_level=3 extended_ms=0" \
982 0 \
983 -C "client hello, adding extended_master_secret extension" \
984 -S "found extended master secret extension" \
985 -S "server hello, adding extended master secret extension" \
986 -C "found extended_master_secret extension" \
987 -C "using extended master secret" \
988 -S "using extended master secret"
989
Janos Follathe2681a42016-03-07 15:57:05 +0000990requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200991run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100992 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200993 "$P_CLI debug_level=3 force_version=ssl3" \
994 0 \
995 -C "client hello, adding extended_master_secret extension" \
996 -S "found extended master secret extension" \
997 -S "server hello, adding extended master secret extension" \
998 -C "found extended_master_secret extension" \
999 -C "using extended master secret" \
1000 -S "using extended master secret"
1001
Janos Follathe2681a42016-03-07 15:57:05 +00001002requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001003run_test "Extended Master Secret: client enabled, server SSLv3" \
1004 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001005 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001006 0 \
1007 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001008 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001009 -S "server hello, adding extended master secret extension" \
1010 -C "found extended_master_secret extension" \
1011 -C "using extended master secret" \
1012 -S "using extended master secret"
1013
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001014# Tests for FALLBACK_SCSV
1015
1016run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001017 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001018 "$P_CLI debug_level=3 force_version=tls1_1" \
1019 0 \
1020 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001021 -S "received FALLBACK_SCSV" \
1022 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001023 -C "is a fatal alert message (msg 86)"
1024
1025run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001026 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001027 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1028 0 \
1029 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001030 -S "received FALLBACK_SCSV" \
1031 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001032 -C "is a fatal alert message (msg 86)"
1033
1034run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001035 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001036 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001037 1 \
1038 -c "adding FALLBACK_SCSV" \
1039 -s "received FALLBACK_SCSV" \
1040 -s "inapropriate fallback" \
1041 -c "is a fatal alert message (msg 86)"
1042
1043run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001044 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001045 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001046 0 \
1047 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001048 -s "received FALLBACK_SCSV" \
1049 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001050 -C "is a fatal alert message (msg 86)"
1051
1052requires_openssl_with_fallback_scsv
1053run_test "Fallback SCSV: default, openssl server" \
1054 "$O_SRV" \
1055 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1056 0 \
1057 -C "adding FALLBACK_SCSV" \
1058 -C "is a fatal alert message (msg 86)"
1059
1060requires_openssl_with_fallback_scsv
1061run_test "Fallback SCSV: enabled, openssl server" \
1062 "$O_SRV" \
1063 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1064 1 \
1065 -c "adding FALLBACK_SCSV" \
1066 -c "is a fatal alert message (msg 86)"
1067
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001068requires_openssl_with_fallback_scsv
1069run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001070 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001071 "$O_CLI -tls1_1" \
1072 0 \
1073 -S "received FALLBACK_SCSV" \
1074 -S "inapropriate fallback"
1075
1076requires_openssl_with_fallback_scsv
1077run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001078 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001079 "$O_CLI -tls1_1 -fallback_scsv" \
1080 1 \
1081 -s "received FALLBACK_SCSV" \
1082 -s "inapropriate fallback"
1083
1084requires_openssl_with_fallback_scsv
1085run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001086 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001087 "$O_CLI -fallback_scsv" \
1088 0 \
1089 -s "received FALLBACK_SCSV" \
1090 -S "inapropriate fallback"
1091
Gilles Peskined50177f2017-05-16 17:53:03 +02001092## ClientHello generated with
1093## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1094## then manually twiddling the ciphersuite list.
1095## The ClientHello content is spelled out below as a hex string as
1096## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1097## The expected response is an inappropriate_fallback alert.
1098requires_openssl_with_fallback_scsv
1099run_test "Fallback SCSV: beginning of list" \
1100 "$P_SRV debug_level=2" \
1101 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1102 0 \
1103 -s "received FALLBACK_SCSV" \
1104 -s "inapropriate fallback"
1105
1106requires_openssl_with_fallback_scsv
1107run_test "Fallback SCSV: end of list" \
1108 "$P_SRV debug_level=2" \
1109 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1110 0 \
1111 -s "received FALLBACK_SCSV" \
1112 -s "inapropriate fallback"
1113
1114## Here the expected response is a valid ServerHello prefix, up to the random.
1115requires_openssl_with_fallback_scsv
1116run_test "Fallback SCSV: not in list" \
1117 "$P_SRV debug_level=2" \
1118 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1119 0 \
1120 -S "received FALLBACK_SCSV" \
1121 -S "inapropriate fallback"
1122
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001123# Tests for CBC 1/n-1 record splitting
1124
1125run_test "CBC Record splitting: TLS 1.2, no splitting" \
1126 "$P_SRV" \
1127 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1128 request_size=123 force_version=tls1_2" \
1129 0 \
1130 -s "Read from client: 123 bytes read" \
1131 -S "Read from client: 1 bytes read" \
1132 -S "122 bytes read"
1133
1134run_test "CBC Record splitting: TLS 1.1, no splitting" \
1135 "$P_SRV" \
1136 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1137 request_size=123 force_version=tls1_1" \
1138 0 \
1139 -s "Read from client: 123 bytes read" \
1140 -S "Read from client: 1 bytes read" \
1141 -S "122 bytes read"
1142
1143run_test "CBC Record splitting: TLS 1.0, splitting" \
1144 "$P_SRV" \
1145 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1146 request_size=123 force_version=tls1" \
1147 0 \
1148 -S "Read from client: 123 bytes read" \
1149 -s "Read from client: 1 bytes read" \
1150 -s "122 bytes read"
1151
Janos Follathe2681a42016-03-07 15:57:05 +00001152requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001153run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001154 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001155 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1156 request_size=123 force_version=ssl3" \
1157 0 \
1158 -S "Read from client: 123 bytes read" \
1159 -s "Read from client: 1 bytes read" \
1160 -s "122 bytes read"
1161
1162run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001163 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001164 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1165 request_size=123 force_version=tls1" \
1166 0 \
1167 -s "Read from client: 123 bytes read" \
1168 -S "Read from client: 1 bytes read" \
1169 -S "122 bytes read"
1170
1171run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1172 "$P_SRV" \
1173 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1174 request_size=123 force_version=tls1 recsplit=0" \
1175 0 \
1176 -s "Read from client: 123 bytes read" \
1177 -S "Read from client: 1 bytes read" \
1178 -S "122 bytes read"
1179
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001180run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1181 "$P_SRV nbio=2" \
1182 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1183 request_size=123 force_version=tls1" \
1184 0 \
1185 -S "Read from client: 123 bytes read" \
1186 -s "Read from client: 1 bytes read" \
1187 -s "122 bytes read"
1188
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001189# Tests for Session Tickets
1190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001191run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001192 "$P_SRV debug_level=3 tickets=1" \
1193 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001194 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001195 -c "client hello, adding session ticket extension" \
1196 -s "found session ticket extension" \
1197 -s "server hello, adding session ticket extension" \
1198 -c "found session_ticket extension" \
1199 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001200 -S "session successfully restored from cache" \
1201 -s "session successfully restored from ticket" \
1202 -s "a session has been resumed" \
1203 -c "a session has been resumed"
1204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001205run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001206 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1207 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001208 0 \
1209 -c "client hello, adding session ticket extension" \
1210 -s "found session ticket extension" \
1211 -s "server hello, adding session ticket extension" \
1212 -c "found session_ticket extension" \
1213 -c "parse new session ticket" \
1214 -S "session successfully restored from cache" \
1215 -s "session successfully restored from ticket" \
1216 -s "a session has been resumed" \
1217 -c "a session has been resumed"
1218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001219run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001220 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1221 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001222 0 \
1223 -c "client hello, adding session ticket extension" \
1224 -s "found session ticket extension" \
1225 -s "server hello, adding session ticket extension" \
1226 -c "found session_ticket extension" \
1227 -c "parse new session ticket" \
1228 -S "session successfully restored from cache" \
1229 -S "session successfully restored from ticket" \
1230 -S "a session has been resumed" \
1231 -C "a session has been resumed"
1232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001233run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001234 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001235 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001236 0 \
1237 -c "client hello, adding session ticket extension" \
1238 -c "found session_ticket extension" \
1239 -c "parse new session ticket" \
1240 -c "a session has been resumed"
1241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001242run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001243 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001244 "( $O_CLI -sess_out $SESSION; \
1245 $O_CLI -sess_in $SESSION; \
1246 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001247 0 \
1248 -s "found session ticket extension" \
1249 -s "server hello, adding session ticket extension" \
1250 -S "session successfully restored from cache" \
1251 -s "session successfully restored from ticket" \
1252 -s "a session has been resumed"
1253
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001254# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_SRV debug_level=3 tickets=0" \
1258 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001259 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001260 -c "client hello, adding session ticket extension" \
1261 -s "found session ticket extension" \
1262 -S "server hello, adding session ticket extension" \
1263 -C "found session_ticket extension" \
1264 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001265 -s "session successfully restored from cache" \
1266 -S "session successfully restored from ticket" \
1267 -s "a session has been resumed" \
1268 -c "a session has been resumed"
1269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001270run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001271 "$P_SRV debug_level=3 tickets=1" \
1272 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001273 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001274 -C "client hello, adding session ticket extension" \
1275 -S "found session ticket extension" \
1276 -S "server hello, adding session ticket extension" \
1277 -C "found session_ticket extension" \
1278 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001279 -s "session successfully restored from cache" \
1280 -S "session successfully restored from ticket" \
1281 -s "a session has been resumed" \
1282 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001283
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001284run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001285 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1286 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001287 0 \
1288 -S "session successfully restored from cache" \
1289 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001290 -S "a session has been resumed" \
1291 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001293run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001294 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1295 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001296 0 \
1297 -s "session successfully restored from cache" \
1298 -S "session successfully restored from ticket" \
1299 -s "a session has been resumed" \
1300 -c "a session has been resumed"
1301
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001302run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001303 "$P_SRV debug_level=3 tickets=0" \
1304 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001305 0 \
1306 -s "session successfully restored from cache" \
1307 -S "session successfully restored from ticket" \
1308 -s "a session has been resumed" \
1309 -c "a session has been resumed"
1310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001311run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001312 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1313 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001314 0 \
1315 -S "session successfully restored from cache" \
1316 -S "session successfully restored from ticket" \
1317 -S "a session has been resumed" \
1318 -C "a session has been resumed"
1319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001320run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001321 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1322 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001323 0 \
1324 -s "session successfully restored from cache" \
1325 -S "session successfully restored from ticket" \
1326 -s "a session has been resumed" \
1327 -c "a session has been resumed"
1328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001329run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001330 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001331 "( $O_CLI -sess_out $SESSION; \
1332 $O_CLI -sess_in $SESSION; \
1333 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001334 0 \
1335 -s "found session ticket extension" \
1336 -S "server hello, adding session ticket extension" \
1337 -s "session successfully restored from cache" \
1338 -S "session successfully restored from ticket" \
1339 -s "a session has been resumed"
1340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001341run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001342 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001343 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001344 0 \
1345 -C "found session_ticket extension" \
1346 -C "parse new session ticket" \
1347 -c "a session has been resumed"
1348
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001349# Tests for Max Fragment Length extension
1350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001351run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001352 "$P_SRV debug_level=3" \
1353 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001354 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001355 -c "Maximum fragment length is 16384" \
1356 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001357 -C "client hello, adding max_fragment_length extension" \
1358 -S "found max fragment length extension" \
1359 -S "server hello, max_fragment_length extension" \
1360 -C "found max_fragment_length extension"
1361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001362run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001363 "$P_SRV debug_level=3" \
1364 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001365 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001366 -c "Maximum fragment length is 4096" \
1367 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001368 -c "client hello, adding max_fragment_length extension" \
1369 -s "found max fragment length extension" \
1370 -s "server hello, max_fragment_length extension" \
1371 -c "found max_fragment_length extension"
1372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001373run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001374 "$P_SRV debug_level=3 max_frag_len=4096" \
1375 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001376 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001377 -c "Maximum fragment length is 16384" \
1378 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001379 -C "client hello, adding max_fragment_length extension" \
1380 -S "found max fragment length extension" \
1381 -S "server hello, max_fragment_length extension" \
1382 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001384requires_gnutls
1385run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001386 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001387 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001388 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001389 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001390 -c "client hello, adding max_fragment_length extension" \
1391 -c "found max_fragment_length extension"
1392
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001393run_test "Max fragment length: client, message just fits" \
1394 "$P_SRV debug_level=3" \
1395 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1396 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001397 -c "Maximum fragment length is 2048" \
1398 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001399 -c "client hello, adding max_fragment_length extension" \
1400 -s "found max fragment length extension" \
1401 -s "server hello, max_fragment_length extension" \
1402 -c "found max_fragment_length extension" \
1403 -c "2048 bytes written in 1 fragments" \
1404 -s "2048 bytes read"
1405
1406run_test "Max fragment length: client, larger message" \
1407 "$P_SRV debug_level=3" \
1408 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1409 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001410 -c "Maximum fragment length is 2048" \
1411 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001412 -c "client hello, adding max_fragment_length extension" \
1413 -s "found max fragment length extension" \
1414 -s "server hello, max_fragment_length extension" \
1415 -c "found max_fragment_length extension" \
1416 -c "2345 bytes written in 2 fragments" \
1417 -s "2048 bytes read" \
1418 -s "297 bytes read"
1419
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001420run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001421 "$P_SRV debug_level=3 dtls=1" \
1422 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1423 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001424 -c "Maximum fragment length is 2048" \
1425 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001426 -c "client hello, adding max_fragment_length extension" \
1427 -s "found max fragment length extension" \
1428 -s "server hello, max_fragment_length extension" \
1429 -c "found max_fragment_length extension" \
1430 -c "fragment larger than.*maximum"
1431
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001432# Tests for renegotiation
1433
Hanno Becker6a243642017-10-12 15:18:45 +01001434# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001435run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001436 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001437 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001438 0 \
1439 -C "client hello, adding renegotiation extension" \
1440 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1441 -S "found renegotiation extension" \
1442 -s "server hello, secure renegotiation extension" \
1443 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001444 -C "=> renegotiate" \
1445 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001446 -S "write hello request"
1447
Hanno Becker6a243642017-10-12 15:18:45 +01001448requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001449run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001450 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001451 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001452 0 \
1453 -c "client hello, adding renegotiation extension" \
1454 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1455 -s "found renegotiation extension" \
1456 -s "server hello, secure renegotiation extension" \
1457 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001458 -c "=> renegotiate" \
1459 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001460 -S "write hello request"
1461
Hanno Becker6a243642017-10-12 15:18:45 +01001462requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001463run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001464 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001465 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001466 0 \
1467 -c "client hello, adding renegotiation extension" \
1468 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1469 -s "found renegotiation extension" \
1470 -s "server hello, secure renegotiation extension" \
1471 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001472 -c "=> renegotiate" \
1473 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001474 -s "write hello request"
1475
Janos Follath88f58082017-10-05 12:29:42 +01001476# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1477# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1478# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001479requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath88f58082017-10-05 12:29:42 +01001480run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1481 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1482 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1483 0 \
1484 -c "client hello, adding renegotiation extension" \
1485 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1486 -s "found renegotiation extension" \
1487 -s "server hello, secure renegotiation extension" \
1488 -c "found renegotiation extension" \
1489 -c "=> renegotiate" \
1490 -s "=> renegotiate" \
1491 -S "write hello request" \
1492 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1493
1494# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1495# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1496# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001497requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath88f58082017-10-05 12:29:42 +01001498run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1499 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1500 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1501 0 \
1502 -c "client hello, adding renegotiation extension" \
1503 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1504 -s "found renegotiation extension" \
1505 -s "server hello, secure renegotiation extension" \
1506 -c "found renegotiation extension" \
1507 -c "=> renegotiate" \
1508 -s "=> renegotiate" \
1509 -s "write hello request" \
1510 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1511
Hanno Becker6a243642017-10-12 15:18:45 +01001512requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001513run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001514 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001515 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001516 0 \
1517 -c "client hello, adding renegotiation extension" \
1518 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1519 -s "found renegotiation extension" \
1520 -s "server hello, secure renegotiation extension" \
1521 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001522 -c "=> renegotiate" \
1523 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001524 -s "write hello request"
1525
Hanno Becker6a243642017-10-12 15:18:45 +01001526requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001527run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001528 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001529 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001530 1 \
1531 -c "client hello, adding renegotiation extension" \
1532 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1533 -S "found renegotiation extension" \
1534 -s "server hello, secure renegotiation extension" \
1535 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001536 -c "=> renegotiate" \
1537 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001538 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001539 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001540 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001541
Hanno Becker6a243642017-10-12 15:18:45 +01001542requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001543run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001544 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001545 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001546 0 \
1547 -C "client hello, adding renegotiation extension" \
1548 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1549 -S "found renegotiation extension" \
1550 -s "server hello, secure renegotiation extension" \
1551 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001552 -C "=> renegotiate" \
1553 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001554 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001555 -S "SSL - An unexpected message was received from our peer" \
1556 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001557
Hanno Becker6a243642017-10-12 15:18:45 +01001558requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001559run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001560 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001561 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001562 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001563 0 \
1564 -C "client hello, adding renegotiation extension" \
1565 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1566 -S "found renegotiation extension" \
1567 -s "server hello, secure renegotiation extension" \
1568 -c "found renegotiation extension" \
1569 -C "=> renegotiate" \
1570 -S "=> renegotiate" \
1571 -s "write hello request" \
1572 -S "SSL - An unexpected message was received from our peer" \
1573 -S "failed"
1574
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001575# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001576requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001577run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001578 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001579 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001580 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001581 0 \
1582 -C "client hello, adding renegotiation extension" \
1583 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1584 -S "found renegotiation extension" \
1585 -s "server hello, secure renegotiation extension" \
1586 -c "found renegotiation extension" \
1587 -C "=> renegotiate" \
1588 -S "=> renegotiate" \
1589 -s "write hello request" \
1590 -S "SSL - An unexpected message was received from our peer" \
1591 -S "failed"
1592
Hanno Becker6a243642017-10-12 15:18:45 +01001593requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001594run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001595 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001596 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001597 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001598 0 \
1599 -C "client hello, adding renegotiation extension" \
1600 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1601 -S "found renegotiation extension" \
1602 -s "server hello, secure renegotiation extension" \
1603 -c "found renegotiation extension" \
1604 -C "=> renegotiate" \
1605 -S "=> renegotiate" \
1606 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001607 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001608
Hanno Becker6a243642017-10-12 15:18:45 +01001609requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001610run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001611 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001612 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001613 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001614 0 \
1615 -c "client hello, adding renegotiation extension" \
1616 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1617 -s "found renegotiation extension" \
1618 -s "server hello, secure renegotiation extension" \
1619 -c "found renegotiation extension" \
1620 -c "=> renegotiate" \
1621 -s "=> renegotiate" \
1622 -s "write hello request" \
1623 -S "SSL - An unexpected message was received from our peer" \
1624 -S "failed"
1625
Hanno Becker6a243642017-10-12 15:18:45 +01001626requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001627run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001628 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001629 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1630 0 \
1631 -C "client hello, adding renegotiation extension" \
1632 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1633 -S "found renegotiation extension" \
1634 -s "server hello, secure renegotiation extension" \
1635 -c "found renegotiation extension" \
1636 -S "record counter limit reached: renegotiate" \
1637 -C "=> renegotiate" \
1638 -S "=> renegotiate" \
1639 -S "write hello request" \
1640 -S "SSL - An unexpected message was received from our peer" \
1641 -S "failed"
1642
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001643# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001644requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001645run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001646 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001647 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001648 0 \
1649 -c "client hello, adding renegotiation extension" \
1650 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1651 -s "found renegotiation extension" \
1652 -s "server hello, secure renegotiation extension" \
1653 -c "found renegotiation extension" \
1654 -s "record counter limit reached: renegotiate" \
1655 -c "=> renegotiate" \
1656 -s "=> renegotiate" \
1657 -s "write hello request" \
1658 -S "SSL - An unexpected message was received from our peer" \
1659 -S "failed"
1660
Hanno Becker6a243642017-10-12 15:18:45 +01001661requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001662run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001663 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001664 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001665 0 \
1666 -c "client hello, adding renegotiation extension" \
1667 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1668 -s "found renegotiation extension" \
1669 -s "server hello, secure renegotiation extension" \
1670 -c "found renegotiation extension" \
1671 -s "record counter limit reached: renegotiate" \
1672 -c "=> renegotiate" \
1673 -s "=> renegotiate" \
1674 -s "write hello request" \
1675 -S "SSL - An unexpected message was received from our peer" \
1676 -S "failed"
1677
Hanno Becker6a243642017-10-12 15:18:45 +01001678requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001679run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001680 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001681 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1682 0 \
1683 -C "client hello, adding renegotiation extension" \
1684 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1685 -S "found renegotiation extension" \
1686 -s "server hello, secure renegotiation extension" \
1687 -c "found renegotiation extension" \
1688 -S "record counter limit reached: renegotiate" \
1689 -C "=> renegotiate" \
1690 -S "=> renegotiate" \
1691 -S "write hello request" \
1692 -S "SSL - An unexpected message was received from our peer" \
1693 -S "failed"
1694
Hanno Becker6a243642017-10-12 15:18:45 +01001695requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001696run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001697 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001698 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001699 0 \
1700 -c "client hello, adding renegotiation extension" \
1701 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1702 -s "found renegotiation extension" \
1703 -s "server hello, secure renegotiation extension" \
1704 -c "found renegotiation extension" \
1705 -c "=> renegotiate" \
1706 -s "=> renegotiate" \
1707 -S "write hello request"
1708
Hanno Becker6a243642017-10-12 15:18:45 +01001709requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001710run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001711 "$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 +02001712 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001713 0 \
1714 -c "client hello, adding renegotiation extension" \
1715 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1716 -s "found renegotiation extension" \
1717 -s "server hello, secure renegotiation extension" \
1718 -c "found renegotiation extension" \
1719 -c "=> renegotiate" \
1720 -s "=> renegotiate" \
1721 -s "write hello request"
1722
Hanno Becker6a243642017-10-12 15:18:45 +01001723requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001724run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001725 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001726 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001727 0 \
1728 -c "client hello, adding renegotiation extension" \
1729 -c "found renegotiation extension" \
1730 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001731 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001732 -C "error" \
1733 -c "HTTP/1.0 200 [Oo][Kk]"
1734
Paul Bakker539d9722015-02-08 16:18:35 +01001735requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001736requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001737run_test "Renegotiation: gnutls server strict, client-initiated" \
1738 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001739 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001740 0 \
1741 -c "client hello, adding renegotiation extension" \
1742 -c "found renegotiation extension" \
1743 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001744 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001745 -C "error" \
1746 -c "HTTP/1.0 200 [Oo][Kk]"
1747
Paul Bakker539d9722015-02-08 16:18:35 +01001748requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001749requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001750run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1751 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1752 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1753 1 \
1754 -c "client hello, adding renegotiation extension" \
1755 -C "found renegotiation extension" \
1756 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001757 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001758 -c "error" \
1759 -C "HTTP/1.0 200 [Oo][Kk]"
1760
Paul Bakker539d9722015-02-08 16:18:35 +01001761requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001762requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001763run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1764 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1765 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1766 allow_legacy=0" \
1767 1 \
1768 -c "client hello, adding renegotiation extension" \
1769 -C "found renegotiation extension" \
1770 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001771 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001772 -c "error" \
1773 -C "HTTP/1.0 200 [Oo][Kk]"
1774
Paul Bakker539d9722015-02-08 16:18:35 +01001775requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001776requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001777run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1778 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1779 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1780 allow_legacy=1" \
1781 0 \
1782 -c "client hello, adding renegotiation extension" \
1783 -C "found renegotiation extension" \
1784 -c "=> renegotiate" \
1785 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001786 -C "error" \
1787 -c "HTTP/1.0 200 [Oo][Kk]"
1788
Hanno Becker6a243642017-10-12 15:18:45 +01001789requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001790run_test "Renegotiation: DTLS, client-initiated" \
1791 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1792 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1793 0 \
1794 -c "client hello, adding renegotiation extension" \
1795 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1796 -s "found renegotiation extension" \
1797 -s "server hello, secure renegotiation extension" \
1798 -c "found renegotiation extension" \
1799 -c "=> renegotiate" \
1800 -s "=> renegotiate" \
1801 -S "write hello request"
1802
Hanno Becker6a243642017-10-12 15:18:45 +01001803requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001804run_test "Renegotiation: DTLS, server-initiated" \
1805 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001806 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1807 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001808 0 \
1809 -c "client hello, adding renegotiation extension" \
1810 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1811 -s "found renegotiation extension" \
1812 -s "server hello, secure renegotiation extension" \
1813 -c "found renegotiation extension" \
1814 -c "=> renegotiate" \
1815 -s "=> renegotiate" \
1816 -s "write hello request"
1817
Hanno Becker6a243642017-10-12 15:18:45 +01001818requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00001819run_test "Renegotiation: DTLS, renego_period overflow" \
1820 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1821 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1822 0 \
1823 -c "client hello, adding renegotiation extension" \
1824 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1825 -s "found renegotiation extension" \
1826 -s "server hello, secure renegotiation extension" \
1827 -s "record counter limit reached: renegotiate" \
1828 -c "=> renegotiate" \
1829 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01001830 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00001831
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001832requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001833requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001834run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1835 "$G_SRV -u --mtu 4096" \
1836 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1837 0 \
1838 -c "client hello, adding renegotiation extension" \
1839 -c "found renegotiation extension" \
1840 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001841 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001842 -C "error" \
1843 -s "Extra-header:"
1844
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001845# Test for the "secure renegotation" extension only (no actual renegotiation)
1846
Paul Bakker539d9722015-02-08 16:18:35 +01001847requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001848run_test "Renego ext: gnutls server strict, client default" \
1849 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1850 "$P_CLI debug_level=3" \
1851 0 \
1852 -c "found renegotiation extension" \
1853 -C "error" \
1854 -c "HTTP/1.0 200 [Oo][Kk]"
1855
Paul Bakker539d9722015-02-08 16:18:35 +01001856requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001857run_test "Renego ext: gnutls server unsafe, client default" \
1858 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1859 "$P_CLI debug_level=3" \
1860 0 \
1861 -C "found renegotiation extension" \
1862 -C "error" \
1863 -c "HTTP/1.0 200 [Oo][Kk]"
1864
Paul Bakker539d9722015-02-08 16:18:35 +01001865requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001866run_test "Renego ext: gnutls server unsafe, client break legacy" \
1867 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1868 "$P_CLI debug_level=3 allow_legacy=-1" \
1869 1 \
1870 -C "found renegotiation extension" \
1871 -c "error" \
1872 -C "HTTP/1.0 200 [Oo][Kk]"
1873
Paul Bakker539d9722015-02-08 16:18:35 +01001874requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001875run_test "Renego ext: gnutls client strict, server default" \
1876 "$P_SRV debug_level=3" \
1877 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1878 0 \
1879 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1880 -s "server hello, secure renegotiation extension"
1881
Paul Bakker539d9722015-02-08 16:18:35 +01001882requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001883run_test "Renego ext: gnutls client unsafe, server default" \
1884 "$P_SRV debug_level=3" \
1885 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1886 0 \
1887 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1888 -S "server hello, secure renegotiation extension"
1889
Paul Bakker539d9722015-02-08 16:18:35 +01001890requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001891run_test "Renego ext: gnutls client unsafe, server break legacy" \
1892 "$P_SRV debug_level=3 allow_legacy=-1" \
1893 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1894 1 \
1895 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1896 -S "server hello, secure renegotiation extension"
1897
Janos Follath0b242342016-02-17 10:11:21 +00001898# Tests for silently dropping trailing extra bytes in .der certificates
1899
1900requires_gnutls
1901run_test "DER format: no trailing bytes" \
1902 "$P_SRV crt_file=data_files/server5-der0.crt \
1903 key_file=data_files/server5.key" \
1904 "$G_CLI " \
1905 0 \
1906 -c "Handshake was completed" \
1907
1908requires_gnutls
1909run_test "DER format: with a trailing zero byte" \
1910 "$P_SRV crt_file=data_files/server5-der1a.crt \
1911 key_file=data_files/server5.key" \
1912 "$G_CLI " \
1913 0 \
1914 -c "Handshake was completed" \
1915
1916requires_gnutls
1917run_test "DER format: with a trailing random byte" \
1918 "$P_SRV crt_file=data_files/server5-der1b.crt \
1919 key_file=data_files/server5.key" \
1920 "$G_CLI " \
1921 0 \
1922 -c "Handshake was completed" \
1923
1924requires_gnutls
1925run_test "DER format: with 2 trailing random bytes" \
1926 "$P_SRV crt_file=data_files/server5-der2.crt \
1927 key_file=data_files/server5.key" \
1928 "$G_CLI " \
1929 0 \
1930 -c "Handshake was completed" \
1931
1932requires_gnutls
1933run_test "DER format: with 4 trailing random bytes" \
1934 "$P_SRV crt_file=data_files/server5-der4.crt \
1935 key_file=data_files/server5.key" \
1936 "$G_CLI " \
1937 0 \
1938 -c "Handshake was completed" \
1939
1940requires_gnutls
1941run_test "DER format: with 8 trailing random bytes" \
1942 "$P_SRV crt_file=data_files/server5-der8.crt \
1943 key_file=data_files/server5.key" \
1944 "$G_CLI " \
1945 0 \
1946 -c "Handshake was completed" \
1947
1948requires_gnutls
1949run_test "DER format: with 9 trailing random bytes" \
1950 "$P_SRV crt_file=data_files/server5-der9.crt \
1951 key_file=data_files/server5.key" \
1952 "$G_CLI " \
1953 0 \
1954 -c "Handshake was completed" \
1955
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001956# Tests for auth_mode
1957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001958run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001959 "$P_SRV crt_file=data_files/server5-badsign.crt \
1960 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001961 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001962 1 \
1963 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001964 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001965 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001966 -c "X509 - Certificate verification failed"
1967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001968run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001969 "$P_SRV crt_file=data_files/server5-badsign.crt \
1970 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001971 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001972 0 \
1973 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001974 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001975 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001976 -C "X509 - Certificate verification failed"
1977
Hanno Beckere6706e62017-05-15 16:05:15 +01001978run_test "Authentication: server goodcert, client optional, no trusted CA" \
1979 "$P_SRV" \
1980 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1981 0 \
1982 -c "x509_verify_cert() returned" \
1983 -c "! The certificate is not correctly signed by the trusted CA" \
1984 -c "! Certificate verification flags"\
1985 -C "! mbedtls_ssl_handshake returned" \
1986 -C "X509 - Certificate verification failed" \
1987 -C "SSL - No CA Chain is set, but required to operate"
1988
1989run_test "Authentication: server goodcert, client required, no trusted CA" \
1990 "$P_SRV" \
1991 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1992 1 \
1993 -c "x509_verify_cert() returned" \
1994 -c "! The certificate is not correctly signed by the trusted CA" \
1995 -c "! Certificate verification flags"\
1996 -c "! mbedtls_ssl_handshake returned" \
1997 -c "SSL - No CA Chain is set, but required to operate"
1998
1999# The purpose of the next two tests is to test the client's behaviour when receiving a server
2000# certificate with an unsupported elliptic curve. This should usually not happen because
2001# the client informs the server about the supported curves - it does, though, in the
2002# corner case of a static ECDH suite, because the server doesn't check the curve on that
2003# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2004# different means to have the server ignoring the client's supported curve list.
2005
2006requires_config_enabled MBEDTLS_ECP_C
2007run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2008 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2009 crt_file=data_files/server5.ku-ka.crt" \
2010 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2011 1 \
2012 -c "bad certificate (EC key curve)"\
2013 -c "! Certificate verification flags"\
2014 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2015
2016requires_config_enabled MBEDTLS_ECP_C
2017run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2018 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2019 crt_file=data_files/server5.ku-ka.crt" \
2020 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2021 1 \
2022 -c "bad certificate (EC key curve)"\
2023 -c "! Certificate verification flags"\
2024 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002026run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002027 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002028 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002029 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002030 0 \
2031 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002032 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002033 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002034 -C "X509 - Certificate verification failed"
2035
Simon Butcher99000142016-10-13 17:21:01 +01002036run_test "Authentication: client SHA256, server required" \
2037 "$P_SRV auth_mode=required" \
2038 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2039 key_file=data_files/server6.key \
2040 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2041 0 \
2042 -c "Supported Signature Algorithm found: 4," \
2043 -c "Supported Signature Algorithm found: 5,"
2044
2045run_test "Authentication: client SHA384, server required" \
2046 "$P_SRV auth_mode=required" \
2047 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2048 key_file=data_files/server6.key \
2049 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2050 0 \
2051 -c "Supported Signature Algorithm found: 4," \
2052 -c "Supported Signature Algorithm found: 5,"
2053
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002054requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2055run_test "Authentication: client has no cert, server required (SSLv3)" \
2056 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2057 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2058 key_file=data_files/server5.key" \
2059 1 \
2060 -S "skip write certificate request" \
2061 -C "skip parse certificate request" \
2062 -c "got a certificate request" \
2063 -c "got no certificate to send" \
2064 -S "x509_verify_cert() returned" \
2065 -s "client has no certificate" \
2066 -s "! mbedtls_ssl_handshake returned" \
2067 -c "! mbedtls_ssl_handshake returned" \
2068 -s "No client certification received from the client, but required by the authentication mode"
2069
2070run_test "Authentication: client has no cert, server required (TLS)" \
2071 "$P_SRV debug_level=3 auth_mode=required" \
2072 "$P_CLI debug_level=3 crt_file=none \
2073 key_file=data_files/server5.key" \
2074 1 \
2075 -S "skip write certificate request" \
2076 -C "skip parse certificate request" \
2077 -c "got a certificate request" \
2078 -c "= write certificate$" \
2079 -C "skip write certificate$" \
2080 -S "x509_verify_cert() returned" \
2081 -s "client has no certificate" \
2082 -s "! mbedtls_ssl_handshake returned" \
2083 -c "! mbedtls_ssl_handshake returned" \
2084 -s "No client certification received from the client, but required by the authentication mode"
2085
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002086run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002087 "$P_SRV debug_level=3 auth_mode=required" \
2088 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002089 key_file=data_files/server5.key" \
2090 1 \
2091 -S "skip write certificate request" \
2092 -C "skip parse certificate request" \
2093 -c "got a certificate request" \
2094 -C "skip write certificate" \
2095 -C "skip write certificate verify" \
2096 -S "skip parse certificate verify" \
2097 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002098 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002099 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002100 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002101 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002102 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002103# We don't check that the client receives the alert because it might
2104# detect that its write end of the connection is closed and abort
2105# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002106
Janos Follath89baba22017-04-10 14:34:35 +01002107run_test "Authentication: client cert not trusted, server required" \
2108 "$P_SRV debug_level=3 auth_mode=required" \
2109 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2110 key_file=data_files/server5.key" \
2111 1 \
2112 -S "skip write certificate request" \
2113 -C "skip parse certificate request" \
2114 -c "got a certificate request" \
2115 -C "skip write certificate" \
2116 -C "skip write certificate verify" \
2117 -S "skip parse certificate verify" \
2118 -s "x509_verify_cert() returned" \
2119 -s "! The certificate is not correctly signed by the trusted CA" \
2120 -s "! mbedtls_ssl_handshake returned" \
2121 -c "! mbedtls_ssl_handshake returned" \
2122 -s "X509 - Certificate verification failed"
2123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002124run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002125 "$P_SRV debug_level=3 auth_mode=optional" \
2126 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002127 key_file=data_files/server5.key" \
2128 0 \
2129 -S "skip write certificate request" \
2130 -C "skip parse certificate request" \
2131 -c "got a certificate request" \
2132 -C "skip write certificate" \
2133 -C "skip write certificate verify" \
2134 -S "skip parse certificate verify" \
2135 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002136 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002137 -S "! mbedtls_ssl_handshake returned" \
2138 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002139 -S "X509 - Certificate verification failed"
2140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002141run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002142 "$P_SRV debug_level=3 auth_mode=none" \
2143 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002144 key_file=data_files/server5.key" \
2145 0 \
2146 -s "skip write certificate request" \
2147 -C "skip parse certificate request" \
2148 -c "got no certificate request" \
2149 -c "skip write certificate" \
2150 -c "skip write certificate verify" \
2151 -s "skip parse certificate verify" \
2152 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002153 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002154 -S "! mbedtls_ssl_handshake returned" \
2155 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002156 -S "X509 - Certificate verification failed"
2157
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002158run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002159 "$P_SRV debug_level=3 auth_mode=optional" \
2160 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002161 0 \
2162 -S "skip write certificate request" \
2163 -C "skip parse certificate request" \
2164 -c "got a certificate request" \
2165 -C "skip write certificate$" \
2166 -C "got no certificate to send" \
2167 -S "SSLv3 client has no certificate" \
2168 -c "skip write certificate verify" \
2169 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002170 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002171 -S "! mbedtls_ssl_handshake returned" \
2172 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002173 -S "X509 - Certificate verification failed"
2174
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002175run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002176 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002177 "$O_CLI" \
2178 0 \
2179 -S "skip write certificate request" \
2180 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002181 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002182 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002183 -S "X509 - Certificate verification failed"
2184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002185run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002186 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002187 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002188 0 \
2189 -C "skip parse certificate request" \
2190 -c "got a certificate request" \
2191 -C "skip write certificate$" \
2192 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002193 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002194
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002195run_test "Authentication: client no cert, openssl server required" \
2196 "$O_SRV -Verify 10" \
2197 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2198 1 \
2199 -C "skip parse certificate request" \
2200 -c "got a certificate request" \
2201 -C "skip write certificate$" \
2202 -c "skip write certificate verify" \
2203 -c "! mbedtls_ssl_handshake returned"
2204
Janos Follathe2681a42016-03-07 15:57:05 +00002205requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002206run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002207 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002208 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002209 0 \
2210 -S "skip write certificate request" \
2211 -C "skip parse certificate request" \
2212 -c "got a certificate request" \
2213 -C "skip write certificate$" \
2214 -c "skip write certificate verify" \
2215 -c "got no certificate to send" \
2216 -s "SSLv3 client has no certificate" \
2217 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002218 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002219 -S "! mbedtls_ssl_handshake returned" \
2220 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002221 -S "X509 - Certificate verification failed"
2222
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002223# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2224# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002225
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002226MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002227MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002228
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002229if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002230 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002231 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002232 printf "test value of ${MAX_IM_CA}. \n"
2233 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002234 printf "The tests assume this value and if it changes, the tests in this\n"
2235 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002236 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002237
2238 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002239fi
2240
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002241run_test "Authentication: server max_int chain, client default" \
2242 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2243 key_file=data_files/dir-maxpath/09.key" \
2244 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2245 0 \
2246 -C "X509 - A fatal error occured"
2247
2248run_test "Authentication: server max_int+1 chain, client default" \
2249 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2250 key_file=data_files/dir-maxpath/10.key" \
2251 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2252 1 \
2253 -c "X509 - A fatal error occured"
2254
2255run_test "Authentication: server max_int+1 chain, client optional" \
2256 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2257 key_file=data_files/dir-maxpath/10.key" \
2258 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2259 auth_mode=optional" \
2260 1 \
2261 -c "X509 - A fatal error occured"
2262
2263run_test "Authentication: server max_int+1 chain, client none" \
2264 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2265 key_file=data_files/dir-maxpath/10.key" \
2266 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2267 auth_mode=none" \
2268 0 \
2269 -C "X509 - A fatal error occured"
2270
2271run_test "Authentication: client max_int+1 chain, server default" \
2272 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2273 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2274 key_file=data_files/dir-maxpath/10.key" \
2275 0 \
2276 -S "X509 - A fatal error occured"
2277
2278run_test "Authentication: client max_int+1 chain, server optional" \
2279 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2280 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2281 key_file=data_files/dir-maxpath/10.key" \
2282 1 \
2283 -s "X509 - A fatal error occured"
2284
2285run_test "Authentication: client max_int+1 chain, server required" \
2286 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2287 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2288 key_file=data_files/dir-maxpath/10.key" \
2289 1 \
2290 -s "X509 - A fatal error occured"
2291
2292run_test "Authentication: client max_int chain, server required" \
2293 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2294 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2295 key_file=data_files/dir-maxpath/09.key" \
2296 0 \
2297 -S "X509 - A fatal error occured"
2298
Janos Follath89baba22017-04-10 14:34:35 +01002299# Tests for CA list in CertificateRequest messages
2300
2301run_test "Authentication: send CA list in CertificateRequest (default)" \
2302 "$P_SRV debug_level=3 auth_mode=required" \
2303 "$P_CLI crt_file=data_files/server6.crt \
2304 key_file=data_files/server6.key" \
2305 0 \
2306 -s "requested DN"
2307
2308run_test "Authentication: do not send CA list in CertificateRequest" \
2309 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2310 "$P_CLI crt_file=data_files/server6.crt \
2311 key_file=data_files/server6.key" \
2312 0 \
2313 -S "requested DN"
2314
2315run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2316 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2317 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2318 key_file=data_files/server5.key" \
2319 1 \
2320 -S "requested DN" \
2321 -s "x509_verify_cert() returned" \
2322 -s "! The certificate is not correctly signed by the trusted CA" \
2323 -s "! mbedtls_ssl_handshake returned" \
2324 -c "! mbedtls_ssl_handshake returned" \
2325 -s "X509 - Certificate verification failed"
2326
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002327# Tests for certificate selection based on SHA verson
2328
2329run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2330 "$P_SRV crt_file=data_files/server5.crt \
2331 key_file=data_files/server5.key \
2332 crt_file2=data_files/server5-sha1.crt \
2333 key_file2=data_files/server5.key" \
2334 "$P_CLI force_version=tls1_2" \
2335 0 \
2336 -c "signed using.*ECDSA with SHA256" \
2337 -C "signed using.*ECDSA with SHA1"
2338
2339run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2340 "$P_SRV crt_file=data_files/server5.crt \
2341 key_file=data_files/server5.key \
2342 crt_file2=data_files/server5-sha1.crt \
2343 key_file2=data_files/server5.key" \
2344 "$P_CLI force_version=tls1_1" \
2345 0 \
2346 -C "signed using.*ECDSA with SHA256" \
2347 -c "signed using.*ECDSA with SHA1"
2348
2349run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2350 "$P_SRV crt_file=data_files/server5.crt \
2351 key_file=data_files/server5.key \
2352 crt_file2=data_files/server5-sha1.crt \
2353 key_file2=data_files/server5.key" \
2354 "$P_CLI force_version=tls1" \
2355 0 \
2356 -C "signed using.*ECDSA with SHA256" \
2357 -c "signed using.*ECDSA with SHA1"
2358
2359run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2360 "$P_SRV crt_file=data_files/server5.crt \
2361 key_file=data_files/server5.key \
2362 crt_file2=data_files/server6.crt \
2363 key_file2=data_files/server6.key" \
2364 "$P_CLI force_version=tls1_1" \
2365 0 \
2366 -c "serial number.*09" \
2367 -c "signed using.*ECDSA with SHA256" \
2368 -C "signed using.*ECDSA with SHA1"
2369
2370run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2371 "$P_SRV crt_file=data_files/server6.crt \
2372 key_file=data_files/server6.key \
2373 crt_file2=data_files/server5.crt \
2374 key_file2=data_files/server5.key" \
2375 "$P_CLI force_version=tls1_1" \
2376 0 \
2377 -c "serial number.*0A" \
2378 -c "signed using.*ECDSA with SHA256" \
2379 -C "signed using.*ECDSA with SHA1"
2380
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002381# tests for SNI
2382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002383run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002384 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002385 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002386 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002387 0 \
2388 -S "parse ServerName extension" \
2389 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2390 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002392run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002393 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002394 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002395 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 +02002396 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002397 0 \
2398 -s "parse ServerName extension" \
2399 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2400 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002402run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002403 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002404 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002405 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 +02002406 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002407 0 \
2408 -s "parse ServerName extension" \
2409 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2410 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002411
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002412run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002413 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002414 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002415 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 +02002416 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002417 1 \
2418 -s "parse ServerName extension" \
2419 -s "ssl_sni_wrapper() returned" \
2420 -s "mbedtls_ssl_handshake returned" \
2421 -c "mbedtls_ssl_handshake returned" \
2422 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002423
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002424run_test "SNI: client auth no override: optional" \
2425 "$P_SRV debug_level=3 auth_mode=optional \
2426 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2427 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2428 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002429 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002430 -S "skip write certificate request" \
2431 -C "skip parse certificate request" \
2432 -c "got a certificate request" \
2433 -C "skip write certificate" \
2434 -C "skip write certificate verify" \
2435 -S "skip parse certificate verify"
2436
2437run_test "SNI: client auth override: none -> optional" \
2438 "$P_SRV debug_level=3 auth_mode=none \
2439 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2440 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2441 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002442 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002443 -S "skip write certificate request" \
2444 -C "skip parse certificate request" \
2445 -c "got a certificate request" \
2446 -C "skip write certificate" \
2447 -C "skip write certificate verify" \
2448 -S "skip parse certificate verify"
2449
2450run_test "SNI: client auth override: optional -> none" \
2451 "$P_SRV debug_level=3 auth_mode=optional \
2452 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2453 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2454 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002455 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002456 -s "skip write certificate request" \
2457 -C "skip parse certificate request" \
2458 -c "got no certificate request" \
2459 -c "skip write certificate" \
2460 -c "skip write certificate verify" \
2461 -s "skip parse certificate verify"
2462
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002463run_test "SNI: CA no override" \
2464 "$P_SRV debug_level=3 auth_mode=optional \
2465 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2466 ca_file=data_files/test-ca.crt \
2467 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2468 "$P_CLI debug_level=3 server_name=localhost \
2469 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2470 1 \
2471 -S "skip write certificate request" \
2472 -C "skip parse certificate request" \
2473 -c "got a certificate request" \
2474 -C "skip write certificate" \
2475 -C "skip write certificate verify" \
2476 -S "skip parse certificate verify" \
2477 -s "x509_verify_cert() returned" \
2478 -s "! The certificate is not correctly signed by the trusted CA" \
2479 -S "The certificate has been revoked (is on a CRL)"
2480
2481run_test "SNI: CA override" \
2482 "$P_SRV debug_level=3 auth_mode=optional \
2483 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2484 ca_file=data_files/test-ca.crt \
2485 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2486 "$P_CLI debug_level=3 server_name=localhost \
2487 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2488 0 \
2489 -S "skip write certificate request" \
2490 -C "skip parse certificate request" \
2491 -c "got a certificate request" \
2492 -C "skip write certificate" \
2493 -C "skip write certificate verify" \
2494 -S "skip parse certificate verify" \
2495 -S "x509_verify_cert() returned" \
2496 -S "! The certificate is not correctly signed by the trusted CA" \
2497 -S "The certificate has been revoked (is on a CRL)"
2498
2499run_test "SNI: CA override with CRL" \
2500 "$P_SRV debug_level=3 auth_mode=optional \
2501 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2502 ca_file=data_files/test-ca.crt \
2503 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2504 "$P_CLI debug_level=3 server_name=localhost \
2505 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2506 1 \
2507 -S "skip write certificate request" \
2508 -C "skip parse certificate request" \
2509 -c "got a certificate request" \
2510 -C "skip write certificate" \
2511 -C "skip write certificate verify" \
2512 -S "skip parse certificate verify" \
2513 -s "x509_verify_cert() returned" \
2514 -S "! The certificate is not correctly signed by the trusted CA" \
2515 -s "The certificate has been revoked (is on a CRL)"
2516
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002517# Tests for non-blocking I/O: exercise a variety of handshake flows
2518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002519run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002520 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2521 "$P_CLI nbio=2 tickets=0" \
2522 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002523 -S "mbedtls_ssl_handshake returned" \
2524 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002525 -c "Read from server: .* bytes read"
2526
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002527run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002528 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2529 "$P_CLI nbio=2 tickets=0" \
2530 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002531 -S "mbedtls_ssl_handshake returned" \
2532 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002533 -c "Read from server: .* bytes read"
2534
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002535run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002536 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2537 "$P_CLI nbio=2 tickets=1" \
2538 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002539 -S "mbedtls_ssl_handshake returned" \
2540 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002541 -c "Read from server: .* bytes read"
2542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002543run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002544 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2545 "$P_CLI nbio=2 tickets=1" \
2546 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002547 -S "mbedtls_ssl_handshake returned" \
2548 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002549 -c "Read from server: .* bytes read"
2550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002551run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002552 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2553 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2554 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002555 -S "mbedtls_ssl_handshake returned" \
2556 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002557 -c "Read from server: .* bytes read"
2558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002559run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002560 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2561 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2562 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002563 -S "mbedtls_ssl_handshake returned" \
2564 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002565 -c "Read from server: .* bytes read"
2566
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002567run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002568 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2569 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2570 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002571 -S "mbedtls_ssl_handshake returned" \
2572 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002573 -c "Read from server: .* bytes read"
2574
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002575# Tests for version negotiation
2576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002577run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002578 "$P_SRV" \
2579 "$P_CLI" \
2580 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002581 -S "mbedtls_ssl_handshake returned" \
2582 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002583 -s "Protocol is TLSv1.2" \
2584 -c "Protocol is TLSv1.2"
2585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002586run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002587 "$P_SRV" \
2588 "$P_CLI max_version=tls1_1" \
2589 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002590 -S "mbedtls_ssl_handshake returned" \
2591 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002592 -s "Protocol is TLSv1.1" \
2593 -c "Protocol is TLSv1.1"
2594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002595run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002596 "$P_SRV max_version=tls1_1" \
2597 "$P_CLI" \
2598 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002599 -S "mbedtls_ssl_handshake returned" \
2600 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002601 -s "Protocol is TLSv1.1" \
2602 -c "Protocol is TLSv1.1"
2603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002604run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002605 "$P_SRV max_version=tls1_1" \
2606 "$P_CLI max_version=tls1_1" \
2607 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002608 -S "mbedtls_ssl_handshake returned" \
2609 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002610 -s "Protocol is TLSv1.1" \
2611 -c "Protocol is TLSv1.1"
2612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002613run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002614 "$P_SRV min_version=tls1_1" \
2615 "$P_CLI max_version=tls1_1" \
2616 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002617 -S "mbedtls_ssl_handshake returned" \
2618 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002619 -s "Protocol is TLSv1.1" \
2620 -c "Protocol is TLSv1.1"
2621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002622run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002623 "$P_SRV max_version=tls1_1" \
2624 "$P_CLI min_version=tls1_1" \
2625 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002626 -S "mbedtls_ssl_handshake returned" \
2627 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002628 -s "Protocol is TLSv1.1" \
2629 -c "Protocol is TLSv1.1"
2630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002631run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002632 "$P_SRV max_version=tls1_1" \
2633 "$P_CLI min_version=tls1_2" \
2634 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002635 -s "mbedtls_ssl_handshake returned" \
2636 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002637 -c "SSL - Handshake protocol not within min/max boundaries"
2638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002639run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002640 "$P_SRV min_version=tls1_2" \
2641 "$P_CLI max_version=tls1_1" \
2642 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002643 -s "mbedtls_ssl_handshake returned" \
2644 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002645 -s "SSL - Handshake protocol not within min/max boundaries"
2646
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002647# Tests for ALPN extension
2648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002649run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002650 "$P_SRV debug_level=3" \
2651 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002652 0 \
2653 -C "client hello, adding alpn extension" \
2654 -S "found alpn extension" \
2655 -C "got an alert message, type: \\[2:120]" \
2656 -S "server hello, adding alpn extension" \
2657 -C "found alpn extension " \
2658 -C "Application Layer Protocol is" \
2659 -S "Application Layer Protocol is"
2660
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002661run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002662 "$P_SRV debug_level=3" \
2663 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002664 0 \
2665 -c "client hello, adding alpn extension" \
2666 -s "found alpn extension" \
2667 -C "got an alert message, type: \\[2:120]" \
2668 -S "server hello, adding alpn extension" \
2669 -C "found alpn extension " \
2670 -c "Application Layer Protocol is (none)" \
2671 -S "Application Layer Protocol is"
2672
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002673run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002674 "$P_SRV debug_level=3 alpn=abc,1234" \
2675 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002676 0 \
2677 -C "client hello, adding alpn extension" \
2678 -S "found alpn extension" \
2679 -C "got an alert message, type: \\[2:120]" \
2680 -S "server hello, adding alpn extension" \
2681 -C "found alpn extension " \
2682 -C "Application Layer Protocol is" \
2683 -s "Application Layer Protocol is (none)"
2684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002685run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002686 "$P_SRV debug_level=3 alpn=abc,1234" \
2687 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002688 0 \
2689 -c "client hello, adding alpn extension" \
2690 -s "found alpn extension" \
2691 -C "got an alert message, type: \\[2:120]" \
2692 -s "server hello, adding alpn extension" \
2693 -c "found alpn extension" \
2694 -c "Application Layer Protocol is abc" \
2695 -s "Application Layer Protocol is abc"
2696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002697run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002698 "$P_SRV debug_level=3 alpn=abc,1234" \
2699 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002700 0 \
2701 -c "client hello, adding alpn extension" \
2702 -s "found alpn extension" \
2703 -C "got an alert message, type: \\[2:120]" \
2704 -s "server hello, adding alpn extension" \
2705 -c "found alpn extension" \
2706 -c "Application Layer Protocol is abc" \
2707 -s "Application Layer Protocol is abc"
2708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002709run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002710 "$P_SRV debug_level=3 alpn=abc,1234" \
2711 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002712 0 \
2713 -c "client hello, adding alpn extension" \
2714 -s "found alpn extension" \
2715 -C "got an alert message, type: \\[2:120]" \
2716 -s "server hello, adding alpn extension" \
2717 -c "found alpn extension" \
2718 -c "Application Layer Protocol is 1234" \
2719 -s "Application Layer Protocol is 1234"
2720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002721run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002722 "$P_SRV debug_level=3 alpn=abc,123" \
2723 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002724 1 \
2725 -c "client hello, adding alpn extension" \
2726 -s "found alpn extension" \
2727 -c "got an alert message, type: \\[2:120]" \
2728 -S "server hello, adding alpn extension" \
2729 -C "found alpn extension" \
2730 -C "Application Layer Protocol is 1234" \
2731 -S "Application Layer Protocol is 1234"
2732
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002733
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002734# Tests for keyUsage in leaf certificates, part 1:
2735# server-side certificate/suite selection
2736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002737run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002738 "$P_SRV key_file=data_files/server2.key \
2739 crt_file=data_files/server2.ku-ds.crt" \
2740 "$P_CLI" \
2741 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002742 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002743
2744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002745run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002746 "$P_SRV key_file=data_files/server2.key \
2747 crt_file=data_files/server2.ku-ke.crt" \
2748 "$P_CLI" \
2749 0 \
2750 -c "Ciphersuite is TLS-RSA-WITH-"
2751
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002752run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002753 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002754 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002755 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002756 1 \
2757 -C "Ciphersuite is "
2758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002759run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002760 "$P_SRV key_file=data_files/server5.key \
2761 crt_file=data_files/server5.ku-ds.crt" \
2762 "$P_CLI" \
2763 0 \
2764 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2765
2766
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002767run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002768 "$P_SRV key_file=data_files/server5.key \
2769 crt_file=data_files/server5.ku-ka.crt" \
2770 "$P_CLI" \
2771 0 \
2772 -c "Ciphersuite is TLS-ECDH-"
2773
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002774run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002775 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002776 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002777 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002778 1 \
2779 -C "Ciphersuite is "
2780
2781# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002782# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002784run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002785 "$O_SRV -key data_files/server2.key \
2786 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002787 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002788 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2789 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002790 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002791 -C "Processing of the Certificate handshake message failed" \
2792 -c "Ciphersuite is TLS-"
2793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002794run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002795 "$O_SRV -key data_files/server2.key \
2796 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002797 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002798 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2799 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002800 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002801 -C "Processing of the Certificate handshake message failed" \
2802 -c "Ciphersuite is TLS-"
2803
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002804run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002805 "$O_SRV -key data_files/server2.key \
2806 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002807 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002808 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2809 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002810 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002811 -C "Processing of the Certificate handshake message failed" \
2812 -c "Ciphersuite is TLS-"
2813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002814run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002815 "$O_SRV -key data_files/server2.key \
2816 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002817 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002818 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2819 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002820 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002821 -c "Processing of the Certificate handshake message failed" \
2822 -C "Ciphersuite is TLS-"
2823
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002824run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2825 "$O_SRV -key data_files/server2.key \
2826 -cert data_files/server2.ku-ke.crt" \
2827 "$P_CLI debug_level=1 auth_mode=optional \
2828 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2829 0 \
2830 -c "bad certificate (usage extensions)" \
2831 -C "Processing of the Certificate handshake message failed" \
2832 -c "Ciphersuite is TLS-" \
2833 -c "! Usage does not match the keyUsage extension"
2834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002835run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002836 "$O_SRV -key data_files/server2.key \
2837 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002838 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002839 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2840 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002841 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002842 -C "Processing of the Certificate handshake message failed" \
2843 -c "Ciphersuite is TLS-"
2844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002845run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002846 "$O_SRV -key data_files/server2.key \
2847 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002848 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002849 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2850 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002851 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002852 -c "Processing of the Certificate handshake message failed" \
2853 -C "Ciphersuite is TLS-"
2854
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002855run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2856 "$O_SRV -key data_files/server2.key \
2857 -cert data_files/server2.ku-ds.crt" \
2858 "$P_CLI debug_level=1 auth_mode=optional \
2859 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2860 0 \
2861 -c "bad certificate (usage extensions)" \
2862 -C "Processing of the Certificate handshake message failed" \
2863 -c "Ciphersuite is TLS-" \
2864 -c "! Usage does not match the keyUsage extension"
2865
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002866# Tests for keyUsage in leaf certificates, part 3:
2867# server-side checking of client cert
2868
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002869run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002870 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002871 "$O_CLI -key data_files/server2.key \
2872 -cert data_files/server2.ku-ds.crt" \
2873 0 \
2874 -S "bad certificate (usage extensions)" \
2875 -S "Processing of the Certificate handshake message failed"
2876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002877run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002878 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002879 "$O_CLI -key data_files/server2.key \
2880 -cert data_files/server2.ku-ke.crt" \
2881 0 \
2882 -s "bad certificate (usage extensions)" \
2883 -S "Processing of the Certificate handshake message failed"
2884
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002885run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002886 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002887 "$O_CLI -key data_files/server2.key \
2888 -cert data_files/server2.ku-ke.crt" \
2889 1 \
2890 -s "bad certificate (usage extensions)" \
2891 -s "Processing of the Certificate handshake message failed"
2892
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002893run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002894 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002895 "$O_CLI -key data_files/server5.key \
2896 -cert data_files/server5.ku-ds.crt" \
2897 0 \
2898 -S "bad certificate (usage extensions)" \
2899 -S "Processing of the Certificate handshake message failed"
2900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002901run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002902 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002903 "$O_CLI -key data_files/server5.key \
2904 -cert data_files/server5.ku-ka.crt" \
2905 0 \
2906 -s "bad certificate (usage extensions)" \
2907 -S "Processing of the Certificate handshake message failed"
2908
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002909# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2910
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002911run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002912 "$P_SRV key_file=data_files/server5.key \
2913 crt_file=data_files/server5.eku-srv.crt" \
2914 "$P_CLI" \
2915 0
2916
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002917run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002918 "$P_SRV key_file=data_files/server5.key \
2919 crt_file=data_files/server5.eku-srv.crt" \
2920 "$P_CLI" \
2921 0
2922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002923run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002924 "$P_SRV key_file=data_files/server5.key \
2925 crt_file=data_files/server5.eku-cs_any.crt" \
2926 "$P_CLI" \
2927 0
2928
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002929run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002930 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002931 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002932 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002933 1
2934
2935# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002937run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002938 "$O_SRV -key data_files/server5.key \
2939 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002940 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002941 0 \
2942 -C "bad certificate (usage extensions)" \
2943 -C "Processing of the Certificate handshake message failed" \
2944 -c "Ciphersuite is TLS-"
2945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002946run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002947 "$O_SRV -key data_files/server5.key \
2948 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002949 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002950 0 \
2951 -C "bad certificate (usage extensions)" \
2952 -C "Processing of the Certificate handshake message failed" \
2953 -c "Ciphersuite is TLS-"
2954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002955run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002956 "$O_SRV -key data_files/server5.key \
2957 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002958 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002959 0 \
2960 -C "bad certificate (usage extensions)" \
2961 -C "Processing of the Certificate handshake message failed" \
2962 -c "Ciphersuite is TLS-"
2963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002964run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002965 "$O_SRV -key data_files/server5.key \
2966 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002967 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002968 1 \
2969 -c "bad certificate (usage extensions)" \
2970 -c "Processing of the Certificate handshake message failed" \
2971 -C "Ciphersuite is TLS-"
2972
2973# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002975run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002976 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002977 "$O_CLI -key data_files/server5.key \
2978 -cert data_files/server5.eku-cli.crt" \
2979 0 \
2980 -S "bad certificate (usage extensions)" \
2981 -S "Processing of the Certificate handshake message failed"
2982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002983run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002984 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002985 "$O_CLI -key data_files/server5.key \
2986 -cert data_files/server5.eku-srv_cli.crt" \
2987 0 \
2988 -S "bad certificate (usage extensions)" \
2989 -S "Processing of the Certificate handshake message failed"
2990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002991run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002992 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002993 "$O_CLI -key data_files/server5.key \
2994 -cert data_files/server5.eku-cs_any.crt" \
2995 0 \
2996 -S "bad certificate (usage extensions)" \
2997 -S "Processing of the Certificate handshake message failed"
2998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002999run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003000 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003001 "$O_CLI -key data_files/server5.key \
3002 -cert data_files/server5.eku-cs.crt" \
3003 0 \
3004 -s "bad certificate (usage extensions)" \
3005 -S "Processing of the Certificate handshake message failed"
3006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003007run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003008 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003009 "$O_CLI -key data_files/server5.key \
3010 -cert data_files/server5.eku-cs.crt" \
3011 1 \
3012 -s "bad certificate (usage extensions)" \
3013 -s "Processing of the Certificate handshake message failed"
3014
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003015# Tests for DHM parameters loading
3016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003017run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003018 "$P_SRV" \
3019 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3020 debug_level=3" \
3021 0 \
3022 -c "value of 'DHM: P ' (2048 bits)" \
3023 -c "value of 'DHM: G ' (2048 bits)"
3024
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003025run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003026 "$P_SRV dhm_file=data_files/dhparams.pem" \
3027 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3028 debug_level=3" \
3029 0 \
3030 -c "value of 'DHM: P ' (1024 bits)" \
3031 -c "value of 'DHM: G ' (2 bits)"
3032
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003033# Tests for DHM client-side size checking
3034
3035run_test "DHM size: server default, client default, OK" \
3036 "$P_SRV" \
3037 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3038 debug_level=1" \
3039 0 \
3040 -C "DHM prime too short:"
3041
3042run_test "DHM size: server default, client 2048, OK" \
3043 "$P_SRV" \
3044 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3045 debug_level=1 dhmlen=2048" \
3046 0 \
3047 -C "DHM prime too short:"
3048
3049run_test "DHM size: server 1024, client default, OK" \
3050 "$P_SRV dhm_file=data_files/dhparams.pem" \
3051 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3052 debug_level=1" \
3053 0 \
3054 -C "DHM prime too short:"
3055
3056run_test "DHM size: server 1000, client default, rejected" \
3057 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3058 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3059 debug_level=1" \
3060 1 \
3061 -c "DHM prime too short:"
3062
3063run_test "DHM size: server default, client 2049, rejected" \
3064 "$P_SRV" \
3065 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3066 debug_level=1 dhmlen=2049" \
3067 1 \
3068 -c "DHM prime too short:"
3069
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003070# Tests for PSK callback
3071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003072run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003073 "$P_SRV psk=abc123 psk_identity=foo" \
3074 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3075 psk_identity=foo psk=abc123" \
3076 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003077 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003078 -S "SSL - Unknown identity received" \
3079 -S "SSL - Verification of the message MAC failed"
3080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003081run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003082 "$P_SRV" \
3083 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3084 psk_identity=foo psk=abc123" \
3085 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003086 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003087 -S "SSL - Unknown identity received" \
3088 -S "SSL - Verification of the message MAC failed"
3089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003090run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003091 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3092 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3093 psk_identity=foo psk=abc123" \
3094 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003095 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003096 -s "SSL - Unknown identity received" \
3097 -S "SSL - Verification of the message MAC failed"
3098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003099run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003100 "$P_SRV psk_list=abc,dead,def,beef" \
3101 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3102 psk_identity=abc psk=dead" \
3103 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003104 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003105 -S "SSL - Unknown identity received" \
3106 -S "SSL - Verification of the message MAC failed"
3107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003108run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003109 "$P_SRV psk_list=abc,dead,def,beef" \
3110 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3111 psk_identity=def psk=beef" \
3112 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003113 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003114 -S "SSL - Unknown identity received" \
3115 -S "SSL - Verification of the message MAC failed"
3116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003117run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003118 "$P_SRV psk_list=abc,dead,def,beef" \
3119 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3120 psk_identity=ghi psk=beef" \
3121 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003122 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003123 -s "SSL - Unknown identity received" \
3124 -S "SSL - Verification of the message MAC failed"
3125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003126run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003127 "$P_SRV psk_list=abc,dead,def,beef" \
3128 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3129 psk_identity=abc psk=beef" \
3130 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003131 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003132 -S "SSL - Unknown identity received" \
3133 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003134
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003135# Tests for EC J-PAKE
3136
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003137requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003138run_test "ECJPAKE: client not configured" \
3139 "$P_SRV debug_level=3" \
3140 "$P_CLI debug_level=3" \
3141 0 \
3142 -C "add ciphersuite: c0ff" \
3143 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003144 -S "found ecjpake kkpp extension" \
3145 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003146 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003147 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003148 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003149 -S "None of the common ciphersuites is usable"
3150
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003151requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003152run_test "ECJPAKE: server not configured" \
3153 "$P_SRV debug_level=3" \
3154 "$P_CLI debug_level=3 ecjpake_pw=bla \
3155 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3156 1 \
3157 -c "add ciphersuite: c0ff" \
3158 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003159 -s "found ecjpake kkpp extension" \
3160 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003161 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003162 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003163 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003164 -s "None of the common ciphersuites is usable"
3165
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003166requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003167run_test "ECJPAKE: working, TLS" \
3168 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3169 "$P_CLI debug_level=3 ecjpake_pw=bla \
3170 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003171 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003172 -c "add ciphersuite: c0ff" \
3173 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003174 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003175 -s "found ecjpake kkpp extension" \
3176 -S "skip ecjpake kkpp extension" \
3177 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003178 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003179 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003180 -S "None of the common ciphersuites is usable" \
3181 -S "SSL - Verification of the message MAC failed"
3182
Janos Follath74537a62016-09-02 13:45:28 +01003183server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003184requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003185run_test "ECJPAKE: password mismatch, TLS" \
3186 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3187 "$P_CLI debug_level=3 ecjpake_pw=bad \
3188 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3189 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003190 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003191 -s "SSL - Verification of the message MAC failed"
3192
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003193requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003194run_test "ECJPAKE: working, DTLS" \
3195 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3196 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3197 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3198 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003199 -c "re-using cached ecjpake parameters" \
3200 -S "SSL - Verification of the message MAC failed"
3201
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003202requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003203run_test "ECJPAKE: working, DTLS, no cookie" \
3204 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3205 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3206 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3207 0 \
3208 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003209 -S "SSL - Verification of the message MAC failed"
3210
Janos Follath74537a62016-09-02 13:45:28 +01003211server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003212requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003213run_test "ECJPAKE: password mismatch, DTLS" \
3214 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3215 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3216 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3217 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003218 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003219 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003220
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003221# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003222requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003223run_test "ECJPAKE: working, DTLS, nolog" \
3224 "$P_SRV dtls=1 ecjpake_pw=bla" \
3225 "$P_CLI dtls=1 ecjpake_pw=bla \
3226 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3227 0
3228
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003229# Tests for ciphersuites per version
3230
Janos Follathe2681a42016-03-07 15:57:05 +00003231requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003232run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003233 "$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 +02003234 "$P_CLI force_version=ssl3" \
3235 0 \
3236 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003238run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003239 "$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 +01003240 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003241 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003242 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003243
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003244run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003245 "$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 +02003246 "$P_CLI force_version=tls1_1" \
3247 0 \
3248 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3249
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003250run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003251 "$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 +02003252 "$P_CLI force_version=tls1_2" \
3253 0 \
3254 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3255
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003256# Test for ClientHello without extensions
3257
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003258requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003259run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003260 "$P_SRV debug_level=3" \
3261 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3262 0 \
3263 -s "dumping 'client hello extensions' (0 bytes)"
3264
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003265requires_gnutls
3266run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3267 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3268 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3269 0 \
3270 -s "dumping 'client hello extensions' (0 bytes)"
3271
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003272# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003273
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003274run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003275 "$P_SRV" \
3276 "$P_CLI request_size=100" \
3277 0 \
3278 -s "Read from client: 100 bytes read$"
3279
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003280run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003281 "$P_SRV" \
3282 "$P_CLI request_size=500" \
3283 0 \
3284 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003285
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003286# Tests for small packets
3287
Janos Follathe2681a42016-03-07 15:57:05 +00003288requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003289run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003290 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003291 "$P_CLI request_size=1 force_version=ssl3 \
3292 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3293 0 \
3294 -s "Read from client: 1 bytes read"
3295
Janos Follathe2681a42016-03-07 15:57:05 +00003296requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003297run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003298 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003299 "$P_CLI request_size=1 force_version=ssl3 \
3300 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3301 0 \
3302 -s "Read from client: 1 bytes read"
3303
3304run_test "Small packet TLS 1.0 BlockCipher" \
3305 "$P_SRV" \
3306 "$P_CLI request_size=1 force_version=tls1 \
3307 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3308 0 \
3309 -s "Read from client: 1 bytes read"
3310
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003311run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3312 "$P_SRV" \
3313 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3314 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3315 0 \
3316 -s "Read from client: 1 bytes read"
3317
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003318run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3319 "$P_SRV" \
3320 "$P_CLI request_size=1 force_version=tls1 \
3321 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3322 trunc_hmac=1" \
3323 0 \
3324 -s "Read from client: 1 bytes read"
3325
3326run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003327 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003328 "$P_CLI request_size=1 force_version=tls1 \
3329 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3330 trunc_hmac=1" \
3331 0 \
3332 -s "Read from client: 1 bytes read"
3333
3334run_test "Small packet TLS 1.1 BlockCipher" \
3335 "$P_SRV" \
3336 "$P_CLI request_size=1 force_version=tls1_1 \
3337 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3338 0 \
3339 -s "Read from client: 1 bytes read"
3340
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003341run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3342 "$P_SRV" \
3343 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3344 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3345 0 \
3346 -s "Read from client: 1 bytes read"
3347
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003348run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003349 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003350 "$P_CLI request_size=1 force_version=tls1_1 \
3351 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3352 0 \
3353 -s "Read from client: 1 bytes read"
3354
3355run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3356 "$P_SRV" \
3357 "$P_CLI request_size=1 force_version=tls1_1 \
3358 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3359 trunc_hmac=1" \
3360 0 \
3361 -s "Read from client: 1 bytes read"
3362
3363run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003364 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003365 "$P_CLI request_size=1 force_version=tls1_1 \
3366 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3367 trunc_hmac=1" \
3368 0 \
3369 -s "Read from client: 1 bytes read"
3370
3371run_test "Small packet TLS 1.2 BlockCipher" \
3372 "$P_SRV" \
3373 "$P_CLI request_size=1 force_version=tls1_2 \
3374 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3375 0 \
3376 -s "Read from client: 1 bytes read"
3377
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003378run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3379 "$P_SRV" \
3380 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3381 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3382 0 \
3383 -s "Read from client: 1 bytes read"
3384
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003385run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3386 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003387 "$P_CLI request_size=1 force_version=tls1_2 \
3388 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003389 0 \
3390 -s "Read from client: 1 bytes read"
3391
3392run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3393 "$P_SRV" \
3394 "$P_CLI request_size=1 force_version=tls1_2 \
3395 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3396 trunc_hmac=1" \
3397 0 \
3398 -s "Read from client: 1 bytes read"
3399
3400run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003401 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003402 "$P_CLI request_size=1 force_version=tls1_2 \
3403 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3404 0 \
3405 -s "Read from client: 1 bytes read"
3406
3407run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003408 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003409 "$P_CLI request_size=1 force_version=tls1_2 \
3410 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3411 trunc_hmac=1" \
3412 0 \
3413 -s "Read from client: 1 bytes read"
3414
3415run_test "Small packet TLS 1.2 AEAD" \
3416 "$P_SRV" \
3417 "$P_CLI request_size=1 force_version=tls1_2 \
3418 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3419 0 \
3420 -s "Read from client: 1 bytes read"
3421
3422run_test "Small packet TLS 1.2 AEAD shorter tag" \
3423 "$P_SRV" \
3424 "$P_CLI request_size=1 force_version=tls1_2 \
3425 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3426 0 \
3427 -s "Read from client: 1 bytes read"
3428
Janos Follath00efff72016-05-06 13:48:23 +01003429# A test for extensions in SSLv3
3430
3431requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3432run_test "SSLv3 with extensions, server side" \
3433 "$P_SRV min_version=ssl3 debug_level=3" \
3434 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3435 0 \
3436 -S "dumping 'client hello extensions'" \
3437 -S "server hello, total extension length:"
3438
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003439# Test for large packets
3440
Janos Follathe2681a42016-03-07 15:57:05 +00003441requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003442run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003443 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003444 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003445 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3446 0 \
3447 -s "Read from client: 16384 bytes read"
3448
Janos Follathe2681a42016-03-07 15:57:05 +00003449requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003450run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003451 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003452 "$P_CLI request_size=16384 force_version=ssl3 \
3453 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3454 0 \
3455 -s "Read from client: 16384 bytes read"
3456
3457run_test "Large packet TLS 1.0 BlockCipher" \
3458 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003459 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003460 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3461 0 \
3462 -s "Read from client: 16384 bytes read"
3463
3464run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3465 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003466 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003467 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3468 trunc_hmac=1" \
3469 0 \
3470 -s "Read from client: 16384 bytes read"
3471
3472run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003473 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003474 "$P_CLI request_size=16384 force_version=tls1 \
3475 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3476 trunc_hmac=1" \
3477 0 \
3478 -s "Read from client: 16384 bytes read"
3479
3480run_test "Large packet TLS 1.1 BlockCipher" \
3481 "$P_SRV" \
3482 "$P_CLI request_size=16384 force_version=tls1_1 \
3483 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3484 0 \
3485 -s "Read from client: 16384 bytes read"
3486
3487run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003488 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003489 "$P_CLI request_size=16384 force_version=tls1_1 \
3490 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3491 0 \
3492 -s "Read from client: 16384 bytes read"
3493
3494run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3495 "$P_SRV" \
3496 "$P_CLI request_size=16384 force_version=tls1_1 \
3497 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3498 trunc_hmac=1" \
3499 0 \
3500 -s "Read from client: 16384 bytes read"
3501
3502run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003503 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003504 "$P_CLI request_size=16384 force_version=tls1_1 \
3505 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3506 trunc_hmac=1" \
3507 0 \
3508 -s "Read from client: 16384 bytes read"
3509
3510run_test "Large packet TLS 1.2 BlockCipher" \
3511 "$P_SRV" \
3512 "$P_CLI request_size=16384 force_version=tls1_2 \
3513 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3514 0 \
3515 -s "Read from client: 16384 bytes read"
3516
3517run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3518 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003519 "$P_CLI request_size=16384 force_version=tls1_2 \
3520 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003521 0 \
3522 -s "Read from client: 16384 bytes read"
3523
3524run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3525 "$P_SRV" \
3526 "$P_CLI request_size=16384 force_version=tls1_2 \
3527 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3528 trunc_hmac=1" \
3529 0 \
3530 -s "Read from client: 16384 bytes read"
3531
3532run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003533 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003534 "$P_CLI request_size=16384 force_version=tls1_2 \
3535 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3536 0 \
3537 -s "Read from client: 16384 bytes read"
3538
3539run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003540 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003541 "$P_CLI request_size=16384 force_version=tls1_2 \
3542 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3543 trunc_hmac=1" \
3544 0 \
3545 -s "Read from client: 16384 bytes read"
3546
3547run_test "Large packet TLS 1.2 AEAD" \
3548 "$P_SRV" \
3549 "$P_CLI request_size=16384 force_version=tls1_2 \
3550 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3551 0 \
3552 -s "Read from client: 16384 bytes read"
3553
3554run_test "Large packet TLS 1.2 AEAD shorter tag" \
3555 "$P_SRV" \
3556 "$P_CLI request_size=16384 force_version=tls1_2 \
3557 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3558 0 \
3559 -s "Read from client: 16384 bytes read"
3560
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003561# Tests for DTLS HelloVerifyRequest
3562
3563run_test "DTLS cookie: enabled" \
3564 "$P_SRV dtls=1 debug_level=2" \
3565 "$P_CLI dtls=1 debug_level=2" \
3566 0 \
3567 -s "cookie verification failed" \
3568 -s "cookie verification passed" \
3569 -S "cookie verification skipped" \
3570 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003571 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003572 -S "SSL - The requested feature is not available"
3573
3574run_test "DTLS cookie: disabled" \
3575 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3576 "$P_CLI dtls=1 debug_level=2" \
3577 0 \
3578 -S "cookie verification failed" \
3579 -S "cookie verification passed" \
3580 -s "cookie verification skipped" \
3581 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003582 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003583 -S "SSL - The requested feature is not available"
3584
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003585run_test "DTLS cookie: default (failing)" \
3586 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3587 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3588 1 \
3589 -s "cookie verification failed" \
3590 -S "cookie verification passed" \
3591 -S "cookie verification skipped" \
3592 -C "received hello verify request" \
3593 -S "hello verification requested" \
3594 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003595
3596requires_ipv6
3597run_test "DTLS cookie: enabled, IPv6" \
3598 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3599 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3600 0 \
3601 -s "cookie verification failed" \
3602 -s "cookie verification passed" \
3603 -S "cookie verification skipped" \
3604 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003605 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003606 -S "SSL - The requested feature is not available"
3607
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003608run_test "DTLS cookie: enabled, nbio" \
3609 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3610 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3611 0 \
3612 -s "cookie verification failed" \
3613 -s "cookie verification passed" \
3614 -S "cookie verification skipped" \
3615 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003616 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003617 -S "SSL - The requested feature is not available"
3618
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003619# Tests for client reconnecting from the same port with DTLS
3620
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003621not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003622run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003623 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3624 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003625 0 \
3626 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003627 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003628 -S "Client initiated reconnection from same port"
3629
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003630not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003631run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003632 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3633 "$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 +02003634 0 \
3635 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003636 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003637 -s "Client initiated reconnection from same port"
3638
Paul Bakker362689d2016-05-13 10:33:25 +01003639not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3640run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003641 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3642 "$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 +02003643 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003644 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003645 -s "Client initiated reconnection from same port"
3646
Paul Bakker362689d2016-05-13 10:33:25 +01003647only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3648run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3649 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3650 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3651 0 \
3652 -S "The operation timed out" \
3653 -s "Client initiated reconnection from same port"
3654
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003655run_test "DTLS client reconnect from same port: no cookies" \
3656 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003657 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3658 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003659 -s "The operation timed out" \
3660 -S "Client initiated reconnection from same port"
3661
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003662# Tests for various cases of client authentication with DTLS
3663# (focused on handshake flows and message parsing)
3664
3665run_test "DTLS client auth: required" \
3666 "$P_SRV dtls=1 auth_mode=required" \
3667 "$P_CLI dtls=1" \
3668 0 \
3669 -s "Verifying peer X.509 certificate... ok"
3670
3671run_test "DTLS client auth: optional, client has no cert" \
3672 "$P_SRV dtls=1 auth_mode=optional" \
3673 "$P_CLI dtls=1 crt_file=none key_file=none" \
3674 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003675 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003676
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003677run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003678 "$P_SRV dtls=1 auth_mode=none" \
3679 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3680 0 \
3681 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003682 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003683
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003684run_test "DTLS wrong PSK: badmac alert" \
3685 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3686 "$P_CLI dtls=1 psk=abc124" \
3687 1 \
3688 -s "SSL - Verification of the message MAC failed" \
3689 -c "SSL - A fatal alert message was received from our peer"
3690
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003691# Tests for receiving fragmented handshake messages with DTLS
3692
3693requires_gnutls
3694run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3695 "$G_SRV -u --mtu 2048 -a" \
3696 "$P_CLI dtls=1 debug_level=2" \
3697 0 \
3698 -C "found fragmented DTLS handshake message" \
3699 -C "error"
3700
3701requires_gnutls
3702run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3703 "$G_SRV -u --mtu 512" \
3704 "$P_CLI dtls=1 debug_level=2" \
3705 0 \
3706 -c "found fragmented DTLS handshake message" \
3707 -C "error"
3708
3709requires_gnutls
3710run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3711 "$G_SRV -u --mtu 128" \
3712 "$P_CLI dtls=1 debug_level=2" \
3713 0 \
3714 -c "found fragmented DTLS handshake message" \
3715 -C "error"
3716
3717requires_gnutls
3718run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3719 "$G_SRV -u --mtu 128" \
3720 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3721 0 \
3722 -c "found fragmented DTLS handshake message" \
3723 -C "error"
3724
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003725requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003726requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003727run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3728 "$G_SRV -u --mtu 256" \
3729 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3730 0 \
3731 -c "found fragmented DTLS handshake message" \
3732 -c "client hello, adding renegotiation extension" \
3733 -c "found renegotiation extension" \
3734 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003735 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003736 -C "error" \
3737 -s "Extra-header:"
3738
3739requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003740requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003741run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3742 "$G_SRV -u --mtu 256" \
3743 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3744 0 \
3745 -c "found fragmented DTLS handshake message" \
3746 -c "client hello, adding renegotiation extension" \
3747 -c "found renegotiation extension" \
3748 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003749 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003750 -C "error" \
3751 -s "Extra-header:"
3752
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003753run_test "DTLS reassembly: no fragmentation (openssl server)" \
3754 "$O_SRV -dtls1 -mtu 2048" \
3755 "$P_CLI dtls=1 debug_level=2" \
3756 0 \
3757 -C "found fragmented DTLS handshake message" \
3758 -C "error"
3759
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003760run_test "DTLS reassembly: some fragmentation (openssl server)" \
3761 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003762 "$P_CLI dtls=1 debug_level=2" \
3763 0 \
3764 -c "found fragmented DTLS handshake message" \
3765 -C "error"
3766
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003767run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003768 "$O_SRV -dtls1 -mtu 256" \
3769 "$P_CLI dtls=1 debug_level=2" \
3770 0 \
3771 -c "found fragmented DTLS handshake message" \
3772 -C "error"
3773
3774run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3775 "$O_SRV -dtls1 -mtu 256" \
3776 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3777 0 \
3778 -c "found fragmented DTLS handshake message" \
3779 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003780
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003781# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003782
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003783not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003784run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003785 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003786 "$P_SRV dtls=1 debug_level=2" \
3787 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003788 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003789 -C "replayed record" \
3790 -S "replayed record" \
3791 -C "record from another epoch" \
3792 -S "record from another epoch" \
3793 -C "discarding invalid record" \
3794 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003795 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003796 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003797 -c "HTTP/1.0 200 OK"
3798
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003799not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003800run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003801 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003802 "$P_SRV dtls=1 debug_level=2" \
3803 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003804 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003805 -c "replayed record" \
3806 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003807 -c "discarding invalid record" \
3808 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003809 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003810 -s "Extra-header:" \
3811 -c "HTTP/1.0 200 OK"
3812
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003813run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3814 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003815 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3816 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003817 0 \
3818 -c "replayed record" \
3819 -S "replayed record" \
3820 -c "discarding invalid record" \
3821 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003822 -c "resend" \
3823 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003824 -s "Extra-header:" \
3825 -c "HTTP/1.0 200 OK"
3826
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003827run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003828 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003829 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003830 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003831 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003832 -c "discarding invalid record (mac)" \
3833 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003834 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003835 -c "HTTP/1.0 200 OK" \
3836 -S "too many records with bad MAC" \
3837 -S "Verification of the message MAC failed"
3838
3839run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3840 -p "$P_PXY bad_ad=1" \
3841 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3842 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3843 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003844 -C "discarding invalid record (mac)" \
3845 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003846 -S "Extra-header:" \
3847 -C "HTTP/1.0 200 OK" \
3848 -s "too many records with bad MAC" \
3849 -s "Verification of the message MAC failed"
3850
3851run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3852 -p "$P_PXY bad_ad=1" \
3853 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3854 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3855 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003856 -c "discarding invalid record (mac)" \
3857 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003858 -s "Extra-header:" \
3859 -c "HTTP/1.0 200 OK" \
3860 -S "too many records with bad MAC" \
3861 -S "Verification of the message MAC failed"
3862
3863run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3864 -p "$P_PXY bad_ad=1" \
3865 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3866 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3867 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003868 -c "discarding invalid record (mac)" \
3869 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003870 -s "Extra-header:" \
3871 -c "HTTP/1.0 200 OK" \
3872 -s "too many records with bad MAC" \
3873 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003874
3875run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003876 -p "$P_PXY delay_ccs=1" \
3877 "$P_SRV dtls=1 debug_level=1" \
3878 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003879 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003880 -c "record from another epoch" \
3881 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003882 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003883 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003884 -s "Extra-header:" \
3885 -c "HTTP/1.0 200 OK"
3886
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003887# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003888
Janos Follath74537a62016-09-02 13:45:28 +01003889client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003890run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003891 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003892 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3893 psk=abc123" \
3894 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003895 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3896 0 \
3897 -s "Extra-header:" \
3898 -c "HTTP/1.0 200 OK"
3899
Janos Follath74537a62016-09-02 13:45:28 +01003900client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003901run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3902 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003903 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3904 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003905 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3906 0 \
3907 -s "Extra-header:" \
3908 -c "HTTP/1.0 200 OK"
3909
Janos Follath74537a62016-09-02 13:45:28 +01003910client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003911run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3912 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003913 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3914 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003915 0 \
3916 -s "Extra-header:" \
3917 -c "HTTP/1.0 200 OK"
3918
Janos Follath74537a62016-09-02 13:45:28 +01003919client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003920run_test "DTLS proxy: 3d, FS, client auth" \
3921 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003922 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3923 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003924 0 \
3925 -s "Extra-header:" \
3926 -c "HTTP/1.0 200 OK"
3927
Janos Follath74537a62016-09-02 13:45:28 +01003928client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003929run_test "DTLS proxy: 3d, FS, ticket" \
3930 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003931 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3932 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003933 0 \
3934 -s "Extra-header:" \
3935 -c "HTTP/1.0 200 OK"
3936
Janos Follath74537a62016-09-02 13:45:28 +01003937client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003938run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3939 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003940 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3941 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003942 0 \
3943 -s "Extra-header:" \
3944 -c "HTTP/1.0 200 OK"
3945
Janos Follath74537a62016-09-02 13:45:28 +01003946client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003947run_test "DTLS proxy: 3d, max handshake, nbio" \
3948 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003949 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3950 auth_mode=required" \
3951 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003952 0 \
3953 -s "Extra-header:" \
3954 -c "HTTP/1.0 200 OK"
3955
Janos Follath74537a62016-09-02 13:45:28 +01003956client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003957run_test "DTLS proxy: 3d, min handshake, resumption" \
3958 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3959 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3960 psk=abc123 debug_level=3" \
3961 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3962 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3963 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3964 0 \
3965 -s "a session has been resumed" \
3966 -c "a session has been resumed" \
3967 -s "Extra-header:" \
3968 -c "HTTP/1.0 200 OK"
3969
Janos Follath74537a62016-09-02 13:45:28 +01003970client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003971run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3972 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3973 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3974 psk=abc123 debug_level=3 nbio=2" \
3975 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3976 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3977 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3978 0 \
3979 -s "a session has been resumed" \
3980 -c "a session has been resumed" \
3981 -s "Extra-header:" \
3982 -c "HTTP/1.0 200 OK"
3983
Janos Follath74537a62016-09-02 13:45:28 +01003984client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01003985requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003986run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003987 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003988 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3989 psk=abc123 renegotiation=1 debug_level=2" \
3990 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3991 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003992 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3993 0 \
3994 -c "=> renegotiate" \
3995 -s "=> renegotiate" \
3996 -s "Extra-header:" \
3997 -c "HTTP/1.0 200 OK"
3998
Janos Follath74537a62016-09-02 13:45:28 +01003999client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004000requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004001run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4002 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004003 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4004 psk=abc123 renegotiation=1 debug_level=2" \
4005 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4006 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004007 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4008 0 \
4009 -c "=> renegotiate" \
4010 -s "=> renegotiate" \
4011 -s "Extra-header:" \
4012 -c "HTTP/1.0 200 OK"
4013
Janos Follath74537a62016-09-02 13:45:28 +01004014client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004015requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004016run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004017 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004018 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004019 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004020 debug_level=2" \
4021 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004022 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004023 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4024 0 \
4025 -c "=> renegotiate" \
4026 -s "=> renegotiate" \
4027 -s "Extra-header:" \
4028 -c "HTTP/1.0 200 OK"
4029
Janos Follath74537a62016-09-02 13:45:28 +01004030client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004031requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004032run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004033 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004034 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004035 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004036 debug_level=2 nbio=2" \
4037 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004038 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004039 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4040 0 \
4041 -c "=> renegotiate" \
4042 -s "=> renegotiate" \
4043 -s "Extra-header:" \
4044 -c "HTTP/1.0 200 OK"
4045
Janos Follath74537a62016-09-02 13:45:28 +01004046client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004047not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004048run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004049 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4050 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004051 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004052 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004053 -c "HTTP/1.0 200 OK"
4054
Janos Follath74537a62016-09-02 13:45:28 +01004055client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004056not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004057run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4058 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4059 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004060 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004061 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004062 -c "HTTP/1.0 200 OK"
4063
Janos Follath74537a62016-09-02 13:45:28 +01004064client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004065not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004066run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4067 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4068 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004069 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004070 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004071 -c "HTTP/1.0 200 OK"
4072
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004073requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004074client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004075not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004076run_test "DTLS proxy: 3d, gnutls server" \
4077 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4078 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004079 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004080 0 \
4081 -s "Extra-header:" \
4082 -c "Extra-header:"
4083
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004084requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004085client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004086not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004087run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4088 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4089 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004090 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004091 0 \
4092 -s "Extra-header:" \
4093 -c "Extra-header:"
4094
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004095requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004096client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004097not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004098run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4099 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4100 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004101 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004102 0 \
4103 -s "Extra-header:" \
4104 -c "Extra-header:"
4105
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004106# Final report
4107
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004108echo "------------------------------------------------------------------------"
4109
4110if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004111 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004112else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004113 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004114fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004115PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004116echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004117
4118exit $FAILS