blob: b909799750cef2f5e265112bfae189d3b677b2d9 [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é-Gonnard590f4162014-11-05 14:23:03 +0100773run_test "Renegotiation: periodic, just below period" \
774 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
775 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
776 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 -S "record counter limit reached: renegotiate" \
783 -C "=> renegotiate" \
784 -S "=> renegotiate" \
785 -S "write hello request" \
786 -S "SSL - An unexpected message was received from our peer" \
787 -S "failed"
788
789run_test "Renegotiation: periodic, just above period" \
790 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
791 "$P_CLI debug_level=3 exchanges=3 renegotiation=1" \
792 0 \
793 -c "client hello, adding renegotiation extension" \
794 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
795 -s "found renegotiation extension" \
796 -s "server hello, secure renegotiation extension" \
797 -c "found renegotiation extension" \
798 -s "record counter limit reached: renegotiate" \
799 -c "=> renegotiate" \
800 -s "=> renegotiate" \
801 -s "write hello request" \
802 -S "SSL - An unexpected message was received from our peer" \
803 -S "failed"
804
805run_test "Renegotiation: periodic, two times period" \
806 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
807 "$P_CLI debug_level=3 exchanges=6 renegotiation=1" \
808 0 \
809 -c "client hello, adding renegotiation extension" \
810 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
811 -s "found renegotiation extension" \
812 -s "server hello, secure renegotiation extension" \
813 -c "found renegotiation extension" \
814 -s "record counter limit reached: renegotiate" \
815 -c "=> renegotiate" \
816 -s "=> renegotiate" \
817 -s "write hello request" \
818 -S "SSL - An unexpected message was received from our peer" \
819 -S "failed"
820
821run_test "Renegotiation: periodic, above period, disabled" \
822 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
823 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
824 0 \
825 -C "client hello, adding renegotiation extension" \
826 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
827 -S "found renegotiation extension" \
828 -s "server hello, secure renegotiation extension" \
829 -c "found renegotiation extension" \
830 -S "record counter limit reached: renegotiate" \
831 -C "=> renegotiate" \
832 -S "=> renegotiate" \
833 -S "write hello request" \
834 -S "SSL - An unexpected message was received from our peer" \
835 -S "failed"
836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200837run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200838 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
839 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200840 0 \
841 -c "client hello, adding renegotiation extension" \
842 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
843 -s "found renegotiation extension" \
844 -s "server hello, secure renegotiation extension" \
845 -c "found renegotiation extension" \
846 -c "=> renegotiate" \
847 -s "=> renegotiate" \
848 -S "write hello request"
849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200850run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200851 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
852 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200853 0 \
854 -c "client hello, adding renegotiation extension" \
855 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
856 -s "found renegotiation extension" \
857 -s "server hello, secure renegotiation extension" \
858 -c "found renegotiation extension" \
859 -c "=> renegotiate" \
860 -s "=> renegotiate" \
861 -s "write hello request"
862
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200863run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200864 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200865 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200866 0 \
867 -c "client hello, adding renegotiation extension" \
868 -c "found renegotiation extension" \
869 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100870 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200871 -C "error" \
872 -c "HTTP/1.0 200 [Oo][Kk]"
873
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100874run_test "Renegotiation: gnutls server strict, client-initiated" \
875 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200876 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200877 0 \
878 -c "client hello, adding renegotiation extension" \
879 -c "found renegotiation extension" \
880 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100881 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200882 -C "error" \
883 -c "HTTP/1.0 200 [Oo][Kk]"
884
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100885run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
886 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
887 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
888 1 \
889 -c "client hello, adding renegotiation extension" \
890 -C "found renegotiation extension" \
891 -c "=> renegotiate" \
892 -c "ssl_handshake() returned" \
893 -c "error" \
894 -C "HTTP/1.0 200 [Oo][Kk]"
895
896run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
897 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
898 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
899 allow_legacy=0" \
900 1 \
901 -c "client hello, adding renegotiation extension" \
902 -C "found renegotiation extension" \
903 -c "=> renegotiate" \
904 -c "ssl_handshake() returned" \
905 -c "error" \
906 -C "HTTP/1.0 200 [Oo][Kk]"
907
908run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
909 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
910 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
911 allow_legacy=1" \
912 0 \
913 -c "client hello, adding renegotiation extension" \
914 -C "found renegotiation extension" \
915 -c "=> renegotiate" \
916 -C "ssl_hanshake() returned" \
917 -C "error" \
918 -c "HTTP/1.0 200 [Oo][Kk]"
919
920# Test for the "secure renegotation" extension only (no actual renegotiation)
921
922run_test "Renego ext: gnutls server strict, client default" \
923 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
924 "$P_CLI debug_level=3" \
925 0 \
926 -c "found renegotiation extension" \
927 -C "error" \
928 -c "HTTP/1.0 200 [Oo][Kk]"
929
930run_test "Renego ext: gnutls server unsafe, client default" \
931 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
932 "$P_CLI debug_level=3" \
933 0 \
934 -C "found renegotiation extension" \
935 -C "error" \
936 -c "HTTP/1.0 200 [Oo][Kk]"
937
938run_test "Renego ext: gnutls server unsafe, client break legacy" \
939 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
940 "$P_CLI debug_level=3 allow_legacy=-1" \
941 1 \
942 -C "found renegotiation extension" \
943 -c "error" \
944 -C "HTTP/1.0 200 [Oo][Kk]"
945
946run_test "Renego ext: gnutls client strict, server default" \
947 "$P_SRV debug_level=3" \
948 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
949 0 \
950 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
951 -s "server hello, secure renegotiation extension"
952
953run_test "Renego ext: gnutls client unsafe, server default" \
954 "$P_SRV debug_level=3" \
955 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
956 0 \
957 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
958 -S "server hello, secure renegotiation extension"
959
960run_test "Renego ext: gnutls client unsafe, server break legacy" \
961 "$P_SRV debug_level=3 allow_legacy=-1" \
962 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
963 1 \
964 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
965 -S "server hello, secure renegotiation extension"
966
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100967# Tests for auth_mode
968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200969run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100970 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100971 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200972 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100973 1 \
974 -c "x509_verify_cert() returned" \
975 -c "! self-signed or not signed by a trusted CA" \
976 -c "! ssl_handshake returned" \
977 -c "X509 - Certificate verification failed"
978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200979run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100980 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100981 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200982 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100983 0 \
984 -c "x509_verify_cert() returned" \
985 -c "! self-signed or not signed by a trusted CA" \
986 -C "! ssl_handshake returned" \
987 -C "X509 - Certificate verification failed"
988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200989run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100990 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100991 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200992 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100993 0 \
994 -C "x509_verify_cert() returned" \
995 -C "! self-signed or not signed by a trusted CA" \
996 -C "! ssl_handshake returned" \
997 -C "X509 - Certificate verification failed"
998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200999run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001000 "$P_SRV debug_level=3 auth_mode=required" \
1001 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001002 key_file=data_files/server5.key" \
1003 1 \
1004 -S "skip write certificate request" \
1005 -C "skip parse certificate request" \
1006 -c "got a certificate request" \
1007 -C "skip write certificate" \
1008 -C "skip write certificate verify" \
1009 -S "skip parse certificate verify" \
1010 -s "x509_verify_cert() returned" \
1011 -S "! self-signed or not signed by a trusted CA" \
1012 -s "! ssl_handshake returned" \
1013 -c "! ssl_handshake returned" \
1014 -s "X509 - Certificate verification failed"
1015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001016run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001017 "$P_SRV debug_level=3 auth_mode=optional" \
1018 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001019 key_file=data_files/server5.key" \
1020 0 \
1021 -S "skip write certificate request" \
1022 -C "skip parse certificate request" \
1023 -c "got a certificate request" \
1024 -C "skip write certificate" \
1025 -C "skip write certificate verify" \
1026 -S "skip parse certificate verify" \
1027 -s "x509_verify_cert() returned" \
1028 -s "! self-signed or not signed by a trusted CA" \
1029 -S "! ssl_handshake returned" \
1030 -C "! ssl_handshake returned" \
1031 -S "X509 - Certificate verification failed"
1032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001033run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001034 "$P_SRV debug_level=3 auth_mode=none" \
1035 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001036 key_file=data_files/server5.key" \
1037 0 \
1038 -s "skip write certificate request" \
1039 -C "skip parse certificate request" \
1040 -c "got no certificate request" \
1041 -c "skip write certificate" \
1042 -c "skip write certificate verify" \
1043 -s "skip parse certificate verify" \
1044 -S "x509_verify_cert() returned" \
1045 -S "! self-signed or not signed by a trusted CA" \
1046 -S "! ssl_handshake returned" \
1047 -C "! ssl_handshake returned" \
1048 -S "X509 - Certificate verification failed"
1049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001050run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001051 "$P_SRV debug_level=3 auth_mode=optional" \
1052 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001053 0 \
1054 -S "skip write certificate request" \
1055 -C "skip parse certificate request" \
1056 -c "got a certificate request" \
1057 -C "skip write certificate$" \
1058 -C "got no certificate to send" \
1059 -S "SSLv3 client has no certificate" \
1060 -c "skip write certificate verify" \
1061 -s "skip parse certificate verify" \
1062 -s "! no client certificate sent" \
1063 -S "! ssl_handshake returned" \
1064 -C "! ssl_handshake returned" \
1065 -S "X509 - Certificate verification failed"
1066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001067run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001068 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001069 "$O_CLI" \
1070 0 \
1071 -S "skip write certificate request" \
1072 -s "skip parse certificate verify" \
1073 -s "! no client certificate sent" \
1074 -S "! ssl_handshake returned" \
1075 -S "X509 - Certificate verification failed"
1076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001077run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001078 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001079 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001080 0 \
1081 -C "skip parse certificate request" \
1082 -c "got a certificate request" \
1083 -C "skip write certificate$" \
1084 -c "skip write certificate verify" \
1085 -C "! ssl_handshake returned"
1086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001087run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001088 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1089 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001090 0 \
1091 -S "skip write certificate request" \
1092 -C "skip parse certificate request" \
1093 -c "got a certificate request" \
1094 -C "skip write certificate$" \
1095 -c "skip write certificate verify" \
1096 -c "got no certificate to send" \
1097 -s "SSLv3 client has no certificate" \
1098 -s "skip parse certificate verify" \
1099 -s "! no client certificate sent" \
1100 -S "! ssl_handshake returned" \
1101 -C "! ssl_handshake returned" \
1102 -S "X509 - Certificate verification failed"
1103
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001104# tests for SNI
1105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001106run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001107 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001108 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001109 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001110 server_name=localhost" \
1111 0 \
1112 -S "parse ServerName extension" \
1113 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1114 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001116run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001117 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001118 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001119 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 +01001120 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001121 server_name=localhost" \
1122 0 \
1123 -s "parse ServerName extension" \
1124 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1125 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001127run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001128 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001129 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001130 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 +01001131 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001132 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001133 0 \
1134 -s "parse ServerName extension" \
1135 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001136 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001138run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001139 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001140 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001141 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 +01001142 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001143 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001144 1 \
1145 -s "parse ServerName extension" \
1146 -s "ssl_sni_wrapper() returned" \
1147 -s "ssl_handshake returned" \
1148 -c "ssl_handshake returned" \
1149 -c "SSL - A fatal alert message was received from our peer"
1150
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001151# Tests for non-blocking I/O: exercise a variety of handshake flows
1152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001153run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001154 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1155 "$P_CLI nbio=2 tickets=0" \
1156 0 \
1157 -S "ssl_handshake returned" \
1158 -C "ssl_handshake returned" \
1159 -c "Read from server: .* bytes read"
1160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001161run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001162 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1163 "$P_CLI nbio=2 tickets=0" \
1164 0 \
1165 -S "ssl_handshake returned" \
1166 -C "ssl_handshake returned" \
1167 -c "Read from server: .* bytes read"
1168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001169run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001170 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1171 "$P_CLI nbio=2 tickets=1" \
1172 0 \
1173 -S "ssl_handshake returned" \
1174 -C "ssl_handshake returned" \
1175 -c "Read from server: .* bytes read"
1176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001177run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001178 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1179 "$P_CLI nbio=2 tickets=1" \
1180 0 \
1181 -S "ssl_handshake returned" \
1182 -C "ssl_handshake returned" \
1183 -c "Read from server: .* bytes read"
1184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001185run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001186 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1187 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1188 0 \
1189 -S "ssl_handshake returned" \
1190 -C "ssl_handshake returned" \
1191 -c "Read from server: .* bytes read"
1192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001193run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001194 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1195 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1196 0 \
1197 -S "ssl_handshake returned" \
1198 -C "ssl_handshake returned" \
1199 -c "Read from server: .* bytes read"
1200
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001201run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001202 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1203 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1204 0 \
1205 -S "ssl_handshake returned" \
1206 -C "ssl_handshake returned" \
1207 -c "Read from server: .* bytes read"
1208
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001209# Tests for version negotiation
1210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001211run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001212 "$P_SRV" \
1213 "$P_CLI" \
1214 0 \
1215 -S "ssl_handshake returned" \
1216 -C "ssl_handshake returned" \
1217 -s "Protocol is TLSv1.2" \
1218 -c "Protocol is TLSv1.2"
1219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001220run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001221 "$P_SRV" \
1222 "$P_CLI max_version=tls1_1" \
1223 0 \
1224 -S "ssl_handshake returned" \
1225 -C "ssl_handshake returned" \
1226 -s "Protocol is TLSv1.1" \
1227 -c "Protocol is TLSv1.1"
1228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001230 "$P_SRV max_version=tls1_1" \
1231 "$P_CLI" \
1232 0 \
1233 -S "ssl_handshake returned" \
1234 -C "ssl_handshake returned" \
1235 -s "Protocol is TLSv1.1" \
1236 -c "Protocol is TLSv1.1"
1237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001238run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001239 "$P_SRV max_version=tls1_1" \
1240 "$P_CLI max_version=tls1_1" \
1241 0 \
1242 -S "ssl_handshake returned" \
1243 -C "ssl_handshake returned" \
1244 -s "Protocol is TLSv1.1" \
1245 -c "Protocol is TLSv1.1"
1246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001247run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001248 "$P_SRV min_version=tls1_1" \
1249 "$P_CLI max_version=tls1_1" \
1250 0 \
1251 -S "ssl_handshake returned" \
1252 -C "ssl_handshake returned" \
1253 -s "Protocol is TLSv1.1" \
1254 -c "Protocol is TLSv1.1"
1255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001257 "$P_SRV max_version=tls1_1" \
1258 "$P_CLI min_version=tls1_1" \
1259 0 \
1260 -S "ssl_handshake returned" \
1261 -C "ssl_handshake returned" \
1262 -s "Protocol is TLSv1.1" \
1263 -c "Protocol is TLSv1.1"
1264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001265run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001266 "$P_SRV max_version=tls1_1" \
1267 "$P_CLI min_version=tls1_2" \
1268 1 \
1269 -s "ssl_handshake returned" \
1270 -c "ssl_handshake returned" \
1271 -c "SSL - Handshake protocol not within min/max boundaries"
1272
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001273run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001274 "$P_SRV min_version=tls1_2" \
1275 "$P_CLI max_version=tls1_1" \
1276 1 \
1277 -s "ssl_handshake returned" \
1278 -c "ssl_handshake returned" \
1279 -s "SSL - Handshake protocol not within min/max boundaries"
1280
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001281# Tests for ALPN extension
1282
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001283if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001285run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001286 "$P_SRV debug_level=3" \
1287 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001288 0 \
1289 -C "client hello, adding alpn extension" \
1290 -S "found alpn extension" \
1291 -C "got an alert message, type: \\[2:120]" \
1292 -S "server hello, adding alpn extension" \
1293 -C "found alpn extension " \
1294 -C "Application Layer Protocol is" \
1295 -S "Application Layer Protocol is"
1296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001297run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001298 "$P_SRV debug_level=3" \
1299 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001300 0 \
1301 -c "client hello, adding alpn extension" \
1302 -s "found alpn extension" \
1303 -C "got an alert message, type: \\[2:120]" \
1304 -S "server hello, adding alpn extension" \
1305 -C "found alpn extension " \
1306 -c "Application Layer Protocol is (none)" \
1307 -S "Application Layer Protocol is"
1308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001309run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001310 "$P_SRV debug_level=3 alpn=abc,1234" \
1311 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001312 0 \
1313 -C "client hello, adding alpn extension" \
1314 -S "found alpn extension" \
1315 -C "got an alert message, type: \\[2:120]" \
1316 -S "server hello, adding alpn extension" \
1317 -C "found alpn extension " \
1318 -C "Application Layer Protocol is" \
1319 -s "Application Layer Protocol is (none)"
1320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001321run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001322 "$P_SRV debug_level=3 alpn=abc,1234" \
1323 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001324 0 \
1325 -c "client hello, adding alpn extension" \
1326 -s "found alpn extension" \
1327 -C "got an alert message, type: \\[2:120]" \
1328 -s "server hello, adding alpn extension" \
1329 -c "found alpn extension" \
1330 -c "Application Layer Protocol is abc" \
1331 -s "Application Layer Protocol is abc"
1332
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001333run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001334 "$P_SRV debug_level=3 alpn=abc,1234" \
1335 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001336 0 \
1337 -c "client hello, adding alpn extension" \
1338 -s "found alpn extension" \
1339 -C "got an alert message, type: \\[2:120]" \
1340 -s "server hello, adding alpn extension" \
1341 -c "found alpn extension" \
1342 -c "Application Layer Protocol is abc" \
1343 -s "Application Layer Protocol is abc"
1344
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001345run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001346 "$P_SRV debug_level=3 alpn=abc,1234" \
1347 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001348 0 \
1349 -c "client hello, adding alpn extension" \
1350 -s "found alpn extension" \
1351 -C "got an alert message, type: \\[2:120]" \
1352 -s "server hello, adding alpn extension" \
1353 -c "found alpn extension" \
1354 -c "Application Layer Protocol is 1234" \
1355 -s "Application Layer Protocol is 1234"
1356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001357run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001358 "$P_SRV debug_level=3 alpn=abc,123" \
1359 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001360 1 \
1361 -c "client hello, adding alpn extension" \
1362 -s "found alpn extension" \
1363 -c "got an alert message, type: \\[2:120]" \
1364 -S "server hello, adding alpn extension" \
1365 -C "found alpn extension" \
1366 -C "Application Layer Protocol is 1234" \
1367 -S "Application Layer Protocol is 1234"
1368
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001369fi
1370
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001371# Tests for keyUsage in leaf certificates, part 1:
1372# server-side certificate/suite selection
1373
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001374run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001375 "$P_SRV key_file=data_files/server2.key \
1376 crt_file=data_files/server2.ku-ds.crt" \
1377 "$P_CLI" \
1378 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001379 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001380
1381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001382run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001383 "$P_SRV key_file=data_files/server2.key \
1384 crt_file=data_files/server2.ku-ke.crt" \
1385 "$P_CLI" \
1386 0 \
1387 -c "Ciphersuite is TLS-RSA-WITH-"
1388
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001389run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001390 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001391 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001392 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001393 1 \
1394 -C "Ciphersuite is "
1395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001396run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001397 "$P_SRV key_file=data_files/server5.key \
1398 crt_file=data_files/server5.ku-ds.crt" \
1399 "$P_CLI" \
1400 0 \
1401 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1402
1403
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001404run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001405 "$P_SRV key_file=data_files/server5.key \
1406 crt_file=data_files/server5.ku-ka.crt" \
1407 "$P_CLI" \
1408 0 \
1409 -c "Ciphersuite is TLS-ECDH-"
1410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001411run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001412 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001413 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001414 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001415 1 \
1416 -C "Ciphersuite is "
1417
1418# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001419# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001421run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001422 "$O_SRV -key data_files/server2.key \
1423 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001424 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001425 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1426 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001427 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001428 -C "Processing of the Certificate handshake message failed" \
1429 -c "Ciphersuite is TLS-"
1430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001431run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001432 "$O_SRV -key data_files/server2.key \
1433 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001434 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001435 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1436 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001437 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001438 -C "Processing of the Certificate handshake message failed" \
1439 -c "Ciphersuite is TLS-"
1440
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001441run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001442 "$O_SRV -key data_files/server2.key \
1443 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001444 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001445 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1446 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001447 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001448 -C "Processing of the Certificate handshake message failed" \
1449 -c "Ciphersuite is TLS-"
1450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001451run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001452 "$O_SRV -key data_files/server2.key \
1453 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001454 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001455 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1456 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001457 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001458 -c "Processing of the Certificate handshake message failed" \
1459 -C "Ciphersuite is TLS-"
1460
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001461run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001462 "$O_SRV -key data_files/server2.key \
1463 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001464 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001465 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1466 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001467 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001468 -C "Processing of the Certificate handshake message failed" \
1469 -c "Ciphersuite is TLS-"
1470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001471run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001472 "$O_SRV -key data_files/server2.key \
1473 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001474 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001475 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1476 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001477 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001478 -c "Processing of the Certificate handshake message failed" \
1479 -C "Ciphersuite is TLS-"
1480
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001481# Tests for keyUsage in leaf certificates, part 3:
1482# server-side checking of client cert
1483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001484run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001485 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001486 "$O_CLI -key data_files/server2.key \
1487 -cert data_files/server2.ku-ds.crt" \
1488 0 \
1489 -S "bad certificate (usage extensions)" \
1490 -S "Processing of the Certificate handshake message failed"
1491
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001492run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001493 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001494 "$O_CLI -key data_files/server2.key \
1495 -cert data_files/server2.ku-ke.crt" \
1496 0 \
1497 -s "bad certificate (usage extensions)" \
1498 -S "Processing of the Certificate handshake message failed"
1499
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001500run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001501 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001502 "$O_CLI -key data_files/server2.key \
1503 -cert data_files/server2.ku-ke.crt" \
1504 1 \
1505 -s "bad certificate (usage extensions)" \
1506 -s "Processing of the Certificate handshake message failed"
1507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001508run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001509 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001510 "$O_CLI -key data_files/server5.key \
1511 -cert data_files/server5.ku-ds.crt" \
1512 0 \
1513 -S "bad certificate (usage extensions)" \
1514 -S "Processing of the Certificate handshake message failed"
1515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001516run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001517 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001518 "$O_CLI -key data_files/server5.key \
1519 -cert data_files/server5.ku-ka.crt" \
1520 0 \
1521 -s "bad certificate (usage extensions)" \
1522 -S "Processing of the Certificate handshake message failed"
1523
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001524# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001526run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001527 "$P_SRV key_file=data_files/server5.key \
1528 crt_file=data_files/server5.eku-srv.crt" \
1529 "$P_CLI" \
1530 0
1531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001532run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001533 "$P_SRV key_file=data_files/server5.key \
1534 crt_file=data_files/server5.eku-srv.crt" \
1535 "$P_CLI" \
1536 0
1537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001538run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001539 "$P_SRV key_file=data_files/server5.key \
1540 crt_file=data_files/server5.eku-cs_any.crt" \
1541 "$P_CLI" \
1542 0
1543
1544# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001545run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001546 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1547 crt_file=data_files/server5.eku-cli.crt" \
1548 "$P_CLI psk=badbad" \
1549 1
1550
1551# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001553run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001554 "$O_SRV -key data_files/server5.key \
1555 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001556 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001557 0 \
1558 -C "bad certificate (usage extensions)" \
1559 -C "Processing of the Certificate handshake message failed" \
1560 -c "Ciphersuite is TLS-"
1561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001562run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001563 "$O_SRV -key data_files/server5.key \
1564 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001565 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001566 0 \
1567 -C "bad certificate (usage extensions)" \
1568 -C "Processing of the Certificate handshake message failed" \
1569 -c "Ciphersuite is TLS-"
1570
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001571run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001572 "$O_SRV -key data_files/server5.key \
1573 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001574 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001575 0 \
1576 -C "bad certificate (usage extensions)" \
1577 -C "Processing of the Certificate handshake message failed" \
1578 -c "Ciphersuite is TLS-"
1579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001580run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001581 "$O_SRV -key data_files/server5.key \
1582 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001583 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001584 1 \
1585 -c "bad certificate (usage extensions)" \
1586 -c "Processing of the Certificate handshake message failed" \
1587 -C "Ciphersuite is TLS-"
1588
1589# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001591run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001592 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001593 "$O_CLI -key data_files/server5.key \
1594 -cert data_files/server5.eku-cli.crt" \
1595 0 \
1596 -S "bad certificate (usage extensions)" \
1597 -S "Processing of the Certificate handshake message failed"
1598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001599run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001600 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001601 "$O_CLI -key data_files/server5.key \
1602 -cert data_files/server5.eku-srv_cli.crt" \
1603 0 \
1604 -S "bad certificate (usage extensions)" \
1605 -S "Processing of the Certificate handshake message failed"
1606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001607run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001608 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001609 "$O_CLI -key data_files/server5.key \
1610 -cert data_files/server5.eku-cs_any.crt" \
1611 0 \
1612 -S "bad certificate (usage extensions)" \
1613 -S "Processing of the Certificate handshake message failed"
1614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001615run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001616 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001617 "$O_CLI -key data_files/server5.key \
1618 -cert data_files/server5.eku-cs.crt" \
1619 0 \
1620 -s "bad certificate (usage extensions)" \
1621 -S "Processing of the Certificate handshake message failed"
1622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001623run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001624 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001625 "$O_CLI -key data_files/server5.key \
1626 -cert data_files/server5.eku-cs.crt" \
1627 1 \
1628 -s "bad certificate (usage extensions)" \
1629 -s "Processing of the Certificate handshake message failed"
1630
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001631# Tests for DHM parameters loading
1632
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001633run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001634 "$P_SRV" \
1635 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1636 debug_level=3" \
1637 0 \
1638 -c "value of 'DHM: P ' (2048 bits)" \
1639 -c "value of 'DHM: G ' (2048 bits)"
1640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001641run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001642 "$P_SRV dhm_file=data_files/dhparams.pem" \
1643 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1644 debug_level=3" \
1645 0 \
1646 -c "value of 'DHM: P ' (1024 bits)" \
1647 -c "value of 'DHM: G ' (2 bits)"
1648
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001649# Tests for PSK callback
1650
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001651run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001652 "$P_SRV psk=abc123 psk_identity=foo" \
1653 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1654 psk_identity=foo psk=abc123" \
1655 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001656 -S "SSL - The server has no ciphersuites in common" \
1657 -S "SSL - Unknown identity received" \
1658 -S "SSL - Verification of the message MAC failed"
1659
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001660run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001661 "$P_SRV" \
1662 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1663 psk_identity=foo psk=abc123" \
1664 1 \
1665 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001666 -S "SSL - Unknown identity received" \
1667 -S "SSL - Verification of the message MAC failed"
1668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001669run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001670 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1671 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1672 psk_identity=foo psk=abc123" \
1673 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001674 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001675 -s "SSL - Unknown identity received" \
1676 -S "SSL - Verification of the message MAC failed"
1677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001678run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001679 "$P_SRV psk_list=abc,dead,def,beef" \
1680 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1681 psk_identity=abc psk=dead" \
1682 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001683 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001684 -S "SSL - Unknown identity received" \
1685 -S "SSL - Verification of the message MAC failed"
1686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001687run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001688 "$P_SRV psk_list=abc,dead,def,beef" \
1689 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1690 psk_identity=def psk=beef" \
1691 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001692 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001693 -S "SSL - Unknown identity received" \
1694 -S "SSL - Verification of the message MAC failed"
1695
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001696run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001697 "$P_SRV psk_list=abc,dead,def,beef" \
1698 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1699 psk_identity=ghi psk=beef" \
1700 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001701 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001702 -s "SSL - Unknown identity received" \
1703 -S "SSL - Verification of the message MAC failed"
1704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001705run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001706 "$P_SRV psk_list=abc,dead,def,beef" \
1707 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1708 psk_identity=abc psk=beef" \
1709 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001710 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001711 -S "SSL - Unknown identity received" \
1712 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001713
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001714# Tests for ciphersuites per version
1715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001716run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001717 "$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" \
1718 "$P_CLI force_version=ssl3" \
1719 0 \
1720 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001722run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001723 "$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" \
1724 "$P_CLI force_version=tls1" \
1725 0 \
1726 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1727
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001728run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001729 "$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" \
1730 "$P_CLI force_version=tls1_1" \
1731 0 \
1732 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001734run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001735 "$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" \
1736 "$P_CLI force_version=tls1_2" \
1737 0 \
1738 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1739
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001740# Tests for ssl_get_bytes_avail()
1741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001742run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001743 "$P_SRV" \
1744 "$P_CLI request_size=100" \
1745 0 \
1746 -s "Read from client: 100 bytes read$"
1747
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001748run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001749 "$P_SRV" \
1750 "$P_CLI request_size=500" \
1751 0 \
1752 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001753
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001754# Tests for small packets
1755
1756run_test "Small packet SSLv3 BlockCipher" \
1757 "$P_SRV" \
1758 "$P_CLI request_size=1 force_version=ssl3 \
1759 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1760 0 \
1761 -s "Read from client: 1 bytes read"
1762
1763run_test "Small packet SSLv3 StreamCipher" \
1764 "$P_SRV" \
1765 "$P_CLI request_size=1 force_version=ssl3 \
1766 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1767 0 \
1768 -s "Read from client: 1 bytes read"
1769
1770run_test "Small packet TLS 1.0 BlockCipher" \
1771 "$P_SRV" \
1772 "$P_CLI request_size=1 force_version=tls1 \
1773 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1774 0 \
1775 -s "Read from client: 1 bytes read"
1776
1777run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1778 "$P_SRV" \
1779 "$P_CLI request_size=1 force_version=tls1 \
1780 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1781 trunc_hmac=1" \
1782 0 \
1783 -s "Read from client: 1 bytes read"
1784
1785run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1786 "$P_SRV" \
1787 "$P_CLI request_size=1 force_version=tls1 \
1788 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1789 trunc_hmac=1" \
1790 0 \
1791 -s "Read from client: 1 bytes read"
1792
1793run_test "Small packet TLS 1.1 BlockCipher" \
1794 "$P_SRV" \
1795 "$P_CLI request_size=1 force_version=tls1_1 \
1796 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1797 0 \
1798 -s "Read from client: 1 bytes read"
1799
1800run_test "Small packet TLS 1.1 StreamCipher" \
1801 "$P_SRV" \
1802 "$P_CLI request_size=1 force_version=tls1_1 \
1803 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1804 0 \
1805 -s "Read from client: 1 bytes read"
1806
1807run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1808 "$P_SRV" \
1809 "$P_CLI request_size=1 force_version=tls1_1 \
1810 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1811 trunc_hmac=1" \
1812 0 \
1813 -s "Read from client: 1 bytes read"
1814
1815run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1816 "$P_SRV" \
1817 "$P_CLI request_size=1 force_version=tls1_1 \
1818 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1819 trunc_hmac=1" \
1820 0 \
1821 -s "Read from client: 1 bytes read"
1822
1823run_test "Small packet TLS 1.2 BlockCipher" \
1824 "$P_SRV" \
1825 "$P_CLI request_size=1 force_version=tls1_2 \
1826 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1827 0 \
1828 -s "Read from client: 1 bytes read"
1829
1830run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1831 "$P_SRV" \
1832 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1833 0 \
1834 -s "Read from client: 1 bytes read"
1835
1836run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1837 "$P_SRV" \
1838 "$P_CLI request_size=1 force_version=tls1_2 \
1839 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1840 trunc_hmac=1" \
1841 0 \
1842 -s "Read from client: 1 bytes read"
1843
1844run_test "Small packet TLS 1.2 StreamCipher" \
1845 "$P_SRV" \
1846 "$P_CLI request_size=1 force_version=tls1_2 \
1847 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1848 0 \
1849 -s "Read from client: 1 bytes read"
1850
1851run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1852 "$P_SRV" \
1853 "$P_CLI request_size=1 force_version=tls1_2 \
1854 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1855 trunc_hmac=1" \
1856 0 \
1857 -s "Read from client: 1 bytes read"
1858
1859run_test "Small packet TLS 1.2 AEAD" \
1860 "$P_SRV" \
1861 "$P_CLI request_size=1 force_version=tls1_2 \
1862 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1863 0 \
1864 -s "Read from client: 1 bytes read"
1865
1866run_test "Small packet TLS 1.2 AEAD shorter tag" \
1867 "$P_SRV" \
1868 "$P_CLI request_size=1 force_version=tls1_2 \
1869 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1870 0 \
1871 -s "Read from client: 1 bytes read"
1872
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001873# Test for large packets
1874
1875run_test "Large packet SSLv3 BlockCipher" \
1876 "$P_SRV" \
1877 "$P_CLI request_size=16384 force_version=ssl3 \
1878 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1879 0 \
1880 -s "Read from client: 16384 bytes read"
1881
1882run_test "Large packet SSLv3 StreamCipher" \
1883 "$P_SRV" \
1884 "$P_CLI request_size=16384 force_version=ssl3 \
1885 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1886 0 \
1887 -s "Read from client: 16384 bytes read"
1888
1889run_test "Large packet TLS 1.0 BlockCipher" \
1890 "$P_SRV" \
1891 "$P_CLI request_size=16384 force_version=tls1 \
1892 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1893 0 \
1894 -s "Read from client: 16384 bytes read"
1895
1896run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1897 "$P_SRV" \
1898 "$P_CLI request_size=16384 force_version=tls1 \
1899 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1900 trunc_hmac=1" \
1901 0 \
1902 -s "Read from client: 16384 bytes read"
1903
1904run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1905 "$P_SRV" \
1906 "$P_CLI request_size=16384 force_version=tls1 \
1907 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1908 trunc_hmac=1" \
1909 0 \
1910 -s "Read from client: 16384 bytes read"
1911
1912run_test "Large packet TLS 1.1 BlockCipher" \
1913 "$P_SRV" \
1914 "$P_CLI request_size=16384 force_version=tls1_1 \
1915 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1916 0 \
1917 -s "Read from client: 16384 bytes read"
1918
1919run_test "Large packet TLS 1.1 StreamCipher" \
1920 "$P_SRV" \
1921 "$P_CLI request_size=16384 force_version=tls1_1 \
1922 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1923 0 \
1924 -s "Read from client: 16384 bytes read"
1925
1926run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1927 "$P_SRV" \
1928 "$P_CLI request_size=16384 force_version=tls1_1 \
1929 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1930 trunc_hmac=1" \
1931 0 \
1932 -s "Read from client: 16384 bytes read"
1933
1934run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1935 "$P_SRV" \
1936 "$P_CLI request_size=16384 force_version=tls1_1 \
1937 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1938 trunc_hmac=1" \
1939 0 \
1940 -s "Read from client: 16384 bytes read"
1941
1942run_test "Large packet TLS 1.2 BlockCipher" \
1943 "$P_SRV" \
1944 "$P_CLI request_size=16384 force_version=tls1_2 \
1945 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1946 0 \
1947 -s "Read from client: 16384 bytes read"
1948
1949run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1950 "$P_SRV" \
1951 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1952 0 \
1953 -s "Read from client: 16384 bytes read"
1954
1955run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1956 "$P_SRV" \
1957 "$P_CLI request_size=16384 force_version=tls1_2 \
1958 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1959 trunc_hmac=1" \
1960 0 \
1961 -s "Read from client: 16384 bytes read"
1962
1963run_test "Large packet TLS 1.2 StreamCipher" \
1964 "$P_SRV" \
1965 "$P_CLI request_size=16384 force_version=tls1_2 \
1966 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1967 0 \
1968 -s "Read from client: 16384 bytes read"
1969
1970run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1971 "$P_SRV" \
1972 "$P_CLI request_size=16384 force_version=tls1_2 \
1973 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1974 trunc_hmac=1" \
1975 0 \
1976 -s "Read from client: 16384 bytes read"
1977
1978run_test "Large packet TLS 1.2 AEAD" \
1979 "$P_SRV" \
1980 "$P_CLI request_size=16384 force_version=tls1_2 \
1981 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1982 0 \
1983 -s "Read from client: 16384 bytes read"
1984
1985run_test "Large packet TLS 1.2 AEAD shorter tag" \
1986 "$P_SRV" \
1987 "$P_CLI request_size=16384 force_version=tls1_2 \
1988 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1989 0 \
1990 -s "Read from client: 16384 bytes read"
1991
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001992# Final report
1993
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001994echo "------------------------------------------------------------------------"
1995
1996if [ $FAILS = 0 ]; then
1997 echo -n "PASSED"
1998else
1999 echo -n "FAILED"
2000fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002001PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002002echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002003
2004exit $FAILS