blob: c56639f0caedc72e03abcdf1706143013863ee5b [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é-Gonnard913030c2014-03-28 10:12:38 +010013# test if it is defined from the environment before assining default
14# if yes, assume it means it's a build with all the options we need (SSLv2)
15if [ -n "${OPENSSL_CMD:-}" ]; then
16 OPENSSL_OK=1
17else
18 OPENSSL_OK=0
19fi
20
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010021# default values, can be overriden by the environment
22: ${P_SRV:=../programs/ssl/ssl_server2}
23: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010024: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010025
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010026O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
27O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010028
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010029TESTS=0
30FAILS=0
31
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020032CONFIG_H='../include/polarssl/config.h'
33
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010035FILTER='.*'
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +010036if [ "$OPENSSL_OK" -gt 0 ]; then
37 EXCLUDE='^$'
38else
39 EXCLUDE='SSLv2'
40fi
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041
42print_usage() {
43 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010044 echo -e " -h|--help\tPrint this help."
45 echo -e " -m|--memcheck\tCheck memory leaks and errors."
46 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
47 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048}
49
50get_options() {
51 while [ $# -gt 0 ]; do
52 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010053 -f|--filter)
54 shift; FILTER=$1
55 ;;
56 -e|--exclude)
57 shift; EXCLUDE=$1
58 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010059 -m|--memcheck)
60 MEMCHECK=1
61 ;;
62 -h|--help)
63 print_usage
64 exit 0
65 ;;
66 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020067 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010068 print_usage
69 exit 1
70 ;;
71 esac
72 shift
73 done
74}
75
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010076# print_name <name>
77print_name() {
78 echo -n "$1 "
79 LEN=`echo "$1" | wc -c`
80 LEN=`echo 72 - $LEN | bc`
81 for i in `seq 1 $LEN`; do echo -n '.'; done
82 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010083
84 TESTS=`echo $TESTS + 1 | bc`
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010085}
86
87# fail <message>
88fail() {
89 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +010090 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010091
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +020092 cp $SRV_OUT o-srv-${TESTS}.log
93 cp $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +010094 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010095
96 FAILS=`echo $FAILS + 1 | bc`
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010097}
98
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +010099# is_polar <cmd_line>
100is_polar() {
101 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
102}
103
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104# has_mem_err <log_file_name>
105has_mem_err() {
106 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
107 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
108 then
109 return 1 # false: does not have errors
110 else
111 return 0 # true: has errors
112 fi
113}
114
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200115# wait for server to start: two versions depending on lsof availability
116wait_server_start() {
117 if which lsof >/dev/null; then
118 # make sure we don't loop forever
119 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
120 WATCHDOG_PID=$!
121
122 # make a tight loop, server usually takes less than 1 sec to start
123 until lsof -nbi TCP:"$PORT" | grep LISTEN >/dev/null; do :; done
124
125 kill $WATCHDOG_PID
126 wait $WATCHDOG_PID
127 else
128 sleep "$START_DELAY"
129 fi
130}
131
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100132# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100133# Options: -s pattern pattern that must be present in server output
134# -c pattern pattern that must be present in client output
135# -S pattern pattern that must be absent in server output
136# -C pattern pattern that must be absent in client output
137run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100138 NAME="$1"
139 SRV_CMD="$2"
140 CLI_CMD="$3"
141 CLI_EXPECT="$4"
142 shift 4
143
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100144 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
145 else
146 return
147 fi
148
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100149 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100150
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100151 # prepend valgrind to our commands if active
152 if [ "$MEMCHECK" -gt 0 ]; then
153 if is_polar "$SRV_CMD"; then
154 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
155 fi
156 if is_polar "$CLI_CMD"; then
157 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
158 fi
159 fi
160
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100161 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200162 echo "$SRV_CMD" > $SRV_OUT
163 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100164 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200165 wait_server_start
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200166 echo "$CLI_CMD" > $CLI_OUT
167 eval "$CLI_CMD" >> $CLI_OUT 2>&1
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100168 CLI_EXIT=$?
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200169 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100170
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100171 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200172 # start watchdog in case SERVERQUIT fails
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200173 ( sleep "$DOG_DELAY"; echo "SERVERQUIT TIMEOUT"; kill $MAIN_PID ) &
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200174 WATCHDOG_PID=$!
175
176 # psk is useful when server only has bad certs
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200177 $P_CLI request_page=SERVERQUIT tickets=0 auth_mode=none psk=abc123 \
Manuel Pégourié-Gonnard84fd6872014-03-13 18:35:10 +0100178 crt_file=data_files/cli2.crt key_file=data_files/cli2.key \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +0200179 >/dev/null 2>&1
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200180
181 wait $SRV_PID
182 kill $WATCHDOG_PID
183 wait $WATCHDOG_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100184 else
185 kill $SRV_PID
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200186 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100187 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100188
189 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200190 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100191 # expected client exit to incorrectly succeed in case of catastrophic
192 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100193 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200194 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100195 else
196 fail "server failed to start"
197 return
198 fi
199 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100200 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200201 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100202 else
203 fail "client failed to start"
204 return
205 fi
206 fi
207
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100208 # check server exit code
209 if [ $? != 0 ]; then
210 fail "server fail"
211 return
212 fi
213
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100214 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100215 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
216 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100217 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100218 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100219 return
220 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100221
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100222 # check other assertions
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100223 while [ $# -gt 0 ]
224 do
225 case $1 in
226 "-s")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200227 if grep "$2" $SRV_OUT >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100228 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100229 return
230 fi
231 ;;
232
233 "-c")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200234 if grep "$2" $CLI_OUT >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100235 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100236 return
237 fi
238 ;;
239
240 "-S")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200241 if grep "$2" $SRV_OUT >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100242 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100243 return
244 fi
245 ;;
246
247 "-C")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200248 if grep "$2" $CLI_OUT >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100250 return
251 fi
252 ;;
253
254 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200255 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100256 exit 1
257 esac
258 shift 2
259 done
260
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100261 # check valgrind's results
262 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200263 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100264 fail "Server has memory errors"
265 return
266 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200267 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100268 fail "Client has memory errors"
269 return
270 fi
271 fi
272
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100273 # if we're here, everything is ok
274 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200275 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100276}
277
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100278cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200279 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200280 kill $SRV_PID >/dev/null 2>&1
281 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100282 exit 1
283}
284
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100285#
286# MAIN
287#
288
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100289get_options "$@"
290
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100291# sanity checks, avoid an avalanche of errors
292if [ ! -x "$P_SRV" ]; then
293 echo "Command '$P_SRV' is not an executable file"
294 exit 1
295fi
296if [ ! -x "$P_CLI" ]; then
297 echo "Command '$P_CLI' is not an executable file"
298 exit 1
299fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100300if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
301 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100302 exit 1
303fi
304
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200305# used by watchdog
306MAIN_PID="$$"
307
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200308# be more patient with valgrind
309if [ "$MEMCHECK" -gt 0 ]; then
310 START_DELAY=3
311 DOG_DELAY=30
312else
313 START_DELAY=1
314 DOG_DELAY=10
315fi
316
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200317# Pick a "unique" port in the range 10000-19999.
318PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200319PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200320
321# fix commands to use this port
322P_SRV="$P_SRV server_port=$PORT"
323P_CLI="$P_CLI server_port=$PORT"
324O_SRV="$O_SRV -accept $PORT"
325O_CLI="$O_CLI -connect localhost:$PORT"
326
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200327# Also pick a unique name for intermediate files
328SRV_OUT="srv_out.$$"
329CLI_OUT="cli_out.$$"
330SESSION="session.$$"
331
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100332trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100333
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200334# Basic test
335
336run_test "Default" \
337 "$P_SRV" \
338 "$P_CLI" \
339 0 \
340 -S "Last error was" \
341 -C "Last error was"
342
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100343# Test for SSLv2 ClientHello
344
345run_test "SSLv2 ClientHello #0 (reference)" \
346 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100347 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100348 0 \
349 -S "parse client hello v2" \
350 -S "ssl_handshake returned"
351
352# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
353run_test "SSLv2 ClientHello #1 (actual test)" \
354 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100355 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100356 0 \
357 -s "parse client hello v2" \
358 -S "ssl_handshake returned"
359
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100360# Tests for Truncated HMAC extension
361
362run_test "Truncated HMAC #0" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100363 "$P_SRV debug_level=5" \
364 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100365 0 \
366 -s "dumping 'computed mac' (20 bytes)"
367
368run_test "Truncated HMAC #1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100369 "$P_SRV debug_level=5" \
370 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100371 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100372 -s "dumping 'computed mac' (10 bytes)"
373
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100374# Tests for Session Tickets
375
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100376run_test "Session resume using tickets #1 (basic)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100377 "$P_SRV debug_level=4 tickets=1" \
378 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100379 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100380 -c "client hello, adding session ticket extension" \
381 -s "found session ticket extension" \
382 -s "server hello, adding session ticket extension" \
383 -c "found session_ticket extension" \
384 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100385 -S "session successfully restored from cache" \
386 -s "session successfully restored from ticket" \
387 -s "a session has been resumed" \
388 -c "a session has been resumed"
389
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100390run_test "Session resume using tickets #2 (cache disabled)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100391 "$P_SRV debug_level=4 tickets=1 cache_max=0" \
392 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100393 0 \
394 -c "client hello, adding session ticket extension" \
395 -s "found session ticket extension" \
396 -s "server hello, adding session ticket extension" \
397 -c "found session_ticket extension" \
398 -c "parse new session ticket" \
399 -S "session successfully restored from cache" \
400 -s "session successfully restored from ticket" \
401 -s "a session has been resumed" \
402 -c "a session has been resumed"
403
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100404run_test "Session resume using tickets #3 (timeout)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100405 "$P_SRV debug_level=4 tickets=1 cache_max=0 ticket_timeout=1" \
406 "$P_CLI debug_level=4 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100407 0 \
408 -c "client hello, adding session ticket extension" \
409 -s "found session ticket extension" \
410 -s "server hello, adding session ticket extension" \
411 -c "found session_ticket extension" \
412 -c "parse new session ticket" \
413 -S "session successfully restored from cache" \
414 -S "session successfully restored from ticket" \
415 -S "a session has been resumed" \
416 -C "a session has been resumed"
417
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100418run_test "Session resume using tickets #4 (openssl server)" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100419 "$O_SRV" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100420 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
421 0 \
422 -c "client hello, adding session ticket extension" \
423 -c "found session_ticket extension" \
424 -c "parse new session ticket" \
425 -c "a session has been resumed"
426
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100427run_test "Session resume using tickets #5 (openssl client)" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100428 "$P_SRV debug_level=4 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200429 "( $O_CLI -sess_out $SESSION; \
430 $O_CLI -sess_in $SESSION; \
431 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100432 0 \
433 -s "found session ticket extension" \
434 -s "server hello, adding session ticket extension" \
435 -S "session successfully restored from cache" \
436 -s "session successfully restored from ticket" \
437 -s "a session has been resumed"
438
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100439# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100440
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100441run_test "Session resume using cache #1 (tickets enabled on client)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100442 "$P_SRV debug_level=4 tickets=0" \
443 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100444 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100445 -c "client hello, adding session ticket extension" \
446 -s "found session ticket extension" \
447 -S "server hello, adding session ticket extension" \
448 -C "found session_ticket extension" \
449 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100450 -s "session successfully restored from cache" \
451 -S "session successfully restored from ticket" \
452 -s "a session has been resumed" \
453 -c "a session has been resumed"
454
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100455run_test "Session resume using cache #2 (tickets enabled on server)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100456 "$P_SRV debug_level=4 tickets=1" \
457 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100458 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100459 -C "client hello, adding session ticket extension" \
460 -S "found session ticket extension" \
461 -S "server hello, adding session ticket extension" \
462 -C "found session_ticket extension" \
463 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100464 -s "session successfully restored from cache" \
465 -S "session successfully restored from ticket" \
466 -s "a session has been resumed" \
467 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100468
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100469run_test "Session resume using cache #3 (cache_max=0)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100470 "$P_SRV debug_level=4 tickets=0 cache_max=0" \
471 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100472 0 \
473 -S "session successfully restored from cache" \
474 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100475 -S "a session has been resumed" \
476 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100477
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100478run_test "Session resume using cache #4 (cache_max=1)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100479 "$P_SRV debug_level=4 tickets=0 cache_max=1" \
480 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100481 0 \
482 -s "session successfully restored from cache" \
483 -S "session successfully restored from ticket" \
484 -s "a session has been resumed" \
485 -c "a session has been resumed"
486
487run_test "Session resume using cache #5 (timemout > delay)" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100488 "$P_SRV debug_level=4 tickets=0" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100489 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100490 0 \
491 -s "session successfully restored from cache" \
492 -S "session successfully restored from ticket" \
493 -s "a session has been resumed" \
494 -c "a session has been resumed"
495
496run_test "Session resume using cache #6 (timeout < delay)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100497 "$P_SRV debug_level=4 tickets=0 cache_timeout=1" \
498 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100499 0 \
500 -S "session successfully restored from cache" \
501 -S "session successfully restored from ticket" \
502 -S "a session has been resumed" \
503 -C "a session has been resumed"
504
505run_test "Session resume using cache #7 (no timeout)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100506 "$P_SRV debug_level=4 tickets=0 cache_timeout=0" \
507 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100508 0 \
509 -s "session successfully restored from cache" \
510 -S "session successfully restored from ticket" \
511 -s "a session has been resumed" \
512 -c "a session has been resumed"
513
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100514run_test "Session resume using cache #8 (openssl client)" \
515 "$P_SRV debug_level=4 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200516 "( $O_CLI -sess_out $SESSION; \
517 $O_CLI -sess_in $SESSION; \
518 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100519 0 \
520 -s "found session ticket extension" \
521 -S "server hello, adding session ticket extension" \
522 -s "session successfully restored from cache" \
523 -S "session successfully restored from ticket" \
524 -s "a session has been resumed"
525
526run_test "Session resume using cache #9 (openssl server)" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100527 "$O_SRV" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100528 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
529 0 \
530 -C "found session_ticket extension" \
531 -C "parse new session ticket" \
532 -c "a session has been resumed"
533
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100534# Tests for Max Fragment Length extension
535
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100536run_test "Max fragment length #1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100537 "$P_SRV debug_level=4" \
538 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100539 0 \
540 -C "client hello, adding max_fragment_length extension" \
541 -S "found max fragment length extension" \
542 -S "server hello, max_fragment_length extension" \
543 -C "found max_fragment_length extension"
544
545run_test "Max fragment length #2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100546 "$P_SRV debug_level=4" \
547 "$P_CLI debug_level=4 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100548 0 \
549 -c "client hello, adding max_fragment_length extension" \
550 -s "found max fragment length extension" \
551 -s "server hello, max_fragment_length extension" \
552 -c "found max_fragment_length extension"
553
554run_test "Max fragment length #3" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100555 "$P_SRV debug_level=4 max_frag_len=4096" \
556 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100557 0 \
558 -C "client hello, adding max_fragment_length extension" \
559 -S "found max fragment length extension" \
560 -S "server hello, max_fragment_length extension" \
561 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100562
563# Tests for renegotiation
564
565run_test "Renegotiation #0 (none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100566 "$P_SRV debug_level=4" \
567 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100568 0 \
569 -C "client hello, adding renegotiation extension" \
570 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
571 -S "found renegotiation extension" \
572 -s "server hello, secure renegotiation extension" \
573 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100574 -C "=> renegotiate" \
575 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100576 -S "write hello request"
577
578run_test "Renegotiation #1 (enabled, client-initiated)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200579 "$P_SRV debug_level=4 renegotiation=1" \
580 "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100581 0 \
582 -c "client hello, adding renegotiation extension" \
583 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
584 -s "found renegotiation extension" \
585 -s "server hello, secure renegotiation extension" \
586 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100587 -c "=> renegotiate" \
588 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100589 -S "write hello request"
590
591run_test "Renegotiation #2 (enabled, server-initiated)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200592 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \
593 "$P_CLI debug_level=4 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100594 0 \
595 -c "client hello, adding renegotiation extension" \
596 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
597 -s "found renegotiation extension" \
598 -s "server hello, secure renegotiation extension" \
599 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100600 -c "=> renegotiate" \
601 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100602 -s "write hello request"
603
604run_test "Renegotiation #3 (enabled, double)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200605 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \
606 "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100607 0 \
608 -c "client hello, adding renegotiation extension" \
609 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
610 -s "found renegotiation extension" \
611 -s "server hello, secure renegotiation extension" \
612 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100613 -c "=> renegotiate" \
614 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100615 -s "write hello request"
616
617run_test "Renegotiation #4 (client-initiated, server-rejected)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100618 "$P_SRV debug_level=4 renegotiation=0" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200619 "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100620 1 \
621 -c "client hello, adding renegotiation extension" \
622 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
623 -S "found renegotiation extension" \
624 -s "server hello, secure renegotiation extension" \
625 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100626 -c "=> renegotiate" \
627 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200628 -S "write hello request" \
629 -c "SSL - An unexpected message was received from our peer" \
630 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100631
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200632run_test "Renegotiation #5 (server-initiated, client-rejected, default)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200633 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100634 "$P_CLI debug_level=4 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100635 0 \
636 -C "client hello, adding renegotiation extension" \
637 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
638 -S "found renegotiation extension" \
639 -s "server hello, secure renegotiation extension" \
640 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100641 -C "=> renegotiate" \
642 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100643 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200644 -S "SSL - An unexpected message was received from our peer" \
645 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100646
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200647run_test "Renegotiation #6 (server-initiated, client-rejected, not enforced)" \
648 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1 \
649 renego_delay=-1" \
650 "$P_CLI debug_level=4 renegotiation=0" \
651 0 \
652 -C "client hello, adding renegotiation extension" \
653 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
654 -S "found renegotiation extension" \
655 -s "server hello, secure renegotiation extension" \
656 -c "found renegotiation extension" \
657 -C "=> renegotiate" \
658 -S "=> renegotiate" \
659 -s "write hello request" \
660 -S "SSL - An unexpected message was received from our peer" \
661 -S "failed"
662
663run_test "Renegotiation #7 (server-initiated, client-rejected, delay 1)" \
664 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1 \
665 renego_delay=1" \
666 "$P_CLI debug_level=4 renegotiation=0" \
667 0 \
668 -C "client hello, adding renegotiation extension" \
669 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
670 -S "found renegotiation extension" \
671 -s "server hello, secure renegotiation extension" \
672 -c "found renegotiation extension" \
673 -C "=> renegotiate" \
674 -S "=> renegotiate" \
675 -s "write hello request" \
676 -S "SSL - An unexpected message was received from our peer" \
677 -S "failed"
678
679run_test "Renegotiation #8 (server-initiated, client-rejected, delay 0)" \
680 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1 \
681 renego_delay=0" \
682 "$P_CLI debug_level=4 renegotiation=0" \
683 0 \
684 -C "client hello, adding renegotiation extension" \
685 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
686 -S "found renegotiation extension" \
687 -s "server hello, secure renegotiation extension" \
688 -c "found renegotiation extension" \
689 -C "=> renegotiate" \
690 -S "=> renegotiate" \
691 -s "write hello request" \
692 -s "SSL - An unexpected message was received from our peer" \
693 -s "failed"
694
695run_test "Renegotiation #9 (server-initiated, client-accepted, delay 0)" \
696 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1 \
697 renego_delay=0" \
698 "$P_CLI debug_level=4 renegotiation=1" \
699 0 \
700 -c "client hello, adding renegotiation extension" \
701 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
702 -s "found renegotiation extension" \
703 -s "server hello, secure renegotiation extension" \
704 -c "found renegotiation extension" \
705 -c "=> renegotiate" \
706 -s "=> renegotiate" \
707 -s "write hello request" \
708 -S "SSL - An unexpected message was received from our peer" \
709 -S "failed"
710
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100711# Tests for auth_mode
712
713run_test "Authentication #1 (server badcert, client required)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100714 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100715 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100716 "$P_CLI debug_level=2 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100717 1 \
718 -c "x509_verify_cert() returned" \
719 -c "! self-signed or not signed by a trusted CA" \
720 -c "! ssl_handshake returned" \
721 -c "X509 - Certificate verification failed"
722
723run_test "Authentication #2 (server badcert, client optional)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100724 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100725 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100726 "$P_CLI debug_level=2 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100727 0 \
728 -c "x509_verify_cert() returned" \
729 -c "! self-signed or not signed by a trusted CA" \
730 -C "! ssl_handshake returned" \
731 -C "X509 - Certificate verification failed"
732
733run_test "Authentication #3 (server badcert, client none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100734 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100735 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100736 "$P_CLI debug_level=2 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100737 0 \
738 -C "x509_verify_cert() returned" \
739 -C "! self-signed or not signed by a trusted CA" \
740 -C "! ssl_handshake returned" \
741 -C "X509 - Certificate verification failed"
742
743run_test "Authentication #4 (client badcert, server required)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100744 "$P_SRV debug_level=4 auth_mode=required" \
745 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100746 key_file=data_files/server5.key" \
747 1 \
748 -S "skip write certificate request" \
749 -C "skip parse certificate request" \
750 -c "got a certificate request" \
751 -C "skip write certificate" \
752 -C "skip write certificate verify" \
753 -S "skip parse certificate verify" \
754 -s "x509_verify_cert() returned" \
755 -S "! self-signed or not signed by a trusted CA" \
756 -s "! ssl_handshake returned" \
757 -c "! ssl_handshake returned" \
758 -s "X509 - Certificate verification failed"
759
760run_test "Authentication #5 (client badcert, server optional)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100761 "$P_SRV debug_level=4 auth_mode=optional" \
762 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100763 key_file=data_files/server5.key" \
764 0 \
765 -S "skip write certificate request" \
766 -C "skip parse certificate request" \
767 -c "got a certificate request" \
768 -C "skip write certificate" \
769 -C "skip write certificate verify" \
770 -S "skip parse certificate verify" \
771 -s "x509_verify_cert() returned" \
772 -s "! self-signed or not signed by a trusted CA" \
773 -S "! ssl_handshake returned" \
774 -C "! ssl_handshake returned" \
775 -S "X509 - Certificate verification failed"
776
777run_test "Authentication #6 (client badcert, server none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100778 "$P_SRV debug_level=4 auth_mode=none" \
779 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100780 key_file=data_files/server5.key" \
781 0 \
782 -s "skip write certificate request" \
783 -C "skip parse certificate request" \
784 -c "got no certificate request" \
785 -c "skip write certificate" \
786 -c "skip write certificate verify" \
787 -s "skip parse certificate verify" \
788 -S "x509_verify_cert() returned" \
789 -S "! self-signed or not signed by a trusted CA" \
790 -S "! ssl_handshake returned" \
791 -C "! ssl_handshake returned" \
792 -S "X509 - Certificate verification failed"
793
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100794run_test "Authentication #7 (client no cert, server optional)" \
795 "$P_SRV debug_level=4 auth_mode=optional" \
796 "$P_CLI debug_level=4 crt_file=none key_file=none" \
797 0 \
798 -S "skip write certificate request" \
799 -C "skip parse certificate request" \
800 -c "got a certificate request" \
801 -C "skip write certificate$" \
802 -C "got no certificate to send" \
803 -S "SSLv3 client has no certificate" \
804 -c "skip write certificate verify" \
805 -s "skip parse certificate verify" \
806 -s "! no client certificate sent" \
807 -S "! ssl_handshake returned" \
808 -C "! ssl_handshake returned" \
809 -S "X509 - Certificate verification failed"
810
811run_test "Authentication #8 (openssl client no cert, server optional)" \
812 "$P_SRV debug_level=4 auth_mode=optional" \
813 "$O_CLI" \
814 0 \
815 -S "skip write certificate request" \
816 -s "skip parse certificate verify" \
817 -s "! no client certificate sent" \
818 -S "! ssl_handshake returned" \
819 -S "X509 - Certificate verification failed"
820
821run_test "Authentication #9 (client no cert, openssl server optional)" \
822 "$O_SRV -verify 10" \
823 "$P_CLI debug_level=4 crt_file=none key_file=none" \
824 0 \
825 -C "skip parse certificate request" \
826 -c "got a certificate request" \
827 -C "skip write certificate$" \
828 -c "skip write certificate verify" \
829 -C "! ssl_handshake returned"
830
831run_test "Authentication #10 (client no cert, ssl3)" \
832 "$P_SRV debug_level=4 auth_mode=optional force_version=ssl3" \
833 "$P_CLI debug_level=4 crt_file=none key_file=none" \
834 0 \
835 -S "skip write certificate request" \
836 -C "skip parse certificate request" \
837 -c "got a certificate request" \
838 -C "skip write certificate$" \
839 -c "skip write certificate verify" \
840 -c "got no certificate to send" \
841 -s "SSLv3 client has no certificate" \
842 -s "skip parse certificate verify" \
843 -s "! no client certificate sent" \
844 -S "! ssl_handshake returned" \
845 -C "! ssl_handshake returned" \
846 -S "X509 - Certificate verification failed"
847
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100848# tests for SNI
849
850run_test "SNI #0 (no SNI callback)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100851 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100852 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100853 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100854 server_name=localhost" \
855 0 \
856 -S "parse ServerName extension" \
857 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
858 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
859
860run_test "SNI #1 (matching cert 1)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100861 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100862 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100863 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 +0100864 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100865 server_name=localhost" \
866 0 \
867 -s "parse ServerName extension" \
868 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
869 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
870
871run_test "SNI #2 (matching cert 2)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100872 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100873 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100874 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 +0100875 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100876 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100877 0 \
878 -s "parse ServerName extension" \
879 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100880 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100881
882run_test "SNI #3 (no matching cert)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100883 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100884 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100885 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 +0100886 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100887 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100888 1 \
889 -s "parse ServerName extension" \
890 -s "ssl_sni_wrapper() returned" \
891 -s "ssl_handshake returned" \
892 -c "ssl_handshake returned" \
893 -c "SSL - A fatal alert message was received from our peer"
894
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +0100895# Tests for non-blocking I/O: exercise a variety of handshake flows
896
897run_test "Non-blocking I/O #1 (basic handshake)" \
898 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
899 "$P_CLI nbio=2 tickets=0" \
900 0 \
901 -S "ssl_handshake returned" \
902 -C "ssl_handshake returned" \
903 -c "Read from server: .* bytes read"
904
905run_test "Non-blocking I/O #2 (client auth)" \
906 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
907 "$P_CLI nbio=2 tickets=0" \
908 0 \
909 -S "ssl_handshake returned" \
910 -C "ssl_handshake returned" \
911 -c "Read from server: .* bytes read"
912
913run_test "Non-blocking I/O #3 (ticket)" \
914 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
915 "$P_CLI nbio=2 tickets=1" \
916 0 \
917 -S "ssl_handshake returned" \
918 -C "ssl_handshake returned" \
919 -c "Read from server: .* bytes read"
920
921run_test "Non-blocking I/O #4 (ticket + client auth)" \
922 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
923 "$P_CLI nbio=2 tickets=1" \
924 0 \
925 -S "ssl_handshake returned" \
926 -C "ssl_handshake returned" \
927 -c "Read from server: .* bytes read"
928
929run_test "Non-blocking I/O #5 (ticket + client auth + resume)" \
930 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
931 "$P_CLI nbio=2 tickets=1 reconnect=1" \
932 0 \
933 -S "ssl_handshake returned" \
934 -C "ssl_handshake returned" \
935 -c "Read from server: .* bytes read"
936
937run_test "Non-blocking I/O #6 (ticket + resume)" \
938 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
939 "$P_CLI nbio=2 tickets=1 reconnect=1" \
940 0 \
941 -S "ssl_handshake returned" \
942 -C "ssl_handshake returned" \
943 -c "Read from server: .* bytes read"
944
945run_test "Non-blocking I/O #7 (session-id resume)" \
946 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
947 "$P_CLI nbio=2 tickets=0 reconnect=1" \
948 0 \
949 -S "ssl_handshake returned" \
950 -C "ssl_handshake returned" \
951 -c "Read from server: .* bytes read"
952
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +0200953# Tests for version negotiation
954
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100955run_test "Version check #1 (all -> 1.2)" \
956 "$P_SRV" \
957 "$P_CLI" \
958 0 \
959 -S "ssl_handshake returned" \
960 -C "ssl_handshake returned" \
961 -s "Protocol is TLSv1.2" \
962 -c "Protocol is TLSv1.2"
963
964run_test "Version check #2 (cli max 1.1 -> 1.1)" \
965 "$P_SRV" \
966 "$P_CLI max_version=tls1_1" \
967 0 \
968 -S "ssl_handshake returned" \
969 -C "ssl_handshake returned" \
970 -s "Protocol is TLSv1.1" \
971 -c "Protocol is TLSv1.1"
972
973run_test "Version check #3 (srv max 1.1 -> 1.1)" \
974 "$P_SRV max_version=tls1_1" \
975 "$P_CLI" \
976 0 \
977 -S "ssl_handshake returned" \
978 -C "ssl_handshake returned" \
979 -s "Protocol is TLSv1.1" \
980 -c "Protocol is TLSv1.1"
981
982run_test "Version check #4 (cli+srv max 1.1 -> 1.1)" \
983 "$P_SRV max_version=tls1_1" \
984 "$P_CLI max_version=tls1_1" \
985 0 \
986 -S "ssl_handshake returned" \
987 -C "ssl_handshake returned" \
988 -s "Protocol is TLSv1.1" \
989 -c "Protocol is TLSv1.1"
990
991run_test "Version check #5 (cli max 1.1, srv min 1.1 -> 1.1)" \
992 "$P_SRV min_version=tls1_1" \
993 "$P_CLI max_version=tls1_1" \
994 0 \
995 -S "ssl_handshake returned" \
996 -C "ssl_handshake returned" \
997 -s "Protocol is TLSv1.1" \
998 -c "Protocol is TLSv1.1"
999
1000run_test "Version check #6 (cli min 1.1, srv max 1.1 -> 1.1)" \
1001 "$P_SRV max_version=tls1_1" \
1002 "$P_CLI min_version=tls1_1" \
1003 0 \
1004 -S "ssl_handshake returned" \
1005 -C "ssl_handshake returned" \
1006 -s "Protocol is TLSv1.1" \
1007 -c "Protocol is TLSv1.1"
1008
1009run_test "Version check #7 (cli min 1.2, srv max 1.1 -> fail)" \
1010 "$P_SRV max_version=tls1_1" \
1011 "$P_CLI min_version=tls1_2" \
1012 1 \
1013 -s "ssl_handshake returned" \
1014 -c "ssl_handshake returned" \
1015 -c "SSL - Handshake protocol not within min/max boundaries"
1016
1017run_test "Version check #8 (srv min 1.2, cli max 1.1 -> fail)" \
1018 "$P_SRV min_version=tls1_2" \
1019 "$P_CLI max_version=tls1_1" \
1020 1 \
1021 -s "ssl_handshake returned" \
1022 -c "ssl_handshake returned" \
1023 -s "SSL - Handshake protocol not within min/max boundaries"
1024
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001025# Tests for ALPN extension
1026
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001027if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1028
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001029run_test "ALPN #0 (none)" \
1030 "$P_SRV debug_level=4" \
1031 "$P_CLI debug_level=4" \
1032 0 \
1033 -C "client hello, adding alpn extension" \
1034 -S "found alpn extension" \
1035 -C "got an alert message, type: \\[2:120]" \
1036 -S "server hello, adding alpn extension" \
1037 -C "found alpn extension " \
1038 -C "Application Layer Protocol is" \
1039 -S "Application Layer Protocol is"
1040
1041run_test "ALPN #1 (client only)" \
1042 "$P_SRV debug_level=4" \
1043 "$P_CLI debug_level=4 alpn=abc,1234" \
1044 0 \
1045 -c "client hello, adding alpn extension" \
1046 -s "found alpn extension" \
1047 -C "got an alert message, type: \\[2:120]" \
1048 -S "server hello, adding alpn extension" \
1049 -C "found alpn extension " \
1050 -c "Application Layer Protocol is (none)" \
1051 -S "Application Layer Protocol is"
1052
1053run_test "ALPN #2 (server only)" \
1054 "$P_SRV debug_level=4 alpn=abc,1234" \
1055 "$P_CLI debug_level=4" \
1056 0 \
1057 -C "client hello, adding alpn extension" \
1058 -S "found alpn extension" \
1059 -C "got an alert message, type: \\[2:120]" \
1060 -S "server hello, adding alpn extension" \
1061 -C "found alpn extension " \
1062 -C "Application Layer Protocol is" \
1063 -s "Application Layer Protocol is (none)"
1064
1065run_test "ALPN #3 (both, common cli1-srv1)" \
1066 "$P_SRV debug_level=4 alpn=abc,1234" \
1067 "$P_CLI debug_level=4 alpn=abc,1234" \
1068 0 \
1069 -c "client hello, adding alpn extension" \
1070 -s "found alpn extension" \
1071 -C "got an alert message, type: \\[2:120]" \
1072 -s "server hello, adding alpn extension" \
1073 -c "found alpn extension" \
1074 -c "Application Layer Protocol is abc" \
1075 -s "Application Layer Protocol is abc"
1076
1077run_test "ALPN #4 (both, common cli2-srv1)" \
1078 "$P_SRV debug_level=4 alpn=abc,1234" \
1079 "$P_CLI debug_level=4 alpn=1234,abc" \
1080 0 \
1081 -c "client hello, adding alpn extension" \
1082 -s "found alpn extension" \
1083 -C "got an alert message, type: \\[2:120]" \
1084 -s "server hello, adding alpn extension" \
1085 -c "found alpn extension" \
1086 -c "Application Layer Protocol is abc" \
1087 -s "Application Layer Protocol is abc"
1088
1089run_test "ALPN #5 (both, common cli1-srv2)" \
1090 "$P_SRV debug_level=4 alpn=abc,1234" \
1091 "$P_CLI debug_level=4 alpn=1234,abcde" \
1092 0 \
1093 -c "client hello, adding alpn extension" \
1094 -s "found alpn extension" \
1095 -C "got an alert message, type: \\[2:120]" \
1096 -s "server hello, adding alpn extension" \
1097 -c "found alpn extension" \
1098 -c "Application Layer Protocol is 1234" \
1099 -s "Application Layer Protocol is 1234"
1100
1101run_test "ALPN #6 (both, no common)" \
1102 "$P_SRV debug_level=4 alpn=abc,123" \
1103 "$P_CLI debug_level=4 alpn=1234,abcde" \
1104 1 \
1105 -c "client hello, adding alpn extension" \
1106 -s "found alpn extension" \
1107 -c "got an alert message, type: \\[2:120]" \
1108 -S "server hello, adding alpn extension" \
1109 -C "found alpn extension" \
1110 -C "Application Layer Protocol is 1234" \
1111 -S "Application Layer Protocol is 1234"
1112
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001113fi
1114
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001115# Tests for keyUsage in leaf certificates, part 1:
1116# server-side certificate/suite selection
1117
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001118run_test "keyUsage srv #1 (RSA, digitalSignature -> (EC)DHE-RSA)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001119 "$P_SRV key_file=data_files/server2.key \
1120 crt_file=data_files/server2.ku-ds.crt" \
1121 "$P_CLI" \
1122 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001123 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001124
1125
1126run_test "keyUsage srv #2 (RSA, keyEncipherment -> RSA)" \
1127 "$P_SRV key_file=data_files/server2.key \
1128 crt_file=data_files/server2.ku-ke.crt" \
1129 "$P_CLI" \
1130 0 \
1131 -c "Ciphersuite is TLS-RSA-WITH-"
1132
1133# add psk to leave an option for client to send SERVERQUIT
1134run_test "keyUsage srv #3 (RSA, keyAgreement -> fail)" \
1135 "$P_SRV psk=abc123 key_file=data_files/server2.key \
1136 crt_file=data_files/server2.ku-ka.crt" \
1137 "$P_CLI psk=badbad" \
1138 1 \
1139 -C "Ciphersuite is "
1140
1141run_test "keyUsage srv #4 (ECDSA, digitalSignature -> ECDHE-ECDSA)" \
1142 "$P_SRV key_file=data_files/server5.key \
1143 crt_file=data_files/server5.ku-ds.crt" \
1144 "$P_CLI" \
1145 0 \
1146 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1147
1148
1149run_test "keyUsage srv #5 (ECDSA, keyAgreement -> ECDH-)" \
1150 "$P_SRV key_file=data_files/server5.key \
1151 crt_file=data_files/server5.ku-ka.crt" \
1152 "$P_CLI" \
1153 0 \
1154 -c "Ciphersuite is TLS-ECDH-"
1155
1156# add psk to leave an option for client to send SERVERQUIT
1157run_test "keyUsage srv #6 (ECDSA, keyEncipherment -> fail)" \
1158 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1159 crt_file=data_files/server5.ku-ke.crt" \
1160 "$P_CLI psk=badbad" \
1161 1 \
1162 -C "Ciphersuite is "
1163
1164# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001165# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001166
1167run_test "keyUsage cli #1 (DigitalSignature+KeyEncipherment, RSA: OK)" \
1168 "$O_SRV -key data_files/server2.key \
1169 -cert data_files/server2.ku-ds_ke.crt" \
1170 "$P_CLI debug_level=2 \
1171 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1172 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001173 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001174 -C "Processing of the Certificate handshake message failed" \
1175 -c "Ciphersuite is TLS-"
1176
1177run_test "keyUsage cli #2 (DigitalSignature+KeyEncipherment, DHE-RSA: OK)" \
1178 "$O_SRV -key data_files/server2.key \
1179 -cert data_files/server2.ku-ds_ke.crt" \
1180 "$P_CLI debug_level=2 \
1181 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1182 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001183 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001184 -C "Processing of the Certificate handshake message failed" \
1185 -c "Ciphersuite is TLS-"
1186
1187run_test "keyUsage cli #3 (KeyEncipherment, RSA: OK)" \
1188 "$O_SRV -key data_files/server2.key \
1189 -cert data_files/server2.ku-ke.crt" \
1190 "$P_CLI debug_level=2 \
1191 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1192 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001193 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001194 -C "Processing of the Certificate handshake message failed" \
1195 -c "Ciphersuite is TLS-"
1196
1197run_test "keyUsage cli #4 (KeyEncipherment, DHE-RSA: fail)" \
1198 "$O_SRV -key data_files/server2.key \
1199 -cert data_files/server2.ku-ke.crt" \
1200 "$P_CLI debug_level=2 \
1201 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1202 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001203 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001204 -c "Processing of the Certificate handshake message failed" \
1205 -C "Ciphersuite is TLS-"
1206
1207run_test "keyUsage cli #5 (DigitalSignature, DHE-RSA: OK)" \
1208 "$O_SRV -key data_files/server2.key \
1209 -cert data_files/server2.ku-ds.crt" \
1210 "$P_CLI debug_level=2 \
1211 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1212 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001213 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001214 -C "Processing of the Certificate handshake message failed" \
1215 -c "Ciphersuite is TLS-"
1216
1217run_test "keyUsage cli #5 (DigitalSignature, RSA: fail)" \
1218 "$O_SRV -key data_files/server2.key \
1219 -cert data_files/server2.ku-ds.crt" \
1220 "$P_CLI debug_level=2 \
1221 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1222 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001223 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001224 -c "Processing of the Certificate handshake message failed" \
1225 -C "Ciphersuite is TLS-"
1226
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001227# Tests for keyUsage in leaf certificates, part 3:
1228# server-side checking of client cert
1229
1230run_test "keyUsage cli-auth #1 (RSA, DigitalSignature: OK)" \
1231 "$P_SRV debug_level=2 auth_mode=optional" \
1232 "$O_CLI -key data_files/server2.key \
1233 -cert data_files/server2.ku-ds.crt" \
1234 0 \
1235 -S "bad certificate (usage extensions)" \
1236 -S "Processing of the Certificate handshake message failed"
1237
1238run_test "keyUsage cli-auth #2 (RSA, KeyEncipherment: fail (soft))" \
1239 "$P_SRV debug_level=2 auth_mode=optional" \
1240 "$O_CLI -key data_files/server2.key \
1241 -cert data_files/server2.ku-ke.crt" \
1242 0 \
1243 -s "bad certificate (usage extensions)" \
1244 -S "Processing of the Certificate handshake message failed"
1245
1246run_test "keyUsage cli-auth #3 (RSA, KeyEncipherment: fail (hard))" \
1247 "$P_SRV debug_level=2 auth_mode=required" \
1248 "$O_CLI -key data_files/server2.key \
1249 -cert data_files/server2.ku-ke.crt" \
1250 1 \
1251 -s "bad certificate (usage extensions)" \
1252 -s "Processing of the Certificate handshake message failed"
1253
1254run_test "keyUsage cli-auth #4 (ECDSA, DigitalSignature: OK)" \
1255 "$P_SRV debug_level=2 auth_mode=optional" \
1256 "$O_CLI -key data_files/server5.key \
1257 -cert data_files/server5.ku-ds.crt" \
1258 0 \
1259 -S "bad certificate (usage extensions)" \
1260 -S "Processing of the Certificate handshake message failed"
1261
1262run_test "keyUsage cli-auth #5 (ECDSA, KeyAgreement: fail (soft))" \
1263 "$P_SRV debug_level=2 auth_mode=optional" \
1264 "$O_CLI -key data_files/server5.key \
1265 -cert data_files/server5.ku-ka.crt" \
1266 0 \
1267 -s "bad certificate (usage extensions)" \
1268 -S "Processing of the Certificate handshake message failed"
1269
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001270# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1271
1272run_test "extKeyUsage srv #1 (serverAuth -> OK)" \
1273 "$P_SRV key_file=data_files/server5.key \
1274 crt_file=data_files/server5.eku-srv.crt" \
1275 "$P_CLI" \
1276 0
1277
1278run_test "extKeyUsage srv #2 (serverAuth,clientAuth -> OK)" \
1279 "$P_SRV key_file=data_files/server5.key \
1280 crt_file=data_files/server5.eku-srv.crt" \
1281 "$P_CLI" \
1282 0
1283
1284run_test "extKeyUsage srv #3 (codeSign,anyEKU -> OK)" \
1285 "$P_SRV key_file=data_files/server5.key \
1286 crt_file=data_files/server5.eku-cs_any.crt" \
1287 "$P_CLI" \
1288 0
1289
1290# add psk to leave an option for client to send SERVERQUIT
1291run_test "extKeyUsage srv #4 (codeSign -> fail)" \
1292 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1293 crt_file=data_files/server5.eku-cli.crt" \
1294 "$P_CLI psk=badbad" \
1295 1
1296
1297# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1298
1299run_test "extKeyUsage cli #1 (serverAuth -> OK)" \
1300 "$O_SRV -key data_files/server5.key \
1301 -cert data_files/server5.eku-srv.crt" \
1302 "$P_CLI debug_level=2" \
1303 0 \
1304 -C "bad certificate (usage extensions)" \
1305 -C "Processing of the Certificate handshake message failed" \
1306 -c "Ciphersuite is TLS-"
1307
1308run_test "extKeyUsage cli #2 (serverAuth,clientAuth -> OK)" \
1309 "$O_SRV -key data_files/server5.key \
1310 -cert data_files/server5.eku-srv_cli.crt" \
1311 "$P_CLI debug_level=2" \
1312 0 \
1313 -C "bad certificate (usage extensions)" \
1314 -C "Processing of the Certificate handshake message failed" \
1315 -c "Ciphersuite is TLS-"
1316
1317run_test "extKeyUsage cli #3 (codeSign,anyEKU -> OK)" \
1318 "$O_SRV -key data_files/server5.key \
1319 -cert data_files/server5.eku-cs_any.crt" \
1320 "$P_CLI debug_level=2" \
1321 0 \
1322 -C "bad certificate (usage extensions)" \
1323 -C "Processing of the Certificate handshake message failed" \
1324 -c "Ciphersuite is TLS-"
1325
1326run_test "extKeyUsage cli #4 (codeSign -> fail)" \
1327 "$O_SRV -key data_files/server5.key \
1328 -cert data_files/server5.eku-cs.crt" \
1329 "$P_CLI debug_level=2" \
1330 1 \
1331 -c "bad certificate (usage extensions)" \
1332 -c "Processing of the Certificate handshake message failed" \
1333 -C "Ciphersuite is TLS-"
1334
1335# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1336
1337run_test "extKeyUsage cli-auth #1 (clientAuth -> OK)" \
1338 "$P_SRV debug_level=2 auth_mode=optional" \
1339 "$O_CLI -key data_files/server5.key \
1340 -cert data_files/server5.eku-cli.crt" \
1341 0 \
1342 -S "bad certificate (usage extensions)" \
1343 -S "Processing of the Certificate handshake message failed"
1344
1345run_test "extKeyUsage cli-auth #2 (serverAuth,clientAuth -> OK)" \
1346 "$P_SRV debug_level=2 auth_mode=optional" \
1347 "$O_CLI -key data_files/server5.key \
1348 -cert data_files/server5.eku-srv_cli.crt" \
1349 0 \
1350 -S "bad certificate (usage extensions)" \
1351 -S "Processing of the Certificate handshake message failed"
1352
1353run_test "extKeyUsage cli-auth #3 (codeSign,anyEKU -> OK)" \
1354 "$P_SRV debug_level=2 auth_mode=optional" \
1355 "$O_CLI -key data_files/server5.key \
1356 -cert data_files/server5.eku-cs_any.crt" \
1357 0 \
1358 -S "bad certificate (usage extensions)" \
1359 -S "Processing of the Certificate handshake message failed"
1360
1361run_test "extKeyUsage cli-auth #4 (codeSign -> fail (soft))" \
1362 "$P_SRV debug_level=2 auth_mode=optional" \
1363 "$O_CLI -key data_files/server5.key \
1364 -cert data_files/server5.eku-cs.crt" \
1365 0 \
1366 -s "bad certificate (usage extensions)" \
1367 -S "Processing of the Certificate handshake message failed"
1368
1369run_test "extKeyUsage cli-auth #4b (codeSign -> fail (hard))" \
1370 "$P_SRV debug_level=2 auth_mode=required" \
1371 "$O_CLI -key data_files/server5.key \
1372 -cert data_files/server5.eku-cs.crt" \
1373 1 \
1374 -s "bad certificate (usage extensions)" \
1375 -s "Processing of the Certificate handshake message failed"
1376
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001377# Tests for DHM parameters loading
1378
1379run_test "DHM parameters #0 (reference)" \
1380 "$P_SRV" \
1381 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1382 debug_level=3" \
1383 0 \
1384 -c "value of 'DHM: P ' (2048 bits)" \
1385 -c "value of 'DHM: G ' (2048 bits)"
1386
1387run_test "DHM parameters #1 (other parameters)" \
1388 "$P_SRV dhm_file=data_files/dhparams.pem" \
1389 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1390 debug_level=3" \
1391 0 \
1392 -c "value of 'DHM: P ' (1024 bits)" \
1393 -c "value of 'DHM: G ' (2 bits)"
1394
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001395# Tests for PSK callback
1396
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001397run_test "PSK callback #0a (psk, no callback)" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001398 "$P_SRV psk=abc123 psk_identity=foo" \
1399 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1400 psk_identity=foo psk=abc123" \
1401 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001402 -S "SSL - The server has no ciphersuites in common" \
1403 -S "SSL - Unknown identity received" \
1404 -S "SSL - Verification of the message MAC failed"
1405
1406run_test "PSK callback #0b (no psk, no callback)" \
1407 "$P_SRV" \
1408 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1409 psk_identity=foo psk=abc123" \
1410 1 \
1411 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001412 -S "SSL - Unknown identity received" \
1413 -S "SSL - Verification of the message MAC failed"
1414
1415run_test "PSK callback #1 (callback overrides other settings)" \
1416 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1417 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1418 psk_identity=foo psk=abc123" \
1419 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001420 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001421 -s "SSL - Unknown identity received" \
1422 -S "SSL - Verification of the message MAC failed"
1423
1424run_test "PSK callback #2 (first id matches)" \
1425 "$P_SRV psk_list=abc,dead,def,beef" \
1426 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1427 psk_identity=abc psk=dead" \
1428 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001429 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001430 -S "SSL - Unknown identity received" \
1431 -S "SSL - Verification of the message MAC failed"
1432
1433run_test "PSK callback #3 (second id matches)" \
1434 "$P_SRV psk_list=abc,dead,def,beef" \
1435 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1436 psk_identity=def psk=beef" \
1437 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001438 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001439 -S "SSL - Unknown identity received" \
1440 -S "SSL - Verification of the message MAC failed"
1441
1442run_test "PSK callback #4 (no match)" \
1443 "$P_SRV psk_list=abc,dead,def,beef" \
1444 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1445 psk_identity=ghi psk=beef" \
1446 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001447 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001448 -s "SSL - Unknown identity received" \
1449 -S "SSL - Verification of the message MAC failed"
1450
1451run_test "PSK callback #5 (wrong key)" \
1452 "$P_SRV psk_list=abc,dead,def,beef" \
1453 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1454 psk_identity=abc psk=beef" \
1455 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001456 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001457 -S "SSL - Unknown identity received" \
1458 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001459
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001460# Tests for ciphersuites per version
1461
1462run_test "Per-version suites #1" \
1463 "$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" \
1464 "$P_CLI force_version=ssl3" \
1465 0 \
1466 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1467
1468run_test "Per-version suites #2" \
1469 "$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" \
1470 "$P_CLI force_version=tls1" \
1471 0 \
1472 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1473
1474run_test "Per-version suites #3" \
1475 "$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" \
1476 "$P_CLI force_version=tls1_1" \
1477 0 \
1478 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1479
1480run_test "Per-version suites #4" \
1481 "$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" \
1482 "$P_CLI force_version=tls1_2" \
1483 0 \
1484 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1485
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001486# Tests for ssl_get_bytes_avail()
1487
1488run_test "ssl_get_bytes_avail #1 (no extra data)" \
1489 "$P_SRV" \
1490 "$P_CLI request_size=100" \
1491 0 \
1492 -s "Read from client: 100 bytes read$"
1493
1494run_test "ssl_get_bytes_avail #2 (extra data)" \
1495 "$P_SRV" \
1496 "$P_CLI request_size=500" \
1497 0 \
1498 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001499
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001500# Tests for small packets
1501
1502run_test "Small packet SSLv3 BlockCipher" \
1503 "$P_SRV" \
1504 "$P_CLI request_size=1 force_version=ssl3 \
1505 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1506 0 \
1507 -s "Read from client: 1 bytes read"
1508
1509run_test "Small packet SSLv3 StreamCipher" \
1510 "$P_SRV" \
1511 "$P_CLI request_size=1 force_version=ssl3 \
1512 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1513 0 \
1514 -s "Read from client: 1 bytes read"
1515
1516run_test "Small packet TLS 1.0 BlockCipher" \
1517 "$P_SRV" \
1518 "$P_CLI request_size=1 force_version=tls1 \
1519 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1520 0 \
1521 -s "Read from client: 1 bytes read"
1522
1523run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1524 "$P_SRV" \
1525 "$P_CLI request_size=1 force_version=tls1 \
1526 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1527 trunc_hmac=1" \
1528 0 \
1529 -s "Read from client: 1 bytes read"
1530
1531run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1532 "$P_SRV" \
1533 "$P_CLI request_size=1 force_version=tls1 \
1534 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1535 trunc_hmac=1" \
1536 0 \
1537 -s "Read from client: 1 bytes read"
1538
1539run_test "Small packet TLS 1.1 BlockCipher" \
1540 "$P_SRV" \
1541 "$P_CLI request_size=1 force_version=tls1_1 \
1542 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1543 0 \
1544 -s "Read from client: 1 bytes read"
1545
1546run_test "Small packet TLS 1.1 StreamCipher" \
1547 "$P_SRV" \
1548 "$P_CLI request_size=1 force_version=tls1_1 \
1549 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1550 0 \
1551 -s "Read from client: 1 bytes read"
1552
1553run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1554 "$P_SRV" \
1555 "$P_CLI request_size=1 force_version=tls1_1 \
1556 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1557 trunc_hmac=1" \
1558 0 \
1559 -s "Read from client: 1 bytes read"
1560
1561run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1562 "$P_SRV" \
1563 "$P_CLI request_size=1 force_version=tls1_1 \
1564 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1565 trunc_hmac=1" \
1566 0 \
1567 -s "Read from client: 1 bytes read"
1568
1569run_test "Small packet TLS 1.2 BlockCipher" \
1570 "$P_SRV" \
1571 "$P_CLI request_size=1 force_version=tls1_2 \
1572 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1573 0 \
1574 -s "Read from client: 1 bytes read"
1575
1576run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1577 "$P_SRV" \
1578 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1579 0 \
1580 -s "Read from client: 1 bytes read"
1581
1582run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1583 "$P_SRV" \
1584 "$P_CLI request_size=1 force_version=tls1_2 \
1585 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1586 trunc_hmac=1" \
1587 0 \
1588 -s "Read from client: 1 bytes read"
1589
1590run_test "Small packet TLS 1.2 StreamCipher" \
1591 "$P_SRV" \
1592 "$P_CLI request_size=1 force_version=tls1_2 \
1593 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1594 0 \
1595 -s "Read from client: 1 bytes read"
1596
1597run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1598 "$P_SRV" \
1599 "$P_CLI request_size=1 force_version=tls1_2 \
1600 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1601 trunc_hmac=1" \
1602 0 \
1603 -s "Read from client: 1 bytes read"
1604
1605run_test "Small packet TLS 1.2 AEAD" \
1606 "$P_SRV" \
1607 "$P_CLI request_size=1 force_version=tls1_2 \
1608 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1609 0 \
1610 -s "Read from client: 1 bytes read"
1611
1612run_test "Small packet TLS 1.2 AEAD shorter tag" \
1613 "$P_SRV" \
1614 "$P_CLI request_size=1 force_version=tls1_2 \
1615 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1616 0 \
1617 -s "Read from client: 1 bytes read"
1618
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001619# Test for large packets
1620
1621run_test "Large packet SSLv3 BlockCipher" \
1622 "$P_SRV" \
1623 "$P_CLI request_size=16384 force_version=ssl3 \
1624 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1625 0 \
1626 -s "Read from client: 16384 bytes read"
1627
1628run_test "Large packet SSLv3 StreamCipher" \
1629 "$P_SRV" \
1630 "$P_CLI request_size=16384 force_version=ssl3 \
1631 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1632 0 \
1633 -s "Read from client: 16384 bytes read"
1634
1635run_test "Large packet TLS 1.0 BlockCipher" \
1636 "$P_SRV" \
1637 "$P_CLI request_size=16384 force_version=tls1 \
1638 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1639 0 \
1640 -s "Read from client: 16384 bytes read"
1641
1642run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1643 "$P_SRV" \
1644 "$P_CLI request_size=16384 force_version=tls1 \
1645 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1646 trunc_hmac=1" \
1647 0 \
1648 -s "Read from client: 16384 bytes read"
1649
1650run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1651 "$P_SRV" \
1652 "$P_CLI request_size=16384 force_version=tls1 \
1653 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1654 trunc_hmac=1" \
1655 0 \
1656 -s "Read from client: 16384 bytes read"
1657
1658run_test "Large packet TLS 1.1 BlockCipher" \
1659 "$P_SRV" \
1660 "$P_CLI request_size=16384 force_version=tls1_1 \
1661 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1662 0 \
1663 -s "Read from client: 16384 bytes read"
1664
1665run_test "Large packet TLS 1.1 StreamCipher" \
1666 "$P_SRV" \
1667 "$P_CLI request_size=16384 force_version=tls1_1 \
1668 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1669 0 \
1670 -s "Read from client: 16384 bytes read"
1671
1672run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1673 "$P_SRV" \
1674 "$P_CLI request_size=16384 force_version=tls1_1 \
1675 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1676 trunc_hmac=1" \
1677 0 \
1678 -s "Read from client: 16384 bytes read"
1679
1680run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1681 "$P_SRV" \
1682 "$P_CLI request_size=16384 force_version=tls1_1 \
1683 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1684 trunc_hmac=1" \
1685 0 \
1686 -s "Read from client: 16384 bytes read"
1687
1688run_test "Large packet TLS 1.2 BlockCipher" \
1689 "$P_SRV" \
1690 "$P_CLI request_size=16384 force_version=tls1_2 \
1691 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1692 0 \
1693 -s "Read from client: 16384 bytes read"
1694
1695run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1696 "$P_SRV" \
1697 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1698 0 \
1699 -s "Read from client: 16384 bytes read"
1700
1701run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1702 "$P_SRV" \
1703 "$P_CLI request_size=16384 force_version=tls1_2 \
1704 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1705 trunc_hmac=1" \
1706 0 \
1707 -s "Read from client: 16384 bytes read"
1708
1709run_test "Large packet TLS 1.2 StreamCipher" \
1710 "$P_SRV" \
1711 "$P_CLI request_size=16384 force_version=tls1_2 \
1712 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1713 0 \
1714 -s "Read from client: 16384 bytes read"
1715
1716run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1717 "$P_SRV" \
1718 "$P_CLI request_size=16384 force_version=tls1_2 \
1719 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1720 trunc_hmac=1" \
1721 0 \
1722 -s "Read from client: 16384 bytes read"
1723
1724run_test "Large packet TLS 1.2 AEAD" \
1725 "$P_SRV" \
1726 "$P_CLI request_size=16384 force_version=tls1_2 \
1727 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1728 0 \
1729 -s "Read from client: 16384 bytes read"
1730
1731run_test "Large packet TLS 1.2 AEAD shorter tag" \
1732 "$P_SRV" \
1733 "$P_CLI request_size=16384 force_version=tls1_2 \
1734 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1735 0 \
1736 -s "Read from client: 16384 bytes read"
1737
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001738# Final report
1739
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001740echo "------------------------------------------------------------------------"
1741
1742if [ $FAILS = 0 ]; then
1743 echo -n "PASSED"
1744else
1745 echo -n "FAILED"
1746fi
1747PASSES=`echo $TESTS - $FAILS | bc`
Manuel Pégourié-Gonnard4145b892014-02-24 13:20:14 +01001748echo " ($PASSES / $TESTS tests)"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001749
1750exit $FAILS