blob: d435ee6b93ab29a3f8e13e8a96f852b018082440 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
21O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
23G_CLI="$GNUTLS_CLI"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010037 echo -e " -h|--help\tPrint this help."
38 echo -e " -m|--memcheck\tCheck memory leaks and errors."
39 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
40 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
72 if openssl ciphers -ssl2 >/dev/null 2>&1; then
73 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
78 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020083# skip next test if GnuTLS isn't available
84requires_gnutls() {
85 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
86 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
87 GNUTLS_AVAILABLE="YES"
88 else
89 GNUTLS_AVAILABLE="NO"
90 fi
91 fi
92 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
93 SKIP_NEXT="YES"
94 fi
95}
96
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010097# print_name <name>
98print_name() {
99 echo -n "$1 "
100 LEN=`echo "$1" | wc -c`
101 LEN=`echo 72 - $LEN | bc`
102 for i in `seq 1 $LEN`; do echo -n '.'; done
103 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100104
105 TESTS=`echo $TESTS + 1 | bc`
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100106}
107
108# fail <message>
109fail() {
110 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100111 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100112
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200113 cp $SRV_OUT o-srv-${TESTS}.log
114 cp $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100115 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100116
117 FAILS=`echo $FAILS + 1 | bc`
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100118}
119
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100120# is_polar <cmd_line>
121is_polar() {
122 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
123}
124
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100125# has_mem_err <log_file_name>
126has_mem_err() {
127 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
128 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
129 then
130 return 1 # false: does not have errors
131 else
132 return 0 # true: has errors
133 fi
134}
135
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200136# wait for server to start: two versions depending on lsof availability
137wait_server_start() {
138 if which lsof >/dev/null; then
139 # make sure we don't loop forever
140 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
141 WATCHDOG_PID=$!
142
143 # make a tight loop, server usually takes less than 1 sec to start
144 until lsof -nbi TCP:"$PORT" | grep LISTEN >/dev/null; do :; done
145
146 kill $WATCHDOG_PID
147 wait $WATCHDOG_PID
148 else
149 sleep "$START_DELAY"
150 fi
151}
152
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100153# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100154# Options: -s pattern pattern that must be present in server output
155# -c pattern pattern that must be present in client output
156# -S pattern pattern that must be absent in server output
157# -C pattern pattern that must be absent in client output
158run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100159 NAME="$1"
160 SRV_CMD="$2"
161 CLI_CMD="$3"
162 CLI_EXPECT="$4"
163 shift 4
164
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100165 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
166 else
167 return
168 fi
169
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100170 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100171
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200172 # should we skip?
173 if [ "X$SKIP_NEXT" = "XYES" ]; then
174 SKIP_NEXT="NO"
175 echo "SKIP"
176 SKIPS=`echo $SKIPS + 1 | bc`
177 return
178 fi
179
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100180 # prepend valgrind to our commands if active
181 if [ "$MEMCHECK" -gt 0 ]; then
182 if is_polar "$SRV_CMD"; then
183 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
184 fi
185 if is_polar "$CLI_CMD"; then
186 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
187 fi
188 fi
189
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100190 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200191 echo "$SRV_CMD" > $SRV_OUT
192 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100193 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200194 wait_server_start
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200195 echo "$CLI_CMD" > $CLI_OUT
196 eval "$CLI_CMD" >> $CLI_OUT 2>&1
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100197 CLI_EXIT=$?
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200198 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100199
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200200 # kill the server
201 kill $SRV_PID
202 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100203
204 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200205 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100206 # expected client exit to incorrectly succeed in case of catastrophic
207 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100208 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200209 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100210 else
211 fail "server failed to start"
212 return
213 fi
214 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100215 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200216 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100217 else
218 fail "client failed to start"
219 return
220 fi
221 fi
222
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100223 # check server exit code
224 if [ $? != 0 ]; then
225 fail "server fail"
226 return
227 fi
228
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100229 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100230 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
231 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100232 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100233 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100234 return
235 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100236
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100237 # check other assertions
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100238 while [ $# -gt 0 ]
239 do
240 case $1 in
241 "-s")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200242 if grep "$2" $SRV_OUT >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100243 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100244 return
245 fi
246 ;;
247
248 "-c")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200249 if grep "$2" $CLI_OUT >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100250 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100251 return
252 fi
253 ;;
254
255 "-S")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200256 if grep "$2" $SRV_OUT >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100257 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100258 return
259 fi
260 ;;
261
262 "-C")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200263 if grep "$2" $CLI_OUT >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100264 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100265 return
266 fi
267 ;;
268
269 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200270 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100271 exit 1
272 esac
273 shift 2
274 done
275
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100276 # check valgrind's results
277 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200278 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100279 fail "Server has memory errors"
280 return
281 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200282 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100283 fail "Client has memory errors"
284 return
285 fi
286 fi
287
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100288 # if we're here, everything is ok
289 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200290 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100291}
292
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100293cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200294 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200295 kill $SRV_PID >/dev/null 2>&1
296 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100297 exit 1
298}
299
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100300#
301# MAIN
302#
303
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100304get_options "$@"
305
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100306# sanity checks, avoid an avalanche of errors
307if [ ! -x "$P_SRV" ]; then
308 echo "Command '$P_SRV' is not an executable file"
309 exit 1
310fi
311if [ ! -x "$P_CLI" ]; then
312 echo "Command '$P_CLI' is not an executable file"
313 exit 1
314fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100315if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
316 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100317 exit 1
318fi
319
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200320# used by watchdog
321MAIN_PID="$$"
322
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200323# be more patient with valgrind
324if [ "$MEMCHECK" -gt 0 ]; then
325 START_DELAY=3
326 DOG_DELAY=30
327else
328 START_DELAY=1
329 DOG_DELAY=10
330fi
331
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200332# Pick a "unique" port in the range 10000-19999.
333PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200334PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200335
336# fix commands to use this port
337P_SRV="$P_SRV server_port=$PORT"
338P_CLI="$P_CLI server_port=$PORT"
339O_SRV="$O_SRV -accept $PORT"
340O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200341G_SRV="$G_SRV -p $PORT"
342G_CLI="$G_CLI -p $PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200343
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200344# Also pick a unique name for intermediate files
345SRV_OUT="srv_out.$$"
346CLI_OUT="cli_out.$$"
347SESSION="session.$$"
348
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200349SKIP_NEXT="NO"
350
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100351trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100352
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200353# Basic test
354
355run_test "Default" \
356 "$P_SRV" \
357 "$P_CLI" \
358 0 \
359 -S "Last error was" \
360 -C "Last error was"
361
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100362# Test for SSLv2 ClientHello
363
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200364requires_openssl_with_sslv2
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100365run_test "SSLv2 ClientHello #0 (reference)" \
366 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100367 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100368 0 \
369 -S "parse client hello v2" \
370 -S "ssl_handshake returned"
371
372# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200373requires_openssl_with_sslv2
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100374run_test "SSLv2 ClientHello #1 (actual test)" \
375 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100376 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100377 0 \
378 -s "parse client hello v2" \
379 -S "ssl_handshake returned"
380
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100381# Tests for Truncated HMAC extension
382
383run_test "Truncated HMAC #0" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100384 "$P_SRV debug_level=5" \
385 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100386 0 \
387 -s "dumping 'computed mac' (20 bytes)"
388
389run_test "Truncated HMAC #1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100390 "$P_SRV debug_level=5" \
391 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100392 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100393 -s "dumping 'computed mac' (10 bytes)"
394
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100395# Tests for Session Tickets
396
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100397run_test "Session resume using tickets #1 (basic)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100398 "$P_SRV debug_level=4 tickets=1" \
399 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100400 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100401 -c "client hello, adding session ticket extension" \
402 -s "found session ticket extension" \
403 -s "server hello, adding session ticket extension" \
404 -c "found session_ticket extension" \
405 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100406 -S "session successfully restored from cache" \
407 -s "session successfully restored from ticket" \
408 -s "a session has been resumed" \
409 -c "a session has been resumed"
410
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100411run_test "Session resume using tickets #2 (cache disabled)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100412 "$P_SRV debug_level=4 tickets=1 cache_max=0" \
413 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100414 0 \
415 -c "client hello, adding session ticket extension" \
416 -s "found session ticket extension" \
417 -s "server hello, adding session ticket extension" \
418 -c "found session_ticket extension" \
419 -c "parse new session ticket" \
420 -S "session successfully restored from cache" \
421 -s "session successfully restored from ticket" \
422 -s "a session has been resumed" \
423 -c "a session has been resumed"
424
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100425run_test "Session resume using tickets #3 (timeout)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100426 "$P_SRV debug_level=4 tickets=1 cache_max=0 ticket_timeout=1" \
427 "$P_CLI debug_level=4 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100428 0 \
429 -c "client hello, adding session ticket extension" \
430 -s "found session ticket extension" \
431 -s "server hello, adding session ticket extension" \
432 -c "found session_ticket extension" \
433 -c "parse new session ticket" \
434 -S "session successfully restored from cache" \
435 -S "session successfully restored from ticket" \
436 -S "a session has been resumed" \
437 -C "a session has been resumed"
438
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100439run_test "Session resume using tickets #4 (openssl server)" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100440 "$O_SRV" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100441 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
442 0 \
443 -c "client hello, adding session ticket extension" \
444 -c "found session_ticket extension" \
445 -c "parse new session ticket" \
446 -c "a session has been resumed"
447
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100448run_test "Session resume using tickets #5 (openssl client)" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100449 "$P_SRV debug_level=4 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200450 "( $O_CLI -sess_out $SESSION; \
451 $O_CLI -sess_in $SESSION; \
452 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100453 0 \
454 -s "found session ticket extension" \
455 -s "server hello, adding session ticket extension" \
456 -S "session successfully restored from cache" \
457 -s "session successfully restored from ticket" \
458 -s "a session has been resumed"
459
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100460# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100461
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100462run_test "Session resume using cache #1 (tickets enabled on client)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100463 "$P_SRV debug_level=4 tickets=0" \
464 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100465 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100466 -c "client hello, adding session ticket extension" \
467 -s "found session ticket extension" \
468 -S "server hello, adding session ticket extension" \
469 -C "found session_ticket extension" \
470 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100471 -s "session successfully restored from cache" \
472 -S "session successfully restored from ticket" \
473 -s "a session has been resumed" \
474 -c "a session has been resumed"
475
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100476run_test "Session resume using cache #2 (tickets enabled on server)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100477 "$P_SRV debug_level=4 tickets=1" \
478 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100479 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100480 -C "client hello, adding session ticket extension" \
481 -S "found session ticket extension" \
482 -S "server hello, adding session ticket extension" \
483 -C "found session_ticket extension" \
484 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100485 -s "session successfully restored from cache" \
486 -S "session successfully restored from ticket" \
487 -s "a session has been resumed" \
488 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100489
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100490run_test "Session resume using cache #3 (cache_max=0)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100491 "$P_SRV debug_level=4 tickets=0 cache_max=0" \
492 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100493 0 \
494 -S "session successfully restored from cache" \
495 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100496 -S "a session has been resumed" \
497 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100498
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100499run_test "Session resume using cache #4 (cache_max=1)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100500 "$P_SRV debug_level=4 tickets=0 cache_max=1" \
501 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100502 0 \
503 -s "session successfully restored from cache" \
504 -S "session successfully restored from ticket" \
505 -s "a session has been resumed" \
506 -c "a session has been resumed"
507
508run_test "Session resume using cache #5 (timemout > delay)" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100509 "$P_SRV debug_level=4 tickets=0" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100510 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100511 0 \
512 -s "session successfully restored from cache" \
513 -S "session successfully restored from ticket" \
514 -s "a session has been resumed" \
515 -c "a session has been resumed"
516
517run_test "Session resume using cache #6 (timeout < delay)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100518 "$P_SRV debug_level=4 tickets=0 cache_timeout=1" \
519 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100520 0 \
521 -S "session successfully restored from cache" \
522 -S "session successfully restored from ticket" \
523 -S "a session has been resumed" \
524 -C "a session has been resumed"
525
526run_test "Session resume using cache #7 (no timeout)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100527 "$P_SRV debug_level=4 tickets=0 cache_timeout=0" \
528 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100529 0 \
530 -s "session successfully restored from cache" \
531 -S "session successfully restored from ticket" \
532 -s "a session has been resumed" \
533 -c "a session has been resumed"
534
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100535run_test "Session resume using cache #8 (openssl client)" \
536 "$P_SRV debug_level=4 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200537 "( $O_CLI -sess_out $SESSION; \
538 $O_CLI -sess_in $SESSION; \
539 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100540 0 \
541 -s "found session ticket extension" \
542 -S "server hello, adding session ticket extension" \
543 -s "session successfully restored from cache" \
544 -S "session successfully restored from ticket" \
545 -s "a session has been resumed"
546
547run_test "Session resume using cache #9 (openssl server)" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100548 "$O_SRV" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100549 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
550 0 \
551 -C "found session_ticket extension" \
552 -C "parse new session ticket" \
553 -c "a session has been resumed"
554
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100555# Tests for Max Fragment Length extension
556
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100557run_test "Max fragment length #1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100558 "$P_SRV debug_level=4" \
559 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100560 0 \
561 -C "client hello, adding max_fragment_length extension" \
562 -S "found max fragment length extension" \
563 -S "server hello, max_fragment_length extension" \
564 -C "found max_fragment_length extension"
565
566run_test "Max fragment length #2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100567 "$P_SRV debug_level=4" \
568 "$P_CLI debug_level=4 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100569 0 \
570 -c "client hello, adding max_fragment_length extension" \
571 -s "found max fragment length extension" \
572 -s "server hello, max_fragment_length extension" \
573 -c "found max_fragment_length extension"
574
575run_test "Max fragment length #3" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100576 "$P_SRV debug_level=4 max_frag_len=4096" \
577 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100578 0 \
579 -C "client hello, adding max_fragment_length extension" \
580 -S "found max fragment length extension" \
581 -S "server hello, max_fragment_length extension" \
582 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100583
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200584run_test "Max fragment length #4 (GnuTLS server)" \
585 "$G_SRV" \
586 "$P_CLI debug_level=4 max_frag_len=4096" \
587 0 \
588 -c "client hello, adding max_fragment_length extension" \
589 -c "found max_fragment_length extension"
590
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100591# Tests for renegotiation
592
593run_test "Renegotiation #0 (none)" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200594 "$P_SRV debug_level=4 exchanges=2" \
595 "$P_CLI debug_level=4 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100596 0 \
597 -C "client hello, adding renegotiation extension" \
598 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
599 -S "found renegotiation extension" \
600 -s "server hello, secure renegotiation extension" \
601 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100602 -C "=> renegotiate" \
603 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100604 -S "write hello request"
605
606run_test "Renegotiation #1 (enabled, client-initiated)" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200607 "$P_SRV debug_level=4 exchanges=2 renegotiation=1" \
608 "$P_CLI debug_level=4 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100609 0 \
610 -c "client hello, adding renegotiation extension" \
611 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
612 -s "found renegotiation extension" \
613 -s "server hello, secure renegotiation extension" \
614 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100615 -c "=> renegotiate" \
616 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100617 -S "write hello request"
618
619run_test "Renegotiation #2 (enabled, server-initiated)" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200620 "$P_SRV debug_level=4 exchanges=2 renegotiation=1 renegotiate=1" \
621 "$P_CLI debug_level=4 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100622 0 \
623 -c "client hello, adding renegotiation extension" \
624 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
625 -s "found renegotiation extension" \
626 -s "server hello, secure renegotiation extension" \
627 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100628 -c "=> renegotiate" \
629 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100630 -s "write hello request"
631
632run_test "Renegotiation #3 (enabled, double)" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200633 "$P_SRV debug_level=4 exchanges=2 renegotiation=1 renegotiate=1" \
634 "$P_CLI debug_level=4 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100635 0 \
636 -c "client hello, adding renegotiation extension" \
637 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
638 -s "found renegotiation extension" \
639 -s "server hello, secure renegotiation extension" \
640 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100641 -c "=> renegotiate" \
642 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100643 -s "write hello request"
644
645run_test "Renegotiation #4 (client-initiated, server-rejected)" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200646 "$P_SRV debug_level=4 exchanges=2 renegotiation=0" \
647 "$P_CLI debug_level=4 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100648 1 \
649 -c "client hello, adding renegotiation extension" \
650 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
651 -S "found renegotiation extension" \
652 -s "server hello, secure renegotiation extension" \
653 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100654 -c "=> renegotiate" \
655 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200656 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200657 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200658 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100659
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200660run_test "Renegotiation #5 (server-initiated, client-rejected, default)" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200661 "$P_SRV debug_level=4 exchanges=2 renegotiation=1 renegotiate=1" \
662 "$P_CLI debug_level=4 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100663 0 \
664 -C "client hello, adding renegotiation extension" \
665 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
666 -S "found renegotiation extension" \
667 -s "server hello, secure renegotiation extension" \
668 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100669 -C "=> renegotiate" \
670 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100671 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200672 -S "SSL - An unexpected message was received from our peer" \
673 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100674
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200675run_test "Renegotiation #6 (server-initiated, client-rejected, not enforced)" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200676 "$P_SRV debug_level=4 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200677 renego_delay=-1" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200678 "$P_CLI debug_level=4 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200679 0 \
680 -C "client hello, adding renegotiation extension" \
681 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
682 -S "found renegotiation extension" \
683 -s "server hello, secure renegotiation extension" \
684 -c "found renegotiation extension" \
685 -C "=> renegotiate" \
686 -S "=> renegotiate" \
687 -s "write hello request" \
688 -S "SSL - An unexpected message was received from our peer" \
689 -S "failed"
690
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200691# delay 2 for 1 alert record + 1 application data record
692run_test "Renegotiation #7 (server-initiated, client-rejected, delay 2)" \
693 "$P_SRV debug_level=4 exchanges=2 renegotiation=1 renegotiate=1 \
694 renego_delay=2" \
695 "$P_CLI debug_level=4 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200696 0 \
697 -C "client hello, adding renegotiation extension" \
698 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
699 -S "found renegotiation extension" \
700 -s "server hello, secure renegotiation extension" \
701 -c "found renegotiation extension" \
702 -C "=> renegotiate" \
703 -S "=> renegotiate" \
704 -s "write hello request" \
705 -S "SSL - An unexpected message was received from our peer" \
706 -S "failed"
707
708run_test "Renegotiation #8 (server-initiated, client-rejected, delay 0)" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200709 "$P_SRV debug_level=4 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200710 renego_delay=0" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200711 "$P_CLI debug_level=4 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200712 0 \
713 -C "client hello, adding renegotiation extension" \
714 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
715 -S "found renegotiation extension" \
716 -s "server hello, secure renegotiation extension" \
717 -c "found renegotiation extension" \
718 -C "=> renegotiate" \
719 -S "=> renegotiate" \
720 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200721 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200722
723run_test "Renegotiation #9 (server-initiated, client-accepted, delay 0)" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200724 "$P_SRV debug_level=4 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200725 renego_delay=0" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200726 "$P_CLI debug_level=4 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200727 0 \
728 -c "client hello, adding renegotiation extension" \
729 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
730 -s "found renegotiation extension" \
731 -s "server hello, secure renegotiation extension" \
732 -c "found renegotiation extension" \
733 -c "=> renegotiate" \
734 -s "=> renegotiate" \
735 -s "write hello request" \
736 -S "SSL - An unexpected message was received from our peer" \
737 -S "failed"
738
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200739run_test "Renegotiation #10 (nbio, enabled, client-initiated)" \
740 "$P_SRV debug_level=4 nbio=2 exchanges=2 renegotiation=1" \
741 "$P_CLI debug_level=4 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
742 0 \
743 -c "client hello, adding renegotiation extension" \
744 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
745 -s "found renegotiation extension" \
746 -s "server hello, secure renegotiation extension" \
747 -c "found renegotiation extension" \
748 -c "=> renegotiate" \
749 -s "=> renegotiate" \
750 -S "write hello request"
751
752run_test "Renegotiation #11 (nbio, enabled, server-initiated)" \
753 "$P_SRV debug_level=4 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
754 "$P_CLI debug_level=4 nbio=2 exchanges=2 renegotiation=1" \
755 0 \
756 -c "client hello, adding renegotiation extension" \
757 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
758 -s "found renegotiation extension" \
759 -s "server hello, secure renegotiation extension" \
760 -c "found renegotiation extension" \
761 -c "=> renegotiate" \
762 -s "=> renegotiate" \
763 -s "write hello request"
764
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100765# Tests for auth_mode
766
767run_test "Authentication #1 (server badcert, client required)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100768 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100769 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100770 "$P_CLI debug_level=2 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100771 1 \
772 -c "x509_verify_cert() returned" \
773 -c "! self-signed or not signed by a trusted CA" \
774 -c "! ssl_handshake returned" \
775 -c "X509 - Certificate verification failed"
776
777run_test "Authentication #2 (server badcert, client optional)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100778 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100779 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100780 "$P_CLI debug_level=2 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100781 0 \
782 -c "x509_verify_cert() returned" \
783 -c "! self-signed or not signed by a trusted CA" \
784 -C "! ssl_handshake returned" \
785 -C "X509 - Certificate verification failed"
786
787run_test "Authentication #3 (server badcert, client none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100788 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100789 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100790 "$P_CLI debug_level=2 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100791 0 \
792 -C "x509_verify_cert() returned" \
793 -C "! self-signed or not signed by a trusted CA" \
794 -C "! ssl_handshake returned" \
795 -C "X509 - Certificate verification failed"
796
797run_test "Authentication #4 (client badcert, server required)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100798 "$P_SRV debug_level=4 auth_mode=required" \
799 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100800 key_file=data_files/server5.key" \
801 1 \
802 -S "skip write certificate request" \
803 -C "skip parse certificate request" \
804 -c "got a certificate request" \
805 -C "skip write certificate" \
806 -C "skip write certificate verify" \
807 -S "skip parse certificate verify" \
808 -s "x509_verify_cert() returned" \
809 -S "! self-signed or not signed by a trusted CA" \
810 -s "! ssl_handshake returned" \
811 -c "! ssl_handshake returned" \
812 -s "X509 - Certificate verification failed"
813
814run_test "Authentication #5 (client badcert, server optional)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100815 "$P_SRV debug_level=4 auth_mode=optional" \
816 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100817 key_file=data_files/server5.key" \
818 0 \
819 -S "skip write certificate request" \
820 -C "skip parse certificate request" \
821 -c "got a certificate request" \
822 -C "skip write certificate" \
823 -C "skip write certificate verify" \
824 -S "skip parse certificate verify" \
825 -s "x509_verify_cert() returned" \
826 -s "! self-signed or not signed by a trusted CA" \
827 -S "! ssl_handshake returned" \
828 -C "! ssl_handshake returned" \
829 -S "X509 - Certificate verification failed"
830
831run_test "Authentication #6 (client badcert, server none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100832 "$P_SRV debug_level=4 auth_mode=none" \
833 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100834 key_file=data_files/server5.key" \
835 0 \
836 -s "skip write certificate request" \
837 -C "skip parse certificate request" \
838 -c "got no certificate request" \
839 -c "skip write certificate" \
840 -c "skip write certificate verify" \
841 -s "skip parse certificate verify" \
842 -S "x509_verify_cert() returned" \
843 -S "! self-signed or not signed by a trusted CA" \
844 -S "! ssl_handshake returned" \
845 -C "! ssl_handshake returned" \
846 -S "X509 - Certificate verification failed"
847
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100848run_test "Authentication #7 (client no cert, server optional)" \
849 "$P_SRV debug_level=4 auth_mode=optional" \
850 "$P_CLI debug_level=4 crt_file=none key_file=none" \
851 0 \
852 -S "skip write certificate request" \
853 -C "skip parse certificate request" \
854 -c "got a certificate request" \
855 -C "skip write certificate$" \
856 -C "got no certificate to send" \
857 -S "SSLv3 client has no certificate" \
858 -c "skip write certificate verify" \
859 -s "skip parse certificate verify" \
860 -s "! no client certificate sent" \
861 -S "! ssl_handshake returned" \
862 -C "! ssl_handshake returned" \
863 -S "X509 - Certificate verification failed"
864
865run_test "Authentication #8 (openssl client no cert, server optional)" \
866 "$P_SRV debug_level=4 auth_mode=optional" \
867 "$O_CLI" \
868 0 \
869 -S "skip write certificate request" \
870 -s "skip parse certificate verify" \
871 -s "! no client certificate sent" \
872 -S "! ssl_handshake returned" \
873 -S "X509 - Certificate verification failed"
874
875run_test "Authentication #9 (client no cert, openssl server optional)" \
876 "$O_SRV -verify 10" \
877 "$P_CLI debug_level=4 crt_file=none key_file=none" \
878 0 \
879 -C "skip parse certificate request" \
880 -c "got a certificate request" \
881 -C "skip write certificate$" \
882 -c "skip write certificate verify" \
883 -C "! ssl_handshake returned"
884
885run_test "Authentication #10 (client no cert, ssl3)" \
886 "$P_SRV debug_level=4 auth_mode=optional force_version=ssl3" \
887 "$P_CLI debug_level=4 crt_file=none key_file=none" \
888 0 \
889 -S "skip write certificate request" \
890 -C "skip parse certificate request" \
891 -c "got a certificate request" \
892 -C "skip write certificate$" \
893 -c "skip write certificate verify" \
894 -c "got no certificate to send" \
895 -s "SSLv3 client has no certificate" \
896 -s "skip parse certificate verify" \
897 -s "! no client certificate sent" \
898 -S "! ssl_handshake returned" \
899 -C "! ssl_handshake returned" \
900 -S "X509 - Certificate verification failed"
901
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100902# tests for SNI
903
904run_test "SNI #0 (no SNI callback)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100905 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100906 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100907 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100908 server_name=localhost" \
909 0 \
910 -S "parse ServerName extension" \
911 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
912 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
913
914run_test "SNI #1 (matching cert 1)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100915 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100916 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100917 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 +0100918 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100919 server_name=localhost" \
920 0 \
921 -s "parse ServerName extension" \
922 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
923 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
924
925run_test "SNI #2 (matching cert 2)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100926 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100927 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100928 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 +0100929 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100930 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100931 0 \
932 -s "parse ServerName extension" \
933 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100934 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100935
936run_test "SNI #3 (no matching cert)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100937 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100938 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100939 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 +0100940 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100941 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100942 1 \
943 -s "parse ServerName extension" \
944 -s "ssl_sni_wrapper() returned" \
945 -s "ssl_handshake returned" \
946 -c "ssl_handshake returned" \
947 -c "SSL - A fatal alert message was received from our peer"
948
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +0100949# Tests for non-blocking I/O: exercise a variety of handshake flows
950
951run_test "Non-blocking I/O #1 (basic handshake)" \
952 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
953 "$P_CLI nbio=2 tickets=0" \
954 0 \
955 -S "ssl_handshake returned" \
956 -C "ssl_handshake returned" \
957 -c "Read from server: .* bytes read"
958
959run_test "Non-blocking I/O #2 (client auth)" \
960 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
961 "$P_CLI nbio=2 tickets=0" \
962 0 \
963 -S "ssl_handshake returned" \
964 -C "ssl_handshake returned" \
965 -c "Read from server: .* bytes read"
966
967run_test "Non-blocking I/O #3 (ticket)" \
968 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
969 "$P_CLI nbio=2 tickets=1" \
970 0 \
971 -S "ssl_handshake returned" \
972 -C "ssl_handshake returned" \
973 -c "Read from server: .* bytes read"
974
975run_test "Non-blocking I/O #4 (ticket + client auth)" \
976 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
977 "$P_CLI nbio=2 tickets=1" \
978 0 \
979 -S "ssl_handshake returned" \
980 -C "ssl_handshake returned" \
981 -c "Read from server: .* bytes read"
982
983run_test "Non-blocking I/O #5 (ticket + client auth + resume)" \
984 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
985 "$P_CLI nbio=2 tickets=1 reconnect=1" \
986 0 \
987 -S "ssl_handshake returned" \
988 -C "ssl_handshake returned" \
989 -c "Read from server: .* bytes read"
990
991run_test "Non-blocking I/O #6 (ticket + resume)" \
992 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
993 "$P_CLI nbio=2 tickets=1 reconnect=1" \
994 0 \
995 -S "ssl_handshake returned" \
996 -C "ssl_handshake returned" \
997 -c "Read from server: .* bytes read"
998
999run_test "Non-blocking I/O #7 (session-id resume)" \
1000 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1001 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1002 0 \
1003 -S "ssl_handshake returned" \
1004 -C "ssl_handshake returned" \
1005 -c "Read from server: .* bytes read"
1006
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001007# Tests for version negotiation
1008
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001009run_test "Version check #1 (all -> 1.2)" \
1010 "$P_SRV" \
1011 "$P_CLI" \
1012 0 \
1013 -S "ssl_handshake returned" \
1014 -C "ssl_handshake returned" \
1015 -s "Protocol is TLSv1.2" \
1016 -c "Protocol is TLSv1.2"
1017
1018run_test "Version check #2 (cli max 1.1 -> 1.1)" \
1019 "$P_SRV" \
1020 "$P_CLI max_version=tls1_1" \
1021 0 \
1022 -S "ssl_handshake returned" \
1023 -C "ssl_handshake returned" \
1024 -s "Protocol is TLSv1.1" \
1025 -c "Protocol is TLSv1.1"
1026
1027run_test "Version check #3 (srv max 1.1 -> 1.1)" \
1028 "$P_SRV max_version=tls1_1" \
1029 "$P_CLI" \
1030 0 \
1031 -S "ssl_handshake returned" \
1032 -C "ssl_handshake returned" \
1033 -s "Protocol is TLSv1.1" \
1034 -c "Protocol is TLSv1.1"
1035
1036run_test "Version check #4 (cli+srv max 1.1 -> 1.1)" \
1037 "$P_SRV max_version=tls1_1" \
1038 "$P_CLI max_version=tls1_1" \
1039 0 \
1040 -S "ssl_handshake returned" \
1041 -C "ssl_handshake returned" \
1042 -s "Protocol is TLSv1.1" \
1043 -c "Protocol is TLSv1.1"
1044
1045run_test "Version check #5 (cli max 1.1, srv min 1.1 -> 1.1)" \
1046 "$P_SRV min_version=tls1_1" \
1047 "$P_CLI max_version=tls1_1" \
1048 0 \
1049 -S "ssl_handshake returned" \
1050 -C "ssl_handshake returned" \
1051 -s "Protocol is TLSv1.1" \
1052 -c "Protocol is TLSv1.1"
1053
1054run_test "Version check #6 (cli min 1.1, srv max 1.1 -> 1.1)" \
1055 "$P_SRV max_version=tls1_1" \
1056 "$P_CLI min_version=tls1_1" \
1057 0 \
1058 -S "ssl_handshake returned" \
1059 -C "ssl_handshake returned" \
1060 -s "Protocol is TLSv1.1" \
1061 -c "Protocol is TLSv1.1"
1062
1063run_test "Version check #7 (cli min 1.2, srv max 1.1 -> fail)" \
1064 "$P_SRV max_version=tls1_1" \
1065 "$P_CLI min_version=tls1_2" \
1066 1 \
1067 -s "ssl_handshake returned" \
1068 -c "ssl_handshake returned" \
1069 -c "SSL - Handshake protocol not within min/max boundaries"
1070
1071run_test "Version check #8 (srv min 1.2, cli max 1.1 -> fail)" \
1072 "$P_SRV min_version=tls1_2" \
1073 "$P_CLI max_version=tls1_1" \
1074 1 \
1075 -s "ssl_handshake returned" \
1076 -c "ssl_handshake returned" \
1077 -s "SSL - Handshake protocol not within min/max boundaries"
1078
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001079# Tests for ALPN extension
1080
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001081if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1082
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001083run_test "ALPN #0 (none)" \
1084 "$P_SRV debug_level=4" \
1085 "$P_CLI debug_level=4" \
1086 0 \
1087 -C "client hello, adding alpn extension" \
1088 -S "found alpn extension" \
1089 -C "got an alert message, type: \\[2:120]" \
1090 -S "server hello, adding alpn extension" \
1091 -C "found alpn extension " \
1092 -C "Application Layer Protocol is" \
1093 -S "Application Layer Protocol is"
1094
1095run_test "ALPN #1 (client only)" \
1096 "$P_SRV debug_level=4" \
1097 "$P_CLI debug_level=4 alpn=abc,1234" \
1098 0 \
1099 -c "client hello, adding alpn extension" \
1100 -s "found alpn extension" \
1101 -C "got an alert message, type: \\[2:120]" \
1102 -S "server hello, adding alpn extension" \
1103 -C "found alpn extension " \
1104 -c "Application Layer Protocol is (none)" \
1105 -S "Application Layer Protocol is"
1106
1107run_test "ALPN #2 (server only)" \
1108 "$P_SRV debug_level=4 alpn=abc,1234" \
1109 "$P_CLI debug_level=4" \
1110 0 \
1111 -C "client hello, adding alpn extension" \
1112 -S "found alpn extension" \
1113 -C "got an alert message, type: \\[2:120]" \
1114 -S "server hello, adding alpn extension" \
1115 -C "found alpn extension " \
1116 -C "Application Layer Protocol is" \
1117 -s "Application Layer Protocol is (none)"
1118
1119run_test "ALPN #3 (both, common cli1-srv1)" \
1120 "$P_SRV debug_level=4 alpn=abc,1234" \
1121 "$P_CLI debug_level=4 alpn=abc,1234" \
1122 0 \
1123 -c "client hello, adding alpn extension" \
1124 -s "found alpn extension" \
1125 -C "got an alert message, type: \\[2:120]" \
1126 -s "server hello, adding alpn extension" \
1127 -c "found alpn extension" \
1128 -c "Application Layer Protocol is abc" \
1129 -s "Application Layer Protocol is abc"
1130
1131run_test "ALPN #4 (both, common cli2-srv1)" \
1132 "$P_SRV debug_level=4 alpn=abc,1234" \
1133 "$P_CLI debug_level=4 alpn=1234,abc" \
1134 0 \
1135 -c "client hello, adding alpn extension" \
1136 -s "found alpn extension" \
1137 -C "got an alert message, type: \\[2:120]" \
1138 -s "server hello, adding alpn extension" \
1139 -c "found alpn extension" \
1140 -c "Application Layer Protocol is abc" \
1141 -s "Application Layer Protocol is abc"
1142
1143run_test "ALPN #5 (both, common cli1-srv2)" \
1144 "$P_SRV debug_level=4 alpn=abc,1234" \
1145 "$P_CLI debug_level=4 alpn=1234,abcde" \
1146 0 \
1147 -c "client hello, adding alpn extension" \
1148 -s "found alpn extension" \
1149 -C "got an alert message, type: \\[2:120]" \
1150 -s "server hello, adding alpn extension" \
1151 -c "found alpn extension" \
1152 -c "Application Layer Protocol is 1234" \
1153 -s "Application Layer Protocol is 1234"
1154
1155run_test "ALPN #6 (both, no common)" \
1156 "$P_SRV debug_level=4 alpn=abc,123" \
1157 "$P_CLI debug_level=4 alpn=1234,abcde" \
1158 1 \
1159 -c "client hello, adding alpn extension" \
1160 -s "found alpn extension" \
1161 -c "got an alert message, type: \\[2:120]" \
1162 -S "server hello, adding alpn extension" \
1163 -C "found alpn extension" \
1164 -C "Application Layer Protocol is 1234" \
1165 -S "Application Layer Protocol is 1234"
1166
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001167fi
1168
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001169# Tests for keyUsage in leaf certificates, part 1:
1170# server-side certificate/suite selection
1171
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001172run_test "keyUsage srv #1 (RSA, digitalSignature -> (EC)DHE-RSA)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001173 "$P_SRV key_file=data_files/server2.key \
1174 crt_file=data_files/server2.ku-ds.crt" \
1175 "$P_CLI" \
1176 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001177 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001178
1179
1180run_test "keyUsage srv #2 (RSA, keyEncipherment -> RSA)" \
1181 "$P_SRV key_file=data_files/server2.key \
1182 crt_file=data_files/server2.ku-ke.crt" \
1183 "$P_CLI" \
1184 0 \
1185 -c "Ciphersuite is TLS-RSA-WITH-"
1186
1187# add psk to leave an option for client to send SERVERQUIT
1188run_test "keyUsage srv #3 (RSA, keyAgreement -> fail)" \
1189 "$P_SRV psk=abc123 key_file=data_files/server2.key \
1190 crt_file=data_files/server2.ku-ka.crt" \
1191 "$P_CLI psk=badbad" \
1192 1 \
1193 -C "Ciphersuite is "
1194
1195run_test "keyUsage srv #4 (ECDSA, digitalSignature -> ECDHE-ECDSA)" \
1196 "$P_SRV key_file=data_files/server5.key \
1197 crt_file=data_files/server5.ku-ds.crt" \
1198 "$P_CLI" \
1199 0 \
1200 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1201
1202
1203run_test "keyUsage srv #5 (ECDSA, keyAgreement -> ECDH-)" \
1204 "$P_SRV key_file=data_files/server5.key \
1205 crt_file=data_files/server5.ku-ka.crt" \
1206 "$P_CLI" \
1207 0 \
1208 -c "Ciphersuite is TLS-ECDH-"
1209
1210# add psk to leave an option for client to send SERVERQUIT
1211run_test "keyUsage srv #6 (ECDSA, keyEncipherment -> fail)" \
1212 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1213 crt_file=data_files/server5.ku-ke.crt" \
1214 "$P_CLI psk=badbad" \
1215 1 \
1216 -C "Ciphersuite is "
1217
1218# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001219# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001220
1221run_test "keyUsage cli #1 (DigitalSignature+KeyEncipherment, RSA: OK)" \
1222 "$O_SRV -key data_files/server2.key \
1223 -cert data_files/server2.ku-ds_ke.crt" \
1224 "$P_CLI debug_level=2 \
1225 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1226 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001227 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001228 -C "Processing of the Certificate handshake message failed" \
1229 -c "Ciphersuite is TLS-"
1230
1231run_test "keyUsage cli #2 (DigitalSignature+KeyEncipherment, DHE-RSA: OK)" \
1232 "$O_SRV -key data_files/server2.key \
1233 -cert data_files/server2.ku-ds_ke.crt" \
1234 "$P_CLI debug_level=2 \
1235 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1236 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001237 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001238 -C "Processing of the Certificate handshake message failed" \
1239 -c "Ciphersuite is TLS-"
1240
1241run_test "keyUsage cli #3 (KeyEncipherment, RSA: OK)" \
1242 "$O_SRV -key data_files/server2.key \
1243 -cert data_files/server2.ku-ke.crt" \
1244 "$P_CLI debug_level=2 \
1245 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1246 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001247 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001248 -C "Processing of the Certificate handshake message failed" \
1249 -c "Ciphersuite is TLS-"
1250
1251run_test "keyUsage cli #4 (KeyEncipherment, DHE-RSA: fail)" \
1252 "$O_SRV -key data_files/server2.key \
1253 -cert data_files/server2.ku-ke.crt" \
1254 "$P_CLI debug_level=2 \
1255 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1256 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001257 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001258 -c "Processing of the Certificate handshake message failed" \
1259 -C "Ciphersuite is TLS-"
1260
1261run_test "keyUsage cli #5 (DigitalSignature, DHE-RSA: OK)" \
1262 "$O_SRV -key data_files/server2.key \
1263 -cert data_files/server2.ku-ds.crt" \
1264 "$P_CLI debug_level=2 \
1265 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1266 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001267 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001268 -C "Processing of the Certificate handshake message failed" \
1269 -c "Ciphersuite is TLS-"
1270
1271run_test "keyUsage cli #5 (DigitalSignature, RSA: fail)" \
1272 "$O_SRV -key data_files/server2.key \
1273 -cert data_files/server2.ku-ds.crt" \
1274 "$P_CLI debug_level=2 \
1275 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1276 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001277 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001278 -c "Processing of the Certificate handshake message failed" \
1279 -C "Ciphersuite is TLS-"
1280
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001281# Tests for keyUsage in leaf certificates, part 3:
1282# server-side checking of client cert
1283
1284run_test "keyUsage cli-auth #1 (RSA, DigitalSignature: OK)" \
1285 "$P_SRV debug_level=2 auth_mode=optional" \
1286 "$O_CLI -key data_files/server2.key \
1287 -cert data_files/server2.ku-ds.crt" \
1288 0 \
1289 -S "bad certificate (usage extensions)" \
1290 -S "Processing of the Certificate handshake message failed"
1291
1292run_test "keyUsage cli-auth #2 (RSA, KeyEncipherment: fail (soft))" \
1293 "$P_SRV debug_level=2 auth_mode=optional" \
1294 "$O_CLI -key data_files/server2.key \
1295 -cert data_files/server2.ku-ke.crt" \
1296 0 \
1297 -s "bad certificate (usage extensions)" \
1298 -S "Processing of the Certificate handshake message failed"
1299
1300run_test "keyUsage cli-auth #3 (RSA, KeyEncipherment: fail (hard))" \
1301 "$P_SRV debug_level=2 auth_mode=required" \
1302 "$O_CLI -key data_files/server2.key \
1303 -cert data_files/server2.ku-ke.crt" \
1304 1 \
1305 -s "bad certificate (usage extensions)" \
1306 -s "Processing of the Certificate handshake message failed"
1307
1308run_test "keyUsage cli-auth #4 (ECDSA, DigitalSignature: OK)" \
1309 "$P_SRV debug_level=2 auth_mode=optional" \
1310 "$O_CLI -key data_files/server5.key \
1311 -cert data_files/server5.ku-ds.crt" \
1312 0 \
1313 -S "bad certificate (usage extensions)" \
1314 -S "Processing of the Certificate handshake message failed"
1315
1316run_test "keyUsage cli-auth #5 (ECDSA, KeyAgreement: fail (soft))" \
1317 "$P_SRV debug_level=2 auth_mode=optional" \
1318 "$O_CLI -key data_files/server5.key \
1319 -cert data_files/server5.ku-ka.crt" \
1320 0 \
1321 -s "bad certificate (usage extensions)" \
1322 -S "Processing of the Certificate handshake message failed"
1323
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001324# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1325
1326run_test "extKeyUsage srv #1 (serverAuth -> OK)" \
1327 "$P_SRV key_file=data_files/server5.key \
1328 crt_file=data_files/server5.eku-srv.crt" \
1329 "$P_CLI" \
1330 0
1331
1332run_test "extKeyUsage srv #2 (serverAuth,clientAuth -> OK)" \
1333 "$P_SRV key_file=data_files/server5.key \
1334 crt_file=data_files/server5.eku-srv.crt" \
1335 "$P_CLI" \
1336 0
1337
1338run_test "extKeyUsage srv #3 (codeSign,anyEKU -> OK)" \
1339 "$P_SRV key_file=data_files/server5.key \
1340 crt_file=data_files/server5.eku-cs_any.crt" \
1341 "$P_CLI" \
1342 0
1343
1344# add psk to leave an option for client to send SERVERQUIT
1345run_test "extKeyUsage srv #4 (codeSign -> fail)" \
1346 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1347 crt_file=data_files/server5.eku-cli.crt" \
1348 "$P_CLI psk=badbad" \
1349 1
1350
1351# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1352
1353run_test "extKeyUsage cli #1 (serverAuth -> OK)" \
1354 "$O_SRV -key data_files/server5.key \
1355 -cert data_files/server5.eku-srv.crt" \
1356 "$P_CLI debug_level=2" \
1357 0 \
1358 -C "bad certificate (usage extensions)" \
1359 -C "Processing of the Certificate handshake message failed" \
1360 -c "Ciphersuite is TLS-"
1361
1362run_test "extKeyUsage cli #2 (serverAuth,clientAuth -> OK)" \
1363 "$O_SRV -key data_files/server5.key \
1364 -cert data_files/server5.eku-srv_cli.crt" \
1365 "$P_CLI debug_level=2" \
1366 0 \
1367 -C "bad certificate (usage extensions)" \
1368 -C "Processing of the Certificate handshake message failed" \
1369 -c "Ciphersuite is TLS-"
1370
1371run_test "extKeyUsage cli #3 (codeSign,anyEKU -> OK)" \
1372 "$O_SRV -key data_files/server5.key \
1373 -cert data_files/server5.eku-cs_any.crt" \
1374 "$P_CLI debug_level=2" \
1375 0 \
1376 -C "bad certificate (usage extensions)" \
1377 -C "Processing of the Certificate handshake message failed" \
1378 -c "Ciphersuite is TLS-"
1379
1380run_test "extKeyUsage cli #4 (codeSign -> fail)" \
1381 "$O_SRV -key data_files/server5.key \
1382 -cert data_files/server5.eku-cs.crt" \
1383 "$P_CLI debug_level=2" \
1384 1 \
1385 -c "bad certificate (usage extensions)" \
1386 -c "Processing of the Certificate handshake message failed" \
1387 -C "Ciphersuite is TLS-"
1388
1389# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1390
1391run_test "extKeyUsage cli-auth #1 (clientAuth -> OK)" \
1392 "$P_SRV debug_level=2 auth_mode=optional" \
1393 "$O_CLI -key data_files/server5.key \
1394 -cert data_files/server5.eku-cli.crt" \
1395 0 \
1396 -S "bad certificate (usage extensions)" \
1397 -S "Processing of the Certificate handshake message failed"
1398
1399run_test "extKeyUsage cli-auth #2 (serverAuth,clientAuth -> OK)" \
1400 "$P_SRV debug_level=2 auth_mode=optional" \
1401 "$O_CLI -key data_files/server5.key \
1402 -cert data_files/server5.eku-srv_cli.crt" \
1403 0 \
1404 -S "bad certificate (usage extensions)" \
1405 -S "Processing of the Certificate handshake message failed"
1406
1407run_test "extKeyUsage cli-auth #3 (codeSign,anyEKU -> OK)" \
1408 "$P_SRV debug_level=2 auth_mode=optional" \
1409 "$O_CLI -key data_files/server5.key \
1410 -cert data_files/server5.eku-cs_any.crt" \
1411 0 \
1412 -S "bad certificate (usage extensions)" \
1413 -S "Processing of the Certificate handshake message failed"
1414
1415run_test "extKeyUsage cli-auth #4 (codeSign -> fail (soft))" \
1416 "$P_SRV debug_level=2 auth_mode=optional" \
1417 "$O_CLI -key data_files/server5.key \
1418 -cert data_files/server5.eku-cs.crt" \
1419 0 \
1420 -s "bad certificate (usage extensions)" \
1421 -S "Processing of the Certificate handshake message failed"
1422
1423run_test "extKeyUsage cli-auth #4b (codeSign -> fail (hard))" \
1424 "$P_SRV debug_level=2 auth_mode=required" \
1425 "$O_CLI -key data_files/server5.key \
1426 -cert data_files/server5.eku-cs.crt" \
1427 1 \
1428 -s "bad certificate (usage extensions)" \
1429 -s "Processing of the Certificate handshake message failed"
1430
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001431# Tests for DHM parameters loading
1432
1433run_test "DHM parameters #0 (reference)" \
1434 "$P_SRV" \
1435 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1436 debug_level=3" \
1437 0 \
1438 -c "value of 'DHM: P ' (2048 bits)" \
1439 -c "value of 'DHM: G ' (2048 bits)"
1440
1441run_test "DHM parameters #1 (other parameters)" \
1442 "$P_SRV dhm_file=data_files/dhparams.pem" \
1443 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1444 debug_level=3" \
1445 0 \
1446 -c "value of 'DHM: P ' (1024 bits)" \
1447 -c "value of 'DHM: G ' (2 bits)"
1448
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001449# Tests for PSK callback
1450
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001451run_test "PSK callback #0a (psk, no callback)" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001452 "$P_SRV psk=abc123 psk_identity=foo" \
1453 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1454 psk_identity=foo psk=abc123" \
1455 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001456 -S "SSL - The server has no ciphersuites in common" \
1457 -S "SSL - Unknown identity received" \
1458 -S "SSL - Verification of the message MAC failed"
1459
1460run_test "PSK callback #0b (no psk, no callback)" \
1461 "$P_SRV" \
1462 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1463 psk_identity=foo psk=abc123" \
1464 1 \
1465 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001466 -S "SSL - Unknown identity received" \
1467 -S "SSL - Verification of the message MAC failed"
1468
1469run_test "PSK callback #1 (callback overrides other settings)" \
1470 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1471 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1472 psk_identity=foo psk=abc123" \
1473 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001474 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001475 -s "SSL - Unknown identity received" \
1476 -S "SSL - Verification of the message MAC failed"
1477
1478run_test "PSK callback #2 (first id matches)" \
1479 "$P_SRV psk_list=abc,dead,def,beef" \
1480 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1481 psk_identity=abc psk=dead" \
1482 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001483 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001484 -S "SSL - Unknown identity received" \
1485 -S "SSL - Verification of the message MAC failed"
1486
1487run_test "PSK callback #3 (second id matches)" \
1488 "$P_SRV psk_list=abc,dead,def,beef" \
1489 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1490 psk_identity=def psk=beef" \
1491 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001492 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001493 -S "SSL - Unknown identity received" \
1494 -S "SSL - Verification of the message MAC failed"
1495
1496run_test "PSK callback #4 (no match)" \
1497 "$P_SRV psk_list=abc,dead,def,beef" \
1498 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1499 psk_identity=ghi psk=beef" \
1500 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001501 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001502 -s "SSL - Unknown identity received" \
1503 -S "SSL - Verification of the message MAC failed"
1504
1505run_test "PSK callback #5 (wrong key)" \
1506 "$P_SRV psk_list=abc,dead,def,beef" \
1507 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1508 psk_identity=abc psk=beef" \
1509 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001510 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001511 -S "SSL - Unknown identity received" \
1512 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001513
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001514# Tests for ciphersuites per version
1515
1516run_test "Per-version suites #1" \
1517 "$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" \
1518 "$P_CLI force_version=ssl3" \
1519 0 \
1520 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1521
1522run_test "Per-version suites #2" \
1523 "$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" \
1524 "$P_CLI force_version=tls1" \
1525 0 \
1526 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1527
1528run_test "Per-version suites #3" \
1529 "$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" \
1530 "$P_CLI force_version=tls1_1" \
1531 0 \
1532 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1533
1534run_test "Per-version suites #4" \
1535 "$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" \
1536 "$P_CLI force_version=tls1_2" \
1537 0 \
1538 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1539
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001540# Tests for ssl_get_bytes_avail()
1541
1542run_test "ssl_get_bytes_avail #1 (no extra data)" \
1543 "$P_SRV" \
1544 "$P_CLI request_size=100" \
1545 0 \
1546 -s "Read from client: 100 bytes read$"
1547
1548run_test "ssl_get_bytes_avail #2 (extra data)" \
1549 "$P_SRV" \
1550 "$P_CLI request_size=500" \
1551 0 \
1552 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001553
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001554# Tests for small packets
1555
1556run_test "Small packet SSLv3 BlockCipher" \
1557 "$P_SRV" \
1558 "$P_CLI request_size=1 force_version=ssl3 \
1559 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1560 0 \
1561 -s "Read from client: 1 bytes read"
1562
1563run_test "Small packet SSLv3 StreamCipher" \
1564 "$P_SRV" \
1565 "$P_CLI request_size=1 force_version=ssl3 \
1566 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1567 0 \
1568 -s "Read from client: 1 bytes read"
1569
1570run_test "Small packet TLS 1.0 BlockCipher" \
1571 "$P_SRV" \
1572 "$P_CLI request_size=1 force_version=tls1 \
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.0 BlockCipher truncated MAC" \
1578 "$P_SRV" \
1579 "$P_CLI request_size=1 force_version=tls1 \
1580 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1581 trunc_hmac=1" \
1582 0 \
1583 -s "Read from client: 1 bytes read"
1584
1585run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1586 "$P_SRV" \
1587 "$P_CLI request_size=1 force_version=tls1 \
1588 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1589 trunc_hmac=1" \
1590 0 \
1591 -s "Read from client: 1 bytes read"
1592
1593run_test "Small packet TLS 1.1 BlockCipher" \
1594 "$P_SRV" \
1595 "$P_CLI request_size=1 force_version=tls1_1 \
1596 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1597 0 \
1598 -s "Read from client: 1 bytes read"
1599
1600run_test "Small packet TLS 1.1 StreamCipher" \
1601 "$P_SRV" \
1602 "$P_CLI request_size=1 force_version=tls1_1 \
1603 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1604 0 \
1605 -s "Read from client: 1 bytes read"
1606
1607run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1608 "$P_SRV" \
1609 "$P_CLI request_size=1 force_version=tls1_1 \
1610 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1611 trunc_hmac=1" \
1612 0 \
1613 -s "Read from client: 1 bytes read"
1614
1615run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1616 "$P_SRV" \
1617 "$P_CLI request_size=1 force_version=tls1_1 \
1618 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1619 trunc_hmac=1" \
1620 0 \
1621 -s "Read from client: 1 bytes read"
1622
1623run_test "Small packet TLS 1.2 BlockCipher" \
1624 "$P_SRV" \
1625 "$P_CLI request_size=1 force_version=tls1_2 \
1626 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1627 0 \
1628 -s "Read from client: 1 bytes read"
1629
1630run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1631 "$P_SRV" \
1632 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1633 0 \
1634 -s "Read from client: 1 bytes read"
1635
1636run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1637 "$P_SRV" \
1638 "$P_CLI request_size=1 force_version=tls1_2 \
1639 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1640 trunc_hmac=1" \
1641 0 \
1642 -s "Read from client: 1 bytes read"
1643
1644run_test "Small packet TLS 1.2 StreamCipher" \
1645 "$P_SRV" \
1646 "$P_CLI request_size=1 force_version=tls1_2 \
1647 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1648 0 \
1649 -s "Read from client: 1 bytes read"
1650
1651run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1652 "$P_SRV" \
1653 "$P_CLI request_size=1 force_version=tls1_2 \
1654 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1655 trunc_hmac=1" \
1656 0 \
1657 -s "Read from client: 1 bytes read"
1658
1659run_test "Small packet TLS 1.2 AEAD" \
1660 "$P_SRV" \
1661 "$P_CLI request_size=1 force_version=tls1_2 \
1662 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1663 0 \
1664 -s "Read from client: 1 bytes read"
1665
1666run_test "Small packet TLS 1.2 AEAD shorter tag" \
1667 "$P_SRV" \
1668 "$P_CLI request_size=1 force_version=tls1_2 \
1669 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1670 0 \
1671 -s "Read from client: 1 bytes read"
1672
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001673# Test for large packets
1674
1675run_test "Large packet SSLv3 BlockCipher" \
1676 "$P_SRV" \
1677 "$P_CLI request_size=16384 force_version=ssl3 \
1678 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1679 0 \
1680 -s "Read from client: 16384 bytes read"
1681
1682run_test "Large packet SSLv3 StreamCipher" \
1683 "$P_SRV" \
1684 "$P_CLI request_size=16384 force_version=ssl3 \
1685 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1686 0 \
1687 -s "Read from client: 16384 bytes read"
1688
1689run_test "Large packet TLS 1.0 BlockCipher" \
1690 "$P_SRV" \
1691 "$P_CLI request_size=16384 force_version=tls1 \
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.0 BlockCipher truncated MAC" \
1697 "$P_SRV" \
1698 "$P_CLI request_size=16384 force_version=tls1 \
1699 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1700 trunc_hmac=1" \
1701 0 \
1702 -s "Read from client: 16384 bytes read"
1703
1704run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1705 "$P_SRV" \
1706 "$P_CLI request_size=16384 force_version=tls1 \
1707 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1708 trunc_hmac=1" \
1709 0 \
1710 -s "Read from client: 16384 bytes read"
1711
1712run_test "Large packet TLS 1.1 BlockCipher" \
1713 "$P_SRV" \
1714 "$P_CLI request_size=16384 force_version=tls1_1 \
1715 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1716 0 \
1717 -s "Read from client: 16384 bytes read"
1718
1719run_test "Large packet TLS 1.1 StreamCipher" \
1720 "$P_SRV" \
1721 "$P_CLI request_size=16384 force_version=tls1_1 \
1722 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1723 0 \
1724 -s "Read from client: 16384 bytes read"
1725
1726run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1727 "$P_SRV" \
1728 "$P_CLI request_size=16384 force_version=tls1_1 \
1729 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1730 trunc_hmac=1" \
1731 0 \
1732 -s "Read from client: 16384 bytes read"
1733
1734run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1735 "$P_SRV" \
1736 "$P_CLI request_size=16384 force_version=tls1_1 \
1737 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1738 trunc_hmac=1" \
1739 0 \
1740 -s "Read from client: 16384 bytes read"
1741
1742run_test "Large packet TLS 1.2 BlockCipher" \
1743 "$P_SRV" \
1744 "$P_CLI request_size=16384 force_version=tls1_2 \
1745 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1746 0 \
1747 -s "Read from client: 16384 bytes read"
1748
1749run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1750 "$P_SRV" \
1751 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1752 0 \
1753 -s "Read from client: 16384 bytes read"
1754
1755run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1756 "$P_SRV" \
1757 "$P_CLI request_size=16384 force_version=tls1_2 \
1758 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1759 trunc_hmac=1" \
1760 0 \
1761 -s "Read from client: 16384 bytes read"
1762
1763run_test "Large packet TLS 1.2 StreamCipher" \
1764 "$P_SRV" \
1765 "$P_CLI request_size=16384 force_version=tls1_2 \
1766 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1767 0 \
1768 -s "Read from client: 16384 bytes read"
1769
1770run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1771 "$P_SRV" \
1772 "$P_CLI request_size=16384 force_version=tls1_2 \
1773 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1774 trunc_hmac=1" \
1775 0 \
1776 -s "Read from client: 16384 bytes read"
1777
1778run_test "Large packet TLS 1.2 AEAD" \
1779 "$P_SRV" \
1780 "$P_CLI request_size=16384 force_version=tls1_2 \
1781 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1782 0 \
1783 -s "Read from client: 16384 bytes read"
1784
1785run_test "Large packet TLS 1.2 AEAD shorter tag" \
1786 "$P_SRV" \
1787 "$P_CLI request_size=16384 force_version=tls1_2 \
1788 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1789 0 \
1790 -s "Read from client: 16384 bytes read"
1791
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001792# Final report
1793
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001794echo "------------------------------------------------------------------------"
1795
1796if [ $FAILS = 0 ]; then
1797 echo -n "PASSED"
1798else
1799 echo -n "FAILED"
1800fi
1801PASSES=`echo $TESTS - $FAILS | bc`
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001802echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001803
1804exit $FAILS