blob: d4a41439d7bc1fad85c89199a65b5206c43d94fe [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é-Gonnardc1da6642014-02-25 14:18:30 +0100334# Test for SSLv2 ClientHello
335
336run_test "SSLv2 ClientHello #0 (reference)" \
337 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100338 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100339 0 \
340 -S "parse client hello v2" \
341 -S "ssl_handshake returned"
342
343# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
344run_test "SSLv2 ClientHello #1 (actual test)" \
345 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100346 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100347 0 \
348 -s "parse client hello v2" \
349 -S "ssl_handshake returned"
350
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100351# Tests for Truncated HMAC extension
352
353run_test "Truncated HMAC #0" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100354 "$P_SRV debug_level=5" \
355 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100356 0 \
357 -s "dumping 'computed mac' (20 bytes)"
358
359run_test "Truncated HMAC #1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100360 "$P_SRV debug_level=5" \
361 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100362 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100363 -s "dumping 'computed mac' (10 bytes)"
364
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100365# Tests for Session Tickets
366
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100367run_test "Session resume using tickets #1 (basic)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100368 "$P_SRV debug_level=4 tickets=1" \
369 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100370 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100371 -c "client hello, adding session ticket extension" \
372 -s "found session ticket extension" \
373 -s "server hello, adding session ticket extension" \
374 -c "found session_ticket extension" \
375 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100376 -S "session successfully restored from cache" \
377 -s "session successfully restored from ticket" \
378 -s "a session has been resumed" \
379 -c "a session has been resumed"
380
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100381run_test "Session resume using tickets #2 (cache disabled)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100382 "$P_SRV debug_level=4 tickets=1 cache_max=0" \
383 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100384 0 \
385 -c "client hello, adding session ticket extension" \
386 -s "found session ticket extension" \
387 -s "server hello, adding session ticket extension" \
388 -c "found session_ticket extension" \
389 -c "parse new session ticket" \
390 -S "session successfully restored from cache" \
391 -s "session successfully restored from ticket" \
392 -s "a session has been resumed" \
393 -c "a session has been resumed"
394
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395run_test "Session resume using tickets #3 (timeout)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100396 "$P_SRV debug_level=4 tickets=1 cache_max=0 ticket_timeout=1" \
397 "$P_CLI debug_level=4 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100398 0 \
399 -c "client hello, adding session ticket extension" \
400 -s "found session ticket extension" \
401 -s "server hello, adding session ticket extension" \
402 -c "found session_ticket extension" \
403 -c "parse new session ticket" \
404 -S "session successfully restored from cache" \
405 -S "session successfully restored from ticket" \
406 -S "a session has been resumed" \
407 -C "a session has been resumed"
408
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100409run_test "Session resume using tickets #4 (openssl server)" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100410 "$O_SRV" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100411 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
412 0 \
413 -c "client hello, adding session ticket extension" \
414 -c "found session_ticket extension" \
415 -c "parse new session ticket" \
416 -c "a session has been resumed"
417
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100418run_test "Session resume using tickets #5 (openssl client)" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100419 "$P_SRV debug_level=4 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200420 "( $O_CLI -sess_out $SESSION; \
421 $O_CLI -sess_in $SESSION; \
422 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100423 0 \
424 -s "found session ticket extension" \
425 -s "server hello, adding session ticket extension" \
426 -S "session successfully restored from cache" \
427 -s "session successfully restored from ticket" \
428 -s "a session has been resumed"
429
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100430# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100431
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100432run_test "Session resume using cache #1 (tickets enabled on client)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100433 "$P_SRV debug_level=4 tickets=0" \
434 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100435 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100436 -c "client hello, adding session ticket extension" \
437 -s "found session ticket extension" \
438 -S "server hello, adding session ticket extension" \
439 -C "found session_ticket extension" \
440 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100441 -s "session successfully restored from cache" \
442 -S "session successfully restored from ticket" \
443 -s "a session has been resumed" \
444 -c "a session has been resumed"
445
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100446run_test "Session resume using cache #2 (tickets enabled on server)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100447 "$P_SRV debug_level=4 tickets=1" \
448 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100449 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100450 -C "client hello, adding session ticket extension" \
451 -S "found session ticket extension" \
452 -S "server hello, adding session ticket extension" \
453 -C "found session_ticket extension" \
454 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100455 -s "session successfully restored from cache" \
456 -S "session successfully restored from ticket" \
457 -s "a session has been resumed" \
458 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100459
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100460run_test "Session resume using cache #3 (cache_max=0)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100461 "$P_SRV debug_level=4 tickets=0 cache_max=0" \
462 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100463 0 \
464 -S "session successfully restored from cache" \
465 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100466 -S "a session has been resumed" \
467 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100468
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100469run_test "Session resume using cache #4 (cache_max=1)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100470 "$P_SRV debug_level=4 tickets=0 cache_max=1" \
471 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100472 0 \
473 -s "session successfully restored from cache" \
474 -S "session successfully restored from ticket" \
475 -s "a session has been resumed" \
476 -c "a session has been resumed"
477
478run_test "Session resume using cache #5 (timemout > delay)" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100479 "$P_SRV debug_level=4 tickets=0" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100480 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=0" \
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 #6 (timeout < delay)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100488 "$P_SRV debug_level=4 tickets=0 cache_timeout=1" \
489 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \
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 #7 (no timeout)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100497 "$P_SRV debug_level=4 tickets=0 cache_timeout=0" \
498 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +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
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100505run_test "Session resume using cache #8 (openssl client)" \
506 "$P_SRV debug_level=4 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200507 "( $O_CLI -sess_out $SESSION; \
508 $O_CLI -sess_in $SESSION; \
509 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100510 0 \
511 -s "found session ticket extension" \
512 -S "server hello, adding session ticket extension" \
513 -s "session successfully restored from cache" \
514 -S "session successfully restored from ticket" \
515 -s "a session has been resumed"
516
517run_test "Session resume using cache #9 (openssl server)" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100518 "$O_SRV" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100519 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
520 0 \
521 -C "found session_ticket extension" \
522 -C "parse new session ticket" \
523 -c "a session has been resumed"
524
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100525# Tests for Max Fragment Length extension
526
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100527run_test "Max fragment length #1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100528 "$P_SRV debug_level=4" \
529 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100530 0 \
531 -C "client hello, adding max_fragment_length extension" \
532 -S "found max fragment length extension" \
533 -S "server hello, max_fragment_length extension" \
534 -C "found max_fragment_length extension"
535
536run_test "Max fragment length #2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100537 "$P_SRV debug_level=4" \
538 "$P_CLI debug_level=4 max_frag_len=4096" \
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 #3" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100546 "$P_SRV debug_level=4 max_frag_len=4096" \
547 "$P_CLI debug_level=4" \
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"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100553
554# Tests for renegotiation
555
556run_test "Renegotiation #0 (none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100557 "$P_SRV debug_level=4" \
558 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100559 0 \
560 -C "client hello, adding renegotiation extension" \
561 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
562 -S "found renegotiation extension" \
563 -s "server hello, secure renegotiation extension" \
564 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100565 -C "=> renegotiate" \
566 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100567 -S "write hello request"
568
569run_test "Renegotiation #1 (enabled, client-initiated)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200570 "$P_SRV debug_level=4 renegotiation=1" \
571 "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100572 0 \
573 -c "client hello, adding renegotiation extension" \
574 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
575 -s "found renegotiation extension" \
576 -s "server hello, secure renegotiation extension" \
577 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100578 -c "=> renegotiate" \
579 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100580 -S "write hello request"
581
582run_test "Renegotiation #2 (enabled, server-initiated)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200583 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \
584 "$P_CLI debug_level=4 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100585 0 \
586 -c "client hello, adding renegotiation extension" \
587 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
588 -s "found renegotiation extension" \
589 -s "server hello, secure renegotiation extension" \
590 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100591 -c "=> renegotiate" \
592 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100593 -s "write hello request"
594
595run_test "Renegotiation #3 (enabled, double)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200596 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \
597 "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100598 0 \
599 -c "client hello, adding renegotiation extension" \
600 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
601 -s "found renegotiation extension" \
602 -s "server hello, secure renegotiation extension" \
603 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100604 -c "=> renegotiate" \
605 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100606 -s "write hello request"
607
608run_test "Renegotiation #4 (client-initiated, server-rejected)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100609 "$P_SRV debug_level=4 renegotiation=0" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200610 "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100611 1 \
612 -c "client hello, adding renegotiation extension" \
613 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
614 -S "found renegotiation extension" \
615 -s "server hello, secure renegotiation extension" \
616 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100617 -c "=> renegotiate" \
618 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200619 -S "write hello request" \
620 -c "SSL - An unexpected message was received from our peer" \
621 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100622
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200623run_test "Renegotiation #5 (server-initiated, client-rejected, default)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200624 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100625 "$P_CLI debug_level=4 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100626 0 \
627 -C "client hello, adding renegotiation extension" \
628 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
629 -S "found renegotiation extension" \
630 -s "server hello, secure renegotiation extension" \
631 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100632 -C "=> renegotiate" \
633 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100634 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200635 -S "SSL - An unexpected message was received from our peer" \
636 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100637
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200638run_test "Renegotiation #6 (server-initiated, client-rejected, not enforced)" \
639 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1 \
640 renego_delay=-1" \
641 "$P_CLI debug_level=4 renegotiation=0" \
642 0 \
643 -C "client hello, adding renegotiation extension" \
644 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
645 -S "found renegotiation extension" \
646 -s "server hello, secure renegotiation extension" \
647 -c "found renegotiation extension" \
648 -C "=> renegotiate" \
649 -S "=> renegotiate" \
650 -s "write hello request" \
651 -S "SSL - An unexpected message was received from our peer" \
652 -S "failed"
653
654run_test "Renegotiation #7 (server-initiated, client-rejected, delay 1)" \
655 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1 \
656 renego_delay=1" \
657 "$P_CLI debug_level=4 renegotiation=0" \
658 0 \
659 -C "client hello, adding renegotiation extension" \
660 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
661 -S "found renegotiation extension" \
662 -s "server hello, secure renegotiation extension" \
663 -c "found renegotiation extension" \
664 -C "=> renegotiate" \
665 -S "=> renegotiate" \
666 -s "write hello request" \
667 -S "SSL - An unexpected message was received from our peer" \
668 -S "failed"
669
670run_test "Renegotiation #8 (server-initiated, client-rejected, delay 0)" \
671 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1 \
672 renego_delay=0" \
673 "$P_CLI debug_level=4 renegotiation=0" \
674 0 \
675 -C "client hello, adding renegotiation extension" \
676 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
677 -S "found renegotiation extension" \
678 -s "server hello, secure renegotiation extension" \
679 -c "found renegotiation extension" \
680 -C "=> renegotiate" \
681 -S "=> renegotiate" \
682 -s "write hello request" \
683 -s "SSL - An unexpected message was received from our peer" \
684 -s "failed"
685
686run_test "Renegotiation #9 (server-initiated, client-accepted, delay 0)" \
687 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1 \
688 renego_delay=0" \
689 "$P_CLI debug_level=4 renegotiation=1" \
690 0 \
691 -c "client hello, adding renegotiation extension" \
692 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
693 -s "found renegotiation extension" \
694 -s "server hello, secure renegotiation extension" \
695 -c "found renegotiation extension" \
696 -c "=> renegotiate" \
697 -s "=> renegotiate" \
698 -s "write hello request" \
699 -S "SSL - An unexpected message was received from our peer" \
700 -S "failed"
701
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100702# Tests for auth_mode
703
704run_test "Authentication #1 (server badcert, client required)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100705 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100706 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100707 "$P_CLI debug_level=2 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100708 1 \
709 -c "x509_verify_cert() returned" \
710 -c "! self-signed or not signed by a trusted CA" \
711 -c "! ssl_handshake returned" \
712 -c "X509 - Certificate verification failed"
713
714run_test "Authentication #2 (server badcert, client optional)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100715 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100716 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100717 "$P_CLI debug_level=2 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100718 0 \
719 -c "x509_verify_cert() returned" \
720 -c "! self-signed or not signed by a trusted CA" \
721 -C "! ssl_handshake returned" \
722 -C "X509 - Certificate verification failed"
723
724run_test "Authentication #3 (server badcert, client none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100725 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100726 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100727 "$P_CLI debug_level=2 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100728 0 \
729 -C "x509_verify_cert() returned" \
730 -C "! self-signed or not signed by a trusted CA" \
731 -C "! ssl_handshake returned" \
732 -C "X509 - Certificate verification failed"
733
734run_test "Authentication #4 (client badcert, server required)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100735 "$P_SRV debug_level=4 auth_mode=required" \
736 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100737 key_file=data_files/server5.key" \
738 1 \
739 -S "skip write certificate request" \
740 -C "skip parse certificate request" \
741 -c "got a certificate request" \
742 -C "skip write certificate" \
743 -C "skip write certificate verify" \
744 -S "skip parse certificate verify" \
745 -s "x509_verify_cert() returned" \
746 -S "! self-signed or not signed by a trusted CA" \
747 -s "! ssl_handshake returned" \
748 -c "! ssl_handshake returned" \
749 -s "X509 - Certificate verification failed"
750
751run_test "Authentication #5 (client badcert, server optional)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100752 "$P_SRV debug_level=4 auth_mode=optional" \
753 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100754 key_file=data_files/server5.key" \
755 0 \
756 -S "skip write certificate request" \
757 -C "skip parse certificate request" \
758 -c "got a certificate request" \
759 -C "skip write certificate" \
760 -C "skip write certificate verify" \
761 -S "skip parse certificate verify" \
762 -s "x509_verify_cert() returned" \
763 -s "! self-signed or not signed by a trusted CA" \
764 -S "! ssl_handshake returned" \
765 -C "! ssl_handshake returned" \
766 -S "X509 - Certificate verification failed"
767
768run_test "Authentication #6 (client badcert, server none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100769 "$P_SRV debug_level=4 auth_mode=none" \
770 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100771 key_file=data_files/server5.key" \
772 0 \
773 -s "skip write certificate request" \
774 -C "skip parse certificate request" \
775 -c "got no certificate request" \
776 -c "skip write certificate" \
777 -c "skip write certificate verify" \
778 -s "skip parse certificate verify" \
779 -S "x509_verify_cert() returned" \
780 -S "! self-signed or not signed by a trusted CA" \
781 -S "! ssl_handshake returned" \
782 -C "! ssl_handshake returned" \
783 -S "X509 - Certificate verification failed"
784
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100785run_test "Authentication #7 (client no cert, server optional)" \
786 "$P_SRV debug_level=4 auth_mode=optional" \
787 "$P_CLI debug_level=4 crt_file=none key_file=none" \
788 0 \
789 -S "skip write certificate request" \
790 -C "skip parse certificate request" \
791 -c "got a certificate request" \
792 -C "skip write certificate$" \
793 -C "got no certificate to send" \
794 -S "SSLv3 client has no certificate" \
795 -c "skip write certificate verify" \
796 -s "skip parse certificate verify" \
797 -s "! no client certificate sent" \
798 -S "! ssl_handshake returned" \
799 -C "! ssl_handshake returned" \
800 -S "X509 - Certificate verification failed"
801
802run_test "Authentication #8 (openssl client no cert, server optional)" \
803 "$P_SRV debug_level=4 auth_mode=optional" \
804 "$O_CLI" \
805 0 \
806 -S "skip write certificate request" \
807 -s "skip parse certificate verify" \
808 -s "! no client certificate sent" \
809 -S "! ssl_handshake returned" \
810 -S "X509 - Certificate verification failed"
811
812run_test "Authentication #9 (client no cert, openssl server optional)" \
813 "$O_SRV -verify 10" \
814 "$P_CLI debug_level=4 crt_file=none key_file=none" \
815 0 \
816 -C "skip parse certificate request" \
817 -c "got a certificate request" \
818 -C "skip write certificate$" \
819 -c "skip write certificate verify" \
820 -C "! ssl_handshake returned"
821
822run_test "Authentication #10 (client no cert, ssl3)" \
823 "$P_SRV debug_level=4 auth_mode=optional force_version=ssl3" \
824 "$P_CLI debug_level=4 crt_file=none key_file=none" \
825 0 \
826 -S "skip write certificate request" \
827 -C "skip parse certificate request" \
828 -c "got a certificate request" \
829 -C "skip write certificate$" \
830 -c "skip write certificate verify" \
831 -c "got no certificate to send" \
832 -s "SSLv3 client has no certificate" \
833 -s "skip parse certificate verify" \
834 -s "! no client certificate sent" \
835 -S "! ssl_handshake returned" \
836 -C "! ssl_handshake returned" \
837 -S "X509 - Certificate verification failed"
838
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100839# tests for SNI
840
841run_test "SNI #0 (no SNI callback)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100842 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100843 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100844 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100845 server_name=localhost" \
846 0 \
847 -S "parse ServerName extension" \
848 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
849 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
850
851run_test "SNI #1 (matching cert 1)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100852 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100853 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100854 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 +0100855 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100856 server_name=localhost" \
857 0 \
858 -s "parse ServerName extension" \
859 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
860 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
861
862run_test "SNI #2 (matching cert 2)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100863 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100864 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100865 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 +0100866 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100867 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100868 0 \
869 -s "parse ServerName extension" \
870 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100871 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100872
873run_test "SNI #3 (no matching cert)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100874 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100875 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100876 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 +0100877 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100878 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100879 1 \
880 -s "parse ServerName extension" \
881 -s "ssl_sni_wrapper() returned" \
882 -s "ssl_handshake returned" \
883 -c "ssl_handshake returned" \
884 -c "SSL - A fatal alert message was received from our peer"
885
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +0100886# Tests for non-blocking I/O: exercise a variety of handshake flows
887
888run_test "Non-blocking I/O #1 (basic handshake)" \
889 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
890 "$P_CLI nbio=2 tickets=0" \
891 0 \
892 -S "ssl_handshake returned" \
893 -C "ssl_handshake returned" \
894 -c "Read from server: .* bytes read"
895
896run_test "Non-blocking I/O #2 (client auth)" \
897 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
898 "$P_CLI nbio=2 tickets=0" \
899 0 \
900 -S "ssl_handshake returned" \
901 -C "ssl_handshake returned" \
902 -c "Read from server: .* bytes read"
903
904run_test "Non-blocking I/O #3 (ticket)" \
905 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
906 "$P_CLI nbio=2 tickets=1" \
907 0 \
908 -S "ssl_handshake returned" \
909 -C "ssl_handshake returned" \
910 -c "Read from server: .* bytes read"
911
912run_test "Non-blocking I/O #4 (ticket + client auth)" \
913 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
914 "$P_CLI nbio=2 tickets=1" \
915 0 \
916 -S "ssl_handshake returned" \
917 -C "ssl_handshake returned" \
918 -c "Read from server: .* bytes read"
919
920run_test "Non-blocking I/O #5 (ticket + client auth + resume)" \
921 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
922 "$P_CLI nbio=2 tickets=1 reconnect=1" \
923 0 \
924 -S "ssl_handshake returned" \
925 -C "ssl_handshake returned" \
926 -c "Read from server: .* bytes read"
927
928run_test "Non-blocking I/O #6 (ticket + resume)" \
929 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
930 "$P_CLI nbio=2 tickets=1 reconnect=1" \
931 0 \
932 -S "ssl_handshake returned" \
933 -C "ssl_handshake returned" \
934 -c "Read from server: .* bytes read"
935
936run_test "Non-blocking I/O #7 (session-id resume)" \
937 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
938 "$P_CLI nbio=2 tickets=0 reconnect=1" \
939 0 \
940 -S "ssl_handshake returned" \
941 -C "ssl_handshake returned" \
942 -c "Read from server: .* bytes read"
943
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +0200944# Tests for version negotiation
945
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100946run_test "Version check #1 (all -> 1.2)" \
947 "$P_SRV" \
948 "$P_CLI" \
949 0 \
950 -S "ssl_handshake returned" \
951 -C "ssl_handshake returned" \
952 -s "Protocol is TLSv1.2" \
953 -c "Protocol is TLSv1.2"
954
955run_test "Version check #2 (cli max 1.1 -> 1.1)" \
956 "$P_SRV" \
957 "$P_CLI max_version=tls1_1" \
958 0 \
959 -S "ssl_handshake returned" \
960 -C "ssl_handshake returned" \
961 -s "Protocol is TLSv1.1" \
962 -c "Protocol is TLSv1.1"
963
964run_test "Version check #3 (srv max 1.1 -> 1.1)" \
965 "$P_SRV max_version=tls1_1" \
966 "$P_CLI" \
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 #4 (cli+srv max 1.1 -> 1.1)" \
974 "$P_SRV max_version=tls1_1" \
975 "$P_CLI max_version=tls1_1" \
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 #5 (cli max 1.1, srv min 1.1 -> 1.1)" \
983 "$P_SRV min_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 #6 (cli min 1.1, srv max 1.1 -> 1.1)" \
992 "$P_SRV max_version=tls1_1" \
993 "$P_CLI min_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 #7 (cli min 1.2, srv max 1.1 -> fail)" \
1001 "$P_SRV max_version=tls1_1" \
1002 "$P_CLI min_version=tls1_2" \
1003 1 \
1004 -s "ssl_handshake returned" \
1005 -c "ssl_handshake returned" \
1006 -c "SSL - Handshake protocol not within min/max boundaries"
1007
1008run_test "Version check #8 (srv min 1.2, cli max 1.1 -> fail)" \
1009 "$P_SRV min_version=tls1_2" \
1010 "$P_CLI max_version=tls1_1" \
1011 1 \
1012 -s "ssl_handshake returned" \
1013 -c "ssl_handshake returned" \
1014 -s "SSL - Handshake protocol not within min/max boundaries"
1015
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001016# Tests for ALPN extension
1017
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001018if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1019
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001020run_test "ALPN #0 (none)" \
1021 "$P_SRV debug_level=4" \
1022 "$P_CLI debug_level=4" \
1023 0 \
1024 -C "client hello, adding alpn extension" \
1025 -S "found alpn extension" \
1026 -C "got an alert message, type: \\[2:120]" \
1027 -S "server hello, adding alpn extension" \
1028 -C "found alpn extension " \
1029 -C "Application Layer Protocol is" \
1030 -S "Application Layer Protocol is"
1031
1032run_test "ALPN #1 (client only)" \
1033 "$P_SRV debug_level=4" \
1034 "$P_CLI debug_level=4 alpn=abc,1234" \
1035 0 \
1036 -c "client hello, adding alpn extension" \
1037 -s "found alpn extension" \
1038 -C "got an alert message, type: \\[2:120]" \
1039 -S "server hello, adding alpn extension" \
1040 -C "found alpn extension " \
1041 -c "Application Layer Protocol is (none)" \
1042 -S "Application Layer Protocol is"
1043
1044run_test "ALPN #2 (server only)" \
1045 "$P_SRV debug_level=4 alpn=abc,1234" \
1046 "$P_CLI debug_level=4" \
1047 0 \
1048 -C "client hello, adding alpn extension" \
1049 -S "found alpn extension" \
1050 -C "got an alert message, type: \\[2:120]" \
1051 -S "server hello, adding alpn extension" \
1052 -C "found alpn extension " \
1053 -C "Application Layer Protocol is" \
1054 -s "Application Layer Protocol is (none)"
1055
1056run_test "ALPN #3 (both, common cli1-srv1)" \
1057 "$P_SRV debug_level=4 alpn=abc,1234" \
1058 "$P_CLI debug_level=4 alpn=abc,1234" \
1059 0 \
1060 -c "client hello, adding alpn extension" \
1061 -s "found alpn extension" \
1062 -C "got an alert message, type: \\[2:120]" \
1063 -s "server hello, adding alpn extension" \
1064 -c "found alpn extension" \
1065 -c "Application Layer Protocol is abc" \
1066 -s "Application Layer Protocol is abc"
1067
1068run_test "ALPN #4 (both, common cli2-srv1)" \
1069 "$P_SRV debug_level=4 alpn=abc,1234" \
1070 "$P_CLI debug_level=4 alpn=1234,abc" \
1071 0 \
1072 -c "client hello, adding alpn extension" \
1073 -s "found alpn extension" \
1074 -C "got an alert message, type: \\[2:120]" \
1075 -s "server hello, adding alpn extension" \
1076 -c "found alpn extension" \
1077 -c "Application Layer Protocol is abc" \
1078 -s "Application Layer Protocol is abc"
1079
1080run_test "ALPN #5 (both, common cli1-srv2)" \
1081 "$P_SRV debug_level=4 alpn=abc,1234" \
1082 "$P_CLI debug_level=4 alpn=1234,abcde" \
1083 0 \
1084 -c "client hello, adding alpn extension" \
1085 -s "found alpn extension" \
1086 -C "got an alert message, type: \\[2:120]" \
1087 -s "server hello, adding alpn extension" \
1088 -c "found alpn extension" \
1089 -c "Application Layer Protocol is 1234" \
1090 -s "Application Layer Protocol is 1234"
1091
1092run_test "ALPN #6 (both, no common)" \
1093 "$P_SRV debug_level=4 alpn=abc,123" \
1094 "$P_CLI debug_level=4 alpn=1234,abcde" \
1095 1 \
1096 -c "client hello, adding alpn extension" \
1097 -s "found alpn extension" \
1098 -c "got an alert message, type: \\[2:120]" \
1099 -S "server hello, adding alpn extension" \
1100 -C "found alpn extension" \
1101 -C "Application Layer Protocol is 1234" \
1102 -S "Application Layer Protocol is 1234"
1103
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001104fi
1105
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001106# Tests for keyUsage in leaf certificates, part 1:
1107# server-side certificate/suite selection
1108
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001109run_test "keyUsage srv #1 (RSA, digitalSignature -> (EC)DHE-RSA)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001110 "$P_SRV key_file=data_files/server2.key \
1111 crt_file=data_files/server2.ku-ds.crt" \
1112 "$P_CLI" \
1113 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001114 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001115
1116
1117run_test "keyUsage srv #2 (RSA, keyEncipherment -> RSA)" \
1118 "$P_SRV key_file=data_files/server2.key \
1119 crt_file=data_files/server2.ku-ke.crt" \
1120 "$P_CLI" \
1121 0 \
1122 -c "Ciphersuite is TLS-RSA-WITH-"
1123
1124# add psk to leave an option for client to send SERVERQUIT
1125run_test "keyUsage srv #3 (RSA, keyAgreement -> fail)" \
1126 "$P_SRV psk=abc123 key_file=data_files/server2.key \
1127 crt_file=data_files/server2.ku-ka.crt" \
1128 "$P_CLI psk=badbad" \
1129 1 \
1130 -C "Ciphersuite is "
1131
1132run_test "keyUsage srv #4 (ECDSA, digitalSignature -> ECDHE-ECDSA)" \
1133 "$P_SRV key_file=data_files/server5.key \
1134 crt_file=data_files/server5.ku-ds.crt" \
1135 "$P_CLI" \
1136 0 \
1137 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1138
1139
1140run_test "keyUsage srv #5 (ECDSA, keyAgreement -> ECDH-)" \
1141 "$P_SRV key_file=data_files/server5.key \
1142 crt_file=data_files/server5.ku-ka.crt" \
1143 "$P_CLI" \
1144 0 \
1145 -c "Ciphersuite is TLS-ECDH-"
1146
1147# add psk to leave an option for client to send SERVERQUIT
1148run_test "keyUsage srv #6 (ECDSA, keyEncipherment -> fail)" \
1149 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1150 crt_file=data_files/server5.ku-ke.crt" \
1151 "$P_CLI psk=badbad" \
1152 1 \
1153 -C "Ciphersuite is "
1154
1155# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001156# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001157
1158run_test "keyUsage cli #1 (DigitalSignature+KeyEncipherment, RSA: OK)" \
1159 "$O_SRV -key data_files/server2.key \
1160 -cert data_files/server2.ku-ds_ke.crt" \
1161 "$P_CLI debug_level=2 \
1162 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1163 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001164 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001165 -C "Processing of the Certificate handshake message failed" \
1166 -c "Ciphersuite is TLS-"
1167
1168run_test "keyUsage cli #2 (DigitalSignature+KeyEncipherment, DHE-RSA: OK)" \
1169 "$O_SRV -key data_files/server2.key \
1170 -cert data_files/server2.ku-ds_ke.crt" \
1171 "$P_CLI debug_level=2 \
1172 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1173 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001174 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001175 -C "Processing of the Certificate handshake message failed" \
1176 -c "Ciphersuite is TLS-"
1177
1178run_test "keyUsage cli #3 (KeyEncipherment, RSA: OK)" \
1179 "$O_SRV -key data_files/server2.key \
1180 -cert data_files/server2.ku-ke.crt" \
1181 "$P_CLI debug_level=2 \
1182 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1183 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001184 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001185 -C "Processing of the Certificate handshake message failed" \
1186 -c "Ciphersuite is TLS-"
1187
1188run_test "keyUsage cli #4 (KeyEncipherment, DHE-RSA: fail)" \
1189 "$O_SRV -key data_files/server2.key \
1190 -cert data_files/server2.ku-ke.crt" \
1191 "$P_CLI debug_level=2 \
1192 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1193 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001194 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001195 -c "Processing of the Certificate handshake message failed" \
1196 -C "Ciphersuite is TLS-"
1197
1198run_test "keyUsage cli #5 (DigitalSignature, DHE-RSA: OK)" \
1199 "$O_SRV -key data_files/server2.key \
1200 -cert data_files/server2.ku-ds.crt" \
1201 "$P_CLI debug_level=2 \
1202 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1203 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001204 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001205 -C "Processing of the Certificate handshake message failed" \
1206 -c "Ciphersuite is TLS-"
1207
1208run_test "keyUsage cli #5 (DigitalSignature, RSA: fail)" \
1209 "$O_SRV -key data_files/server2.key \
1210 -cert data_files/server2.ku-ds.crt" \
1211 "$P_CLI debug_level=2 \
1212 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1213 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001214 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001215 -c "Processing of the Certificate handshake message failed" \
1216 -C "Ciphersuite is TLS-"
1217
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001218# Tests for keyUsage in leaf certificates, part 3:
1219# server-side checking of client cert
1220
1221run_test "keyUsage cli-auth #1 (RSA, DigitalSignature: OK)" \
1222 "$P_SRV debug_level=2 auth_mode=optional" \
1223 "$O_CLI -key data_files/server2.key \
1224 -cert data_files/server2.ku-ds.crt" \
1225 0 \
1226 -S "bad certificate (usage extensions)" \
1227 -S "Processing of the Certificate handshake message failed"
1228
1229run_test "keyUsage cli-auth #2 (RSA, KeyEncipherment: fail (soft))" \
1230 "$P_SRV debug_level=2 auth_mode=optional" \
1231 "$O_CLI -key data_files/server2.key \
1232 -cert data_files/server2.ku-ke.crt" \
1233 0 \
1234 -s "bad certificate (usage extensions)" \
1235 -S "Processing of the Certificate handshake message failed"
1236
1237run_test "keyUsage cli-auth #3 (RSA, KeyEncipherment: fail (hard))" \
1238 "$P_SRV debug_level=2 auth_mode=required" \
1239 "$O_CLI -key data_files/server2.key \
1240 -cert data_files/server2.ku-ke.crt" \
1241 1 \
1242 -s "bad certificate (usage extensions)" \
1243 -s "Processing of the Certificate handshake message failed"
1244
1245run_test "keyUsage cli-auth #4 (ECDSA, DigitalSignature: OK)" \
1246 "$P_SRV debug_level=2 auth_mode=optional" \
1247 "$O_CLI -key data_files/server5.key \
1248 -cert data_files/server5.ku-ds.crt" \
1249 0 \
1250 -S "bad certificate (usage extensions)" \
1251 -S "Processing of the Certificate handshake message failed"
1252
1253run_test "keyUsage cli-auth #5 (ECDSA, KeyAgreement: fail (soft))" \
1254 "$P_SRV debug_level=2 auth_mode=optional" \
1255 "$O_CLI -key data_files/server5.key \
1256 -cert data_files/server5.ku-ka.crt" \
1257 0 \
1258 -s "bad certificate (usage extensions)" \
1259 -S "Processing of the Certificate handshake message failed"
1260
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001261# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1262
1263run_test "extKeyUsage srv #1 (serverAuth -> OK)" \
1264 "$P_SRV key_file=data_files/server5.key \
1265 crt_file=data_files/server5.eku-srv.crt" \
1266 "$P_CLI" \
1267 0
1268
1269run_test "extKeyUsage srv #2 (serverAuth,clientAuth -> OK)" \
1270 "$P_SRV key_file=data_files/server5.key \
1271 crt_file=data_files/server5.eku-srv.crt" \
1272 "$P_CLI" \
1273 0
1274
1275run_test "extKeyUsage srv #3 (codeSign,anyEKU -> OK)" \
1276 "$P_SRV key_file=data_files/server5.key \
1277 crt_file=data_files/server5.eku-cs_any.crt" \
1278 "$P_CLI" \
1279 0
1280
1281# add psk to leave an option for client to send SERVERQUIT
1282run_test "extKeyUsage srv #4 (codeSign -> fail)" \
1283 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1284 crt_file=data_files/server5.eku-cli.crt" \
1285 "$P_CLI psk=badbad" \
1286 1
1287
1288# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1289
1290run_test "extKeyUsage cli #1 (serverAuth -> OK)" \
1291 "$O_SRV -key data_files/server5.key \
1292 -cert data_files/server5.eku-srv.crt" \
1293 "$P_CLI debug_level=2" \
1294 0 \
1295 -C "bad certificate (usage extensions)" \
1296 -C "Processing of the Certificate handshake message failed" \
1297 -c "Ciphersuite is TLS-"
1298
1299run_test "extKeyUsage cli #2 (serverAuth,clientAuth -> OK)" \
1300 "$O_SRV -key data_files/server5.key \
1301 -cert data_files/server5.eku-srv_cli.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 #3 (codeSign,anyEKU -> OK)" \
1309 "$O_SRV -key data_files/server5.key \
1310 -cert data_files/server5.eku-cs_any.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 #4 (codeSign -> fail)" \
1318 "$O_SRV -key data_files/server5.key \
1319 -cert data_files/server5.eku-cs.crt" \
1320 "$P_CLI debug_level=2" \
1321 1 \
1322 -c "bad certificate (usage extensions)" \
1323 -c "Processing of the Certificate handshake message failed" \
1324 -C "Ciphersuite is TLS-"
1325
1326# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1327
1328run_test "extKeyUsage cli-auth #1 (clientAuth -> OK)" \
1329 "$P_SRV debug_level=2 auth_mode=optional" \
1330 "$O_CLI -key data_files/server5.key \
1331 -cert data_files/server5.eku-cli.crt" \
1332 0 \
1333 -S "bad certificate (usage extensions)" \
1334 -S "Processing of the Certificate handshake message failed"
1335
1336run_test "extKeyUsage cli-auth #2 (serverAuth,clientAuth -> OK)" \
1337 "$P_SRV debug_level=2 auth_mode=optional" \
1338 "$O_CLI -key data_files/server5.key \
1339 -cert data_files/server5.eku-srv_cli.crt" \
1340 0 \
1341 -S "bad certificate (usage extensions)" \
1342 -S "Processing of the Certificate handshake message failed"
1343
1344run_test "extKeyUsage cli-auth #3 (codeSign,anyEKU -> OK)" \
1345 "$P_SRV debug_level=2 auth_mode=optional" \
1346 "$O_CLI -key data_files/server5.key \
1347 -cert data_files/server5.eku-cs_any.crt" \
1348 0 \
1349 -S "bad certificate (usage extensions)" \
1350 -S "Processing of the Certificate handshake message failed"
1351
1352run_test "extKeyUsage cli-auth #4 (codeSign -> fail (soft))" \
1353 "$P_SRV debug_level=2 auth_mode=optional" \
1354 "$O_CLI -key data_files/server5.key \
1355 -cert data_files/server5.eku-cs.crt" \
1356 0 \
1357 -s "bad certificate (usage extensions)" \
1358 -S "Processing of the Certificate handshake message failed"
1359
1360run_test "extKeyUsage cli-auth #4b (codeSign -> fail (hard))" \
1361 "$P_SRV debug_level=2 auth_mode=required" \
1362 "$O_CLI -key data_files/server5.key \
1363 -cert data_files/server5.eku-cs.crt" \
1364 1 \
1365 -s "bad certificate (usage extensions)" \
1366 -s "Processing of the Certificate handshake message failed"
1367
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001368# Tests for DHM parameters loading
1369
1370run_test "DHM parameters #0 (reference)" \
1371 "$P_SRV" \
1372 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1373 debug_level=3" \
1374 0 \
1375 -c "value of 'DHM: P ' (2048 bits)" \
1376 -c "value of 'DHM: G ' (2048 bits)"
1377
1378run_test "DHM parameters #1 (other parameters)" \
1379 "$P_SRV dhm_file=data_files/dhparams.pem" \
1380 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1381 debug_level=3" \
1382 0 \
1383 -c "value of 'DHM: P ' (1024 bits)" \
1384 -c "value of 'DHM: G ' (2 bits)"
1385
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001386# Tests for PSK callback
1387
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001388run_test "PSK callback #0a (psk, no callback)" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001389 "$P_SRV psk=abc123 psk_identity=foo" \
1390 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1391 psk_identity=foo psk=abc123" \
1392 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001393 -S "SSL - The server has no ciphersuites in common" \
1394 -S "SSL - Unknown identity received" \
1395 -S "SSL - Verification of the message MAC failed"
1396
1397run_test "PSK callback #0b (no psk, no callback)" \
1398 "$P_SRV" \
1399 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1400 psk_identity=foo psk=abc123" \
1401 1 \
1402 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001403 -S "SSL - Unknown identity received" \
1404 -S "SSL - Verification of the message MAC failed"
1405
1406run_test "PSK callback #1 (callback overrides other settings)" \
1407 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1408 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1409 psk_identity=foo psk=abc123" \
1410 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001411 -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 #2 (first id matches)" \
1416 "$P_SRV psk_list=abc,dead,def,beef" \
1417 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1418 psk_identity=abc psk=dead" \
1419 0 \
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 #3 (second 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=def psk=beef" \
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 #4 (no match)" \
1434 "$P_SRV psk_list=abc,dead,def,beef" \
1435 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1436 psk_identity=ghi psk=beef" \
1437 1 \
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 #5 (wrong key)" \
1443 "$P_SRV psk_list=abc,dead,def,beef" \
1444 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1445 psk_identity=abc 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"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001450
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001451# Tests for ciphersuites per version
1452
1453run_test "Per-version suites #1" \
1454 "$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" \
1455 "$P_CLI force_version=ssl3" \
1456 0 \
1457 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1458
1459run_test "Per-version suites #2" \
1460 "$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" \
1461 "$P_CLI force_version=tls1" \
1462 0 \
1463 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1464
1465run_test "Per-version suites #3" \
1466 "$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" \
1467 "$P_CLI force_version=tls1_1" \
1468 0 \
1469 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1470
1471run_test "Per-version suites #4" \
1472 "$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" \
1473 "$P_CLI force_version=tls1_2" \
1474 0 \
1475 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1476
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001477# Tests for ssl_get_bytes_avail()
1478
1479run_test "ssl_get_bytes_avail #1 (no extra data)" \
1480 "$P_SRV" \
1481 "$P_CLI request_size=100" \
1482 0 \
1483 -s "Read from client: 100 bytes read$"
1484
1485run_test "ssl_get_bytes_avail #2 (extra data)" \
1486 "$P_SRV" \
1487 "$P_CLI request_size=500" \
1488 0 \
1489 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001490
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001491# Tests for small packets
1492
1493run_test "Small packet SSLv3 BlockCipher" \
1494 "$P_SRV" \
1495 "$P_CLI request_size=1 force_version=ssl3 \
1496 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1497 0 \
1498 -s "Read from client: 1 bytes read"
1499
1500run_test "Small packet SSLv3 StreamCipher" \
1501 "$P_SRV" \
1502 "$P_CLI request_size=1 force_version=ssl3 \
1503 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1504 0 \
1505 -s "Read from client: 1 bytes read"
1506
1507run_test "Small packet TLS 1.0 BlockCipher" \
1508 "$P_SRV" \
1509 "$P_CLI request_size=1 force_version=tls1 \
1510 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1511 0 \
1512 -s "Read from client: 1 bytes read"
1513
1514run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1515 "$P_SRV" \
1516 "$P_CLI request_size=1 force_version=tls1 \
1517 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1518 trunc_hmac=1" \
1519 0 \
1520 -s "Read from client: 1 bytes read"
1521
1522run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1523 "$P_SRV" \
1524 "$P_CLI request_size=1 force_version=tls1 \
1525 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1526 trunc_hmac=1" \
1527 0 \
1528 -s "Read from client: 1 bytes read"
1529
1530run_test "Small packet TLS 1.1 BlockCipher" \
1531 "$P_SRV" \
1532 "$P_CLI request_size=1 force_version=tls1_1 \
1533 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1534 0 \
1535 -s "Read from client: 1 bytes read"
1536
1537run_test "Small packet TLS 1.1 StreamCipher" \
1538 "$P_SRV" \
1539 "$P_CLI request_size=1 force_version=tls1_1 \
1540 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1541 0 \
1542 -s "Read from client: 1 bytes read"
1543
1544run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1545 "$P_SRV" \
1546 "$P_CLI request_size=1 force_version=tls1_1 \
1547 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1548 trunc_hmac=1" \
1549 0 \
1550 -s "Read from client: 1 bytes read"
1551
1552run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1553 "$P_SRV" \
1554 "$P_CLI request_size=1 force_version=tls1_1 \
1555 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1556 trunc_hmac=1" \
1557 0 \
1558 -s "Read from client: 1 bytes read"
1559
1560run_test "Small packet TLS 1.2 BlockCipher" \
1561 "$P_SRV" \
1562 "$P_CLI request_size=1 force_version=tls1_2 \
1563 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1564 0 \
1565 -s "Read from client: 1 bytes read"
1566
1567run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1568 "$P_SRV" \
1569 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1570 0 \
1571 -s "Read from client: 1 bytes read"
1572
1573run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1574 "$P_SRV" \
1575 "$P_CLI request_size=1 force_version=tls1_2 \
1576 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1577 trunc_hmac=1" \
1578 0 \
1579 -s "Read from client: 1 bytes read"
1580
1581run_test "Small packet TLS 1.2 StreamCipher" \
1582 "$P_SRV" \
1583 "$P_CLI request_size=1 force_version=tls1_2 \
1584 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1585 0 \
1586 -s "Read from client: 1 bytes read"
1587
1588run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1589 "$P_SRV" \
1590 "$P_CLI request_size=1 force_version=tls1_2 \
1591 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1592 trunc_hmac=1" \
1593 0 \
1594 -s "Read from client: 1 bytes read"
1595
1596run_test "Small packet TLS 1.2 AEAD" \
1597 "$P_SRV" \
1598 "$P_CLI request_size=1 force_version=tls1_2 \
1599 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1600 0 \
1601 -s "Read from client: 1 bytes read"
1602
1603run_test "Small packet TLS 1.2 AEAD shorter tag" \
1604 "$P_SRV" \
1605 "$P_CLI request_size=1 force_version=tls1_2 \
1606 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1607 0 \
1608 -s "Read from client: 1 bytes read"
1609
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001610# Test for large packets
1611
1612run_test "Large packet SSLv3 BlockCipher" \
1613 "$P_SRV" \
1614 "$P_CLI request_size=16384 force_version=ssl3 \
1615 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1616 0 \
1617 -s "Read from client: 16384 bytes read"
1618
1619run_test "Large packet SSLv3 StreamCipher" \
1620 "$P_SRV" \
1621 "$P_CLI request_size=16384 force_version=ssl3 \
1622 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1623 0 \
1624 -s "Read from client: 16384 bytes read"
1625
1626run_test "Large packet TLS 1.0 BlockCipher" \
1627 "$P_SRV" \
1628 "$P_CLI request_size=16384 force_version=tls1 \
1629 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1630 0 \
1631 -s "Read from client: 16384 bytes read"
1632
1633run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1634 "$P_SRV" \
1635 "$P_CLI request_size=16384 force_version=tls1 \
1636 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1637 trunc_hmac=1" \
1638 0 \
1639 -s "Read from client: 16384 bytes read"
1640
1641run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1642 "$P_SRV" \
1643 "$P_CLI request_size=16384 force_version=tls1 \
1644 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1645 trunc_hmac=1" \
1646 0 \
1647 -s "Read from client: 16384 bytes read"
1648
1649run_test "Large packet TLS 1.1 BlockCipher" \
1650 "$P_SRV" \
1651 "$P_CLI request_size=16384 force_version=tls1_1 \
1652 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1653 0 \
1654 -s "Read from client: 16384 bytes read"
1655
1656run_test "Large packet TLS 1.1 StreamCipher" \
1657 "$P_SRV" \
1658 "$P_CLI request_size=16384 force_version=tls1_1 \
1659 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1660 0 \
1661 -s "Read from client: 16384 bytes read"
1662
1663run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1664 "$P_SRV" \
1665 "$P_CLI request_size=16384 force_version=tls1_1 \
1666 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1667 trunc_hmac=1" \
1668 0 \
1669 -s "Read from client: 16384 bytes read"
1670
1671run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1672 "$P_SRV" \
1673 "$P_CLI request_size=16384 force_version=tls1_1 \
1674 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1675 trunc_hmac=1" \
1676 0 \
1677 -s "Read from client: 16384 bytes read"
1678
1679run_test "Large packet TLS 1.2 BlockCipher" \
1680 "$P_SRV" \
1681 "$P_CLI request_size=16384 force_version=tls1_2 \
1682 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1683 0 \
1684 -s "Read from client: 16384 bytes read"
1685
1686run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1687 "$P_SRV" \
1688 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1689 0 \
1690 -s "Read from client: 16384 bytes read"
1691
1692run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1693 "$P_SRV" \
1694 "$P_CLI request_size=16384 force_version=tls1_2 \
1695 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1696 trunc_hmac=1" \
1697 0 \
1698 -s "Read from client: 16384 bytes read"
1699
1700run_test "Large packet TLS 1.2 StreamCipher" \
1701 "$P_SRV" \
1702 "$P_CLI request_size=16384 force_version=tls1_2 \
1703 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1704 0 \
1705 -s "Read from client: 16384 bytes read"
1706
1707run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1708 "$P_SRV" \
1709 "$P_CLI request_size=16384 force_version=tls1_2 \
1710 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1711 trunc_hmac=1" \
1712 0 \
1713 -s "Read from client: 16384 bytes read"
1714
1715run_test "Large packet TLS 1.2 AEAD" \
1716 "$P_SRV" \
1717 "$P_CLI request_size=16384 force_version=tls1_2 \
1718 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1719 0 \
1720 -s "Read from client: 16384 bytes read"
1721
1722run_test "Large packet TLS 1.2 AEAD shorter tag" \
1723 "$P_SRV" \
1724 "$P_CLI request_size=16384 force_version=tls1_2 \
1725 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1726 0 \
1727 -s "Read from client: 16384 bytes read"
1728
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001729# Final report
1730
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001731echo "------------------------------------------------------------------------"
1732
1733if [ $FAILS = 0 ]; then
1734 echo -n "PASSED"
1735else
1736 echo -n "FAILED"
1737fi
1738PASSES=`echo $TESTS - $FAILS | bc`
Manuel Pégourié-Gonnard4145b892014-02-24 13:20:14 +01001739echo " ($PASSES / $TESTS tests)"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001740
1741exit $FAILS