blob: dcf9bb1c21ecdf8bb982a4c0c5b12684a1de8ab0 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnard6461f362015-06-29 16:20:13 +020020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010021O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010023G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010037 printf " -h|--help\tPrint this help.\n"
38 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
39 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
40 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Janos Follath4dfecab2016-03-14 13:40:43 +000069# skip next test if the flag is not enabled in config.h
70requires_config_enabled() {
71 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
72 SKIP_NEXT="YES"
73 fi
74}
75
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020076# skip next test if OpenSSL can't send SSLv2 ClientHello
77requires_openssl_with_sslv2() {
78 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020079 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020080 OPENSSL_HAS_SSL2="YES"
81 else
82 OPENSSL_HAS_SSL2="NO"
83 fi
84 fi
85 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
86 SKIP_NEXT="YES"
87 fi
88}
89
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020090# skip next test if OpenSSL doesn't support FALLBACK_SCSV
91requires_openssl_with_fallback_scsv() {
92 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
93 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
94 then
95 OPENSSL_HAS_FBSCSV="YES"
96 else
97 OPENSSL_HAS_FBSCSV="NO"
98 fi
99 fi
100 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
101 SKIP_NEXT="YES"
102 fi
103}
104
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200105# skip next test if GnuTLS isn't available
106requires_gnutls() {
107 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
108 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
109 GNUTLS_AVAILABLE="YES"
110 else
111 GNUTLS_AVAILABLE="NO"
112 fi
113 fi
114 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
115 SKIP_NEXT="YES"
116 fi
117}
118
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100119# print_name <name>
120print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100121 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200122 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100123 for i in `seq 1 $LEN`; do printf '.'; done
124 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100125
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200126 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100127}
128
129# fail <message>
130fail() {
131 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100132 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100133
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200134 mv $SRV_OUT o-srv-${TESTS}.log
135 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100136 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100137
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200138 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
139 echo " ! server output:"
140 cat o-srv-${TESTS}.log
141 echo " ! ============================================================"
142 echo " ! client output:"
143 cat o-cli-${TESTS}.log
144 fi
145
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200146 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100147}
148
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100149# is_polar <cmd_line>
150is_polar() {
151 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
152}
153
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100154# has_mem_err <log_file_name>
155has_mem_err() {
156 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
157 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
158 then
159 return 1 # false: does not have errors
160 else
161 return 0 # true: has errors
162 fi
163}
164
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200165# wait for server to start: two versions depending on lsof availability
166wait_server_start() {
Manuel Pégourié-Gonnard84690c32015-08-04 20:34:39 +0200167 if which lsof >/dev/null 2>&1; then
168 START_TIME=$( date +%s )
169 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200170
171 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard84690c32015-08-04 20:34:39 +0200172 while [ $DONE -eq 0 ]; do
173 if lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null
174 then
175 DONE=1
176 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
177 echo "SERVERSTART TIMEOUT"
178 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
179 DONE=1
180 fi
181 done
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200182 else
183 sleep "$START_DELAY"
184 fi
185}
186
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200187# wait for client to terminate and set CLI_EXIT
188# must be called right after starting the client
189wait_client_done() {
190 CLI_PID=$!
191
192 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
193 WATCHDOG_PID=$!
194
195 wait $CLI_PID
196 CLI_EXIT=$?
197
198 kill $WATCHDOG_PID
199 wait $WATCHDOG_PID
200
201 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
202}
203
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100204# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100205# Options: -s pattern pattern that must be present in server output
206# -c pattern pattern that must be present in client output
207# -S pattern pattern that must be absent in server output
208# -C pattern pattern that must be absent in client output
209run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100210 NAME="$1"
211 SRV_CMD="$2"
212 CLI_CMD="$3"
213 CLI_EXPECT="$4"
214 shift 4
215
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100216 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
217 else
218 return
219 fi
220
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100221 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100222
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200223 # should we skip?
224 if [ "X$SKIP_NEXT" = "XYES" ]; then
225 SKIP_NEXT="NO"
226 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200227 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200228 return
229 fi
230
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100231 # prepend valgrind to our commands if active
232 if [ "$MEMCHECK" -gt 0 ]; then
233 if is_polar "$SRV_CMD"; then
234 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
235 fi
236 if is_polar "$CLI_CMD"; then
237 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
238 fi
239 fi
240
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100241 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200242 echo "$SRV_CMD" > $SRV_OUT
243 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100244 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200245 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200246
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200247 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200248 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
249 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100250
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200251 # kill the server
252 kill $SRV_PID
253 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100254
255 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200256 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100257 # expected client exit to incorrectly succeed in case of catastrophic
258 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100259 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200260 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100261 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100262 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100263 return
264 fi
265 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100266 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200267 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100268 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100269 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100270 return
271 fi
272 fi
273
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100274 # check server exit code
275 if [ $? != 0 ]; then
276 fail "server fail"
277 return
278 fi
279
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100280 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100281 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
282 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100283 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100284 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100285 return
286 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100287
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100288 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200289 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100290 while [ $# -gt 0 ]
291 do
292 case $1 in
293 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200294 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100295 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100296 return
297 fi
298 ;;
299
300 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200301 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100302 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100303 return
304 fi
305 ;;
306
307 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200308 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100309 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100310 return
311 fi
312 ;;
313
314 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200315 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100316 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100317 return
318 fi
319 ;;
320
321 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200322 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100323 exit 1
324 esac
325 shift 2
326 done
327
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100328 # check valgrind's results
329 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200330 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100331 fail "Server has memory errors"
332 return
333 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200334 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100335 fail "Client has memory errors"
336 return
337 fi
338 fi
339
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100340 # if we're here, everything is ok
341 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200342 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100343}
344
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100345cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200346 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200347 kill $SRV_PID >/dev/null 2>&1
348 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100349 exit 1
350}
351
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100352#
353# MAIN
354#
355
Manuel Pégourié-Gonnard751286b2015-03-10 13:41:04 +0000356if cd $( dirname $0 ); then :; else
357 echo "cd $( dirname $0 ) failed" >&2
358 exit 1
359fi
360
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100361get_options "$@"
362
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100363# sanity checks, avoid an avalanche of errors
364if [ ! -x "$P_SRV" ]; then
365 echo "Command '$P_SRV' is not an executable file"
366 exit 1
367fi
368if [ ! -x "$P_CLI" ]; then
369 echo "Command '$P_CLI' is not an executable file"
370 exit 1
371fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100372if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
373 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100374 exit 1
375fi
376
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200377# used by watchdog
378MAIN_PID="$$"
379
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200380# be more patient with valgrind
381if [ "$MEMCHECK" -gt 0 ]; then
382 START_DELAY=3
383 DOG_DELAY=30
384else
385 START_DELAY=1
386 DOG_DELAY=10
387fi
388
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200389# Pick a "unique" port in the range 10000-19999.
390PORT="0000$$"
Manuel Pégourié-Gonnarddc370e42015-01-22 10:24:59 +0000391PORT="1$( printf $PORT | tail -c 4 )"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200392
393# fix commands to use this port
394P_SRV="$P_SRV server_port=$PORT"
395P_CLI="$P_CLI server_port=$PORT"
396O_SRV="$O_SRV -accept $PORT"
397O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200398G_SRV="$G_SRV -p $PORT"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100399G_CLI="$G_CLI -p $PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200400
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200401# Also pick a unique name for intermediate files
402SRV_OUT="srv_out.$$"
403CLI_OUT="cli_out.$$"
404SESSION="session.$$"
405
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200406SKIP_NEXT="NO"
407
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100408trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100409
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200410# Basic test
411
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200412# Checks that:
413# - things work with all ciphersuites active (used with config-full in all.sh)
414# - the expected (highest security) parameters are selected
415# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200416run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200417 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200418 "$P_CLI" \
419 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200420 -s "Protocol is TLSv1.2" \
421 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
422 -s "client hello v3, signature_algorithm ext: 6" \
423 -s "ECDHE curve: secp521r1" \
424 -S "error" \
425 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200426
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100427# Tests for rc4 option
428
429run_test "RC4: server disabled, client enabled" \
430 "$P_SRV" \
431 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
432 1 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100433 -s "SSL - None of the common ciphersuites is usable"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100434
435run_test "RC4: server enabled, client disabled" \
436 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
437 "$P_CLI" \
438 1 \
439 -s "SSL - The server has no ciphersuites in common"
440
441run_test "RC4: both enabled" \
442 "$P_SRV arc4=1" \
443 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
444 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100445 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100446 -S "SSL - The server has no ciphersuites in common"
447
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100448# Test for SSLv2 ClientHello
449
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200450requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200451run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100452 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100453 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100454 0 \
455 -S "parse client hello v2" \
456 -S "ssl_handshake returned"
457
458# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200459requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200460run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200461 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100462 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100463 0 \
464 -s "parse client hello v2" \
465 -S "ssl_handshake returned"
466
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100467# Tests for Truncated HMAC extension
468
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100469run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200470 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100471 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100472 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100473 -s "dumping 'computed mac' (20 bytes)" \
474 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100475
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100476run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200477 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100478 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
479 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100480 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100481 -s "dumping 'computed mac' (20 bytes)" \
482 -S "dumping 'computed mac' (10 bytes)"
483
484run_test "Truncated HMAC: client enabled, server default" \
485 "$P_SRV debug_level=4" \
486 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
487 trunc_hmac=1" \
488 0 \
489 -S "dumping 'computed mac' (20 bytes)" \
490 -s "dumping 'computed mac' (10 bytes)"
491
492run_test "Truncated HMAC: client enabled, server disabled" \
493 "$P_SRV debug_level=4 trunc_hmac=0" \
494 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
495 trunc_hmac=1" \
496 0 \
497 -s "dumping 'computed mac' (20 bytes)" \
498 -S "dumping 'computed mac' (10 bytes)"
499
500run_test "Truncated HMAC: client enabled, server enabled" \
501 "$P_SRV debug_level=4 trunc_hmac=1" \
502 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
503 trunc_hmac=1" \
504 0 \
505 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100506 -s "dumping 'computed mac' (10 bytes)"
507
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100508# Tests for Encrypt-then-MAC extension
509
510run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100511 "$P_SRV debug_level=3 \
512 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100513 "$P_CLI debug_level=3" \
514 0 \
515 -c "client hello, adding encrypt_then_mac extension" \
516 -s "found encrypt then mac extension" \
517 -s "server hello, adding encrypt then mac extension" \
518 -c "found encrypt_then_mac extension" \
519 -c "using encrypt then mac" \
520 -s "using encrypt then mac"
521
522run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100523 "$P_SRV debug_level=3 etm=0 \
524 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100525 "$P_CLI debug_level=3 etm=1" \
526 0 \
527 -c "client hello, adding encrypt_then_mac extension" \
528 -s "found encrypt then mac extension" \
529 -S "server hello, adding encrypt then mac extension" \
530 -C "found encrypt_then_mac extension" \
531 -C "using encrypt then mac" \
532 -S "using encrypt then mac"
533
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100534run_test "Encrypt then MAC: client enabled, aead cipher" \
535 "$P_SRV debug_level=3 etm=1 \
536 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
537 "$P_CLI debug_level=3 etm=1" \
538 0 \
539 -c "client hello, adding encrypt_then_mac extension" \
540 -s "found encrypt then mac extension" \
541 -S "server hello, adding encrypt then mac extension" \
542 -C "found encrypt_then_mac extension" \
543 -C "using encrypt then mac" \
544 -S "using encrypt then mac"
545
546run_test "Encrypt then MAC: client enabled, stream cipher" \
547 "$P_SRV debug_level=3 etm=1 \
548 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100549 "$P_CLI debug_level=3 etm=1 arc4=1" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100550 0 \
551 -c "client hello, adding encrypt_then_mac extension" \
552 -s "found encrypt then mac extension" \
553 -S "server hello, adding encrypt then mac extension" \
554 -C "found encrypt_then_mac extension" \
555 -C "using encrypt then mac" \
556 -S "using encrypt then mac"
557
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100558run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100559 "$P_SRV debug_level=3 etm=1 \
560 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100561 "$P_CLI debug_level=3 etm=0" \
562 0 \
563 -C "client hello, adding encrypt_then_mac extension" \
564 -S "found encrypt then mac extension" \
565 -S "server hello, adding encrypt then mac extension" \
566 -C "found encrypt_then_mac extension" \
567 -C "using encrypt then mac" \
568 -S "using encrypt then mac"
569
Janos Follath4dfecab2016-03-14 13:40:43 +0000570requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100571run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100572 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100573 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100574 "$P_CLI debug_level=3 force_version=ssl3" \
575 0 \
576 -C "client hello, adding encrypt_then_mac extension" \
577 -S "found encrypt then mac extension" \
578 -S "server hello, adding encrypt then mac extension" \
579 -C "found encrypt_then_mac extension" \
580 -C "using encrypt then mac" \
581 -S "using encrypt then mac"
582
Janos Follath4dfecab2016-03-14 13:40:43 +0000583requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100584run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100585 "$P_SRV debug_level=3 force_version=ssl3 \
586 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100587 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100588 0 \
589 -c "client hello, adding encrypt_then_mac extension" \
590 -s "found encrypt then mac extension" \
591 -S "server hello, adding encrypt then mac extension" \
592 -C "found encrypt_then_mac extension" \
593 -C "using encrypt then mac" \
594 -S "using encrypt then mac"
595
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200596# Tests for Extended Master Secret extension
597
598run_test "Extended Master Secret: default" \
599 "$P_SRV debug_level=3" \
600 "$P_CLI debug_level=3" \
601 0 \
602 -c "client hello, adding extended_master_secret extension" \
603 -s "found extended master secret extension" \
604 -s "server hello, adding extended master secret extension" \
605 -c "found extended_master_secret extension" \
606 -c "using extended master secret" \
607 -s "using extended master secret"
608
609run_test "Extended Master Secret: client enabled, server disabled" \
610 "$P_SRV debug_level=3 extended_ms=0" \
611 "$P_CLI debug_level=3 extended_ms=1" \
612 0 \
613 -c "client hello, adding extended_master_secret extension" \
614 -s "found extended master secret extension" \
615 -S "server hello, adding extended master secret extension" \
616 -C "found extended_master_secret extension" \
617 -C "using extended master secret" \
618 -S "using extended master secret"
619
620run_test "Extended Master Secret: client disabled, server enabled" \
621 "$P_SRV debug_level=3 extended_ms=1" \
622 "$P_CLI debug_level=3 extended_ms=0" \
623 0 \
624 -C "client hello, adding extended_master_secret extension" \
625 -S "found extended master secret extension" \
626 -S "server hello, adding extended master secret extension" \
627 -C "found extended_master_secret extension" \
628 -C "using extended master secret" \
629 -S "using extended master secret"
630
Janos Follath4dfecab2016-03-14 13:40:43 +0000631requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200632run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100633 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200634 "$P_CLI debug_level=3 force_version=ssl3" \
635 0 \
636 -C "client hello, adding extended_master_secret extension" \
637 -S "found extended master secret extension" \
638 -S "server hello, adding extended master secret extension" \
639 -C "found extended_master_secret extension" \
640 -C "using extended master secret" \
641 -S "using extended master secret"
642
Janos Follath4dfecab2016-03-14 13:40:43 +0000643requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200644run_test "Extended Master Secret: client enabled, server SSLv3" \
645 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100646 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200647 0 \
648 -c "client hello, adding extended_master_secret extension" \
649 -s "found extended master secret extension" \
650 -S "server hello, adding extended master secret extension" \
651 -C "found extended_master_secret extension" \
652 -C "using extended master secret" \
653 -S "using extended master secret"
654
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200655# Tests for FALLBACK_SCSV
656
657run_test "Fallback SCSV: default" \
658 "$P_SRV" \
659 "$P_CLI debug_level=3 force_version=tls1_1" \
660 0 \
661 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200662 -S "received FALLBACK_SCSV" \
663 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200664 -C "is a fatal alert message (msg 86)"
665
666run_test "Fallback SCSV: explicitly disabled" \
667 "$P_SRV" \
668 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
669 0 \
670 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200671 -S "received FALLBACK_SCSV" \
672 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200673 -C "is a fatal alert message (msg 86)"
674
675run_test "Fallback SCSV: enabled" \
676 "$P_SRV" \
677 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200678 1 \
679 -c "adding FALLBACK_SCSV" \
680 -s "received FALLBACK_SCSV" \
681 -s "inapropriate fallback" \
682 -c "is a fatal alert message (msg 86)"
683
684run_test "Fallback SCSV: enabled, max version" \
685 "$P_SRV" \
686 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200687 0 \
688 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200689 -s "received FALLBACK_SCSV" \
690 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200691 -C "is a fatal alert message (msg 86)"
692
693requires_openssl_with_fallback_scsv
694run_test "Fallback SCSV: default, openssl server" \
695 "$O_SRV" \
696 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
697 0 \
698 -C "adding FALLBACK_SCSV" \
699 -C "is a fatal alert message (msg 86)"
700
701requires_openssl_with_fallback_scsv
702run_test "Fallback SCSV: enabled, openssl server" \
703 "$O_SRV" \
704 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
705 1 \
706 -c "adding FALLBACK_SCSV" \
707 -c "is a fatal alert message (msg 86)"
708
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200709requires_openssl_with_fallback_scsv
710run_test "Fallback SCSV: disabled, openssl client" \
711 "$P_SRV" \
712 "$O_CLI -tls1_1" \
713 0 \
714 -S "received FALLBACK_SCSV" \
715 -S "inapropriate fallback"
716
717requires_openssl_with_fallback_scsv
718run_test "Fallback SCSV: enabled, openssl client" \
719 "$P_SRV" \
720 "$O_CLI -tls1_1 -fallback_scsv" \
721 1 \
722 -s "received FALLBACK_SCSV" \
723 -s "inapropriate fallback"
724
725requires_openssl_with_fallback_scsv
726run_test "Fallback SCSV: enabled, max version, openssl client" \
727 "$P_SRV" \
728 "$O_CLI -fallback_scsv" \
729 0 \
730 -s "received FALLBACK_SCSV" \
731 -S "inapropriate fallback"
732
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100733# Tests for CBC 1/n-1 record splitting
734
735run_test "CBC Record splitting: TLS 1.2, no splitting" \
736 "$P_SRV" \
737 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
738 request_size=123 force_version=tls1_2" \
739 0 \
740 -s "Read from client: 123 bytes read" \
741 -S "Read from client: 1 bytes read" \
742 -S "122 bytes read"
743
744run_test "CBC Record splitting: TLS 1.1, no splitting" \
745 "$P_SRV" \
746 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
747 request_size=123 force_version=tls1_1" \
748 0 \
749 -s "Read from client: 123 bytes read" \
750 -S "Read from client: 1 bytes read" \
751 -S "122 bytes read"
752
753run_test "CBC Record splitting: TLS 1.0, splitting" \
754 "$P_SRV" \
755 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
756 request_size=123 force_version=tls1" \
757 0 \
758 -S "Read from client: 123 bytes read" \
759 -s "Read from client: 1 bytes read" \
760 -s "122 bytes read"
761
Janos Follath4dfecab2016-03-14 13:40:43 +0000762requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100763run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100764 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100765 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
766 request_size=123 force_version=ssl3" \
767 0 \
768 -S "Read from client: 123 bytes read" \
769 -s "Read from client: 1 bytes read" \
770 -s "122 bytes read"
771
772run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100773 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100774 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
775 request_size=123 force_version=tls1" \
776 0 \
777 -s "Read from client: 123 bytes read" \
778 -S "Read from client: 1 bytes read" \
779 -S "122 bytes read"
780
781run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
782 "$P_SRV" \
783 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
784 request_size=123 force_version=tls1 recsplit=0" \
785 0 \
786 -s "Read from client: 123 bytes read" \
787 -S "Read from client: 1 bytes read" \
788 -S "122 bytes read"
789
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100790run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
791 "$P_SRV nbio=2" \
792 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
793 request_size=123 force_version=tls1" \
794 0 \
795 -S "Read from client: 123 bytes read" \
796 -s "Read from client: 1 bytes read" \
797 -s "122 bytes read"
798
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100799# Tests for Session Tickets
800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200801run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200802 "$P_SRV debug_level=3 tickets=1" \
803 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100804 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100805 -c "client hello, adding session ticket extension" \
806 -s "found session ticket extension" \
807 -s "server hello, adding session ticket extension" \
808 -c "found session_ticket extension" \
809 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100810 -S "session successfully restored from cache" \
811 -s "session successfully restored from ticket" \
812 -s "a session has been resumed" \
813 -c "a session has been resumed"
814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200815run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200816 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
817 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100818 0 \
819 -c "client hello, adding session ticket extension" \
820 -s "found session ticket extension" \
821 -s "server hello, adding session ticket extension" \
822 -c "found session_ticket extension" \
823 -c "parse new session ticket" \
824 -S "session successfully restored from cache" \
825 -s "session successfully restored from ticket" \
826 -s "a session has been resumed" \
827 -c "a session has been resumed"
828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200829run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200830 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
831 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100832 0 \
833 -c "client hello, adding session ticket extension" \
834 -s "found session ticket extension" \
835 -s "server hello, adding session ticket extension" \
836 -c "found session_ticket extension" \
837 -c "parse new session ticket" \
838 -S "session successfully restored from cache" \
839 -S "session successfully restored from ticket" \
840 -S "a session has been resumed" \
841 -C "a session has been resumed"
842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200843run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100844 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200845 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100846 0 \
847 -c "client hello, adding session ticket extension" \
848 -c "found session_ticket extension" \
849 -c "parse new session ticket" \
850 -c "a session has been resumed"
851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200852run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200853 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200854 "( $O_CLI -sess_out $SESSION; \
855 $O_CLI -sess_in $SESSION; \
856 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100857 0 \
858 -s "found session ticket extension" \
859 -s "server hello, adding session ticket extension" \
860 -S "session successfully restored from cache" \
861 -s "session successfully restored from ticket" \
862 -s "a session has been resumed"
863
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100864# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200866run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200867 "$P_SRV debug_level=3 tickets=0" \
868 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100869 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100870 -c "client hello, adding session ticket extension" \
871 -s "found session ticket extension" \
872 -S "server hello, adding session ticket extension" \
873 -C "found session_ticket extension" \
874 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100875 -s "session successfully restored from cache" \
876 -S "session successfully restored from ticket" \
877 -s "a session has been resumed" \
878 -c "a session has been resumed"
879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200880run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200881 "$P_SRV debug_level=3 tickets=1" \
882 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100883 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100884 -C "client hello, adding session ticket extension" \
885 -S "found session ticket extension" \
886 -S "server hello, adding session ticket extension" \
887 -C "found session_ticket extension" \
888 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100889 -s "session successfully restored from cache" \
890 -S "session successfully restored from ticket" \
891 -s "a session has been resumed" \
892 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100893
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200894run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200895 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
896 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100897 0 \
898 -S "session successfully restored from cache" \
899 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100900 -S "a session has been resumed" \
901 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200903run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200904 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
905 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100906 0 \
907 -s "session successfully restored from cache" \
908 -S "session successfully restored from ticket" \
909 -s "a session has been resumed" \
910 -c "a session has been resumed"
911
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200912run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200913 "$P_SRV debug_level=3 tickets=0" \
914 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100915 0 \
916 -s "session successfully restored from cache" \
917 -S "session successfully restored from ticket" \
918 -s "a session has been resumed" \
919 -c "a session has been resumed"
920
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200921run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200922 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
923 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100924 0 \
925 -S "session successfully restored from cache" \
926 -S "session successfully restored from ticket" \
927 -S "a session has been resumed" \
928 -C "a session has been resumed"
929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200930run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200931 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
932 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100933 0 \
934 -s "session successfully restored from cache" \
935 -S "session successfully restored from ticket" \
936 -s "a session has been resumed" \
937 -c "a session has been resumed"
938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200939run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200940 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200941 "( $O_CLI -sess_out $SESSION; \
942 $O_CLI -sess_in $SESSION; \
943 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100944 0 \
945 -s "found session ticket extension" \
946 -S "server hello, adding session ticket extension" \
947 -s "session successfully restored from cache" \
948 -S "session successfully restored from ticket" \
949 -s "a session has been resumed"
950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200951run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100952 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200953 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100954 0 \
955 -C "found session_ticket extension" \
956 -C "parse new session ticket" \
957 -c "a session has been resumed"
958
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100959# Tests for Max Fragment Length extension
960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200961run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200962 "$P_SRV debug_level=3" \
963 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100964 0 \
965 -C "client hello, adding max_fragment_length extension" \
966 -S "found max fragment length extension" \
967 -S "server hello, max_fragment_length extension" \
968 -C "found max_fragment_length extension"
969
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200970run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200971 "$P_SRV debug_level=3" \
972 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100973 0 \
974 -c "client hello, adding max_fragment_length extension" \
975 -s "found max fragment length extension" \
976 -s "server hello, max_fragment_length extension" \
977 -c "found max_fragment_length extension"
978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200979run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200980 "$P_SRV debug_level=3 max_frag_len=4096" \
981 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100982 0 \
983 -C "client hello, adding max_fragment_length extension" \
984 -S "found max fragment length extension" \
985 -S "server hello, max_fragment_length extension" \
986 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100987
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200988requires_gnutls
989run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200990 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200991 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200992 0 \
993 -c "client hello, adding max_fragment_length extension" \
994 -c "found max_fragment_length extension"
995
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100996# Tests for renegotiation
997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200998run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200999 "$P_SRV debug_level=3 exchanges=2" \
1000 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001001 0 \
1002 -C "client hello, adding renegotiation extension" \
1003 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1004 -S "found renegotiation extension" \
1005 -s "server hello, secure renegotiation extension" \
1006 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001007 -C "=> renegotiate" \
1008 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001009 -S "write hello request"
1010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001011run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001012 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
1013 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001014 0 \
1015 -c "client hello, adding renegotiation extension" \
1016 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1017 -s "found renegotiation extension" \
1018 -s "server hello, secure renegotiation extension" \
1019 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001020 -c "=> renegotiate" \
1021 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001022 -S "write hello request"
1023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001024run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001025 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1026 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001027 0 \
1028 -c "client hello, adding renegotiation extension" \
1029 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1030 -s "found renegotiation extension" \
1031 -s "server hello, secure renegotiation extension" \
1032 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001033 -c "=> renegotiate" \
1034 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001035 -s "write hello request"
1036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001037run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001038 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1039 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001040 0 \
1041 -c "client hello, adding renegotiation extension" \
1042 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1043 -s "found renegotiation extension" \
1044 -s "server hello, secure renegotiation extension" \
1045 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001046 -c "=> renegotiate" \
1047 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001048 -s "write hello request"
1049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001050run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001051 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1052 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001053 1 \
1054 -c "client hello, adding renegotiation extension" \
1055 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1056 -S "found renegotiation extension" \
1057 -s "server hello, secure renegotiation extension" \
1058 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001059 -c "=> renegotiate" \
1060 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001061 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001062 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001063 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001065run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001066 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1067 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001068 0 \
1069 -C "client hello, adding renegotiation extension" \
1070 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1071 -S "found renegotiation extension" \
1072 -s "server hello, secure renegotiation extension" \
1073 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001074 -C "=> renegotiate" \
1075 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001076 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001077 -S "SSL - An unexpected message was received from our peer" \
1078 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001080run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001081 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001082 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001083 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001084 0 \
1085 -C "client hello, adding renegotiation extension" \
1086 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1087 -S "found renegotiation extension" \
1088 -s "server hello, secure renegotiation extension" \
1089 -c "found renegotiation extension" \
1090 -C "=> renegotiate" \
1091 -S "=> renegotiate" \
1092 -s "write hello request" \
1093 -S "SSL - An unexpected message was received from our peer" \
1094 -S "failed"
1095
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001096# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001097run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001098 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001099 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001100 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001101 0 \
1102 -C "client hello, adding renegotiation extension" \
1103 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1104 -S "found renegotiation extension" \
1105 -s "server hello, secure renegotiation extension" \
1106 -c "found renegotiation extension" \
1107 -C "=> renegotiate" \
1108 -S "=> renegotiate" \
1109 -s "write hello request" \
1110 -S "SSL - An unexpected message was received from our peer" \
1111 -S "failed"
1112
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001113run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001114 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001115 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001116 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001117 0 \
1118 -C "client hello, adding renegotiation extension" \
1119 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1120 -S "found renegotiation extension" \
1121 -s "server hello, secure renegotiation extension" \
1122 -c "found renegotiation extension" \
1123 -C "=> renegotiate" \
1124 -S "=> renegotiate" \
1125 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001126 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001127
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001128run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001129 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001130 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001131 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001132 0 \
1133 -c "client hello, adding renegotiation extension" \
1134 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1135 -s "found renegotiation extension" \
1136 -s "server hello, secure renegotiation extension" \
1137 -c "found renegotiation extension" \
1138 -c "=> renegotiate" \
1139 -s "=> renegotiate" \
1140 -s "write hello request" \
1141 -S "SSL - An unexpected message was received from our peer" \
1142 -S "failed"
1143
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001144run_test "Renegotiation: periodic, just below period" \
1145 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1146 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1147 0 \
1148 -C "client hello, adding renegotiation extension" \
1149 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1150 -S "found renegotiation extension" \
1151 -s "server hello, secure renegotiation extension" \
1152 -c "found renegotiation extension" \
1153 -S "record counter limit reached: renegotiate" \
1154 -C "=> renegotiate" \
1155 -S "=> renegotiate" \
1156 -S "write hello request" \
1157 -S "SSL - An unexpected message was received from our peer" \
1158 -S "failed"
1159
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001160# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001161run_test "Renegotiation: periodic, just above period" \
1162 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001163 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001164 0 \
1165 -c "client hello, adding renegotiation extension" \
1166 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1167 -s "found renegotiation extension" \
1168 -s "server hello, secure renegotiation extension" \
1169 -c "found renegotiation extension" \
1170 -s "record counter limit reached: renegotiate" \
1171 -c "=> renegotiate" \
1172 -s "=> renegotiate" \
1173 -s "write hello request" \
1174 -S "SSL - An unexpected message was received from our peer" \
1175 -S "failed"
1176
1177run_test "Renegotiation: periodic, two times period" \
1178 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001179 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001180 0 \
1181 -c "client hello, adding renegotiation extension" \
1182 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1183 -s "found renegotiation extension" \
1184 -s "server hello, secure renegotiation extension" \
1185 -c "found renegotiation extension" \
1186 -s "record counter limit reached: renegotiate" \
1187 -c "=> renegotiate" \
1188 -s "=> renegotiate" \
1189 -s "write hello request" \
1190 -S "SSL - An unexpected message was received from our peer" \
1191 -S "failed"
1192
1193run_test "Renegotiation: periodic, above period, disabled" \
1194 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1195 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1196 0 \
1197 -C "client hello, adding renegotiation extension" \
1198 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1199 -S "found renegotiation extension" \
1200 -s "server hello, secure renegotiation extension" \
1201 -c "found renegotiation extension" \
1202 -S "record counter limit reached: renegotiate" \
1203 -C "=> renegotiate" \
1204 -S "=> renegotiate" \
1205 -S "write hello request" \
1206 -S "SSL - An unexpected message was received from our peer" \
1207 -S "failed"
1208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001209run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001210 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1211 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001212 0 \
1213 -c "client hello, adding renegotiation extension" \
1214 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1215 -s "found renegotiation extension" \
1216 -s "server hello, secure renegotiation extension" \
1217 -c "found renegotiation extension" \
1218 -c "=> renegotiate" \
1219 -s "=> renegotiate" \
1220 -S "write hello request"
1221
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001222run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001223 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1224 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001225 0 \
1226 -c "client hello, adding renegotiation extension" \
1227 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1228 -s "found renegotiation extension" \
1229 -s "server hello, secure renegotiation extension" \
1230 -c "found renegotiation extension" \
1231 -c "=> renegotiate" \
1232 -s "=> renegotiate" \
1233 -s "write hello request"
1234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001235run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001236 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001237 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001238 0 \
1239 -c "client hello, adding renegotiation extension" \
1240 -c "found renegotiation extension" \
1241 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001242 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001243 -C "error" \
1244 -c "HTTP/1.0 200 [Oo][Kk]"
1245
Paul Bakker539d9722015-02-08 16:18:35 +01001246requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001247run_test "Renegotiation: gnutls server strict, client-initiated" \
1248 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001249 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001250 0 \
1251 -c "client hello, adding renegotiation extension" \
1252 -c "found renegotiation extension" \
1253 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001254 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001255 -C "error" \
1256 -c "HTTP/1.0 200 [Oo][Kk]"
1257
Paul Bakker539d9722015-02-08 16:18:35 +01001258requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001259run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1260 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1261 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1262 1 \
1263 -c "client hello, adding renegotiation extension" \
1264 -C "found renegotiation extension" \
1265 -c "=> renegotiate" \
1266 -c "ssl_handshake() returned" \
1267 -c "error" \
1268 -C "HTTP/1.0 200 [Oo][Kk]"
1269
Paul Bakker539d9722015-02-08 16:18:35 +01001270requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001271run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1272 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1273 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1274 allow_legacy=0" \
1275 1 \
1276 -c "client hello, adding renegotiation extension" \
1277 -C "found renegotiation extension" \
1278 -c "=> renegotiate" \
1279 -c "ssl_handshake() returned" \
1280 -c "error" \
1281 -C "HTTP/1.0 200 [Oo][Kk]"
1282
Paul Bakker539d9722015-02-08 16:18:35 +01001283requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001284run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1285 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1286 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1287 allow_legacy=1" \
1288 0 \
1289 -c "client hello, adding renegotiation extension" \
1290 -C "found renegotiation extension" \
1291 -c "=> renegotiate" \
1292 -C "ssl_hanshake() returned" \
1293 -C "error" \
1294 -c "HTTP/1.0 200 [Oo][Kk]"
1295
1296# Test for the "secure renegotation" extension only (no actual renegotiation)
1297
Paul Bakker539d9722015-02-08 16:18:35 +01001298requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001299run_test "Renego ext: gnutls server strict, client default" \
1300 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1301 "$P_CLI debug_level=3" \
1302 0 \
1303 -c "found renegotiation extension" \
1304 -C "error" \
1305 -c "HTTP/1.0 200 [Oo][Kk]"
1306
Paul Bakker539d9722015-02-08 16:18:35 +01001307requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001308run_test "Renego ext: gnutls server unsafe, client default" \
1309 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1310 "$P_CLI debug_level=3" \
1311 0 \
1312 -C "found renegotiation extension" \
1313 -C "error" \
1314 -c "HTTP/1.0 200 [Oo][Kk]"
1315
Paul Bakker539d9722015-02-08 16:18:35 +01001316requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001317run_test "Renego ext: gnutls server unsafe, client break legacy" \
1318 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1319 "$P_CLI debug_level=3 allow_legacy=-1" \
1320 1 \
1321 -C "found renegotiation extension" \
1322 -c "error" \
1323 -C "HTTP/1.0 200 [Oo][Kk]"
1324
Paul Bakker539d9722015-02-08 16:18:35 +01001325requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001326run_test "Renego ext: gnutls client strict, server default" \
1327 "$P_SRV debug_level=3" \
1328 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1329 0 \
1330 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1331 -s "server hello, secure renegotiation extension"
1332
Paul Bakker539d9722015-02-08 16:18:35 +01001333requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001334run_test "Renego ext: gnutls client unsafe, server default" \
1335 "$P_SRV debug_level=3" \
1336 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1337 0 \
1338 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1339 -S "server hello, secure renegotiation extension"
1340
Paul Bakker539d9722015-02-08 16:18:35 +01001341requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001342run_test "Renego ext: gnutls client unsafe, server break legacy" \
1343 "$P_SRV debug_level=3 allow_legacy=-1" \
1344 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1345 1 \
1346 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1347 -S "server hello, secure renegotiation extension"
1348
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001349# Tests for auth_mode
1350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001351run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001352 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001353 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001354 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001355 1 \
1356 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001357 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001358 -c "! ssl_handshake returned" \
1359 -c "X509 - Certificate verification failed"
1360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001361run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001362 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001363 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001365 0 \
1366 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001367 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001368 -C "! ssl_handshake returned" \
1369 -C "X509 - Certificate verification failed"
1370
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001371run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001372 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001373 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001374 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001375 0 \
1376 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001377 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001378 -C "! ssl_handshake returned" \
1379 -C "X509 - Certificate verification failed"
1380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001381run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001382 "$P_SRV debug_level=3 auth_mode=required" \
1383 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001384 key_file=data_files/server5.key" \
1385 1 \
1386 -S "skip write certificate request" \
1387 -C "skip parse certificate request" \
1388 -c "got a certificate request" \
1389 -C "skip write certificate" \
1390 -C "skip write certificate verify" \
1391 -S "skip parse certificate verify" \
1392 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001393 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001394 -s "! ssl_handshake returned" \
1395 -c "! ssl_handshake returned" \
1396 -s "X509 - Certificate verification failed"
1397
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001398run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001399 "$P_SRV debug_level=3 auth_mode=optional" \
1400 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001401 key_file=data_files/server5.key" \
1402 0 \
1403 -S "skip write certificate request" \
1404 -C "skip parse certificate request" \
1405 -c "got a certificate request" \
1406 -C "skip write certificate" \
1407 -C "skip write certificate verify" \
1408 -S "skip parse certificate verify" \
1409 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001410 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001411 -S "! ssl_handshake returned" \
1412 -C "! ssl_handshake returned" \
1413 -S "X509 - Certificate verification failed"
1414
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001415run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001416 "$P_SRV debug_level=3 auth_mode=none" \
1417 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001418 key_file=data_files/server5.key" \
1419 0 \
1420 -s "skip write certificate request" \
1421 -C "skip parse certificate request" \
1422 -c "got no certificate request" \
1423 -c "skip write certificate" \
1424 -c "skip write certificate verify" \
1425 -s "skip parse certificate verify" \
1426 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001427 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001428 -S "! ssl_handshake returned" \
1429 -C "! ssl_handshake returned" \
1430 -S "X509 - Certificate verification failed"
1431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001432run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001433 "$P_SRV debug_level=3 auth_mode=optional" \
1434 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001435 0 \
1436 -S "skip write certificate request" \
1437 -C "skip parse certificate request" \
1438 -c "got a certificate request" \
1439 -C "skip write certificate$" \
1440 -C "got no certificate to send" \
1441 -S "SSLv3 client has no certificate" \
1442 -c "skip write certificate verify" \
1443 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001444 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001445 -S "! ssl_handshake returned" \
1446 -C "! ssl_handshake returned" \
1447 -S "X509 - Certificate verification failed"
1448
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001449run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001450 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001451 "$O_CLI" \
1452 0 \
1453 -S "skip write certificate request" \
1454 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001455 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001456 -S "! ssl_handshake returned" \
1457 -S "X509 - Certificate verification failed"
1458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001459run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001460 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001461 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001462 0 \
1463 -C "skip parse certificate request" \
1464 -c "got a certificate request" \
1465 -C "skip write certificate$" \
1466 -c "skip write certificate verify" \
1467 -C "! ssl_handshake returned"
1468
Janos Follath4dfecab2016-03-14 13:40:43 +00001469requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001470run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001471 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001472 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001473 0 \
1474 -S "skip write certificate request" \
1475 -C "skip parse certificate request" \
1476 -c "got a certificate request" \
1477 -C "skip write certificate$" \
1478 -c "skip write certificate verify" \
1479 -c "got no certificate to send" \
1480 -s "SSLv3 client has no certificate" \
1481 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001482 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001483 -S "! ssl_handshake returned" \
1484 -C "! ssl_handshake returned" \
1485 -S "X509 - Certificate verification failed"
1486
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001487# Tests for certificate selection based on SHA verson
1488
1489run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1490 "$P_SRV crt_file=data_files/server5.crt \
1491 key_file=data_files/server5.key \
1492 crt_file2=data_files/server5-sha1.crt \
1493 key_file2=data_files/server5.key" \
1494 "$P_CLI force_version=tls1_2" \
1495 0 \
1496 -c "signed using.*ECDSA with SHA256" \
1497 -C "signed using.*ECDSA with SHA1"
1498
1499run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1500 "$P_SRV crt_file=data_files/server5.crt \
1501 key_file=data_files/server5.key \
1502 crt_file2=data_files/server5-sha1.crt \
1503 key_file2=data_files/server5.key" \
1504 "$P_CLI force_version=tls1_1" \
1505 0 \
1506 -C "signed using.*ECDSA with SHA256" \
1507 -c "signed using.*ECDSA with SHA1"
1508
1509run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1510 "$P_SRV crt_file=data_files/server5.crt \
1511 key_file=data_files/server5.key \
1512 crt_file2=data_files/server5-sha1.crt \
1513 key_file2=data_files/server5.key" \
1514 "$P_CLI force_version=tls1" \
1515 0 \
1516 -C "signed using.*ECDSA with SHA256" \
1517 -c "signed using.*ECDSA with SHA1"
1518
1519run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1520 "$P_SRV crt_file=data_files/server5.crt \
1521 key_file=data_files/server5.key \
1522 crt_file2=data_files/server6.crt \
1523 key_file2=data_files/server6.key" \
1524 "$P_CLI force_version=tls1_1" \
1525 0 \
1526 -c "serial number.*09" \
1527 -c "signed using.*ECDSA with SHA256" \
1528 -C "signed using.*ECDSA with SHA1"
1529
1530run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1531 "$P_SRV crt_file=data_files/server6.crt \
1532 key_file=data_files/server6.key \
1533 crt_file2=data_files/server5.crt \
1534 key_file2=data_files/server5.key" \
1535 "$P_CLI force_version=tls1_1" \
1536 0 \
1537 -c "serial number.*0A" \
1538 -c "signed using.*ECDSA with SHA256" \
1539 -C "signed using.*ECDSA with SHA1"
1540
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001541# tests for SNI
1542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001543run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001544 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001545 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001546 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001547 server_name=localhost" \
1548 0 \
1549 -S "parse ServerName extension" \
1550 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1551 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001553run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001554 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001555 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001556 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001557 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001558 server_name=localhost" \
1559 0 \
1560 -s "parse ServerName extension" \
1561 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1562 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001564run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001565 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001566 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001567 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001568 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001569 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001570 0 \
1571 -s "parse ServerName extension" \
1572 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001573 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001575run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001576 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001577 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001578 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001579 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001580 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001581 1 \
1582 -s "parse ServerName extension" \
1583 -s "ssl_sni_wrapper() returned" \
1584 -s "ssl_handshake returned" \
1585 -c "ssl_handshake returned" \
1586 -c "SSL - A fatal alert message was received from our peer"
1587
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001588# Tests for non-blocking I/O: exercise a variety of handshake flows
1589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001590run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001591 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1592 "$P_CLI nbio=2 tickets=0" \
1593 0 \
1594 -S "ssl_handshake returned" \
1595 -C "ssl_handshake returned" \
1596 -c "Read from server: .* bytes read"
1597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001598run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001599 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1600 "$P_CLI nbio=2 tickets=0" \
1601 0 \
1602 -S "ssl_handshake returned" \
1603 -C "ssl_handshake returned" \
1604 -c "Read from server: .* bytes read"
1605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001606run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001607 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1608 "$P_CLI nbio=2 tickets=1" \
1609 0 \
1610 -S "ssl_handshake returned" \
1611 -C "ssl_handshake returned" \
1612 -c "Read from server: .* bytes read"
1613
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001614run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001615 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1616 "$P_CLI nbio=2 tickets=1" \
1617 0 \
1618 -S "ssl_handshake returned" \
1619 -C "ssl_handshake returned" \
1620 -c "Read from server: .* bytes read"
1621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001622run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001623 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1624 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1625 0 \
1626 -S "ssl_handshake returned" \
1627 -C "ssl_handshake returned" \
1628 -c "Read from server: .* bytes read"
1629
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001630run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001631 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1632 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1633 0 \
1634 -S "ssl_handshake returned" \
1635 -C "ssl_handshake returned" \
1636 -c "Read from server: .* bytes read"
1637
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001638run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001639 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1640 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1641 0 \
1642 -S "ssl_handshake returned" \
1643 -C "ssl_handshake returned" \
1644 -c "Read from server: .* bytes read"
1645
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001646# Tests for version negotiation
1647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001648run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001649 "$P_SRV" \
1650 "$P_CLI" \
1651 0 \
1652 -S "ssl_handshake returned" \
1653 -C "ssl_handshake returned" \
1654 -s "Protocol is TLSv1.2" \
1655 -c "Protocol is TLSv1.2"
1656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001657run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001658 "$P_SRV" \
1659 "$P_CLI max_version=tls1_1" \
1660 0 \
1661 -S "ssl_handshake returned" \
1662 -C "ssl_handshake returned" \
1663 -s "Protocol is TLSv1.1" \
1664 -c "Protocol is TLSv1.1"
1665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001666run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001667 "$P_SRV max_version=tls1_1" \
1668 "$P_CLI" \
1669 0 \
1670 -S "ssl_handshake returned" \
1671 -C "ssl_handshake returned" \
1672 -s "Protocol is TLSv1.1" \
1673 -c "Protocol is TLSv1.1"
1674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001675run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001676 "$P_SRV max_version=tls1_1" \
1677 "$P_CLI max_version=tls1_1" \
1678 0 \
1679 -S "ssl_handshake returned" \
1680 -C "ssl_handshake returned" \
1681 -s "Protocol is TLSv1.1" \
1682 -c "Protocol is TLSv1.1"
1683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001684run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001685 "$P_SRV min_version=tls1_1" \
1686 "$P_CLI max_version=tls1_1" \
1687 0 \
1688 -S "ssl_handshake returned" \
1689 -C "ssl_handshake returned" \
1690 -s "Protocol is TLSv1.1" \
1691 -c "Protocol is TLSv1.1"
1692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001693run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001694 "$P_SRV max_version=tls1_1" \
1695 "$P_CLI min_version=tls1_1" \
1696 0 \
1697 -S "ssl_handshake returned" \
1698 -C "ssl_handshake returned" \
1699 -s "Protocol is TLSv1.1" \
1700 -c "Protocol is TLSv1.1"
1701
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001702run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001703 "$P_SRV max_version=tls1_1" \
1704 "$P_CLI min_version=tls1_2" \
1705 1 \
1706 -s "ssl_handshake returned" \
1707 -c "ssl_handshake returned" \
1708 -c "SSL - Handshake protocol not within min/max boundaries"
1709
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001710run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001711 "$P_SRV min_version=tls1_2" \
1712 "$P_CLI max_version=tls1_1" \
1713 1 \
1714 -s "ssl_handshake returned" \
1715 -c "ssl_handshake returned" \
1716 -s "SSL - Handshake protocol not within min/max boundaries"
1717
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001718# Tests for ALPN extension
1719
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001720if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001722run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001723 "$P_SRV debug_level=3" \
1724 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001725 0 \
1726 -C "client hello, adding alpn extension" \
1727 -S "found alpn extension" \
1728 -C "got an alert message, type: \\[2:120]" \
1729 -S "server hello, adding alpn extension" \
1730 -C "found alpn extension " \
1731 -C "Application Layer Protocol is" \
1732 -S "Application Layer Protocol is"
1733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001734run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001735 "$P_SRV debug_level=3" \
1736 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001737 0 \
1738 -c "client hello, adding alpn extension" \
1739 -s "found alpn extension" \
1740 -C "got an alert message, type: \\[2:120]" \
1741 -S "server hello, adding alpn extension" \
1742 -C "found alpn extension " \
1743 -c "Application Layer Protocol is (none)" \
1744 -S "Application Layer Protocol is"
1745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001746run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001747 "$P_SRV debug_level=3 alpn=abc,1234" \
1748 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001749 0 \
1750 -C "client hello, adding alpn extension" \
1751 -S "found alpn extension" \
1752 -C "got an alert message, type: \\[2:120]" \
1753 -S "server hello, adding alpn extension" \
1754 -C "found alpn extension " \
1755 -C "Application Layer Protocol is" \
1756 -s "Application Layer Protocol is (none)"
1757
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001758run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001759 "$P_SRV debug_level=3 alpn=abc,1234" \
1760 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001761 0 \
1762 -c "client hello, adding alpn extension" \
1763 -s "found alpn extension" \
1764 -C "got an alert message, type: \\[2:120]" \
1765 -s "server hello, adding alpn extension" \
1766 -c "found alpn extension" \
1767 -c "Application Layer Protocol is abc" \
1768 -s "Application Layer Protocol is abc"
1769
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001770run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001771 "$P_SRV debug_level=3 alpn=abc,1234" \
1772 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001773 0 \
1774 -c "client hello, adding alpn extension" \
1775 -s "found alpn extension" \
1776 -C "got an alert message, type: \\[2:120]" \
1777 -s "server hello, adding alpn extension" \
1778 -c "found alpn extension" \
1779 -c "Application Layer Protocol is abc" \
1780 -s "Application Layer Protocol is abc"
1781
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001782run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001783 "$P_SRV debug_level=3 alpn=abc,1234" \
1784 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001785 0 \
1786 -c "client hello, adding alpn extension" \
1787 -s "found alpn extension" \
1788 -C "got an alert message, type: \\[2:120]" \
1789 -s "server hello, adding alpn extension" \
1790 -c "found alpn extension" \
1791 -c "Application Layer Protocol is 1234" \
1792 -s "Application Layer Protocol is 1234"
1793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001794run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001795 "$P_SRV debug_level=3 alpn=abc,123" \
1796 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001797 1 \
1798 -c "client hello, adding alpn extension" \
1799 -s "found alpn extension" \
1800 -c "got an alert message, type: \\[2:120]" \
1801 -S "server hello, adding alpn extension" \
1802 -C "found alpn extension" \
1803 -C "Application Layer Protocol is 1234" \
1804 -S "Application Layer Protocol is 1234"
1805
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001806fi
1807
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001808# Tests for keyUsage in leaf certificates, part 1:
1809# server-side certificate/suite selection
1810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001811run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001812 "$P_SRV key_file=data_files/server2.key \
1813 crt_file=data_files/server2.ku-ds.crt" \
1814 "$P_CLI" \
1815 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001816 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001817
1818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001819run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001820 "$P_SRV key_file=data_files/server2.key \
1821 crt_file=data_files/server2.ku-ke.crt" \
1822 "$P_CLI" \
1823 0 \
1824 -c "Ciphersuite is TLS-RSA-WITH-"
1825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001826run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001827 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001828 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001829 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001830 1 \
1831 -C "Ciphersuite is "
1832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001833run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001834 "$P_SRV key_file=data_files/server5.key \
1835 crt_file=data_files/server5.ku-ds.crt" \
1836 "$P_CLI" \
1837 0 \
1838 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1839
1840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001841run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001842 "$P_SRV key_file=data_files/server5.key \
1843 crt_file=data_files/server5.ku-ka.crt" \
1844 "$P_CLI" \
1845 0 \
1846 -c "Ciphersuite is TLS-ECDH-"
1847
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001848run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001849 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001850 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001851 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001852 1 \
1853 -C "Ciphersuite is "
1854
1855# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001856# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001858run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001859 "$O_SRV -key data_files/server2.key \
1860 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001861 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001862 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1863 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001864 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001865 -C "Processing of the Certificate handshake message failed" \
1866 -c "Ciphersuite is TLS-"
1867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001868run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001869 "$O_SRV -key data_files/server2.key \
1870 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001871 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001872 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1873 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001874 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001875 -C "Processing of the Certificate handshake message failed" \
1876 -c "Ciphersuite is TLS-"
1877
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001878run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001879 "$O_SRV -key data_files/server2.key \
1880 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001881 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001882 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1883 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001884 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001885 -C "Processing of the Certificate handshake message failed" \
1886 -c "Ciphersuite is TLS-"
1887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001888run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001889 "$O_SRV -key data_files/server2.key \
1890 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001891 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001892 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1893 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001894 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001895 -c "Processing of the Certificate handshake message failed" \
1896 -C "Ciphersuite is TLS-"
1897
Manuel Pégourié-Gonnarde16b62c2015-04-17 16:55:53 +02001898run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
1899 "$O_SRV -key data_files/server2.key \
1900 -cert data_files/server2.ku-ke.crt" \
1901 "$P_CLI debug_level=1 auth_mode=optional \
1902 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1903 0 \
1904 -c "bad certificate (usage extensions)" \
1905 -C "Processing of the Certificate handshake message failed" \
1906 -c "Ciphersuite is TLS-" \
1907 -c "! Usage does not match the keyUsage extension"
1908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001909run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001910 "$O_SRV -key data_files/server2.key \
1911 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001912 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001913 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1914 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001915 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001916 -C "Processing of the Certificate handshake message failed" \
1917 -c "Ciphersuite is TLS-"
1918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001919run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001920 "$O_SRV -key data_files/server2.key \
1921 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001922 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001923 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1924 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001925 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001926 -c "Processing of the Certificate handshake message failed" \
1927 -C "Ciphersuite is TLS-"
1928
Manuel Pégourié-Gonnarde16b62c2015-04-17 16:55:53 +02001929run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
1930 "$O_SRV -key data_files/server2.key \
1931 -cert data_files/server2.ku-ds.crt" \
1932 "$P_CLI debug_level=1 auth_mode=optional \
1933 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1934 0 \
1935 -c "bad certificate (usage extensions)" \
1936 -C "Processing of the Certificate handshake message failed" \
1937 -c "Ciphersuite is TLS-" \
1938 -c "! Usage does not match the keyUsage extension"
1939
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001940# Tests for keyUsage in leaf certificates, part 3:
1941# server-side checking of client cert
1942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001943run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001944 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001945 "$O_CLI -key data_files/server2.key \
1946 -cert data_files/server2.ku-ds.crt" \
1947 0 \
1948 -S "bad certificate (usage extensions)" \
1949 -S "Processing of the Certificate handshake message failed"
1950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001951run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001952 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001953 "$O_CLI -key data_files/server2.key \
1954 -cert data_files/server2.ku-ke.crt" \
1955 0 \
1956 -s "bad certificate (usage extensions)" \
1957 -S "Processing of the Certificate handshake message failed"
1958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001959run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001960 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001961 "$O_CLI -key data_files/server2.key \
1962 -cert data_files/server2.ku-ke.crt" \
1963 1 \
1964 -s "bad certificate (usage extensions)" \
1965 -s "Processing of the Certificate handshake message failed"
1966
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001967run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001968 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001969 "$O_CLI -key data_files/server5.key \
1970 -cert data_files/server5.ku-ds.crt" \
1971 0 \
1972 -S "bad certificate (usage extensions)" \
1973 -S "Processing of the Certificate handshake message failed"
1974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001975run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001976 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001977 "$O_CLI -key data_files/server5.key \
1978 -cert data_files/server5.ku-ka.crt" \
1979 0 \
1980 -s "bad certificate (usage extensions)" \
1981 -S "Processing of the Certificate handshake message failed"
1982
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001983# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001985run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001986 "$P_SRV key_file=data_files/server5.key \
1987 crt_file=data_files/server5.eku-srv.crt" \
1988 "$P_CLI" \
1989 0
1990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001991run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001992 "$P_SRV key_file=data_files/server5.key \
1993 crt_file=data_files/server5.eku-srv.crt" \
1994 "$P_CLI" \
1995 0
1996
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001997run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001998 "$P_SRV key_file=data_files/server5.key \
1999 crt_file=data_files/server5.eku-cs_any.crt" \
2000 "$P_CLI" \
2001 0
2002
2003# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002004run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002005 "$P_SRV psk=abc123 key_file=data_files/server5.key \
2006 crt_file=data_files/server5.eku-cli.crt" \
2007 "$P_CLI psk=badbad" \
2008 1
2009
2010# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002012run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002013 "$O_SRV -key data_files/server5.key \
2014 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002015 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002016 0 \
2017 -C "bad certificate (usage extensions)" \
2018 -C "Processing of the Certificate handshake message failed" \
2019 -c "Ciphersuite is TLS-"
2020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002021run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002022 "$O_SRV -key data_files/server5.key \
2023 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002024 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002025 0 \
2026 -C "bad certificate (usage extensions)" \
2027 -C "Processing of the Certificate handshake message failed" \
2028 -c "Ciphersuite is TLS-"
2029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002030run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002031 "$O_SRV -key data_files/server5.key \
2032 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002033 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002034 0 \
2035 -C "bad certificate (usage extensions)" \
2036 -C "Processing of the Certificate handshake message failed" \
2037 -c "Ciphersuite is TLS-"
2038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002039run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002040 "$O_SRV -key data_files/server5.key \
2041 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002042 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002043 1 \
2044 -c "bad certificate (usage extensions)" \
2045 -c "Processing of the Certificate handshake message failed" \
2046 -C "Ciphersuite is TLS-"
2047
2048# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002050run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002051 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002052 "$O_CLI -key data_files/server5.key \
2053 -cert data_files/server5.eku-cli.crt" \
2054 0 \
2055 -S "bad certificate (usage extensions)" \
2056 -S "Processing of the Certificate handshake message failed"
2057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002058run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002059 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002060 "$O_CLI -key data_files/server5.key \
2061 -cert data_files/server5.eku-srv_cli.crt" \
2062 0 \
2063 -S "bad certificate (usage extensions)" \
2064 -S "Processing of the Certificate handshake message failed"
2065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002066run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002067 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002068 "$O_CLI -key data_files/server5.key \
2069 -cert data_files/server5.eku-cs_any.crt" \
2070 0 \
2071 -S "bad certificate (usage extensions)" \
2072 -S "Processing of the Certificate handshake message failed"
2073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002074run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002075 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002076 "$O_CLI -key data_files/server5.key \
2077 -cert data_files/server5.eku-cs.crt" \
2078 0 \
2079 -s "bad certificate (usage extensions)" \
2080 -S "Processing of the Certificate handshake message failed"
2081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002082run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002083 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002084 "$O_CLI -key data_files/server5.key \
2085 -cert data_files/server5.eku-cs.crt" \
2086 1 \
2087 -s "bad certificate (usage extensions)" \
2088 -s "Processing of the Certificate handshake message failed"
2089
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002090# Tests for DHM parameters loading
2091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002092run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002093 "$P_SRV" \
2094 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2095 debug_level=3" \
2096 0 \
2097 -c "value of 'DHM: P ' (2048 bits)" \
2098 -c "value of 'DHM: G ' (2048 bits)"
2099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002100run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002101 "$P_SRV dhm_file=data_files/dhparams.pem" \
2102 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2103 debug_level=3" \
2104 0 \
2105 -c "value of 'DHM: P ' (1024 bits)" \
2106 -c "value of 'DHM: G ' (2 bits)"
2107
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002108# Tests for PSK callback
2109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002110run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002111 "$P_SRV psk=abc123 psk_identity=foo" \
2112 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2113 psk_identity=foo psk=abc123" \
2114 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002115 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002116 -S "SSL - Unknown identity received" \
2117 -S "SSL - Verification of the message MAC failed"
2118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002119run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002120 "$P_SRV" \
2121 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2122 psk_identity=foo psk=abc123" \
2123 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002124 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002125 -S "SSL - Unknown identity received" \
2126 -S "SSL - Verification of the message MAC failed"
2127
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002128run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002129 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2130 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2131 psk_identity=foo psk=abc123" \
2132 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002133 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002134 -s "SSL - Unknown identity received" \
2135 -S "SSL - Verification of the message MAC failed"
2136
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002137run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002138 "$P_SRV psk_list=abc,dead,def,beef" \
2139 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2140 psk_identity=abc psk=dead" \
2141 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002142 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002143 -S "SSL - Unknown identity received" \
2144 -S "SSL - Verification of the message MAC failed"
2145
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002146run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002147 "$P_SRV psk_list=abc,dead,def,beef" \
2148 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2149 psk_identity=def psk=beef" \
2150 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002151 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002152 -S "SSL - Unknown identity received" \
2153 -S "SSL - Verification of the message MAC failed"
2154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002155run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002156 "$P_SRV psk_list=abc,dead,def,beef" \
2157 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2158 psk_identity=ghi psk=beef" \
2159 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002160 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002161 -s "SSL - Unknown identity received" \
2162 -S "SSL - Verification of the message MAC failed"
2163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002164run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002165 "$P_SRV psk_list=abc,dead,def,beef" \
2166 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2167 psk_identity=abc psk=beef" \
2168 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002169 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002170 -S "SSL - Unknown identity received" \
2171 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002172
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002173# Tests for ciphersuites per version
2174
Janos Follath4dfecab2016-03-14 13:40:43 +00002175requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002176run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002177 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002178 "$P_CLI force_version=ssl3" \
2179 0 \
2180 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2181
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002182run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002183 "$P_SRV arc4=1 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
2184 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002185 0 \
2186 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002188run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002189 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
2190 "$P_CLI force_version=tls1_1" \
2191 0 \
2192 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2193
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002194run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002195 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
2196 "$P_CLI force_version=tls1_2" \
2197 0 \
2198 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2199
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002200# Tests for ssl_get_bytes_avail()
2201
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002202run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002203 "$P_SRV" \
2204 "$P_CLI request_size=100" \
2205 0 \
2206 -s "Read from client: 100 bytes read$"
2207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002208run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002209 "$P_SRV" \
2210 "$P_CLI request_size=500" \
2211 0 \
2212 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002213
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002214# Tests for small packets
2215
Janos Follath4dfecab2016-03-14 13:40:43 +00002216requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002217run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002218 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002219 "$P_CLI request_size=1 force_version=ssl3 \
2220 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2221 0 \
2222 -s "Read from client: 1 bytes read"
2223
Janos Follath4dfecab2016-03-14 13:40:43 +00002224requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002225run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002226 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002227 "$P_CLI request_size=1 force_version=ssl3 \
2228 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2229 0 \
2230 -s "Read from client: 1 bytes read"
2231
2232run_test "Small packet TLS 1.0 BlockCipher" \
2233 "$P_SRV" \
2234 "$P_CLI request_size=1 force_version=tls1 \
2235 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2236 0 \
2237 -s "Read from client: 1 bytes read"
2238
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002239run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2240 "$P_SRV" \
2241 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2242 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2243 0 \
2244 -s "Read from client: 1 bytes read"
2245
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002246run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2247 "$P_SRV" \
2248 "$P_CLI request_size=1 force_version=tls1 \
2249 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2250 trunc_hmac=1" \
2251 0 \
2252 -s "Read from client: 1 bytes read"
2253
2254run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002255 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002256 "$P_CLI request_size=1 force_version=tls1 \
2257 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2258 trunc_hmac=1" \
2259 0 \
2260 -s "Read from client: 1 bytes read"
2261
2262run_test "Small packet TLS 1.1 BlockCipher" \
2263 "$P_SRV" \
2264 "$P_CLI request_size=1 force_version=tls1_1 \
2265 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2266 0 \
2267 -s "Read from client: 1 bytes read"
2268
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002269run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2270 "$P_SRV" \
2271 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2272 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2273 0 \
2274 -s "Read from client: 1 bytes read"
2275
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002276run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002277 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002278 "$P_CLI request_size=1 force_version=tls1_1 \
2279 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2280 0 \
2281 -s "Read from client: 1 bytes read"
2282
2283run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2284 "$P_SRV" \
2285 "$P_CLI request_size=1 force_version=tls1_1 \
2286 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2287 trunc_hmac=1" \
2288 0 \
2289 -s "Read from client: 1 bytes read"
2290
2291run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002292 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002293 "$P_CLI request_size=1 force_version=tls1_1 \
2294 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2295 trunc_hmac=1" \
2296 0 \
2297 -s "Read from client: 1 bytes read"
2298
2299run_test "Small packet TLS 1.2 BlockCipher" \
2300 "$P_SRV" \
2301 "$P_CLI request_size=1 force_version=tls1_2 \
2302 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2303 0 \
2304 -s "Read from client: 1 bytes read"
2305
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002306run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2307 "$P_SRV" \
2308 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2309 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2310 0 \
2311 -s "Read from client: 1 bytes read"
2312
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002313run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2314 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002315 "$P_CLI request_size=1 force_version=tls1_2 \
2316 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002317 0 \
2318 -s "Read from client: 1 bytes read"
2319
2320run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2321 "$P_SRV" \
2322 "$P_CLI request_size=1 force_version=tls1_2 \
2323 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2324 trunc_hmac=1" \
2325 0 \
2326 -s "Read from client: 1 bytes read"
2327
2328run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002329 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002330 "$P_CLI request_size=1 force_version=tls1_2 \
2331 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2332 0 \
2333 -s "Read from client: 1 bytes read"
2334
2335run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002336 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002337 "$P_CLI request_size=1 force_version=tls1_2 \
2338 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2339 trunc_hmac=1" \
2340 0 \
2341 -s "Read from client: 1 bytes read"
2342
2343run_test "Small packet TLS 1.2 AEAD" \
2344 "$P_SRV" \
2345 "$P_CLI request_size=1 force_version=tls1_2 \
2346 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2347 0 \
2348 -s "Read from client: 1 bytes read"
2349
2350run_test "Small packet TLS 1.2 AEAD shorter tag" \
2351 "$P_SRV" \
2352 "$P_CLI request_size=1 force_version=tls1_2 \
2353 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2354 0 \
2355 -s "Read from client: 1 bytes read"
2356
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002357# Test for large packets
2358
Janos Follath4dfecab2016-03-14 13:40:43 +00002359requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002360run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002361 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002362 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002363 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2364 0 \
2365 -s "Read from client: 16384 bytes read"
2366
Janos Follath4dfecab2016-03-14 13:40:43 +00002367requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002368run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002369 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002370 "$P_CLI request_size=16384 force_version=ssl3 \
2371 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2372 0 \
2373 -s "Read from client: 16384 bytes read"
2374
2375run_test "Large packet TLS 1.0 BlockCipher" \
2376 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002377 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002378 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2379 0 \
2380 -s "Read from client: 16384 bytes read"
2381
2382run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2383 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002384 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002385 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2386 trunc_hmac=1" \
2387 0 \
2388 -s "Read from client: 16384 bytes read"
2389
2390run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002391 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002392 "$P_CLI request_size=16384 force_version=tls1 \
2393 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2394 trunc_hmac=1" \
2395 0 \
2396 -s "Read from client: 16384 bytes read"
2397
2398run_test "Large packet TLS 1.1 BlockCipher" \
2399 "$P_SRV" \
2400 "$P_CLI request_size=16384 force_version=tls1_1 \
2401 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2402 0 \
2403 -s "Read from client: 16384 bytes read"
2404
2405run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002406 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002407 "$P_CLI request_size=16384 force_version=tls1_1 \
2408 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2409 0 \
2410 -s "Read from client: 16384 bytes read"
2411
2412run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2413 "$P_SRV" \
2414 "$P_CLI request_size=16384 force_version=tls1_1 \
2415 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2416 trunc_hmac=1" \
2417 0 \
2418 -s "Read from client: 16384 bytes read"
2419
2420run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002421 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002422 "$P_CLI request_size=16384 force_version=tls1_1 \
2423 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2424 trunc_hmac=1" \
2425 0 \
2426 -s "Read from client: 16384 bytes read"
2427
2428run_test "Large packet TLS 1.2 BlockCipher" \
2429 "$P_SRV" \
2430 "$P_CLI request_size=16384 force_version=tls1_2 \
2431 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2432 0 \
2433 -s "Read from client: 16384 bytes read"
2434
2435run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2436 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002437 "$P_CLI request_size=16384 force_version=tls1_2 \
2438 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002439 0 \
2440 -s "Read from client: 16384 bytes read"
2441
2442run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2443 "$P_SRV" \
2444 "$P_CLI request_size=16384 force_version=tls1_2 \
2445 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2446 trunc_hmac=1" \
2447 0 \
2448 -s "Read from client: 16384 bytes read"
2449
2450run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002451 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002452 "$P_CLI request_size=16384 force_version=tls1_2 \
2453 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2454 0 \
2455 -s "Read from client: 16384 bytes read"
2456
2457run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002458 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002459 "$P_CLI request_size=16384 force_version=tls1_2 \
2460 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2461 trunc_hmac=1" \
2462 0 \
2463 -s "Read from client: 16384 bytes read"
2464
2465run_test "Large packet TLS 1.2 AEAD" \
2466 "$P_SRV" \
2467 "$P_CLI request_size=16384 force_version=tls1_2 \
2468 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2469 0 \
2470 -s "Read from client: 16384 bytes read"
2471
2472run_test "Large packet TLS 1.2 AEAD shorter tag" \
2473 "$P_SRV" \
2474 "$P_CLI request_size=16384 force_version=tls1_2 \
2475 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2476 0 \
2477 -s "Read from client: 16384 bytes read"
2478
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002479# Final report
2480
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002481echo "------------------------------------------------------------------------"
2482
2483if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002484 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002485else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002486 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002487fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002488PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002489echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002490
2491exit $FAILS