blob: 63258cc6007e923bbb0de4f947cf44cd69119b36 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010017
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010018O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
19O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010020
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010021TESTS=0
22FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020023SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010024
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020025CONFIG_H='../include/polarssl/config.h'
26
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010027MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010028FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020029EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010030
31print_usage() {
32 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010033 echo -e " -h|--help\tPrint this help."
34 echo -e " -m|--memcheck\tCheck memory leaks and errors."
35 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
36 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010037}
38
39get_options() {
40 while [ $# -gt 0 ]; do
41 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010042 -f|--filter)
43 shift; FILTER=$1
44 ;;
45 -e|--exclude)
46 shift; EXCLUDE=$1
47 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048 -m|--memcheck)
49 MEMCHECK=1
50 ;;
51 -h|--help)
52 print_usage
53 exit 0
54 ;;
55 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020056 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010057 print_usage
58 exit 1
59 ;;
60 esac
61 shift
62 done
63}
64
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020065# skip next test if OpenSSL can't send SSLv2 ClientHello
66requires_openssl_with_sslv2() {
67 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
68 if openssl ciphers -ssl2 >/dev/null 2>&1; then
69 OPENSSL_HAS_SSL2="YES"
70 else
71 OPENSSL_HAS_SSL2="NO"
72 fi
73 fi
74 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
75 SKIP_NEXT="YES"
76 fi
77}
78
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010079# print_name <name>
80print_name() {
81 echo -n "$1 "
82 LEN=`echo "$1" | wc -c`
83 LEN=`echo 72 - $LEN | bc`
84 for i in `seq 1 $LEN`; do echo -n '.'; done
85 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010086
87 TESTS=`echo $TESTS + 1 | bc`
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010088}
89
90# fail <message>
91fail() {
92 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +010093 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010094
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +020095 cp $SRV_OUT o-srv-${TESTS}.log
96 cp $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +010097 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010098
99 FAILS=`echo $FAILS + 1 | bc`
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100100}
101
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100102# is_polar <cmd_line>
103is_polar() {
104 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
105}
106
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100107# has_mem_err <log_file_name>
108has_mem_err() {
109 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
110 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
111 then
112 return 1 # false: does not have errors
113 else
114 return 0 # true: has errors
115 fi
116}
117
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200118# wait for server to start: two versions depending on lsof availability
119wait_server_start() {
120 if which lsof >/dev/null; then
121 # make sure we don't loop forever
122 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
123 WATCHDOG_PID=$!
124
125 # make a tight loop, server usually takes less than 1 sec to start
126 until lsof -nbi TCP:"$PORT" | grep LISTEN >/dev/null; do :; done
127
128 kill $WATCHDOG_PID
129 wait $WATCHDOG_PID
130 else
131 sleep "$START_DELAY"
132 fi
133}
134
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100135# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100136# Options: -s pattern pattern that must be present in server output
137# -c pattern pattern that must be present in client output
138# -S pattern pattern that must be absent in server output
139# -C pattern pattern that must be absent in client output
140run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100141 NAME="$1"
142 SRV_CMD="$2"
143 CLI_CMD="$3"
144 CLI_EXPECT="$4"
145 shift 4
146
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100147 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
148 else
149 return
150 fi
151
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100152 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100153
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200154 # should we skip?
155 if [ "X$SKIP_NEXT" = "XYES" ]; then
156 SKIP_NEXT="NO"
157 echo "SKIP"
158 SKIPS=`echo $SKIPS + 1 | bc`
159 return
160 fi
161
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100162 # prepend valgrind to our commands if active
163 if [ "$MEMCHECK" -gt 0 ]; then
164 if is_polar "$SRV_CMD"; then
165 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
166 fi
167 if is_polar "$CLI_CMD"; then
168 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
169 fi
170 fi
171
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100172 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200173 echo "$SRV_CMD" > $SRV_OUT
174 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100175 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200176 wait_server_start
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200177 echo "$CLI_CMD" > $CLI_OUT
178 eval "$CLI_CMD" >> $CLI_OUT 2>&1
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100179 CLI_EXIT=$?
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200180 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100181
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200182 # kill the server
183 kill $SRV_PID
184 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100185
186 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200187 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100188 # expected client exit to incorrectly succeed in case of catastrophic
189 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100190 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200191 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100192 else
193 fail "server failed to start"
194 return
195 fi
196 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100197 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200198 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100199 else
200 fail "client failed to start"
201 return
202 fi
203 fi
204
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100205 # check server exit code
206 if [ $? != 0 ]; then
207 fail "server fail"
208 return
209 fi
210
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100211 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100212 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
213 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100214 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100215 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100216 return
217 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100218
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100219 # check other assertions
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100220 while [ $# -gt 0 ]
221 do
222 case $1 in
223 "-s")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200224 if grep "$2" $SRV_OUT >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100225 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100226 return
227 fi
228 ;;
229
230 "-c")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200231 if grep "$2" $CLI_OUT >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100232 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100233 return
234 fi
235 ;;
236
237 "-S")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200238 if grep "$2" $SRV_OUT >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100239 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100240 return
241 fi
242 ;;
243
244 "-C")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200245 if grep "$2" $CLI_OUT >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100246 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100247 return
248 fi
249 ;;
250
251 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200252 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100253 exit 1
254 esac
255 shift 2
256 done
257
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100258 # check valgrind's results
259 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200260 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100261 fail "Server has memory errors"
262 return
263 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200264 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100265 fail "Client has memory errors"
266 return
267 fi
268 fi
269
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100270 # if we're here, everything is ok
271 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200272 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100273}
274
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100275cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200276 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200277 kill $SRV_PID >/dev/null 2>&1
278 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100279 exit 1
280}
281
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100282#
283# MAIN
284#
285
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100286get_options "$@"
287
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100288# sanity checks, avoid an avalanche of errors
289if [ ! -x "$P_SRV" ]; then
290 echo "Command '$P_SRV' is not an executable file"
291 exit 1
292fi
293if [ ! -x "$P_CLI" ]; then
294 echo "Command '$P_CLI' is not an executable file"
295 exit 1
296fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100297if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
298 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100299 exit 1
300fi
301
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200302# used by watchdog
303MAIN_PID="$$"
304
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200305# be more patient with valgrind
306if [ "$MEMCHECK" -gt 0 ]; then
307 START_DELAY=3
308 DOG_DELAY=30
309else
310 START_DELAY=1
311 DOG_DELAY=10
312fi
313
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200314# Pick a "unique" port in the range 10000-19999.
315PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200316PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200317
318# fix commands to use this port
319P_SRV="$P_SRV server_port=$PORT"
320P_CLI="$P_CLI server_port=$PORT"
321O_SRV="$O_SRV -accept $PORT"
322O_CLI="$O_CLI -connect localhost:$PORT"
323
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200324# Also pick a unique name for intermediate files
325SRV_OUT="srv_out.$$"
326CLI_OUT="cli_out.$$"
327SESSION="session.$$"
328
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200329SKIP_NEXT="NO"
330
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100331trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100332
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200333# Basic test
334
335run_test "Default" \
336 "$P_SRV" \
337 "$P_CLI" \
338 0 \
339 -S "Last error was" \
340 -C "Last error was"
341
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100342# Test for SSLv2 ClientHello
343
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200344requires_openssl_with_sslv2
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100345run_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
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200353requires_openssl_with_sslv2
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100354run_test "SSLv2 ClientHello #1 (actual test)" \
355 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100356 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100357 0 \
358 -s "parse client hello v2" \
359 -S "ssl_handshake returned"
360
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100361# Tests for Truncated HMAC extension
362
363run_test "Truncated HMAC #0" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100364 "$P_SRV debug_level=5" \
365 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100366 0 \
367 -s "dumping 'computed mac' (20 bytes)"
368
369run_test "Truncated HMAC #1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100370 "$P_SRV debug_level=5" \
371 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100372 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100373 -s "dumping 'computed mac' (10 bytes)"
374
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100375# Tests for Session Tickets
376
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100377run_test "Session resume using tickets #1 (basic)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100378 "$P_SRV debug_level=4 tickets=1" \
379 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100380 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100381 -c "client hello, adding session ticket extension" \
382 -s "found session ticket extension" \
383 -s "server hello, adding session ticket extension" \
384 -c "found session_ticket extension" \
385 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100386 -S "session successfully restored from cache" \
387 -s "session successfully restored from ticket" \
388 -s "a session has been resumed" \
389 -c "a session has been resumed"
390
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100391run_test "Session resume using tickets #2 (cache disabled)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100392 "$P_SRV debug_level=4 tickets=1 cache_max=0" \
393 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100394 0 \
395 -c "client hello, adding session ticket extension" \
396 -s "found session ticket extension" \
397 -s "server hello, adding session ticket extension" \
398 -c "found session_ticket extension" \
399 -c "parse new session ticket" \
400 -S "session successfully restored from cache" \
401 -s "session successfully restored from ticket" \
402 -s "a session has been resumed" \
403 -c "a session has been resumed"
404
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100405run_test "Session resume using tickets #3 (timeout)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100406 "$P_SRV debug_level=4 tickets=1 cache_max=0 ticket_timeout=1" \
407 "$P_CLI debug_level=4 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100408 0 \
409 -c "client hello, adding session ticket extension" \
410 -s "found session ticket extension" \
411 -s "server hello, adding session ticket extension" \
412 -c "found session_ticket extension" \
413 -c "parse new session ticket" \
414 -S "session successfully restored from cache" \
415 -S "session successfully restored from ticket" \
416 -S "a session has been resumed" \
417 -C "a session has been resumed"
418
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100419run_test "Session resume using tickets #4 (openssl server)" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100420 "$O_SRV" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100421 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
422 0 \
423 -c "client hello, adding session ticket extension" \
424 -c "found session_ticket extension" \
425 -c "parse new session ticket" \
426 -c "a session has been resumed"
427
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100428run_test "Session resume using tickets #5 (openssl client)" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100429 "$P_SRV debug_level=4 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200430 "( $O_CLI -sess_out $SESSION; \
431 $O_CLI -sess_in $SESSION; \
432 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100433 0 \
434 -s "found session ticket extension" \
435 -s "server hello, adding session ticket extension" \
436 -S "session successfully restored from cache" \
437 -s "session successfully restored from ticket" \
438 -s "a session has been resumed"
439
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100440# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100441
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100442run_test "Session resume using cache #1 (tickets enabled on client)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100443 "$P_SRV debug_level=4 tickets=0" \
444 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100445 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100446 -c "client hello, adding session ticket extension" \
447 -s "found session ticket extension" \
448 -S "server hello, adding session ticket extension" \
449 -C "found session_ticket extension" \
450 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100451 -s "session successfully restored from cache" \
452 -S "session successfully restored from ticket" \
453 -s "a session has been resumed" \
454 -c "a session has been resumed"
455
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100456run_test "Session resume using cache #2 (tickets enabled on server)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100457 "$P_SRV debug_level=4 tickets=1" \
458 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100459 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100460 -C "client hello, adding session ticket extension" \
461 -S "found session ticket extension" \
462 -S "server hello, adding session ticket extension" \
463 -C "found session_ticket extension" \
464 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100465 -s "session successfully restored from cache" \
466 -S "session successfully restored from ticket" \
467 -s "a session has been resumed" \
468 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100469
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100470run_test "Session resume using cache #3 (cache_max=0)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100471 "$P_SRV debug_level=4 tickets=0 cache_max=0" \
472 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100473 0 \
474 -S "session successfully restored from cache" \
475 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100476 -S "a session has been resumed" \
477 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100478
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100479run_test "Session resume using cache #4 (cache_max=1)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100480 "$P_SRV debug_level=4 tickets=0 cache_max=1" \
481 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100482 0 \
483 -s "session successfully restored from cache" \
484 -S "session successfully restored from ticket" \
485 -s "a session has been resumed" \
486 -c "a session has been resumed"
487
488run_test "Session resume using cache #5 (timemout > delay)" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100489 "$P_SRV debug_level=4 tickets=0" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100490 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100491 0 \
492 -s "session successfully restored from cache" \
493 -S "session successfully restored from ticket" \
494 -s "a session has been resumed" \
495 -c "a session has been resumed"
496
497run_test "Session resume using cache #6 (timeout < delay)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100498 "$P_SRV debug_level=4 tickets=0 cache_timeout=1" \
499 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100500 0 \
501 -S "session successfully restored from cache" \
502 -S "session successfully restored from ticket" \
503 -S "a session has been resumed" \
504 -C "a session has been resumed"
505
506run_test "Session resume using cache #7 (no timeout)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100507 "$P_SRV debug_level=4 tickets=0 cache_timeout=0" \
508 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100509 0 \
510 -s "session successfully restored from cache" \
511 -S "session successfully restored from ticket" \
512 -s "a session has been resumed" \
513 -c "a session has been resumed"
514
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100515run_test "Session resume using cache #8 (openssl client)" \
516 "$P_SRV debug_level=4 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200517 "( $O_CLI -sess_out $SESSION; \
518 $O_CLI -sess_in $SESSION; \
519 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100520 0 \
521 -s "found session ticket extension" \
522 -S "server hello, adding session ticket extension" \
523 -s "session successfully restored from cache" \
524 -S "session successfully restored from ticket" \
525 -s "a session has been resumed"
526
527run_test "Session resume using cache #9 (openssl server)" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100528 "$O_SRV" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100529 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
530 0 \
531 -C "found session_ticket extension" \
532 -C "parse new session ticket" \
533 -c "a session has been resumed"
534
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100535# Tests for Max Fragment Length extension
536
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100537run_test "Max fragment length #1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100538 "$P_SRV debug_level=4" \
539 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100540 0 \
541 -C "client hello, adding max_fragment_length extension" \
542 -S "found max fragment length extension" \
543 -S "server hello, max_fragment_length extension" \
544 -C "found max_fragment_length extension"
545
546run_test "Max fragment length #2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100547 "$P_SRV debug_level=4" \
548 "$P_CLI debug_level=4 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100549 0 \
550 -c "client hello, adding max_fragment_length extension" \
551 -s "found max fragment length extension" \
552 -s "server hello, max_fragment_length extension" \
553 -c "found max_fragment_length extension"
554
555run_test "Max fragment length #3" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100556 "$P_SRV debug_level=4 max_frag_len=4096" \
557 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100558 0 \
559 -C "client hello, adding max_fragment_length extension" \
560 -S "found max fragment length extension" \
561 -S "server hello, max_fragment_length extension" \
562 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100563
564# Tests for renegotiation
565
566run_test "Renegotiation #0 (none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100567 "$P_SRV debug_level=4" \
568 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100569 0 \
570 -C "client hello, adding renegotiation extension" \
571 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
572 -S "found renegotiation extension" \
573 -s "server hello, secure renegotiation extension" \
574 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100575 -C "=> renegotiate" \
576 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100577 -S "write hello request"
578
579run_test "Renegotiation #1 (enabled, client-initiated)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200580 "$P_SRV debug_level=4 renegotiation=1" \
581 "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100582 0 \
583 -c "client hello, adding renegotiation extension" \
584 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
585 -s "found renegotiation extension" \
586 -s "server hello, secure renegotiation extension" \
587 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100588 -c "=> renegotiate" \
589 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100590 -S "write hello request"
591
592run_test "Renegotiation #2 (enabled, server-initiated)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200593 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \
594 "$P_CLI debug_level=4 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100595 0 \
596 -c "client hello, adding renegotiation extension" \
597 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
598 -s "found renegotiation extension" \
599 -s "server hello, secure renegotiation extension" \
600 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100601 -c "=> renegotiate" \
602 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100603 -s "write hello request"
604
605run_test "Renegotiation #3 (enabled, double)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200606 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \
607 "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100608 0 \
609 -c "client hello, adding renegotiation extension" \
610 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
611 -s "found renegotiation extension" \
612 -s "server hello, secure renegotiation extension" \
613 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100614 -c "=> renegotiate" \
615 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100616 -s "write hello request"
617
618run_test "Renegotiation #4 (client-initiated, server-rejected)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100619 "$P_SRV debug_level=4 renegotiation=0" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200620 "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100621 1 \
622 -c "client hello, adding renegotiation extension" \
623 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
624 -S "found renegotiation extension" \
625 -s "server hello, secure renegotiation extension" \
626 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100627 -c "=> renegotiate" \
628 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200629 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200630 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200631 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100632
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200633run_test "Renegotiation #5 (server-initiated, client-rejected, default)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200634 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100635 "$P_CLI debug_level=4 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100636 0 \
637 -C "client hello, adding renegotiation extension" \
638 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
639 -S "found renegotiation extension" \
640 -s "server hello, secure renegotiation extension" \
641 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100642 -C "=> renegotiate" \
643 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100644 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200645 -S "SSL - An unexpected message was received from our peer" \
646 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100647
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200648run_test "Renegotiation #6 (server-initiated, client-rejected, not enforced)" \
649 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1 \
650 renego_delay=-1" \
651 "$P_CLI debug_level=4 renegotiation=0" \
652 0 \
653 -C "client hello, adding renegotiation extension" \
654 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
655 -S "found renegotiation extension" \
656 -s "server hello, secure renegotiation extension" \
657 -c "found renegotiation extension" \
658 -C "=> renegotiate" \
659 -S "=> renegotiate" \
660 -s "write hello request" \
661 -S "SSL - An unexpected message was received from our peer" \
662 -S "failed"
663
664run_test "Renegotiation #7 (server-initiated, client-rejected, delay 1)" \
665 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1 \
666 renego_delay=1" \
667 "$P_CLI debug_level=4 renegotiation=0" \
668 0 \
669 -C "client hello, adding renegotiation extension" \
670 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
671 -S "found renegotiation extension" \
672 -s "server hello, secure renegotiation extension" \
673 -c "found renegotiation extension" \
674 -C "=> renegotiate" \
675 -S "=> renegotiate" \
676 -s "write hello request" \
677 -S "SSL - An unexpected message was received from our peer" \
678 -S "failed"
679
680run_test "Renegotiation #8 (server-initiated, client-rejected, delay 0)" \
681 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1 \
682 renego_delay=0" \
683 "$P_CLI debug_level=4 renegotiation=0" \
684 0 \
685 -C "client hello, adding renegotiation extension" \
686 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
687 -S "found renegotiation extension" \
688 -s "server hello, secure renegotiation extension" \
689 -c "found renegotiation extension" \
690 -C "=> renegotiate" \
691 -S "=> renegotiate" \
692 -s "write hello request" \
693 -s "SSL - An unexpected message was received from our peer" \
694 -s "failed"
695
696run_test "Renegotiation #9 (server-initiated, client-accepted, delay 0)" \
697 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1 \
698 renego_delay=0" \
699 "$P_CLI debug_level=4 renegotiation=1" \
700 0 \
701 -c "client hello, adding renegotiation extension" \
702 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
703 -s "found renegotiation extension" \
704 -s "server hello, secure renegotiation extension" \
705 -c "found renegotiation extension" \
706 -c "=> renegotiate" \
707 -s "=> renegotiate" \
708 -s "write hello request" \
709 -S "SSL - An unexpected message was received from our peer" \
710 -S "failed"
711
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100712# Tests for auth_mode
713
714run_test "Authentication #1 (server badcert, client required)" \
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=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100718 1 \
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 #2 (server badcert, client optional)" \
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=optional" \
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 #3 (server badcert, client none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100735 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100736 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100737 "$P_CLI debug_level=2 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100738 0 \
739 -C "x509_verify_cert() returned" \
740 -C "! self-signed or not signed by a trusted CA" \
741 -C "! ssl_handshake returned" \
742 -C "X509 - Certificate verification failed"
743
744run_test "Authentication #4 (client badcert, server required)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100745 "$P_SRV debug_level=4 auth_mode=required" \
746 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100747 key_file=data_files/server5.key" \
748 1 \
749 -S "skip write certificate request" \
750 -C "skip parse certificate request" \
751 -c "got a certificate request" \
752 -C "skip write certificate" \
753 -C "skip write certificate verify" \
754 -S "skip parse certificate verify" \
755 -s "x509_verify_cert() returned" \
756 -S "! self-signed or not signed by a trusted CA" \
757 -s "! ssl_handshake returned" \
758 -c "! ssl_handshake returned" \
759 -s "X509 - Certificate verification failed"
760
761run_test "Authentication #5 (client badcert, server optional)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100762 "$P_SRV debug_level=4 auth_mode=optional" \
763 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100764 key_file=data_files/server5.key" \
765 0 \
766 -S "skip write certificate request" \
767 -C "skip parse certificate request" \
768 -c "got a certificate request" \
769 -C "skip write certificate" \
770 -C "skip write certificate verify" \
771 -S "skip parse certificate verify" \
772 -s "x509_verify_cert() returned" \
773 -s "! self-signed or not signed by a trusted CA" \
774 -S "! ssl_handshake returned" \
775 -C "! ssl_handshake returned" \
776 -S "X509 - Certificate verification failed"
777
778run_test "Authentication #6 (client badcert, server none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100779 "$P_SRV debug_level=4 auth_mode=none" \
780 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100781 key_file=data_files/server5.key" \
782 0 \
783 -s "skip write certificate request" \
784 -C "skip parse certificate request" \
785 -c "got no certificate request" \
786 -c "skip write certificate" \
787 -c "skip write certificate verify" \
788 -s "skip parse certificate verify" \
789 -S "x509_verify_cert() returned" \
790 -S "! self-signed or not signed by a trusted CA" \
791 -S "! ssl_handshake returned" \
792 -C "! ssl_handshake returned" \
793 -S "X509 - Certificate verification failed"
794
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100795run_test "Authentication #7 (client no cert, server optional)" \
796 "$P_SRV debug_level=4 auth_mode=optional" \
797 "$P_CLI debug_level=4 crt_file=none key_file=none" \
798 0 \
799 -S "skip write certificate request" \
800 -C "skip parse certificate request" \
801 -c "got a certificate request" \
802 -C "skip write certificate$" \
803 -C "got no certificate to send" \
804 -S "SSLv3 client has no certificate" \
805 -c "skip write certificate verify" \
806 -s "skip parse certificate verify" \
807 -s "! no client certificate sent" \
808 -S "! ssl_handshake returned" \
809 -C "! ssl_handshake returned" \
810 -S "X509 - Certificate verification failed"
811
812run_test "Authentication #8 (openssl client no cert, server optional)" \
813 "$P_SRV debug_level=4 auth_mode=optional" \
814 "$O_CLI" \
815 0 \
816 -S "skip write certificate request" \
817 -s "skip parse certificate verify" \
818 -s "! no client certificate sent" \
819 -S "! ssl_handshake returned" \
820 -S "X509 - Certificate verification failed"
821
822run_test "Authentication #9 (client no cert, openssl server optional)" \
823 "$O_SRV -verify 10" \
824 "$P_CLI debug_level=4 crt_file=none key_file=none" \
825 0 \
826 -C "skip parse certificate request" \
827 -c "got a certificate request" \
828 -C "skip write certificate$" \
829 -c "skip write certificate verify" \
830 -C "! ssl_handshake returned"
831
832run_test "Authentication #10 (client no cert, ssl3)" \
833 "$P_SRV debug_level=4 auth_mode=optional force_version=ssl3" \
834 "$P_CLI debug_level=4 crt_file=none key_file=none" \
835 0 \
836 -S "skip write certificate request" \
837 -C "skip parse certificate request" \
838 -c "got a certificate request" \
839 -C "skip write certificate$" \
840 -c "skip write certificate verify" \
841 -c "got no certificate to send" \
842 -s "SSLv3 client has no certificate" \
843 -s "skip parse certificate verify" \
844 -s "! no client certificate sent" \
845 -S "! ssl_handshake returned" \
846 -C "! ssl_handshake returned" \
847 -S "X509 - Certificate verification failed"
848
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100849# tests for SNI
850
851run_test "SNI #0 (no SNI callback)" \
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é-Gonnardc1da6642014-02-25 14:18:30 +0100854 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100855 server_name=localhost" \
856 0 \
857 -S "parse ServerName extension" \
858 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
859 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
860
861run_test "SNI #1 (matching cert 1)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100862 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100863 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100864 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 +0100865 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100866 server_name=localhost" \
867 0 \
868 -s "parse ServerName extension" \
869 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
870 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
871
872run_test "SNI #2 (matching cert 2)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100873 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100874 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100875 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 +0100876 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100877 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100878 0 \
879 -s "parse ServerName extension" \
880 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100881 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100882
883run_test "SNI #3 (no matching cert)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100884 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100885 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100886 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 +0100887 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100888 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100889 1 \
890 -s "parse ServerName extension" \
891 -s "ssl_sni_wrapper() returned" \
892 -s "ssl_handshake returned" \
893 -c "ssl_handshake returned" \
894 -c "SSL - A fatal alert message was received from our peer"
895
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +0100896# Tests for non-blocking I/O: exercise a variety of handshake flows
897
898run_test "Non-blocking I/O #1 (basic handshake)" \
899 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
900 "$P_CLI nbio=2 tickets=0" \
901 0 \
902 -S "ssl_handshake returned" \
903 -C "ssl_handshake returned" \
904 -c "Read from server: .* bytes read"
905
906run_test "Non-blocking I/O #2 (client auth)" \
907 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
908 "$P_CLI nbio=2 tickets=0" \
909 0 \
910 -S "ssl_handshake returned" \
911 -C "ssl_handshake returned" \
912 -c "Read from server: .* bytes read"
913
914run_test "Non-blocking I/O #3 (ticket)" \
915 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
916 "$P_CLI nbio=2 tickets=1" \
917 0 \
918 -S "ssl_handshake returned" \
919 -C "ssl_handshake returned" \
920 -c "Read from server: .* bytes read"
921
922run_test "Non-blocking I/O #4 (ticket + client auth)" \
923 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
924 "$P_CLI nbio=2 tickets=1" \
925 0 \
926 -S "ssl_handshake returned" \
927 -C "ssl_handshake returned" \
928 -c "Read from server: .* bytes read"
929
930run_test "Non-blocking I/O #5 (ticket + client auth + resume)" \
931 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
932 "$P_CLI nbio=2 tickets=1 reconnect=1" \
933 0 \
934 -S "ssl_handshake returned" \
935 -C "ssl_handshake returned" \
936 -c "Read from server: .* bytes read"
937
938run_test "Non-blocking I/O #6 (ticket + resume)" \
939 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
940 "$P_CLI nbio=2 tickets=1 reconnect=1" \
941 0 \
942 -S "ssl_handshake returned" \
943 -C "ssl_handshake returned" \
944 -c "Read from server: .* bytes read"
945
946run_test "Non-blocking I/O #7 (session-id resume)" \
947 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
948 "$P_CLI nbio=2 tickets=0 reconnect=1" \
949 0 \
950 -S "ssl_handshake returned" \
951 -C "ssl_handshake returned" \
952 -c "Read from server: .* bytes read"
953
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +0200954# Tests for version negotiation
955
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100956run_test "Version check #1 (all -> 1.2)" \
957 "$P_SRV" \
958 "$P_CLI" \
959 0 \
960 -S "ssl_handshake returned" \
961 -C "ssl_handshake returned" \
962 -s "Protocol is TLSv1.2" \
963 -c "Protocol is TLSv1.2"
964
965run_test "Version check #2 (cli max 1.1 -> 1.1)" \
966 "$P_SRV" \
967 "$P_CLI max_version=tls1_1" \
968 0 \
969 -S "ssl_handshake returned" \
970 -C "ssl_handshake returned" \
971 -s "Protocol is TLSv1.1" \
972 -c "Protocol is TLSv1.1"
973
974run_test "Version check #3 (srv max 1.1 -> 1.1)" \
975 "$P_SRV max_version=tls1_1" \
976 "$P_CLI" \
977 0 \
978 -S "ssl_handshake returned" \
979 -C "ssl_handshake returned" \
980 -s "Protocol is TLSv1.1" \
981 -c "Protocol is TLSv1.1"
982
983run_test "Version check #4 (cli+srv max 1.1 -> 1.1)" \
984 "$P_SRV max_version=tls1_1" \
985 "$P_CLI max_version=tls1_1" \
986 0 \
987 -S "ssl_handshake returned" \
988 -C "ssl_handshake returned" \
989 -s "Protocol is TLSv1.1" \
990 -c "Protocol is TLSv1.1"
991
992run_test "Version check #5 (cli max 1.1, srv min 1.1 -> 1.1)" \
993 "$P_SRV min_version=tls1_1" \
994 "$P_CLI max_version=tls1_1" \
995 0 \
996 -S "ssl_handshake returned" \
997 -C "ssl_handshake returned" \
998 -s "Protocol is TLSv1.1" \
999 -c "Protocol is TLSv1.1"
1000
1001run_test "Version check #6 (cli min 1.1, srv max 1.1 -> 1.1)" \
1002 "$P_SRV max_version=tls1_1" \
1003 "$P_CLI min_version=tls1_1" \
1004 0 \
1005 -S "ssl_handshake returned" \
1006 -C "ssl_handshake returned" \
1007 -s "Protocol is TLSv1.1" \
1008 -c "Protocol is TLSv1.1"
1009
1010run_test "Version check #7 (cli min 1.2, srv max 1.1 -> fail)" \
1011 "$P_SRV max_version=tls1_1" \
1012 "$P_CLI min_version=tls1_2" \
1013 1 \
1014 -s "ssl_handshake returned" \
1015 -c "ssl_handshake returned" \
1016 -c "SSL - Handshake protocol not within min/max boundaries"
1017
1018run_test "Version check #8 (srv min 1.2, cli max 1.1 -> fail)" \
1019 "$P_SRV min_version=tls1_2" \
1020 "$P_CLI max_version=tls1_1" \
1021 1 \
1022 -s "ssl_handshake returned" \
1023 -c "ssl_handshake returned" \
1024 -s "SSL - Handshake protocol not within min/max boundaries"
1025
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001026# Tests for ALPN extension
1027
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001028if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1029
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001030run_test "ALPN #0 (none)" \
1031 "$P_SRV debug_level=4" \
1032 "$P_CLI debug_level=4" \
1033 0 \
1034 -C "client hello, adding alpn extension" \
1035 -S "found alpn extension" \
1036 -C "got an alert message, type: \\[2:120]" \
1037 -S "server hello, adding alpn extension" \
1038 -C "found alpn extension " \
1039 -C "Application Layer Protocol is" \
1040 -S "Application Layer Protocol is"
1041
1042run_test "ALPN #1 (client only)" \
1043 "$P_SRV debug_level=4" \
1044 "$P_CLI debug_level=4 alpn=abc,1234" \
1045 0 \
1046 -c "client hello, adding alpn extension" \
1047 -s "found alpn extension" \
1048 -C "got an alert message, type: \\[2:120]" \
1049 -S "server hello, adding alpn extension" \
1050 -C "found alpn extension " \
1051 -c "Application Layer Protocol is (none)" \
1052 -S "Application Layer Protocol is"
1053
1054run_test "ALPN #2 (server only)" \
1055 "$P_SRV debug_level=4 alpn=abc,1234" \
1056 "$P_CLI debug_level=4" \
1057 0 \
1058 -C "client hello, adding alpn extension" \
1059 -S "found alpn extension" \
1060 -C "got an alert message, type: \\[2:120]" \
1061 -S "server hello, adding alpn extension" \
1062 -C "found alpn extension " \
1063 -C "Application Layer Protocol is" \
1064 -s "Application Layer Protocol is (none)"
1065
1066run_test "ALPN #3 (both, common cli1-srv1)" \
1067 "$P_SRV debug_level=4 alpn=abc,1234" \
1068 "$P_CLI debug_level=4 alpn=abc,1234" \
1069 0 \
1070 -c "client hello, adding alpn extension" \
1071 -s "found alpn extension" \
1072 -C "got an alert message, type: \\[2:120]" \
1073 -s "server hello, adding alpn extension" \
1074 -c "found alpn extension" \
1075 -c "Application Layer Protocol is abc" \
1076 -s "Application Layer Protocol is abc"
1077
1078run_test "ALPN #4 (both, common cli2-srv1)" \
1079 "$P_SRV debug_level=4 alpn=abc,1234" \
1080 "$P_CLI debug_level=4 alpn=1234,abc" \
1081 0 \
1082 -c "client hello, adding alpn extension" \
1083 -s "found alpn extension" \
1084 -C "got an alert message, type: \\[2:120]" \
1085 -s "server hello, adding alpn extension" \
1086 -c "found alpn extension" \
1087 -c "Application Layer Protocol is abc" \
1088 -s "Application Layer Protocol is abc"
1089
1090run_test "ALPN #5 (both, common cli1-srv2)" \
1091 "$P_SRV debug_level=4 alpn=abc,1234" \
1092 "$P_CLI debug_level=4 alpn=1234,abcde" \
1093 0 \
1094 -c "client hello, adding alpn extension" \
1095 -s "found alpn extension" \
1096 -C "got an alert message, type: \\[2:120]" \
1097 -s "server hello, adding alpn extension" \
1098 -c "found alpn extension" \
1099 -c "Application Layer Protocol is 1234" \
1100 -s "Application Layer Protocol is 1234"
1101
1102run_test "ALPN #6 (both, no common)" \
1103 "$P_SRV debug_level=4 alpn=abc,123" \
1104 "$P_CLI debug_level=4 alpn=1234,abcde" \
1105 1 \
1106 -c "client hello, adding alpn extension" \
1107 -s "found alpn extension" \
1108 -c "got an alert message, type: \\[2:120]" \
1109 -S "server hello, adding alpn extension" \
1110 -C "found alpn extension" \
1111 -C "Application Layer Protocol is 1234" \
1112 -S "Application Layer Protocol is 1234"
1113
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001114fi
1115
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001116# Tests for keyUsage in leaf certificates, part 1:
1117# server-side certificate/suite selection
1118
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001119run_test "keyUsage srv #1 (RSA, digitalSignature -> (EC)DHE-RSA)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001120 "$P_SRV key_file=data_files/server2.key \
1121 crt_file=data_files/server2.ku-ds.crt" \
1122 "$P_CLI" \
1123 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001124 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001125
1126
1127run_test "keyUsage srv #2 (RSA, keyEncipherment -> RSA)" \
1128 "$P_SRV key_file=data_files/server2.key \
1129 crt_file=data_files/server2.ku-ke.crt" \
1130 "$P_CLI" \
1131 0 \
1132 -c "Ciphersuite is TLS-RSA-WITH-"
1133
1134# add psk to leave an option for client to send SERVERQUIT
1135run_test "keyUsage srv #3 (RSA, keyAgreement -> fail)" \
1136 "$P_SRV psk=abc123 key_file=data_files/server2.key \
1137 crt_file=data_files/server2.ku-ka.crt" \
1138 "$P_CLI psk=badbad" \
1139 1 \
1140 -C "Ciphersuite is "
1141
1142run_test "keyUsage srv #4 (ECDSA, digitalSignature -> ECDHE-ECDSA)" \
1143 "$P_SRV key_file=data_files/server5.key \
1144 crt_file=data_files/server5.ku-ds.crt" \
1145 "$P_CLI" \
1146 0 \
1147 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1148
1149
1150run_test "keyUsage srv #5 (ECDSA, keyAgreement -> ECDH-)" \
1151 "$P_SRV key_file=data_files/server5.key \
1152 crt_file=data_files/server5.ku-ka.crt" \
1153 "$P_CLI" \
1154 0 \
1155 -c "Ciphersuite is TLS-ECDH-"
1156
1157# add psk to leave an option for client to send SERVERQUIT
1158run_test "keyUsage srv #6 (ECDSA, keyEncipherment -> fail)" \
1159 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1160 crt_file=data_files/server5.ku-ke.crt" \
1161 "$P_CLI psk=badbad" \
1162 1 \
1163 -C "Ciphersuite is "
1164
1165# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001166# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001167
1168run_test "keyUsage cli #1 (DigitalSignature+KeyEncipherment, 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-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 #2 (DigitalSignature+KeyEncipherment, DHE-RSA: OK)" \
1179 "$O_SRV -key data_files/server2.key \
1180 -cert data_files/server2.ku-ds_ke.crt" \
1181 "$P_CLI debug_level=2 \
1182 force_ciphersuite=TLS-DHE-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 #3 (KeyEncipherment, RSA: OK)" \
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-RSA-WITH-AES-128-CBC-SHA" \
1193 0 \
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 #4 (KeyEncipherment, DHE-RSA: fail)" \
1199 "$O_SRV -key data_files/server2.key \
1200 -cert data_files/server2.ku-ke.crt" \
1201 "$P_CLI debug_level=2 \
1202 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1203 1 \
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, DHE-RSA: OK)" \
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-DHE-RSA-WITH-AES-128-CBC-SHA" \
1213 0 \
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
1218run_test "keyUsage cli #5 (DigitalSignature, RSA: fail)" \
1219 "$O_SRV -key data_files/server2.key \
1220 -cert data_files/server2.ku-ds.crt" \
1221 "$P_CLI debug_level=2 \
1222 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1223 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001224 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001225 -c "Processing of the Certificate handshake message failed" \
1226 -C "Ciphersuite is TLS-"
1227
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001228# Tests for keyUsage in leaf certificates, part 3:
1229# server-side checking of client cert
1230
1231run_test "keyUsage cli-auth #1 (RSA, DigitalSignature: OK)" \
1232 "$P_SRV debug_level=2 auth_mode=optional" \
1233 "$O_CLI -key data_files/server2.key \
1234 -cert data_files/server2.ku-ds.crt" \
1235 0 \
1236 -S "bad certificate (usage extensions)" \
1237 -S "Processing of the Certificate handshake message failed"
1238
1239run_test "keyUsage cli-auth #2 (RSA, KeyEncipherment: fail (soft))" \
1240 "$P_SRV debug_level=2 auth_mode=optional" \
1241 "$O_CLI -key data_files/server2.key \
1242 -cert data_files/server2.ku-ke.crt" \
1243 0 \
1244 -s "bad certificate (usage extensions)" \
1245 -S "Processing of the Certificate handshake message failed"
1246
1247run_test "keyUsage cli-auth #3 (RSA, KeyEncipherment: fail (hard))" \
1248 "$P_SRV debug_level=2 auth_mode=required" \
1249 "$O_CLI -key data_files/server2.key \
1250 -cert data_files/server2.ku-ke.crt" \
1251 1 \
1252 -s "bad certificate (usage extensions)" \
1253 -s "Processing of the Certificate handshake message failed"
1254
1255run_test "keyUsage cli-auth #4 (ECDSA, DigitalSignature: OK)" \
1256 "$P_SRV debug_level=2 auth_mode=optional" \
1257 "$O_CLI -key data_files/server5.key \
1258 -cert data_files/server5.ku-ds.crt" \
1259 0 \
1260 -S "bad certificate (usage extensions)" \
1261 -S "Processing of the Certificate handshake message failed"
1262
1263run_test "keyUsage cli-auth #5 (ECDSA, KeyAgreement: fail (soft))" \
1264 "$P_SRV debug_level=2 auth_mode=optional" \
1265 "$O_CLI -key data_files/server5.key \
1266 -cert data_files/server5.ku-ka.crt" \
1267 0 \
1268 -s "bad certificate (usage extensions)" \
1269 -S "Processing of the Certificate handshake message failed"
1270
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001271# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1272
1273run_test "extKeyUsage srv #1 (serverAuth -> OK)" \
1274 "$P_SRV key_file=data_files/server5.key \
1275 crt_file=data_files/server5.eku-srv.crt" \
1276 "$P_CLI" \
1277 0
1278
1279run_test "extKeyUsage srv #2 (serverAuth,clientAuth -> OK)" \
1280 "$P_SRV key_file=data_files/server5.key \
1281 crt_file=data_files/server5.eku-srv.crt" \
1282 "$P_CLI" \
1283 0
1284
1285run_test "extKeyUsage srv #3 (codeSign,anyEKU -> OK)" \
1286 "$P_SRV key_file=data_files/server5.key \
1287 crt_file=data_files/server5.eku-cs_any.crt" \
1288 "$P_CLI" \
1289 0
1290
1291# add psk to leave an option for client to send SERVERQUIT
1292run_test "extKeyUsage srv #4 (codeSign -> fail)" \
1293 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1294 crt_file=data_files/server5.eku-cli.crt" \
1295 "$P_CLI psk=badbad" \
1296 1
1297
1298# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1299
1300run_test "extKeyUsage cli #1 (serverAuth -> OK)" \
1301 "$O_SRV -key data_files/server5.key \
1302 -cert data_files/server5.eku-srv.crt" \
1303 "$P_CLI debug_level=2" \
1304 0 \
1305 -C "bad certificate (usage extensions)" \
1306 -C "Processing of the Certificate handshake message failed" \
1307 -c "Ciphersuite is TLS-"
1308
1309run_test "extKeyUsage cli #2 (serverAuth,clientAuth -> OK)" \
1310 "$O_SRV -key data_files/server5.key \
1311 -cert data_files/server5.eku-srv_cli.crt" \
1312 "$P_CLI debug_level=2" \
1313 0 \
1314 -C "bad certificate (usage extensions)" \
1315 -C "Processing of the Certificate handshake message failed" \
1316 -c "Ciphersuite is TLS-"
1317
1318run_test "extKeyUsage cli #3 (codeSign,anyEKU -> OK)" \
1319 "$O_SRV -key data_files/server5.key \
1320 -cert data_files/server5.eku-cs_any.crt" \
1321 "$P_CLI debug_level=2" \
1322 0 \
1323 -C "bad certificate (usage extensions)" \
1324 -C "Processing of the Certificate handshake message failed" \
1325 -c "Ciphersuite is TLS-"
1326
1327run_test "extKeyUsage cli #4 (codeSign -> fail)" \
1328 "$O_SRV -key data_files/server5.key \
1329 -cert data_files/server5.eku-cs.crt" \
1330 "$P_CLI debug_level=2" \
1331 1 \
1332 -c "bad certificate (usage extensions)" \
1333 -c "Processing of the Certificate handshake message failed" \
1334 -C "Ciphersuite is TLS-"
1335
1336# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1337
1338run_test "extKeyUsage cli-auth #1 (clientAuth -> OK)" \
1339 "$P_SRV debug_level=2 auth_mode=optional" \
1340 "$O_CLI -key data_files/server5.key \
1341 -cert data_files/server5.eku-cli.crt" \
1342 0 \
1343 -S "bad certificate (usage extensions)" \
1344 -S "Processing of the Certificate handshake message failed"
1345
1346run_test "extKeyUsage cli-auth #2 (serverAuth,clientAuth -> OK)" \
1347 "$P_SRV debug_level=2 auth_mode=optional" \
1348 "$O_CLI -key data_files/server5.key \
1349 -cert data_files/server5.eku-srv_cli.crt" \
1350 0 \
1351 -S "bad certificate (usage extensions)" \
1352 -S "Processing of the Certificate handshake message failed"
1353
1354run_test "extKeyUsage cli-auth #3 (codeSign,anyEKU -> OK)" \
1355 "$P_SRV debug_level=2 auth_mode=optional" \
1356 "$O_CLI -key data_files/server5.key \
1357 -cert data_files/server5.eku-cs_any.crt" \
1358 0 \
1359 -S "bad certificate (usage extensions)" \
1360 -S "Processing of the Certificate handshake message failed"
1361
1362run_test "extKeyUsage cli-auth #4 (codeSign -> fail (soft))" \
1363 "$P_SRV debug_level=2 auth_mode=optional" \
1364 "$O_CLI -key data_files/server5.key \
1365 -cert data_files/server5.eku-cs.crt" \
1366 0 \
1367 -s "bad certificate (usage extensions)" \
1368 -S "Processing of the Certificate handshake message failed"
1369
1370run_test "extKeyUsage cli-auth #4b (codeSign -> fail (hard))" \
1371 "$P_SRV debug_level=2 auth_mode=required" \
1372 "$O_CLI -key data_files/server5.key \
1373 -cert data_files/server5.eku-cs.crt" \
1374 1 \
1375 -s "bad certificate (usage extensions)" \
1376 -s "Processing of the Certificate handshake message failed"
1377
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001378# Tests for DHM parameters loading
1379
1380run_test "DHM parameters #0 (reference)" \
1381 "$P_SRV" \
1382 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1383 debug_level=3" \
1384 0 \
1385 -c "value of 'DHM: P ' (2048 bits)" \
1386 -c "value of 'DHM: G ' (2048 bits)"
1387
1388run_test "DHM parameters #1 (other parameters)" \
1389 "$P_SRV dhm_file=data_files/dhparams.pem" \
1390 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1391 debug_level=3" \
1392 0 \
1393 -c "value of 'DHM: P ' (1024 bits)" \
1394 -c "value of 'DHM: G ' (2 bits)"
1395
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001396# Tests for PSK callback
1397
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001398run_test "PSK callback #0a (psk, no callback)" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001399 "$P_SRV psk=abc123 psk_identity=foo" \
1400 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1401 psk_identity=foo psk=abc123" \
1402 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001403 -S "SSL - The server has no ciphersuites in common" \
1404 -S "SSL - Unknown identity received" \
1405 -S "SSL - Verification of the message MAC failed"
1406
1407run_test "PSK callback #0b (no psk, no callback)" \
1408 "$P_SRV" \
1409 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1410 psk_identity=foo psk=abc123" \
1411 1 \
1412 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001413 -S "SSL - Unknown identity received" \
1414 -S "SSL - Verification of the message MAC failed"
1415
1416run_test "PSK callback #1 (callback overrides other settings)" \
1417 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1418 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1419 psk_identity=foo psk=abc123" \
1420 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001421 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001422 -s "SSL - Unknown identity received" \
1423 -S "SSL - Verification of the message MAC failed"
1424
1425run_test "PSK callback #2 (first id matches)" \
1426 "$P_SRV psk_list=abc,dead,def,beef" \
1427 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1428 psk_identity=abc psk=dead" \
1429 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001430 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001431 -S "SSL - Unknown identity received" \
1432 -S "SSL - Verification of the message MAC failed"
1433
1434run_test "PSK callback #3 (second id matches)" \
1435 "$P_SRV psk_list=abc,dead,def,beef" \
1436 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1437 psk_identity=def psk=beef" \
1438 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001439 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001440 -S "SSL - Unknown identity received" \
1441 -S "SSL - Verification of the message MAC failed"
1442
1443run_test "PSK callback #4 (no match)" \
1444 "$P_SRV psk_list=abc,dead,def,beef" \
1445 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1446 psk_identity=ghi psk=beef" \
1447 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001448 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001449 -s "SSL - Unknown identity received" \
1450 -S "SSL - Verification of the message MAC failed"
1451
1452run_test "PSK callback #5 (wrong key)" \
1453 "$P_SRV psk_list=abc,dead,def,beef" \
1454 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1455 psk_identity=abc psk=beef" \
1456 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001457 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001458 -S "SSL - Unknown identity received" \
1459 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001460
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001461# Tests for ciphersuites per version
1462
1463run_test "Per-version suites #1" \
1464 "$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" \
1465 "$P_CLI force_version=ssl3" \
1466 0 \
1467 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1468
1469run_test "Per-version suites #2" \
1470 "$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" \
1471 "$P_CLI force_version=tls1" \
1472 0 \
1473 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1474
1475run_test "Per-version suites #3" \
1476 "$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" \
1477 "$P_CLI force_version=tls1_1" \
1478 0 \
1479 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1480
1481run_test "Per-version suites #4" \
1482 "$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" \
1483 "$P_CLI force_version=tls1_2" \
1484 0 \
1485 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1486
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001487# Tests for ssl_get_bytes_avail()
1488
1489run_test "ssl_get_bytes_avail #1 (no extra data)" \
1490 "$P_SRV" \
1491 "$P_CLI request_size=100" \
1492 0 \
1493 -s "Read from client: 100 bytes read$"
1494
1495run_test "ssl_get_bytes_avail #2 (extra data)" \
1496 "$P_SRV" \
1497 "$P_CLI request_size=500" \
1498 0 \
1499 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001500
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001501# Tests for small packets
1502
1503run_test "Small packet SSLv3 BlockCipher" \
1504 "$P_SRV" \
1505 "$P_CLI request_size=1 force_version=ssl3 \
1506 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1507 0 \
1508 -s "Read from client: 1 bytes read"
1509
1510run_test "Small packet SSLv3 StreamCipher" \
1511 "$P_SRV" \
1512 "$P_CLI request_size=1 force_version=ssl3 \
1513 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1514 0 \
1515 -s "Read from client: 1 bytes read"
1516
1517run_test "Small packet TLS 1.0 BlockCipher" \
1518 "$P_SRV" \
1519 "$P_CLI request_size=1 force_version=tls1 \
1520 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1521 0 \
1522 -s "Read from client: 1 bytes read"
1523
1524run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1525 "$P_SRV" \
1526 "$P_CLI request_size=1 force_version=tls1 \
1527 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1528 trunc_hmac=1" \
1529 0 \
1530 -s "Read from client: 1 bytes read"
1531
1532run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1533 "$P_SRV" \
1534 "$P_CLI request_size=1 force_version=tls1 \
1535 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1536 trunc_hmac=1" \
1537 0 \
1538 -s "Read from client: 1 bytes read"
1539
1540run_test "Small packet TLS 1.1 BlockCipher" \
1541 "$P_SRV" \
1542 "$P_CLI request_size=1 force_version=tls1_1 \
1543 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1544 0 \
1545 -s "Read from client: 1 bytes read"
1546
1547run_test "Small packet TLS 1.1 StreamCipher" \
1548 "$P_SRV" \
1549 "$P_CLI request_size=1 force_version=tls1_1 \
1550 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1551 0 \
1552 -s "Read from client: 1 bytes read"
1553
1554run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1555 "$P_SRV" \
1556 "$P_CLI request_size=1 force_version=tls1_1 \
1557 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1558 trunc_hmac=1" \
1559 0 \
1560 -s "Read from client: 1 bytes read"
1561
1562run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1563 "$P_SRV" \
1564 "$P_CLI request_size=1 force_version=tls1_1 \
1565 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1566 trunc_hmac=1" \
1567 0 \
1568 -s "Read from client: 1 bytes read"
1569
1570run_test "Small packet TLS 1.2 BlockCipher" \
1571 "$P_SRV" \
1572 "$P_CLI request_size=1 force_version=tls1_2 \
1573 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1574 0 \
1575 -s "Read from client: 1 bytes read"
1576
1577run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1578 "$P_SRV" \
1579 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1580 0 \
1581 -s "Read from client: 1 bytes read"
1582
1583run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1584 "$P_SRV" \
1585 "$P_CLI request_size=1 force_version=tls1_2 \
1586 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1587 trunc_hmac=1" \
1588 0 \
1589 -s "Read from client: 1 bytes read"
1590
1591run_test "Small packet TLS 1.2 StreamCipher" \
1592 "$P_SRV" \
1593 "$P_CLI request_size=1 force_version=tls1_2 \
1594 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1595 0 \
1596 -s "Read from client: 1 bytes read"
1597
1598run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1599 "$P_SRV" \
1600 "$P_CLI request_size=1 force_version=tls1_2 \
1601 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1602 trunc_hmac=1" \
1603 0 \
1604 -s "Read from client: 1 bytes read"
1605
1606run_test "Small packet TLS 1.2 AEAD" \
1607 "$P_SRV" \
1608 "$P_CLI request_size=1 force_version=tls1_2 \
1609 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1610 0 \
1611 -s "Read from client: 1 bytes read"
1612
1613run_test "Small packet TLS 1.2 AEAD shorter tag" \
1614 "$P_SRV" \
1615 "$P_CLI request_size=1 force_version=tls1_2 \
1616 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1617 0 \
1618 -s "Read from client: 1 bytes read"
1619
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001620# Test for large packets
1621
1622run_test "Large packet SSLv3 BlockCipher" \
1623 "$P_SRV" \
1624 "$P_CLI request_size=16384 force_version=ssl3 \
1625 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1626 0 \
1627 -s "Read from client: 16384 bytes read"
1628
1629run_test "Large packet SSLv3 StreamCipher" \
1630 "$P_SRV" \
1631 "$P_CLI request_size=16384 force_version=ssl3 \
1632 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1633 0 \
1634 -s "Read from client: 16384 bytes read"
1635
1636run_test "Large packet TLS 1.0 BlockCipher" \
1637 "$P_SRV" \
1638 "$P_CLI request_size=16384 force_version=tls1 \
1639 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1640 0 \
1641 -s "Read from client: 16384 bytes read"
1642
1643run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1644 "$P_SRV" \
1645 "$P_CLI request_size=16384 force_version=tls1 \
1646 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1647 trunc_hmac=1" \
1648 0 \
1649 -s "Read from client: 16384 bytes read"
1650
1651run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1652 "$P_SRV" \
1653 "$P_CLI request_size=16384 force_version=tls1 \
1654 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1655 trunc_hmac=1" \
1656 0 \
1657 -s "Read from client: 16384 bytes read"
1658
1659run_test "Large packet TLS 1.1 BlockCipher" \
1660 "$P_SRV" \
1661 "$P_CLI request_size=16384 force_version=tls1_1 \
1662 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1663 0 \
1664 -s "Read from client: 16384 bytes read"
1665
1666run_test "Large packet TLS 1.1 StreamCipher" \
1667 "$P_SRV" \
1668 "$P_CLI request_size=16384 force_version=tls1_1 \
1669 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1670 0 \
1671 -s "Read from client: 16384 bytes read"
1672
1673run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1674 "$P_SRV" \
1675 "$P_CLI request_size=16384 force_version=tls1_1 \
1676 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1677 trunc_hmac=1" \
1678 0 \
1679 -s "Read from client: 16384 bytes read"
1680
1681run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1682 "$P_SRV" \
1683 "$P_CLI request_size=16384 force_version=tls1_1 \
1684 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1685 trunc_hmac=1" \
1686 0 \
1687 -s "Read from client: 16384 bytes read"
1688
1689run_test "Large packet TLS 1.2 BlockCipher" \
1690 "$P_SRV" \
1691 "$P_CLI request_size=16384 force_version=tls1_2 \
1692 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1693 0 \
1694 -s "Read from client: 16384 bytes read"
1695
1696run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1697 "$P_SRV" \
1698 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1699 0 \
1700 -s "Read from client: 16384 bytes read"
1701
1702run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1703 "$P_SRV" \
1704 "$P_CLI request_size=16384 force_version=tls1_2 \
1705 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1706 trunc_hmac=1" \
1707 0 \
1708 -s "Read from client: 16384 bytes read"
1709
1710run_test "Large packet TLS 1.2 StreamCipher" \
1711 "$P_SRV" \
1712 "$P_CLI request_size=16384 force_version=tls1_2 \
1713 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1714 0 \
1715 -s "Read from client: 16384 bytes read"
1716
1717run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1718 "$P_SRV" \
1719 "$P_CLI request_size=16384 force_version=tls1_2 \
1720 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1721 trunc_hmac=1" \
1722 0 \
1723 -s "Read from client: 16384 bytes read"
1724
1725run_test "Large packet TLS 1.2 AEAD" \
1726 "$P_SRV" \
1727 "$P_CLI request_size=16384 force_version=tls1_2 \
1728 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1729 0 \
1730 -s "Read from client: 16384 bytes read"
1731
1732run_test "Large packet TLS 1.2 AEAD shorter tag" \
1733 "$P_SRV" \
1734 "$P_CLI request_size=16384 force_version=tls1_2 \
1735 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1736 0 \
1737 -s "Read from client: 16384 bytes read"
1738
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001739# Final report
1740
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001741echo "------------------------------------------------------------------------"
1742
1743if [ $FAILS = 0 ]; then
1744 echo -n "PASSED"
1745else
1746 echo -n "FAILED"
1747fi
1748PASSES=`echo $TESTS - $FAILS | bc`
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001749echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001750
1751exit $FAILS