blob: bd98bdb427a7e36d1a7c5f3e5d1870080dff9986 [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"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010023G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
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"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100367G_CLI="$G_CLI -p $PORT localhost"
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" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100806 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200807 -C "error" \
808 -c "HTTP/1.0 200 [Oo][Kk]"
809
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100810run_test "Renegotiation: gnutls server strict, client-initiated" \
811 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
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" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100817 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200818 -C "error" \
819 -c "HTTP/1.0 200 [Oo][Kk]"
820
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100821run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
822 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
823 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
824 1 \
825 -c "client hello, adding renegotiation extension" \
826 -C "found renegotiation extension" \
827 -c "=> renegotiate" \
828 -c "ssl_handshake() returned" \
829 -c "error" \
830 -C "HTTP/1.0 200 [Oo][Kk]"
831
832run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
833 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
834 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
835 allow_legacy=0" \
836 1 \
837 -c "client hello, adding renegotiation extension" \
838 -C "found renegotiation extension" \
839 -c "=> renegotiate" \
840 -c "ssl_handshake() returned" \
841 -c "error" \
842 -C "HTTP/1.0 200 [Oo][Kk]"
843
844run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
845 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
846 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
847 allow_legacy=1" \
848 0 \
849 -c "client hello, adding renegotiation extension" \
850 -C "found renegotiation extension" \
851 -c "=> renegotiate" \
852 -C "ssl_hanshake() returned" \
853 -C "error" \
854 -c "HTTP/1.0 200 [Oo][Kk]"
855
856# Test for the "secure renegotation" extension only (no actual renegotiation)
857
858run_test "Renego ext: gnutls server strict, client default" \
859 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
860 "$P_CLI debug_level=3" \
861 0 \
862 -c "found renegotiation extension" \
863 -C "error" \
864 -c "HTTP/1.0 200 [Oo][Kk]"
865
866run_test "Renego ext: gnutls server unsafe, client default" \
867 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
868 "$P_CLI debug_level=3" \
869 0 \
870 -C "found renegotiation extension" \
871 -C "error" \
872 -c "HTTP/1.0 200 [Oo][Kk]"
873
874run_test "Renego ext: gnutls server unsafe, client break legacy" \
875 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
876 "$P_CLI debug_level=3 allow_legacy=-1" \
877 1 \
878 -C "found renegotiation extension" \
879 -c "error" \
880 -C "HTTP/1.0 200 [Oo][Kk]"
881
882run_test "Renego ext: gnutls client strict, server default" \
883 "$P_SRV debug_level=3" \
884 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
885 0 \
886 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
887 -s "server hello, secure renegotiation extension"
888
889run_test "Renego ext: gnutls client unsafe, server default" \
890 "$P_SRV debug_level=3" \
891 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
892 0 \
893 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
894 -S "server hello, secure renegotiation extension"
895
896run_test "Renego ext: gnutls client unsafe, server break legacy" \
897 "$P_SRV debug_level=3 allow_legacy=-1" \
898 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
899 1 \
900 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
901 -S "server hello, secure renegotiation extension"
902
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100903# Tests for auth_mode
904
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200905run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100906 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100907 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200908 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100909 1 \
910 -c "x509_verify_cert() returned" \
911 -c "! self-signed or not signed by a trusted CA" \
912 -c "! ssl_handshake returned" \
913 -c "X509 - Certificate verification failed"
914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200915run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100916 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100917 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200918 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100919 0 \
920 -c "x509_verify_cert() returned" \
921 -c "! self-signed or not signed by a trusted CA" \
922 -C "! ssl_handshake returned" \
923 -C "X509 - Certificate verification failed"
924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200925run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100926 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100927 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200928 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100929 0 \
930 -C "x509_verify_cert() returned" \
931 -C "! self-signed or not signed by a trusted CA" \
932 -C "! ssl_handshake returned" \
933 -C "X509 - Certificate verification failed"
934
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200935run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200936 "$P_SRV debug_level=3 auth_mode=required" \
937 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100938 key_file=data_files/server5.key" \
939 1 \
940 -S "skip write certificate request" \
941 -C "skip parse certificate request" \
942 -c "got a certificate request" \
943 -C "skip write certificate" \
944 -C "skip write certificate verify" \
945 -S "skip parse certificate verify" \
946 -s "x509_verify_cert() returned" \
947 -S "! self-signed or not signed by a trusted CA" \
948 -s "! ssl_handshake returned" \
949 -c "! ssl_handshake returned" \
950 -s "X509 - Certificate verification failed"
951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200952run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200953 "$P_SRV debug_level=3 auth_mode=optional" \
954 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100955 key_file=data_files/server5.key" \
956 0 \
957 -S "skip write certificate request" \
958 -C "skip parse certificate request" \
959 -c "got a certificate request" \
960 -C "skip write certificate" \
961 -C "skip write certificate verify" \
962 -S "skip parse certificate verify" \
963 -s "x509_verify_cert() returned" \
964 -s "! self-signed or not signed by a trusted CA" \
965 -S "! ssl_handshake returned" \
966 -C "! ssl_handshake returned" \
967 -S "X509 - Certificate verification failed"
968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200969run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200970 "$P_SRV debug_level=3 auth_mode=none" \
971 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100972 key_file=data_files/server5.key" \
973 0 \
974 -s "skip write certificate request" \
975 -C "skip parse certificate request" \
976 -c "got no certificate request" \
977 -c "skip write certificate" \
978 -c "skip write certificate verify" \
979 -s "skip parse certificate verify" \
980 -S "x509_verify_cert() returned" \
981 -S "! self-signed or not signed by a trusted CA" \
982 -S "! ssl_handshake returned" \
983 -C "! ssl_handshake returned" \
984 -S "X509 - Certificate verification failed"
985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200986run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200987 "$P_SRV debug_level=3 auth_mode=optional" \
988 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100989 0 \
990 -S "skip write certificate request" \
991 -C "skip parse certificate request" \
992 -c "got a certificate request" \
993 -C "skip write certificate$" \
994 -C "got no certificate to send" \
995 -S "SSLv3 client has no certificate" \
996 -c "skip write certificate verify" \
997 -s "skip parse certificate verify" \
998 -s "! no client certificate sent" \
999 -S "! ssl_handshake returned" \
1000 -C "! ssl_handshake returned" \
1001 -S "X509 - Certificate verification failed"
1002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001003run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001004 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001005 "$O_CLI" \
1006 0 \
1007 -S "skip write certificate request" \
1008 -s "skip parse certificate verify" \
1009 -s "! no client certificate sent" \
1010 -S "! ssl_handshake returned" \
1011 -S "X509 - Certificate verification failed"
1012
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001013run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001014 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001015 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001016 0 \
1017 -C "skip parse certificate request" \
1018 -c "got a certificate request" \
1019 -C "skip write certificate$" \
1020 -c "skip write certificate verify" \
1021 -C "! ssl_handshake returned"
1022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001023run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001024 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1025 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001026 0 \
1027 -S "skip write certificate request" \
1028 -C "skip parse certificate request" \
1029 -c "got a certificate request" \
1030 -C "skip write certificate$" \
1031 -c "skip write certificate verify" \
1032 -c "got no certificate to send" \
1033 -s "SSLv3 client has no certificate" \
1034 -s "skip parse certificate verify" \
1035 -s "! no client certificate sent" \
1036 -S "! ssl_handshake returned" \
1037 -C "! ssl_handshake returned" \
1038 -S "X509 - Certificate verification failed"
1039
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001040# tests for SNI
1041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001042run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001043 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001044 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001045 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001046 server_name=localhost" \
1047 0 \
1048 -S "parse ServerName extension" \
1049 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1050 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001052run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001053 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001054 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001055 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 +01001056 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001057 server_name=localhost" \
1058 0 \
1059 -s "parse ServerName extension" \
1060 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1061 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001063run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001064 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001065 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001066 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 +01001067 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001068 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001069 0 \
1070 -s "parse ServerName extension" \
1071 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001072 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001074run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001075 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001076 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001077 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 +01001078 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001079 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001080 1 \
1081 -s "parse ServerName extension" \
1082 -s "ssl_sni_wrapper() returned" \
1083 -s "ssl_handshake returned" \
1084 -c "ssl_handshake returned" \
1085 -c "SSL - A fatal alert message was received from our peer"
1086
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001087# Tests for non-blocking I/O: exercise a variety of handshake flows
1088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001089run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001090 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1091 "$P_CLI nbio=2 tickets=0" \
1092 0 \
1093 -S "ssl_handshake returned" \
1094 -C "ssl_handshake returned" \
1095 -c "Read from server: .* bytes read"
1096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001097run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001098 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1099 "$P_CLI nbio=2 tickets=0" \
1100 0 \
1101 -S "ssl_handshake returned" \
1102 -C "ssl_handshake returned" \
1103 -c "Read from server: .* bytes read"
1104
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001105run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001106 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1107 "$P_CLI nbio=2 tickets=1" \
1108 0 \
1109 -S "ssl_handshake returned" \
1110 -C "ssl_handshake returned" \
1111 -c "Read from server: .* bytes read"
1112
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001113run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001114 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1115 "$P_CLI nbio=2 tickets=1" \
1116 0 \
1117 -S "ssl_handshake returned" \
1118 -C "ssl_handshake returned" \
1119 -c "Read from server: .* bytes read"
1120
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001121run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001122 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1123 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1124 0 \
1125 -S "ssl_handshake returned" \
1126 -C "ssl_handshake returned" \
1127 -c "Read from server: .* bytes read"
1128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001129run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001130 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1131 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1132 0 \
1133 -S "ssl_handshake returned" \
1134 -C "ssl_handshake returned" \
1135 -c "Read from server: .* bytes read"
1136
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001137run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001138 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1139 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1140 0 \
1141 -S "ssl_handshake returned" \
1142 -C "ssl_handshake returned" \
1143 -c "Read from server: .* bytes read"
1144
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001145# Tests for version negotiation
1146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001147run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001148 "$P_SRV" \
1149 "$P_CLI" \
1150 0 \
1151 -S "ssl_handshake returned" \
1152 -C "ssl_handshake returned" \
1153 -s "Protocol is TLSv1.2" \
1154 -c "Protocol is TLSv1.2"
1155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001156run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001157 "$P_SRV" \
1158 "$P_CLI max_version=tls1_1" \
1159 0 \
1160 -S "ssl_handshake returned" \
1161 -C "ssl_handshake returned" \
1162 -s "Protocol is TLSv1.1" \
1163 -c "Protocol is TLSv1.1"
1164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001165run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001166 "$P_SRV max_version=tls1_1" \
1167 "$P_CLI" \
1168 0 \
1169 -S "ssl_handshake returned" \
1170 -C "ssl_handshake returned" \
1171 -s "Protocol is TLSv1.1" \
1172 -c "Protocol is TLSv1.1"
1173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001174run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001175 "$P_SRV max_version=tls1_1" \
1176 "$P_CLI max_version=tls1_1" \
1177 0 \
1178 -S "ssl_handshake returned" \
1179 -C "ssl_handshake returned" \
1180 -s "Protocol is TLSv1.1" \
1181 -c "Protocol is TLSv1.1"
1182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001183run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001184 "$P_SRV min_version=tls1_1" \
1185 "$P_CLI max_version=tls1_1" \
1186 0 \
1187 -S "ssl_handshake returned" \
1188 -C "ssl_handshake returned" \
1189 -s "Protocol is TLSv1.1" \
1190 -c "Protocol is TLSv1.1"
1191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001192run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001193 "$P_SRV max_version=tls1_1" \
1194 "$P_CLI min_version=tls1_1" \
1195 0 \
1196 -S "ssl_handshake returned" \
1197 -C "ssl_handshake returned" \
1198 -s "Protocol is TLSv1.1" \
1199 -c "Protocol is TLSv1.1"
1200
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001201run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001202 "$P_SRV max_version=tls1_1" \
1203 "$P_CLI min_version=tls1_2" \
1204 1 \
1205 -s "ssl_handshake returned" \
1206 -c "ssl_handshake returned" \
1207 -c "SSL - Handshake protocol not within min/max boundaries"
1208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001209run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001210 "$P_SRV min_version=tls1_2" \
1211 "$P_CLI max_version=tls1_1" \
1212 1 \
1213 -s "ssl_handshake returned" \
1214 -c "ssl_handshake returned" \
1215 -s "SSL - Handshake protocol not within min/max boundaries"
1216
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001217# Tests for ALPN extension
1218
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001219if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001221run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001222 "$P_SRV debug_level=3" \
1223 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001224 0 \
1225 -C "client hello, adding alpn extension" \
1226 -S "found alpn extension" \
1227 -C "got an alert message, type: \\[2:120]" \
1228 -S "server hello, adding alpn extension" \
1229 -C "found alpn extension " \
1230 -C "Application Layer Protocol is" \
1231 -S "Application Layer Protocol is"
1232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001233run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001234 "$P_SRV debug_level=3" \
1235 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001236 0 \
1237 -c "client hello, adding alpn extension" \
1238 -s "found alpn extension" \
1239 -C "got an alert message, type: \\[2:120]" \
1240 -S "server hello, adding alpn extension" \
1241 -C "found alpn extension " \
1242 -c "Application Layer Protocol is (none)" \
1243 -S "Application Layer Protocol is"
1244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001245run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001246 "$P_SRV debug_level=3 alpn=abc,1234" \
1247 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001248 0 \
1249 -C "client hello, adding alpn extension" \
1250 -S "found alpn extension" \
1251 -C "got an alert message, type: \\[2:120]" \
1252 -S "server hello, adding alpn extension" \
1253 -C "found alpn extension " \
1254 -C "Application Layer Protocol is" \
1255 -s "Application Layer Protocol is (none)"
1256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001257run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001258 "$P_SRV debug_level=3 alpn=abc,1234" \
1259 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001260 0 \
1261 -c "client hello, adding alpn extension" \
1262 -s "found alpn extension" \
1263 -C "got an alert message, type: \\[2:120]" \
1264 -s "server hello, adding alpn extension" \
1265 -c "found alpn extension" \
1266 -c "Application Layer Protocol is abc" \
1267 -s "Application Layer Protocol is abc"
1268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001269run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001270 "$P_SRV debug_level=3 alpn=abc,1234" \
1271 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001272 0 \
1273 -c "client hello, adding alpn extension" \
1274 -s "found alpn extension" \
1275 -C "got an alert message, type: \\[2:120]" \
1276 -s "server hello, adding alpn extension" \
1277 -c "found alpn extension" \
1278 -c "Application Layer Protocol is abc" \
1279 -s "Application Layer Protocol is abc"
1280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001281run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001282 "$P_SRV debug_level=3 alpn=abc,1234" \
1283 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001284 0 \
1285 -c "client hello, adding alpn extension" \
1286 -s "found alpn extension" \
1287 -C "got an alert message, type: \\[2:120]" \
1288 -s "server hello, adding alpn extension" \
1289 -c "found alpn extension" \
1290 -c "Application Layer Protocol is 1234" \
1291 -s "Application Layer Protocol is 1234"
1292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001293run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001294 "$P_SRV debug_level=3 alpn=abc,123" \
1295 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001296 1 \
1297 -c "client hello, adding alpn extension" \
1298 -s "found alpn extension" \
1299 -c "got an alert message, type: \\[2:120]" \
1300 -S "server hello, adding alpn extension" \
1301 -C "found alpn extension" \
1302 -C "Application Layer Protocol is 1234" \
1303 -S "Application Layer Protocol is 1234"
1304
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001305fi
1306
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001307# Tests for keyUsage in leaf certificates, part 1:
1308# server-side certificate/suite selection
1309
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001310run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001311 "$P_SRV key_file=data_files/server2.key \
1312 crt_file=data_files/server2.ku-ds.crt" \
1313 "$P_CLI" \
1314 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001315 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001316
1317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001318run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001319 "$P_SRV key_file=data_files/server2.key \
1320 crt_file=data_files/server2.ku-ke.crt" \
1321 "$P_CLI" \
1322 0 \
1323 -c "Ciphersuite is TLS-RSA-WITH-"
1324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001325run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001326 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001327 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001328 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001329 1 \
1330 -C "Ciphersuite is "
1331
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001332run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001333 "$P_SRV key_file=data_files/server5.key \
1334 crt_file=data_files/server5.ku-ds.crt" \
1335 "$P_CLI" \
1336 0 \
1337 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1338
1339
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001340run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001341 "$P_SRV key_file=data_files/server5.key \
1342 crt_file=data_files/server5.ku-ka.crt" \
1343 "$P_CLI" \
1344 0 \
1345 -c "Ciphersuite is TLS-ECDH-"
1346
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001347run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001348 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001349 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001350 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001351 1 \
1352 -C "Ciphersuite is "
1353
1354# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001355# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001357run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001358 "$O_SRV -key data_files/server2.key \
1359 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001360 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001361 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1362 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001363 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001364 -C "Processing of the Certificate handshake message failed" \
1365 -c "Ciphersuite is TLS-"
1366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001367run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001368 "$O_SRV -key data_files/server2.key \
1369 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001370 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001371 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1372 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001373 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001374 -C "Processing of the Certificate handshake message failed" \
1375 -c "Ciphersuite is TLS-"
1376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001377run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001378 "$O_SRV -key data_files/server2.key \
1379 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001380 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001381 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1382 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001383 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001384 -C "Processing of the Certificate handshake message failed" \
1385 -c "Ciphersuite is TLS-"
1386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001387run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001388 "$O_SRV -key data_files/server2.key \
1389 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001390 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001391 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1392 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001393 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001394 -c "Processing of the Certificate handshake message failed" \
1395 -C "Ciphersuite is TLS-"
1396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001397run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001398 "$O_SRV -key data_files/server2.key \
1399 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001400 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001401 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1402 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001403 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001404 -C "Processing of the Certificate handshake message failed" \
1405 -c "Ciphersuite is TLS-"
1406
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001407run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001408 "$O_SRV -key data_files/server2.key \
1409 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001410 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001411 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1412 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001413 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001414 -c "Processing of the Certificate handshake message failed" \
1415 -C "Ciphersuite is TLS-"
1416
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001417# Tests for keyUsage in leaf certificates, part 3:
1418# server-side checking of client cert
1419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001420run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001421 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001422 "$O_CLI -key data_files/server2.key \
1423 -cert data_files/server2.ku-ds.crt" \
1424 0 \
1425 -S "bad certificate (usage extensions)" \
1426 -S "Processing of the Certificate handshake message failed"
1427
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001428run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001429 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001430 "$O_CLI -key data_files/server2.key \
1431 -cert data_files/server2.ku-ke.crt" \
1432 0 \
1433 -s "bad certificate (usage extensions)" \
1434 -S "Processing of the Certificate handshake message failed"
1435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001436run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001437 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001438 "$O_CLI -key data_files/server2.key \
1439 -cert data_files/server2.ku-ke.crt" \
1440 1 \
1441 -s "bad certificate (usage extensions)" \
1442 -s "Processing of the Certificate handshake message failed"
1443
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001444run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001445 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001446 "$O_CLI -key data_files/server5.key \
1447 -cert data_files/server5.ku-ds.crt" \
1448 0 \
1449 -S "bad certificate (usage extensions)" \
1450 -S "Processing of the Certificate handshake message failed"
1451
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001452run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001453 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001454 "$O_CLI -key data_files/server5.key \
1455 -cert data_files/server5.ku-ka.crt" \
1456 0 \
1457 -s "bad certificate (usage extensions)" \
1458 -S "Processing of the Certificate handshake message failed"
1459
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001460# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001462run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001463 "$P_SRV key_file=data_files/server5.key \
1464 crt_file=data_files/server5.eku-srv.crt" \
1465 "$P_CLI" \
1466 0
1467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001468run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001469 "$P_SRV key_file=data_files/server5.key \
1470 crt_file=data_files/server5.eku-srv.crt" \
1471 "$P_CLI" \
1472 0
1473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001474run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001475 "$P_SRV key_file=data_files/server5.key \
1476 crt_file=data_files/server5.eku-cs_any.crt" \
1477 "$P_CLI" \
1478 0
1479
1480# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001481run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001482 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1483 crt_file=data_files/server5.eku-cli.crt" \
1484 "$P_CLI psk=badbad" \
1485 1
1486
1487# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1488
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001489run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001490 "$O_SRV -key data_files/server5.key \
1491 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001492 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001493 0 \
1494 -C "bad certificate (usage extensions)" \
1495 -C "Processing of the Certificate handshake message failed" \
1496 -c "Ciphersuite is TLS-"
1497
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001498run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001499 "$O_SRV -key data_files/server5.key \
1500 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001501 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001502 0 \
1503 -C "bad certificate (usage extensions)" \
1504 -C "Processing of the Certificate handshake message failed" \
1505 -c "Ciphersuite is TLS-"
1506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001508 "$O_SRV -key data_files/server5.key \
1509 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001510 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001511 0 \
1512 -C "bad certificate (usage extensions)" \
1513 -C "Processing of the Certificate handshake message failed" \
1514 -c "Ciphersuite is TLS-"
1515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001516run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001517 "$O_SRV -key data_files/server5.key \
1518 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001519 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001520 1 \
1521 -c "bad certificate (usage extensions)" \
1522 -c "Processing of the Certificate handshake message failed" \
1523 -C "Ciphersuite is TLS-"
1524
1525# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1526
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001527run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001528 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001529 "$O_CLI -key data_files/server5.key \
1530 -cert data_files/server5.eku-cli.crt" \
1531 0 \
1532 -S "bad certificate (usage extensions)" \
1533 -S "Processing of the Certificate handshake message failed"
1534
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001535run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001536 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001537 "$O_CLI -key data_files/server5.key \
1538 -cert data_files/server5.eku-srv_cli.crt" \
1539 0 \
1540 -S "bad certificate (usage extensions)" \
1541 -S "Processing of the Certificate handshake message failed"
1542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001543run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001544 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001545 "$O_CLI -key data_files/server5.key \
1546 -cert data_files/server5.eku-cs_any.crt" \
1547 0 \
1548 -S "bad certificate (usage extensions)" \
1549 -S "Processing of the Certificate handshake message failed"
1550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001551run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001552 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001553 "$O_CLI -key data_files/server5.key \
1554 -cert data_files/server5.eku-cs.crt" \
1555 0 \
1556 -s "bad certificate (usage extensions)" \
1557 -S "Processing of the Certificate handshake message failed"
1558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001559run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001560 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001561 "$O_CLI -key data_files/server5.key \
1562 -cert data_files/server5.eku-cs.crt" \
1563 1 \
1564 -s "bad certificate (usage extensions)" \
1565 -s "Processing of the Certificate handshake message failed"
1566
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001567# Tests for DHM parameters loading
1568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001569run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001570 "$P_SRV" \
1571 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1572 debug_level=3" \
1573 0 \
1574 -c "value of 'DHM: P ' (2048 bits)" \
1575 -c "value of 'DHM: G ' (2048 bits)"
1576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001577run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001578 "$P_SRV dhm_file=data_files/dhparams.pem" \
1579 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1580 debug_level=3" \
1581 0 \
1582 -c "value of 'DHM: P ' (1024 bits)" \
1583 -c "value of 'DHM: G ' (2 bits)"
1584
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001585# Tests for PSK callback
1586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001587run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001588 "$P_SRV psk=abc123 psk_identity=foo" \
1589 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1590 psk_identity=foo psk=abc123" \
1591 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001592 -S "SSL - The server has no ciphersuites in common" \
1593 -S "SSL - Unknown identity received" \
1594 -S "SSL - Verification of the message MAC failed"
1595
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001596run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001597 "$P_SRV" \
1598 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1599 psk_identity=foo psk=abc123" \
1600 1 \
1601 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001602 -S "SSL - Unknown identity received" \
1603 -S "SSL - Verification of the message MAC failed"
1604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001605run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001606 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1607 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1608 psk_identity=foo psk=abc123" \
1609 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001610 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001611 -s "SSL - Unknown identity received" \
1612 -S "SSL - Verification of the message MAC failed"
1613
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001614run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001615 "$P_SRV psk_list=abc,dead,def,beef" \
1616 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1617 psk_identity=abc psk=dead" \
1618 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001619 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001620 -S "SSL - Unknown identity received" \
1621 -S "SSL - Verification of the message MAC failed"
1622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001623run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001624 "$P_SRV psk_list=abc,dead,def,beef" \
1625 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1626 psk_identity=def psk=beef" \
1627 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001628 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001629 -S "SSL - Unknown identity received" \
1630 -S "SSL - Verification of the message MAC failed"
1631
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001632run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001633 "$P_SRV psk_list=abc,dead,def,beef" \
1634 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1635 psk_identity=ghi psk=beef" \
1636 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001637 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001638 -s "SSL - Unknown identity received" \
1639 -S "SSL - Verification of the message MAC failed"
1640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001641run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001642 "$P_SRV psk_list=abc,dead,def,beef" \
1643 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1644 psk_identity=abc psk=beef" \
1645 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001646 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001647 -S "SSL - Unknown identity received" \
1648 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001649
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001650# Tests for ciphersuites per version
1651
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001652run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001653 "$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" \
1654 "$P_CLI force_version=ssl3" \
1655 0 \
1656 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001658run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001659 "$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" \
1660 "$P_CLI force_version=tls1" \
1661 0 \
1662 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1663
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001664run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001665 "$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" \
1666 "$P_CLI force_version=tls1_1" \
1667 0 \
1668 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1669
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001670run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001671 "$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" \
1672 "$P_CLI force_version=tls1_2" \
1673 0 \
1674 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1675
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001676# Tests for ssl_get_bytes_avail()
1677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001678run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001679 "$P_SRV" \
1680 "$P_CLI request_size=100" \
1681 0 \
1682 -s "Read from client: 100 bytes read$"
1683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001684run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001685 "$P_SRV" \
1686 "$P_CLI request_size=500" \
1687 0 \
1688 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001689
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001690# Tests for small packets
1691
1692run_test "Small packet SSLv3 BlockCipher" \
1693 "$P_SRV" \
1694 "$P_CLI request_size=1 force_version=ssl3 \
1695 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1696 0 \
1697 -s "Read from client: 1 bytes read"
1698
1699run_test "Small packet SSLv3 StreamCipher" \
1700 "$P_SRV" \
1701 "$P_CLI request_size=1 force_version=ssl3 \
1702 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1703 0 \
1704 -s "Read from client: 1 bytes read"
1705
1706run_test "Small packet TLS 1.0 BlockCipher" \
1707 "$P_SRV" \
1708 "$P_CLI request_size=1 force_version=tls1 \
1709 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1710 0 \
1711 -s "Read from client: 1 bytes read"
1712
1713run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1714 "$P_SRV" \
1715 "$P_CLI request_size=1 force_version=tls1 \
1716 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1717 trunc_hmac=1" \
1718 0 \
1719 -s "Read from client: 1 bytes read"
1720
1721run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1722 "$P_SRV" \
1723 "$P_CLI request_size=1 force_version=tls1 \
1724 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1725 trunc_hmac=1" \
1726 0 \
1727 -s "Read from client: 1 bytes read"
1728
1729run_test "Small packet TLS 1.1 BlockCipher" \
1730 "$P_SRV" \
1731 "$P_CLI request_size=1 force_version=tls1_1 \
1732 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1733 0 \
1734 -s "Read from client: 1 bytes read"
1735
1736run_test "Small packet TLS 1.1 StreamCipher" \
1737 "$P_SRV" \
1738 "$P_CLI request_size=1 force_version=tls1_1 \
1739 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1740 0 \
1741 -s "Read from client: 1 bytes read"
1742
1743run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1744 "$P_SRV" \
1745 "$P_CLI request_size=1 force_version=tls1_1 \
1746 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1747 trunc_hmac=1" \
1748 0 \
1749 -s "Read from client: 1 bytes read"
1750
1751run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1752 "$P_SRV" \
1753 "$P_CLI request_size=1 force_version=tls1_1 \
1754 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1755 trunc_hmac=1" \
1756 0 \
1757 -s "Read from client: 1 bytes read"
1758
1759run_test "Small packet TLS 1.2 BlockCipher" \
1760 "$P_SRV" \
1761 "$P_CLI request_size=1 force_version=tls1_2 \
1762 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1763 0 \
1764 -s "Read from client: 1 bytes read"
1765
1766run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1767 "$P_SRV" \
1768 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1769 0 \
1770 -s "Read from client: 1 bytes read"
1771
1772run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1773 "$P_SRV" \
1774 "$P_CLI request_size=1 force_version=tls1_2 \
1775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1776 trunc_hmac=1" \
1777 0 \
1778 -s "Read from client: 1 bytes read"
1779
1780run_test "Small packet TLS 1.2 StreamCipher" \
1781 "$P_SRV" \
1782 "$P_CLI request_size=1 force_version=tls1_2 \
1783 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1784 0 \
1785 -s "Read from client: 1 bytes read"
1786
1787run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1788 "$P_SRV" \
1789 "$P_CLI request_size=1 force_version=tls1_2 \
1790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1791 trunc_hmac=1" \
1792 0 \
1793 -s "Read from client: 1 bytes read"
1794
1795run_test "Small packet TLS 1.2 AEAD" \
1796 "$P_SRV" \
1797 "$P_CLI request_size=1 force_version=tls1_2 \
1798 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1799 0 \
1800 -s "Read from client: 1 bytes read"
1801
1802run_test "Small packet TLS 1.2 AEAD shorter tag" \
1803 "$P_SRV" \
1804 "$P_CLI request_size=1 force_version=tls1_2 \
1805 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1806 0 \
1807 -s "Read from client: 1 bytes read"
1808
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001809# Test for large packets
1810
1811run_test "Large packet SSLv3 BlockCipher" \
1812 "$P_SRV" \
1813 "$P_CLI request_size=16384 force_version=ssl3 \
1814 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1815 0 \
1816 -s "Read from client: 16384 bytes read"
1817
1818run_test "Large packet SSLv3 StreamCipher" \
1819 "$P_SRV" \
1820 "$P_CLI request_size=16384 force_version=ssl3 \
1821 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1822 0 \
1823 -s "Read from client: 16384 bytes read"
1824
1825run_test "Large packet TLS 1.0 BlockCipher" \
1826 "$P_SRV" \
1827 "$P_CLI request_size=16384 force_version=tls1 \
1828 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1829 0 \
1830 -s "Read from client: 16384 bytes read"
1831
1832run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1833 "$P_SRV" \
1834 "$P_CLI request_size=16384 force_version=tls1 \
1835 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1836 trunc_hmac=1" \
1837 0 \
1838 -s "Read from client: 16384 bytes read"
1839
1840run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1841 "$P_SRV" \
1842 "$P_CLI request_size=16384 force_version=tls1 \
1843 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1844 trunc_hmac=1" \
1845 0 \
1846 -s "Read from client: 16384 bytes read"
1847
1848run_test "Large packet TLS 1.1 BlockCipher" \
1849 "$P_SRV" \
1850 "$P_CLI request_size=16384 force_version=tls1_1 \
1851 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1852 0 \
1853 -s "Read from client: 16384 bytes read"
1854
1855run_test "Large packet TLS 1.1 StreamCipher" \
1856 "$P_SRV" \
1857 "$P_CLI request_size=16384 force_version=tls1_1 \
1858 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1859 0 \
1860 -s "Read from client: 16384 bytes read"
1861
1862run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1863 "$P_SRV" \
1864 "$P_CLI request_size=16384 force_version=tls1_1 \
1865 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1866 trunc_hmac=1" \
1867 0 \
1868 -s "Read from client: 16384 bytes read"
1869
1870run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1871 "$P_SRV" \
1872 "$P_CLI request_size=16384 force_version=tls1_1 \
1873 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1874 trunc_hmac=1" \
1875 0 \
1876 -s "Read from client: 16384 bytes read"
1877
1878run_test "Large packet TLS 1.2 BlockCipher" \
1879 "$P_SRV" \
1880 "$P_CLI request_size=16384 force_version=tls1_2 \
1881 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1882 0 \
1883 -s "Read from client: 16384 bytes read"
1884
1885run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1886 "$P_SRV" \
1887 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1888 0 \
1889 -s "Read from client: 16384 bytes read"
1890
1891run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1892 "$P_SRV" \
1893 "$P_CLI request_size=16384 force_version=tls1_2 \
1894 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1895 trunc_hmac=1" \
1896 0 \
1897 -s "Read from client: 16384 bytes read"
1898
1899run_test "Large packet TLS 1.2 StreamCipher" \
1900 "$P_SRV" \
1901 "$P_CLI request_size=16384 force_version=tls1_2 \
1902 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1903 0 \
1904 -s "Read from client: 16384 bytes read"
1905
1906run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1907 "$P_SRV" \
1908 "$P_CLI request_size=16384 force_version=tls1_2 \
1909 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1910 trunc_hmac=1" \
1911 0 \
1912 -s "Read from client: 16384 bytes read"
1913
1914run_test "Large packet TLS 1.2 AEAD" \
1915 "$P_SRV" \
1916 "$P_CLI request_size=16384 force_version=tls1_2 \
1917 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1918 0 \
1919 -s "Read from client: 16384 bytes read"
1920
1921run_test "Large packet TLS 1.2 AEAD shorter tag" \
1922 "$P_SRV" \
1923 "$P_CLI request_size=16384 force_version=tls1_2 \
1924 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1925 0 \
1926 -s "Read from client: 16384 bytes read"
1927
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001928# Final report
1929
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001930echo "------------------------------------------------------------------------"
1931
1932if [ $FAILS = 0 ]; then
1933 echo -n "PASSED"
1934else
1935 echo -n "FAILED"
1936fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02001937PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001938echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001939
1940exit $FAILS