blob: 4eafed436f40a03548aeeeaca3af9494e445a1b9 [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
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 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 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200100 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100101 for i in `seq 1 $LEN`; do echo -n '.'; done
102 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100103
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200104 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100105}
106
107# fail <message>
108fail() {
109 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100110 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100111
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200112 mv $SRV_OUT o-srv-${TESTS}.log
113 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100114 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100115
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200116 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
117 echo " ! server output:"
118 cat o-srv-${TESTS}.log
119 echo " ! ============================================================"
120 echo " ! client output:"
121 cat o-cli-${TESTS}.log
122 fi
123
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200124 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100125}
126
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100127# is_polar <cmd_line>
128is_polar() {
129 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
130}
131
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100132# has_mem_err <log_file_name>
133has_mem_err() {
134 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
135 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
136 then
137 return 1 # false: does not have errors
138 else
139 return 0 # true: has errors
140 fi
141}
142
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200143# wait for server to start: two versions depending on lsof availability
144wait_server_start() {
145 if which lsof >/dev/null; then
146 # make sure we don't loop forever
147 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
148 WATCHDOG_PID=$!
149
150 # make a tight loop, server usually takes less than 1 sec to start
151 until lsof -nbi TCP:"$PORT" | grep LISTEN >/dev/null; do :; done
152
153 kill $WATCHDOG_PID
154 wait $WATCHDOG_PID
155 else
156 sleep "$START_DELAY"
157 fi
158}
159
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200160# wait for client to terminate and set CLI_EXIT
161# must be called right after starting the client
162wait_client_done() {
163 CLI_PID=$!
164
165 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
166 WATCHDOG_PID=$!
167
168 wait $CLI_PID
169 CLI_EXIT=$?
170
171 kill $WATCHDOG_PID
172 wait $WATCHDOG_PID
173
174 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
175}
176
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100177# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100178# Options: -s pattern pattern that must be present in server output
179# -c pattern pattern that must be present in client output
180# -S pattern pattern that must be absent in server output
181# -C pattern pattern that must be absent in client output
182run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100183 NAME="$1"
184 SRV_CMD="$2"
185 CLI_CMD="$3"
186 CLI_EXPECT="$4"
187 shift 4
188
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100189 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
190 else
191 return
192 fi
193
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100194 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100195
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200196 # should we skip?
197 if [ "X$SKIP_NEXT" = "XYES" ]; then
198 SKIP_NEXT="NO"
199 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200200 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200201 return
202 fi
203
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100204 # prepend valgrind to our commands if active
205 if [ "$MEMCHECK" -gt 0 ]; then
206 if is_polar "$SRV_CMD"; then
207 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
208 fi
209 if is_polar "$CLI_CMD"; then
210 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
211 fi
212 fi
213
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100214 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200215 echo "$SRV_CMD" > $SRV_OUT
216 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100217 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200218 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200219
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200220 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200221 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
222 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100223
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200224 # kill the server
225 kill $SRV_PID
226 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100227
228 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200229 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100230 # expected client exit to incorrectly succeed in case of catastrophic
231 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100232 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200233 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100234 else
235 fail "server failed to start"
236 return
237 fi
238 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100239 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200240 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100241 else
242 fail "client failed to start"
243 return
244 fi
245 fi
246
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100247 # check server exit code
248 if [ $? != 0 ]; then
249 fail "server fail"
250 return
251 fi
252
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100253 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100254 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
255 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100256 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100257 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100258 return
259 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100260
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100261 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200262 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100263 while [ $# -gt 0 ]
264 do
265 case $1 in
266 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200267 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100268 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100269 return
270 fi
271 ;;
272
273 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200274 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100275 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100276 return
277 fi
278 ;;
279
280 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200281 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100282 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100283 return
284 fi
285 ;;
286
287 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200288 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100289 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100290 return
291 fi
292 ;;
293
294 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200295 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100296 exit 1
297 esac
298 shift 2
299 done
300
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100301 # check valgrind's results
302 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200303 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100304 fail "Server has memory errors"
305 return
306 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200307 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100308 fail "Client has memory errors"
309 return
310 fi
311 fi
312
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100313 # if we're here, everything is ok
314 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200315 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100316}
317
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100318cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200319 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200320 kill $SRV_PID >/dev/null 2>&1
321 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100322 exit 1
323}
324
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100325#
326# MAIN
327#
328
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100329get_options "$@"
330
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100331# sanity checks, avoid an avalanche of errors
332if [ ! -x "$P_SRV" ]; then
333 echo "Command '$P_SRV' is not an executable file"
334 exit 1
335fi
336if [ ! -x "$P_CLI" ]; then
337 echo "Command '$P_CLI' is not an executable file"
338 exit 1
339fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100340if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
341 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100342 exit 1
343fi
344
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200345# used by watchdog
346MAIN_PID="$$"
347
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200348# be more patient with valgrind
349if [ "$MEMCHECK" -gt 0 ]; then
350 START_DELAY=3
351 DOG_DELAY=30
352else
353 START_DELAY=1
354 DOG_DELAY=10
355fi
356
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200357# Pick a "unique" port in the range 10000-19999.
358PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200359PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200360
361# fix commands to use this port
362P_SRV="$P_SRV server_port=$PORT"
363P_CLI="$P_CLI server_port=$PORT"
364O_SRV="$O_SRV -accept $PORT"
365O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200366G_SRV="$G_SRV -p $PORT"
367G_CLI="$G_CLI -p $PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200368
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200369# Also pick a unique name for intermediate files
370SRV_OUT="srv_out.$$"
371CLI_OUT="cli_out.$$"
372SESSION="session.$$"
373
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200374SKIP_NEXT="NO"
375
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100376trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100377
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200378# Basic test
379
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200380# Checks that:
381# - things work with all ciphersuites active (used with config-full in all.sh)
382# - the expected (highest security) parameters are selected
383# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200384run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200385 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200386 "$P_CLI" \
387 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200388 -s "Protocol is TLSv1.2" \
389 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
390 -s "client hello v3, signature_algorithm ext: 6" \
391 -s "ECDHE curve: secp521r1" \
392 -S "error" \
393 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200394
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100395# Test for SSLv2 ClientHello
396
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200397requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200398run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100399 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100400 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100401 0 \
402 -S "parse client hello v2" \
403 -S "ssl_handshake returned"
404
405# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200406requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200407run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200408 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100409 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100410 0 \
411 -s "parse client hello v2" \
412 -S "ssl_handshake returned"
413
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100414# Tests for Truncated HMAC extension
415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200416run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200417 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100418 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100419 0 \
420 -s "dumping 'computed mac' (20 bytes)"
421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200422run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200423 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100424 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100425 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100426 -s "dumping 'computed mac' (10 bytes)"
427
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100428# Tests for Session Tickets
429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200430run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200431 "$P_SRV debug_level=3 tickets=1" \
432 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100433 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100434 -c "client hello, adding session ticket extension" \
435 -s "found session ticket extension" \
436 -s "server hello, adding session ticket extension" \
437 -c "found session_ticket extension" \
438 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100439 -S "session successfully restored from cache" \
440 -s "session successfully restored from ticket" \
441 -s "a session has been resumed" \
442 -c "a session has been resumed"
443
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200444run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200445 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
446 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100447 0 \
448 -c "client hello, adding session ticket extension" \
449 -s "found session ticket extension" \
450 -s "server hello, adding session ticket extension" \
451 -c "found session_ticket extension" \
452 -c "parse new session ticket" \
453 -S "session successfully restored from cache" \
454 -s "session successfully restored from ticket" \
455 -s "a session has been resumed" \
456 -c "a session has been resumed"
457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200458run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200459 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
460 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100461 0 \
462 -c "client hello, adding session ticket extension" \
463 -s "found session ticket extension" \
464 -s "server hello, adding session ticket extension" \
465 -c "found session_ticket extension" \
466 -c "parse new session ticket" \
467 -S "session successfully restored from cache" \
468 -S "session successfully restored from ticket" \
469 -S "a session has been resumed" \
470 -C "a session has been resumed"
471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200472run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100473 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200474 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100475 0 \
476 -c "client hello, adding session ticket extension" \
477 -c "found session_ticket extension" \
478 -c "parse new session ticket" \
479 -c "a session has been resumed"
480
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200481run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200482 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200483 "( $O_CLI -sess_out $SESSION; \
484 $O_CLI -sess_in $SESSION; \
485 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100486 0 \
487 -s "found session ticket extension" \
488 -s "server hello, adding session ticket extension" \
489 -S "session successfully restored from cache" \
490 -s "session successfully restored from ticket" \
491 -s "a session has been resumed"
492
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100493# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200495run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200496 "$P_SRV debug_level=3 tickets=0" \
497 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100498 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100499 -c "client hello, adding session ticket extension" \
500 -s "found session ticket extension" \
501 -S "server hello, adding session ticket extension" \
502 -C "found session_ticket extension" \
503 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100504 -s "session successfully restored from cache" \
505 -S "session successfully restored from ticket" \
506 -s "a session has been resumed" \
507 -c "a session has been resumed"
508
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200509run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200510 "$P_SRV debug_level=3 tickets=1" \
511 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100512 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100513 -C "client hello, adding session ticket extension" \
514 -S "found session ticket extension" \
515 -S "server hello, adding session ticket extension" \
516 -C "found session_ticket extension" \
517 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100518 -s "session successfully restored from cache" \
519 -S "session successfully restored from ticket" \
520 -s "a session has been resumed" \
521 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200523run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200524 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
525 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100526 0 \
527 -S "session successfully restored from cache" \
528 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100529 -S "a session has been resumed" \
530 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200532run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200533 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
534 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100535 0 \
536 -s "session successfully restored from cache" \
537 -S "session successfully restored from ticket" \
538 -s "a session has been resumed" \
539 -c "a session has been resumed"
540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200541run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200542 "$P_SRV debug_level=3 tickets=0" \
543 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100544 0 \
545 -s "session successfully restored from cache" \
546 -S "session successfully restored from ticket" \
547 -s "a session has been resumed" \
548 -c "a session has been resumed"
549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200550run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200551 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
552 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100553 0 \
554 -S "session successfully restored from cache" \
555 -S "session successfully restored from ticket" \
556 -S "a session has been resumed" \
557 -C "a session has been resumed"
558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200559run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200560 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
561 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100562 0 \
563 -s "session successfully restored from cache" \
564 -S "session successfully restored from ticket" \
565 -s "a session has been resumed" \
566 -c "a session has been resumed"
567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200568run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200569 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200570 "( $O_CLI -sess_out $SESSION; \
571 $O_CLI -sess_in $SESSION; \
572 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100573 0 \
574 -s "found session ticket extension" \
575 -S "server hello, adding session ticket extension" \
576 -s "session successfully restored from cache" \
577 -S "session successfully restored from ticket" \
578 -s "a session has been resumed"
579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200580run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100581 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200582 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100583 0 \
584 -C "found session_ticket extension" \
585 -C "parse new session ticket" \
586 -c "a session has been resumed"
587
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100588# Tests for Max Fragment Length extension
589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200590run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200591 "$P_SRV debug_level=3" \
592 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100593 0 \
594 -C "client hello, adding max_fragment_length extension" \
595 -S "found max fragment length extension" \
596 -S "server hello, max_fragment_length extension" \
597 -C "found max_fragment_length extension"
598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200599run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200600 "$P_SRV debug_level=3" \
601 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100602 0 \
603 -c "client hello, adding max_fragment_length extension" \
604 -s "found max fragment length extension" \
605 -s "server hello, max_fragment_length extension" \
606 -c "found max_fragment_length extension"
607
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200608run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200609 "$P_SRV debug_level=3 max_frag_len=4096" \
610 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100611 0 \
612 -C "client hello, adding max_fragment_length extension" \
613 -S "found max fragment length extension" \
614 -S "server hello, max_fragment_length extension" \
615 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200617requires_gnutls
618run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200619 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200620 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200621 0 \
622 -c "client hello, adding max_fragment_length extension" \
623 -c "found max_fragment_length extension"
624
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100625# Tests for renegotiation
626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200627run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200628 "$P_SRV debug_level=3 exchanges=2" \
629 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100630 0 \
631 -C "client hello, adding renegotiation extension" \
632 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
633 -S "found renegotiation extension" \
634 -s "server hello, secure renegotiation extension" \
635 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100636 -C "=> renegotiate" \
637 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100638 -S "write hello request"
639
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200640run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200641 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
642 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100643 0 \
644 -c "client hello, adding renegotiation extension" \
645 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
646 -s "found renegotiation extension" \
647 -s "server hello, secure renegotiation extension" \
648 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100649 -c "=> renegotiate" \
650 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100651 -S "write hello request"
652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200653run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200654 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
655 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100656 0 \
657 -c "client hello, adding renegotiation extension" \
658 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
659 -s "found renegotiation extension" \
660 -s "server hello, secure renegotiation extension" \
661 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100662 -c "=> renegotiate" \
663 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100664 -s "write hello request"
665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200666run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200667 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
668 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100669 0 \
670 -c "client hello, adding renegotiation extension" \
671 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
672 -s "found renegotiation extension" \
673 -s "server hello, secure renegotiation extension" \
674 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100675 -c "=> renegotiate" \
676 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100677 -s "write hello request"
678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200679run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200680 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
681 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100682 1 \
683 -c "client hello, adding renegotiation extension" \
684 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
685 -S "found renegotiation extension" \
686 -s "server hello, secure renegotiation extension" \
687 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100688 -c "=> renegotiate" \
689 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200690 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200691 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200692 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200694run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200695 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
696 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100697 0 \
698 -C "client hello, adding renegotiation extension" \
699 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
700 -S "found renegotiation extension" \
701 -s "server hello, secure renegotiation extension" \
702 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100703 -C "=> renegotiate" \
704 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100705 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200706 -S "SSL - An unexpected message was received from our peer" \
707 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200709run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200710 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200711 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200712 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200713 0 \
714 -C "client hello, adding renegotiation extension" \
715 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
716 -S "found renegotiation extension" \
717 -s "server hello, secure renegotiation extension" \
718 -c "found renegotiation extension" \
719 -C "=> renegotiate" \
720 -S "=> renegotiate" \
721 -s "write hello request" \
722 -S "SSL - An unexpected message was received from our peer" \
723 -S "failed"
724
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200725# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200726run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200727 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200728 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200729 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200730 0 \
731 -C "client hello, adding renegotiation extension" \
732 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
733 -S "found renegotiation extension" \
734 -s "server hello, secure renegotiation extension" \
735 -c "found renegotiation extension" \
736 -C "=> renegotiate" \
737 -S "=> renegotiate" \
738 -s "write hello request" \
739 -S "SSL - An unexpected message was received from our peer" \
740 -S "failed"
741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200742run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200743 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200744 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200745 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200746 0 \
747 -C "client hello, adding renegotiation extension" \
748 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
749 -S "found renegotiation extension" \
750 -s "server hello, secure renegotiation extension" \
751 -c "found renegotiation extension" \
752 -C "=> renegotiate" \
753 -S "=> renegotiate" \
754 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200755 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200757run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200758 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200759 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200760 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200761 0 \
762 -c "client hello, adding renegotiation extension" \
763 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
764 -s "found renegotiation extension" \
765 -s "server hello, secure renegotiation extension" \
766 -c "found renegotiation extension" \
767 -c "=> renegotiate" \
768 -s "=> renegotiate" \
769 -s "write hello request" \
770 -S "SSL - An unexpected message was received from our peer" \
771 -S "failed"
772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200773run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200774 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
775 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200776 0 \
777 -c "client hello, adding renegotiation extension" \
778 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
779 -s "found renegotiation extension" \
780 -s "server hello, secure renegotiation extension" \
781 -c "found renegotiation extension" \
782 -c "=> renegotiate" \
783 -s "=> renegotiate" \
784 -S "write hello request"
785
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200786run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200787 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
788 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200789 0 \
790 -c "client hello, adding renegotiation extension" \
791 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
792 -s "found renegotiation extension" \
793 -s "server hello, secure renegotiation extension" \
794 -c "found renegotiation extension" \
795 -c "=> renegotiate" \
796 -s "=> renegotiate" \
797 -s "write hello request"
798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200799run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200800 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200801 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200802 0 \
803 -c "client hello, adding renegotiation extension" \
804 -c "found renegotiation extension" \
805 -c "=> renegotiate" \
806 -C "ssl_handshake returned" \
807 -C "error" \
808 -c "HTTP/1.0 200 [Oo][Kk]"
809
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200810run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200811 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200812 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200813 0 \
814 -c "client hello, adding renegotiation extension" \
815 -c "found renegotiation extension" \
816 -c "=> renegotiate" \
817 -C "ssl_handshake returned" \
818 -C "error" \
819 -c "HTTP/1.0 200 [Oo][Kk]"
820
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100821# Tests for auth_mode
822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200823run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100824 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100825 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200826 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100827 1 \
828 -c "x509_verify_cert() returned" \
829 -c "! self-signed or not signed by a trusted CA" \
830 -c "! ssl_handshake returned" \
831 -c "X509 - Certificate verification failed"
832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200833run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100834 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100835 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200836 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100837 0 \
838 -c "x509_verify_cert() returned" \
839 -c "! self-signed or not signed by a trusted CA" \
840 -C "! ssl_handshake returned" \
841 -C "X509 - Certificate verification failed"
842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200843run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100844 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100845 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200846 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100847 0 \
848 -C "x509_verify_cert() returned" \
849 -C "! self-signed or not signed by a trusted CA" \
850 -C "! ssl_handshake returned" \
851 -C "X509 - Certificate verification failed"
852
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200853run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200854 "$P_SRV debug_level=3 auth_mode=required" \
855 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100856 key_file=data_files/server5.key" \
857 1 \
858 -S "skip write certificate request" \
859 -C "skip parse certificate request" \
860 -c "got a certificate request" \
861 -C "skip write certificate" \
862 -C "skip write certificate verify" \
863 -S "skip parse certificate verify" \
864 -s "x509_verify_cert() returned" \
865 -S "! self-signed or not signed by a trusted CA" \
866 -s "! ssl_handshake returned" \
867 -c "! ssl_handshake returned" \
868 -s "X509 - Certificate verification failed"
869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200870run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200871 "$P_SRV debug_level=3 auth_mode=optional" \
872 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100873 key_file=data_files/server5.key" \
874 0 \
875 -S "skip write certificate request" \
876 -C "skip parse certificate request" \
877 -c "got a certificate request" \
878 -C "skip write certificate" \
879 -C "skip write certificate verify" \
880 -S "skip parse certificate verify" \
881 -s "x509_verify_cert() returned" \
882 -s "! self-signed or not signed by a trusted CA" \
883 -S "! ssl_handshake returned" \
884 -C "! ssl_handshake returned" \
885 -S "X509 - Certificate verification failed"
886
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200887run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200888 "$P_SRV debug_level=3 auth_mode=none" \
889 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100890 key_file=data_files/server5.key" \
891 0 \
892 -s "skip write certificate request" \
893 -C "skip parse certificate request" \
894 -c "got no certificate request" \
895 -c "skip write certificate" \
896 -c "skip write certificate verify" \
897 -s "skip parse certificate verify" \
898 -S "x509_verify_cert() returned" \
899 -S "! self-signed or not signed by a trusted CA" \
900 -S "! ssl_handshake returned" \
901 -C "! ssl_handshake returned" \
902 -S "X509 - Certificate verification failed"
903
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200904run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200905 "$P_SRV debug_level=3 auth_mode=optional" \
906 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100907 0 \
908 -S "skip write certificate request" \
909 -C "skip parse certificate request" \
910 -c "got a certificate request" \
911 -C "skip write certificate$" \
912 -C "got no certificate to send" \
913 -S "SSLv3 client has no certificate" \
914 -c "skip write certificate verify" \
915 -s "skip parse certificate verify" \
916 -s "! no client certificate sent" \
917 -S "! ssl_handshake returned" \
918 -C "! ssl_handshake returned" \
919 -S "X509 - Certificate verification failed"
920
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200921run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200922 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100923 "$O_CLI" \
924 0 \
925 -S "skip write certificate request" \
926 -s "skip parse certificate verify" \
927 -s "! no client certificate sent" \
928 -S "! ssl_handshake returned" \
929 -S "X509 - Certificate verification failed"
930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200931run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100932 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200933 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100934 0 \
935 -C "skip parse certificate request" \
936 -c "got a certificate request" \
937 -C "skip write certificate$" \
938 -c "skip write certificate verify" \
939 -C "! ssl_handshake returned"
940
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200941run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200942 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
943 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100944 0 \
945 -S "skip write certificate request" \
946 -C "skip parse certificate request" \
947 -c "got a certificate request" \
948 -C "skip write certificate$" \
949 -c "skip write certificate verify" \
950 -c "got no certificate to send" \
951 -s "SSLv3 client has no certificate" \
952 -s "skip parse certificate verify" \
953 -s "! no client certificate sent" \
954 -S "! ssl_handshake returned" \
955 -C "! ssl_handshake returned" \
956 -S "X509 - Certificate verification failed"
957
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100958# tests for SNI
959
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200960run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200961 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100962 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100963 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100964 server_name=localhost" \
965 0 \
966 -S "parse ServerName extension" \
967 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
968 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
969
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200970run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200971 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100972 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100973 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 +0100974 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100975 server_name=localhost" \
976 0 \
977 -s "parse ServerName extension" \
978 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
979 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200981run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200982 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100983 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100984 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 +0100985 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100986 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100987 0 \
988 -s "parse ServerName extension" \
989 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100990 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100991
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200992run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200993 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100994 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100995 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 +0100996 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100997 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100998 1 \
999 -s "parse ServerName extension" \
1000 -s "ssl_sni_wrapper() returned" \
1001 -s "ssl_handshake returned" \
1002 -c "ssl_handshake returned" \
1003 -c "SSL - A fatal alert message was received from our peer"
1004
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001005# Tests for non-blocking I/O: exercise a variety of handshake flows
1006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001007run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001008 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1009 "$P_CLI nbio=2 tickets=0" \
1010 0 \
1011 -S "ssl_handshake returned" \
1012 -C "ssl_handshake returned" \
1013 -c "Read from server: .* bytes read"
1014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001015run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001016 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1017 "$P_CLI nbio=2 tickets=0" \
1018 0 \
1019 -S "ssl_handshake returned" \
1020 -C "ssl_handshake returned" \
1021 -c "Read from server: .* bytes read"
1022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001023run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001024 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1025 "$P_CLI nbio=2 tickets=1" \
1026 0 \
1027 -S "ssl_handshake returned" \
1028 -C "ssl_handshake returned" \
1029 -c "Read from server: .* bytes read"
1030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001031run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001032 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1033 "$P_CLI nbio=2 tickets=1" \
1034 0 \
1035 -S "ssl_handshake returned" \
1036 -C "ssl_handshake returned" \
1037 -c "Read from server: .* bytes read"
1038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001039run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001040 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1041 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1042 0 \
1043 -S "ssl_handshake returned" \
1044 -C "ssl_handshake returned" \
1045 -c "Read from server: .* bytes read"
1046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001047run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001048 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1049 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1050 0 \
1051 -S "ssl_handshake returned" \
1052 -C "ssl_handshake returned" \
1053 -c "Read from server: .* bytes read"
1054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001055run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001056 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1057 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1058 0 \
1059 -S "ssl_handshake returned" \
1060 -C "ssl_handshake returned" \
1061 -c "Read from server: .* bytes read"
1062
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001063# Tests for version negotiation
1064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001065run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001066 "$P_SRV" \
1067 "$P_CLI" \
1068 0 \
1069 -S "ssl_handshake returned" \
1070 -C "ssl_handshake returned" \
1071 -s "Protocol is TLSv1.2" \
1072 -c "Protocol is TLSv1.2"
1073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001074run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001075 "$P_SRV" \
1076 "$P_CLI max_version=tls1_1" \
1077 0 \
1078 -S "ssl_handshake returned" \
1079 -C "ssl_handshake returned" \
1080 -s "Protocol is TLSv1.1" \
1081 -c "Protocol is TLSv1.1"
1082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001083run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001084 "$P_SRV max_version=tls1_1" \
1085 "$P_CLI" \
1086 0 \
1087 -S "ssl_handshake returned" \
1088 -C "ssl_handshake returned" \
1089 -s "Protocol is TLSv1.1" \
1090 -c "Protocol is TLSv1.1"
1091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001092run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001093 "$P_SRV max_version=tls1_1" \
1094 "$P_CLI max_version=tls1_1" \
1095 0 \
1096 -S "ssl_handshake returned" \
1097 -C "ssl_handshake returned" \
1098 -s "Protocol is TLSv1.1" \
1099 -c "Protocol is TLSv1.1"
1100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001101run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001102 "$P_SRV min_version=tls1_1" \
1103 "$P_CLI max_version=tls1_1" \
1104 0 \
1105 -S "ssl_handshake returned" \
1106 -C "ssl_handshake returned" \
1107 -s "Protocol is TLSv1.1" \
1108 -c "Protocol is TLSv1.1"
1109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001110run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001111 "$P_SRV max_version=tls1_1" \
1112 "$P_CLI min_version=tls1_1" \
1113 0 \
1114 -S "ssl_handshake returned" \
1115 -C "ssl_handshake returned" \
1116 -s "Protocol is TLSv1.1" \
1117 -c "Protocol is TLSv1.1"
1118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001119run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001120 "$P_SRV max_version=tls1_1" \
1121 "$P_CLI min_version=tls1_2" \
1122 1 \
1123 -s "ssl_handshake returned" \
1124 -c "ssl_handshake returned" \
1125 -c "SSL - Handshake protocol not within min/max boundaries"
1126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001127run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001128 "$P_SRV min_version=tls1_2" \
1129 "$P_CLI max_version=tls1_1" \
1130 1 \
1131 -s "ssl_handshake returned" \
1132 -c "ssl_handshake returned" \
1133 -s "SSL - Handshake protocol not within min/max boundaries"
1134
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001135# Tests for ALPN extension
1136
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001137if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001139run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001140 "$P_SRV debug_level=3" \
1141 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001142 0 \
1143 -C "client hello, adding alpn extension" \
1144 -S "found alpn extension" \
1145 -C "got an alert message, type: \\[2:120]" \
1146 -S "server hello, adding alpn extension" \
1147 -C "found alpn extension " \
1148 -C "Application Layer Protocol is" \
1149 -S "Application Layer Protocol is"
1150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001151run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001152 "$P_SRV debug_level=3" \
1153 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001154 0 \
1155 -c "client hello, adding alpn extension" \
1156 -s "found alpn extension" \
1157 -C "got an alert message, type: \\[2:120]" \
1158 -S "server hello, adding alpn extension" \
1159 -C "found alpn extension " \
1160 -c "Application Layer Protocol is (none)" \
1161 -S "Application Layer Protocol is"
1162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001163run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001164 "$P_SRV debug_level=3 alpn=abc,1234" \
1165 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001166 0 \
1167 -C "client hello, adding alpn extension" \
1168 -S "found alpn extension" \
1169 -C "got an alert message, type: \\[2:120]" \
1170 -S "server hello, adding alpn extension" \
1171 -C "found alpn extension " \
1172 -C "Application Layer Protocol is" \
1173 -s "Application Layer Protocol is (none)"
1174
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001175run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001176 "$P_SRV debug_level=3 alpn=abc,1234" \
1177 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001178 0 \
1179 -c "client hello, adding alpn extension" \
1180 -s "found alpn extension" \
1181 -C "got an alert message, type: \\[2:120]" \
1182 -s "server hello, adding alpn extension" \
1183 -c "found alpn extension" \
1184 -c "Application Layer Protocol is abc" \
1185 -s "Application Layer Protocol is abc"
1186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001187run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001188 "$P_SRV debug_level=3 alpn=abc,1234" \
1189 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001190 0 \
1191 -c "client hello, adding alpn extension" \
1192 -s "found alpn extension" \
1193 -C "got an alert message, type: \\[2:120]" \
1194 -s "server hello, adding alpn extension" \
1195 -c "found alpn extension" \
1196 -c "Application Layer Protocol is abc" \
1197 -s "Application Layer Protocol is abc"
1198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001199run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001200 "$P_SRV debug_level=3 alpn=abc,1234" \
1201 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001202 0 \
1203 -c "client hello, adding alpn extension" \
1204 -s "found alpn extension" \
1205 -C "got an alert message, type: \\[2:120]" \
1206 -s "server hello, adding alpn extension" \
1207 -c "found alpn extension" \
1208 -c "Application Layer Protocol is 1234" \
1209 -s "Application Layer Protocol is 1234"
1210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001211run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001212 "$P_SRV debug_level=3 alpn=abc,123" \
1213 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001214 1 \
1215 -c "client hello, adding alpn extension" \
1216 -s "found alpn extension" \
1217 -c "got an alert message, type: \\[2:120]" \
1218 -S "server hello, adding alpn extension" \
1219 -C "found alpn extension" \
1220 -C "Application Layer Protocol is 1234" \
1221 -S "Application Layer Protocol is 1234"
1222
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001223fi
1224
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001225# Tests for keyUsage in leaf certificates, part 1:
1226# server-side certificate/suite selection
1227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001228run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001229 "$P_SRV key_file=data_files/server2.key \
1230 crt_file=data_files/server2.ku-ds.crt" \
1231 "$P_CLI" \
1232 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001233 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001234
1235
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001236run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001237 "$P_SRV key_file=data_files/server2.key \
1238 crt_file=data_files/server2.ku-ke.crt" \
1239 "$P_CLI" \
1240 0 \
1241 -c "Ciphersuite is TLS-RSA-WITH-"
1242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001243run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001244 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001245 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001246 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001247 1 \
1248 -C "Ciphersuite is "
1249
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001250run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001251 "$P_SRV key_file=data_files/server5.key \
1252 crt_file=data_files/server5.ku-ds.crt" \
1253 "$P_CLI" \
1254 0 \
1255 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1256
1257
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001258run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001259 "$P_SRV key_file=data_files/server5.key \
1260 crt_file=data_files/server5.ku-ka.crt" \
1261 "$P_CLI" \
1262 0 \
1263 -c "Ciphersuite is TLS-ECDH-"
1264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001265run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001266 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001267 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001268 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001269 1 \
1270 -C "Ciphersuite is "
1271
1272# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001273# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001275run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001276 "$O_SRV -key data_files/server2.key \
1277 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001278 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001279 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1280 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001281 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001282 -C "Processing of the Certificate handshake message failed" \
1283 -c "Ciphersuite is TLS-"
1284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001285run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001286 "$O_SRV -key data_files/server2.key \
1287 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001289 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1290 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001291 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001292 -C "Processing of the Certificate handshake message failed" \
1293 -c "Ciphersuite is TLS-"
1294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001295run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001296 "$O_SRV -key data_files/server2.key \
1297 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001298 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001299 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1300 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001301 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001302 -C "Processing of the Certificate handshake message failed" \
1303 -c "Ciphersuite is TLS-"
1304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001305run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001306 "$O_SRV -key data_files/server2.key \
1307 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001308 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001309 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1310 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001311 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001312 -c "Processing of the Certificate handshake message failed" \
1313 -C "Ciphersuite is TLS-"
1314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001315run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001316 "$O_SRV -key data_files/server2.key \
1317 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001318 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001319 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1320 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001321 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001322 -C "Processing of the Certificate handshake message failed" \
1323 -c "Ciphersuite is TLS-"
1324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001325run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001326 "$O_SRV -key data_files/server2.key \
1327 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001328 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001329 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1330 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001331 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001332 -c "Processing of the Certificate handshake message failed" \
1333 -C "Ciphersuite is TLS-"
1334
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001335# Tests for keyUsage in leaf certificates, part 3:
1336# server-side checking of client cert
1337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001338run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001339 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001340 "$O_CLI -key data_files/server2.key \
1341 -cert data_files/server2.ku-ds.crt" \
1342 0 \
1343 -S "bad certificate (usage extensions)" \
1344 -S "Processing of the Certificate handshake message failed"
1345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001348 "$O_CLI -key data_files/server2.key \
1349 -cert data_files/server2.ku-ke.crt" \
1350 0 \
1351 -s "bad certificate (usage extensions)" \
1352 -S "Processing of the Certificate handshake message failed"
1353
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001354run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001355 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001356 "$O_CLI -key data_files/server2.key \
1357 -cert data_files/server2.ku-ke.crt" \
1358 1 \
1359 -s "bad certificate (usage extensions)" \
1360 -s "Processing of the Certificate handshake message failed"
1361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001362run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001363 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001364 "$O_CLI -key data_files/server5.key \
1365 -cert data_files/server5.ku-ds.crt" \
1366 0 \
1367 -S "bad certificate (usage extensions)" \
1368 -S "Processing of the Certificate handshake message failed"
1369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001370run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001371 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001372 "$O_CLI -key data_files/server5.key \
1373 -cert data_files/server5.ku-ka.crt" \
1374 0 \
1375 -s "bad certificate (usage extensions)" \
1376 -S "Processing of the Certificate handshake message failed"
1377
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001378# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001380run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001381 "$P_SRV key_file=data_files/server5.key \
1382 crt_file=data_files/server5.eku-srv.crt" \
1383 "$P_CLI" \
1384 0
1385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001386run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001387 "$P_SRV key_file=data_files/server5.key \
1388 crt_file=data_files/server5.eku-srv.crt" \
1389 "$P_CLI" \
1390 0
1391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001392run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001393 "$P_SRV key_file=data_files/server5.key \
1394 crt_file=data_files/server5.eku-cs_any.crt" \
1395 "$P_CLI" \
1396 0
1397
1398# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001399run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001400 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1401 crt_file=data_files/server5.eku-cli.crt" \
1402 "$P_CLI psk=badbad" \
1403 1
1404
1405# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1406
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001407run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001408 "$O_SRV -key data_files/server5.key \
1409 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001410 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001411 0 \
1412 -C "bad certificate (usage extensions)" \
1413 -C "Processing of the Certificate handshake message failed" \
1414 -c "Ciphersuite is TLS-"
1415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001416run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001417 "$O_SRV -key data_files/server5.key \
1418 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001419 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001420 0 \
1421 -C "bad certificate (usage extensions)" \
1422 -C "Processing of the Certificate handshake message failed" \
1423 -c "Ciphersuite is TLS-"
1424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001425run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001426 "$O_SRV -key data_files/server5.key \
1427 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001428 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001429 0 \
1430 -C "bad certificate (usage extensions)" \
1431 -C "Processing of the Certificate handshake message failed" \
1432 -c "Ciphersuite is TLS-"
1433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001434run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001435 "$O_SRV -key data_files/server5.key \
1436 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001437 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001438 1 \
1439 -c "bad certificate (usage extensions)" \
1440 -c "Processing of the Certificate handshake message failed" \
1441 -C "Ciphersuite is TLS-"
1442
1443# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001445run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001446 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001447 "$O_CLI -key data_files/server5.key \
1448 -cert data_files/server5.eku-cli.crt" \
1449 0 \
1450 -S "bad certificate (usage extensions)" \
1451 -S "Processing of the Certificate handshake message failed"
1452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001453run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001454 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001455 "$O_CLI -key data_files/server5.key \
1456 -cert data_files/server5.eku-srv_cli.crt" \
1457 0 \
1458 -S "bad certificate (usage extensions)" \
1459 -S "Processing of the Certificate handshake message failed"
1460
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001461run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001462 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001463 "$O_CLI -key data_files/server5.key \
1464 -cert data_files/server5.eku-cs_any.crt" \
1465 0 \
1466 -S "bad certificate (usage extensions)" \
1467 -S "Processing of the Certificate handshake message failed"
1468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001469run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001470 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001471 "$O_CLI -key data_files/server5.key \
1472 -cert data_files/server5.eku-cs.crt" \
1473 0 \
1474 -s "bad certificate (usage extensions)" \
1475 -S "Processing of the Certificate handshake message failed"
1476
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001477run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001478 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001479 "$O_CLI -key data_files/server5.key \
1480 -cert data_files/server5.eku-cs.crt" \
1481 1 \
1482 -s "bad certificate (usage extensions)" \
1483 -s "Processing of the Certificate handshake message failed"
1484
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001485# Tests for DHM parameters loading
1486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001487run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001488 "$P_SRV" \
1489 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1490 debug_level=3" \
1491 0 \
1492 -c "value of 'DHM: P ' (2048 bits)" \
1493 -c "value of 'DHM: G ' (2048 bits)"
1494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001495run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001496 "$P_SRV dhm_file=data_files/dhparams.pem" \
1497 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1498 debug_level=3" \
1499 0 \
1500 -c "value of 'DHM: P ' (1024 bits)" \
1501 -c "value of 'DHM: G ' (2 bits)"
1502
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001503# Tests for PSK callback
1504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001505run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001506 "$P_SRV psk=abc123 psk_identity=foo" \
1507 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1508 psk_identity=foo psk=abc123" \
1509 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001510 -S "SSL - The server has no ciphersuites in common" \
1511 -S "SSL - Unknown identity received" \
1512 -S "SSL - Verification of the message MAC failed"
1513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001514run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001515 "$P_SRV" \
1516 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1517 psk_identity=foo psk=abc123" \
1518 1 \
1519 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001520 -S "SSL - Unknown identity received" \
1521 -S "SSL - Verification of the message MAC failed"
1522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001523run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001524 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1525 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1526 psk_identity=foo psk=abc123" \
1527 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001528 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001529 -s "SSL - Unknown identity received" \
1530 -S "SSL - Verification of the message MAC failed"
1531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001532run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001533 "$P_SRV psk_list=abc,dead,def,beef" \
1534 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1535 psk_identity=abc psk=dead" \
1536 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001537 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001538 -S "SSL - Unknown identity received" \
1539 -S "SSL - Verification of the message MAC failed"
1540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001541run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001542 "$P_SRV psk_list=abc,dead,def,beef" \
1543 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1544 psk_identity=def psk=beef" \
1545 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001546 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001547 -S "SSL - Unknown identity received" \
1548 -S "SSL - Verification of the message MAC failed"
1549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001550run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001551 "$P_SRV psk_list=abc,dead,def,beef" \
1552 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1553 psk_identity=ghi psk=beef" \
1554 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001555 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001556 -s "SSL - Unknown identity received" \
1557 -S "SSL - Verification of the message MAC failed"
1558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001559run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001560 "$P_SRV psk_list=abc,dead,def,beef" \
1561 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1562 psk_identity=abc psk=beef" \
1563 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001564 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001565 -S "SSL - Unknown identity received" \
1566 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001567
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001568# Tests for ciphersuites per version
1569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001570run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001571 "$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" \
1572 "$P_CLI force_version=ssl3" \
1573 0 \
1574 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1575
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001576run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001577 "$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" \
1578 "$P_CLI force_version=tls1" \
1579 0 \
1580 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001582run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001583 "$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" \
1584 "$P_CLI force_version=tls1_1" \
1585 0 \
1586 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001588run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001589 "$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" \
1590 "$P_CLI force_version=tls1_2" \
1591 0 \
1592 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1593
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001594# Tests for ssl_get_bytes_avail()
1595
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001596run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001597 "$P_SRV" \
1598 "$P_CLI request_size=100" \
1599 0 \
1600 -s "Read from client: 100 bytes read$"
1601
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001602run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001603 "$P_SRV" \
1604 "$P_CLI request_size=500" \
1605 0 \
1606 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001607
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001608# Tests for small packets
1609
1610run_test "Small packet SSLv3 BlockCipher" \
1611 "$P_SRV" \
1612 "$P_CLI request_size=1 force_version=ssl3 \
1613 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1614 0 \
1615 -s "Read from client: 1 bytes read"
1616
1617run_test "Small packet SSLv3 StreamCipher" \
1618 "$P_SRV" \
1619 "$P_CLI request_size=1 force_version=ssl3 \
1620 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1621 0 \
1622 -s "Read from client: 1 bytes read"
1623
1624run_test "Small packet TLS 1.0 BlockCipher" \
1625 "$P_SRV" \
1626 "$P_CLI request_size=1 force_version=tls1 \
1627 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1628 0 \
1629 -s "Read from client: 1 bytes read"
1630
1631run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1632 "$P_SRV" \
1633 "$P_CLI request_size=1 force_version=tls1 \
1634 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1635 trunc_hmac=1" \
1636 0 \
1637 -s "Read from client: 1 bytes read"
1638
1639run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1640 "$P_SRV" \
1641 "$P_CLI request_size=1 force_version=tls1 \
1642 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1643 trunc_hmac=1" \
1644 0 \
1645 -s "Read from client: 1 bytes read"
1646
1647run_test "Small packet TLS 1.1 BlockCipher" \
1648 "$P_SRV" \
1649 "$P_CLI request_size=1 force_version=tls1_1 \
1650 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1651 0 \
1652 -s "Read from client: 1 bytes read"
1653
1654run_test "Small packet TLS 1.1 StreamCipher" \
1655 "$P_SRV" \
1656 "$P_CLI request_size=1 force_version=tls1_1 \
1657 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1658 0 \
1659 -s "Read from client: 1 bytes read"
1660
1661run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1662 "$P_SRV" \
1663 "$P_CLI request_size=1 force_version=tls1_1 \
1664 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1665 trunc_hmac=1" \
1666 0 \
1667 -s "Read from client: 1 bytes read"
1668
1669run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1670 "$P_SRV" \
1671 "$P_CLI request_size=1 force_version=tls1_1 \
1672 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1673 trunc_hmac=1" \
1674 0 \
1675 -s "Read from client: 1 bytes read"
1676
1677run_test "Small packet TLS 1.2 BlockCipher" \
1678 "$P_SRV" \
1679 "$P_CLI request_size=1 force_version=tls1_2 \
1680 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1681 0 \
1682 -s "Read from client: 1 bytes read"
1683
1684run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1685 "$P_SRV" \
1686 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1687 0 \
1688 -s "Read from client: 1 bytes read"
1689
1690run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1691 "$P_SRV" \
1692 "$P_CLI request_size=1 force_version=tls1_2 \
1693 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1694 trunc_hmac=1" \
1695 0 \
1696 -s "Read from client: 1 bytes read"
1697
1698run_test "Small packet TLS 1.2 StreamCipher" \
1699 "$P_SRV" \
1700 "$P_CLI request_size=1 force_version=tls1_2 \
1701 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1702 0 \
1703 -s "Read from client: 1 bytes read"
1704
1705run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1706 "$P_SRV" \
1707 "$P_CLI request_size=1 force_version=tls1_2 \
1708 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1709 trunc_hmac=1" \
1710 0 \
1711 -s "Read from client: 1 bytes read"
1712
1713run_test "Small packet TLS 1.2 AEAD" \
1714 "$P_SRV" \
1715 "$P_CLI request_size=1 force_version=tls1_2 \
1716 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1717 0 \
1718 -s "Read from client: 1 bytes read"
1719
1720run_test "Small packet TLS 1.2 AEAD shorter tag" \
1721 "$P_SRV" \
1722 "$P_CLI request_size=1 force_version=tls1_2 \
1723 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1724 0 \
1725 -s "Read from client: 1 bytes read"
1726
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001727# Test for large packets
1728
1729run_test "Large packet SSLv3 BlockCipher" \
1730 "$P_SRV" \
1731 "$P_CLI request_size=16384 force_version=ssl3 \
1732 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1733 0 \
1734 -s "Read from client: 16384 bytes read"
1735
1736run_test "Large packet SSLv3 StreamCipher" \
1737 "$P_SRV" \
1738 "$P_CLI request_size=16384 force_version=ssl3 \
1739 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1740 0 \
1741 -s "Read from client: 16384 bytes read"
1742
1743run_test "Large packet TLS 1.0 BlockCipher" \
1744 "$P_SRV" \
1745 "$P_CLI request_size=16384 force_version=tls1 \
1746 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1747 0 \
1748 -s "Read from client: 16384 bytes read"
1749
1750run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1751 "$P_SRV" \
1752 "$P_CLI request_size=16384 force_version=tls1 \
1753 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1754 trunc_hmac=1" \
1755 0 \
1756 -s "Read from client: 16384 bytes read"
1757
1758run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1759 "$P_SRV" \
1760 "$P_CLI request_size=16384 force_version=tls1 \
1761 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1762 trunc_hmac=1" \
1763 0 \
1764 -s "Read from client: 16384 bytes read"
1765
1766run_test "Large packet TLS 1.1 BlockCipher" \
1767 "$P_SRV" \
1768 "$P_CLI request_size=16384 force_version=tls1_1 \
1769 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1770 0 \
1771 -s "Read from client: 16384 bytes read"
1772
1773run_test "Large packet TLS 1.1 StreamCipher" \
1774 "$P_SRV" \
1775 "$P_CLI request_size=16384 force_version=tls1_1 \
1776 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1777 0 \
1778 -s "Read from client: 16384 bytes read"
1779
1780run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1781 "$P_SRV" \
1782 "$P_CLI request_size=16384 force_version=tls1_1 \
1783 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1784 trunc_hmac=1" \
1785 0 \
1786 -s "Read from client: 16384 bytes read"
1787
1788run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1789 "$P_SRV" \
1790 "$P_CLI request_size=16384 force_version=tls1_1 \
1791 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1792 trunc_hmac=1" \
1793 0 \
1794 -s "Read from client: 16384 bytes read"
1795
1796run_test "Large packet TLS 1.2 BlockCipher" \
1797 "$P_SRV" \
1798 "$P_CLI request_size=16384 force_version=tls1_2 \
1799 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1800 0 \
1801 -s "Read from client: 16384 bytes read"
1802
1803run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1804 "$P_SRV" \
1805 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1806 0 \
1807 -s "Read from client: 16384 bytes read"
1808
1809run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1810 "$P_SRV" \
1811 "$P_CLI request_size=16384 force_version=tls1_2 \
1812 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1813 trunc_hmac=1" \
1814 0 \
1815 -s "Read from client: 16384 bytes read"
1816
1817run_test "Large packet TLS 1.2 StreamCipher" \
1818 "$P_SRV" \
1819 "$P_CLI request_size=16384 force_version=tls1_2 \
1820 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1821 0 \
1822 -s "Read from client: 16384 bytes read"
1823
1824run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1825 "$P_SRV" \
1826 "$P_CLI request_size=16384 force_version=tls1_2 \
1827 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1828 trunc_hmac=1" \
1829 0 \
1830 -s "Read from client: 16384 bytes read"
1831
1832run_test "Large packet TLS 1.2 AEAD" \
1833 "$P_SRV" \
1834 "$P_CLI request_size=16384 force_version=tls1_2 \
1835 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1836 0 \
1837 -s "Read from client: 16384 bytes read"
1838
1839run_test "Large packet TLS 1.2 AEAD shorter tag" \
1840 "$P_SRV" \
1841 "$P_CLI request_size=16384 force_version=tls1_2 \
1842 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1843 0 \
1844 -s "Read from client: 16384 bytes read"
1845
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001846# Final report
1847
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001848echo "------------------------------------------------------------------------"
1849
1850if [ $FAILS = 0 ]; then
1851 echo -n "PASSED"
1852else
1853 echo -n "FAILED"
1854fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02001855PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001856echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001857
1858exit $FAILS