blob: e39320bd6c46710f6759027a9be747f8d896a6fc [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
21O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
23G_CLI="$GNUTLS_CLI"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010037 echo -e " -h|--help\tPrint this help."
38 echo -e " -m|--memcheck\tCheck memory leaks and errors."
39 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
40 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
78 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020083# skip next test if GnuTLS isn't available
84requires_gnutls() {
85 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
86 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
87 GNUTLS_AVAILABLE="YES"
88 else
89 GNUTLS_AVAILABLE="NO"
90 fi
91 fi
92 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
93 SKIP_NEXT="YES"
94 fi
95}
96
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010097# print_name <name>
98print_name() {
99 echo -n "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200100 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100101 for i in `seq 1 $LEN`; do echo -n '.'; done
102 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100103
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200104 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100105}
106
107# fail <message>
108fail() {
109 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100110 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100111
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200112 mv $SRV_OUT o-srv-${TESTS}.log
113 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100114 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100115
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200116 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100117}
118
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100119# is_polar <cmd_line>
120is_polar() {
121 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
122}
123
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100124# has_mem_err <log_file_name>
125has_mem_err() {
126 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
127 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
128 then
129 return 1 # false: does not have errors
130 else
131 return 0 # true: has errors
132 fi
133}
134
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200135# wait for server to start: two versions depending on lsof availability
136wait_server_start() {
137 if which lsof >/dev/null; then
138 # make sure we don't loop forever
139 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
140 WATCHDOG_PID=$!
141
142 # make a tight loop, server usually takes less than 1 sec to start
143 until lsof -nbi TCP:"$PORT" | grep LISTEN >/dev/null; do :; done
144
145 kill $WATCHDOG_PID
146 wait $WATCHDOG_PID
147 else
148 sleep "$START_DELAY"
149 fi
150}
151
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200152# wait for client to terminate and set CLI_EXIT
153# must be called right after starting the client
154wait_client_done() {
155 CLI_PID=$!
156
157 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
158 WATCHDOG_PID=$!
159
160 wait $CLI_PID
161 CLI_EXIT=$?
162
163 kill $WATCHDOG_PID
164 wait $WATCHDOG_PID
165
166 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
167}
168
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100169# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100170# Options: -s pattern pattern that must be present in server output
171# -c pattern pattern that must be present in client output
172# -S pattern pattern that must be absent in server output
173# -C pattern pattern that must be absent in client output
174run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100175 NAME="$1"
176 SRV_CMD="$2"
177 CLI_CMD="$3"
178 CLI_EXPECT="$4"
179 shift 4
180
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100181 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
182 else
183 return
184 fi
185
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100186 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100187
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200188 # should we skip?
189 if [ "X$SKIP_NEXT" = "XYES" ]; then
190 SKIP_NEXT="NO"
191 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200192 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200193 return
194 fi
195
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100196 # prepend valgrind to our commands if active
197 if [ "$MEMCHECK" -gt 0 ]; then
198 if is_polar "$SRV_CMD"; then
199 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
200 fi
201 if is_polar "$CLI_CMD"; then
202 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
203 fi
204 fi
205
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100206 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200207 echo "$SRV_CMD" > $SRV_OUT
208 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100209 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200210 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200211
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200212 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200213 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
214 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100215
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200216 # kill the server
217 kill $SRV_PID
218 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100219
220 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200221 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100222 # expected client exit to incorrectly succeed in case of catastrophic
223 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100224 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200225 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100226 else
227 fail "server failed to start"
228 return
229 fi
230 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100231 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200232 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100233 else
234 fail "client failed to start"
235 return
236 fi
237 fi
238
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100239 # check server exit code
240 if [ $? != 0 ]; then
241 fail "server fail"
242 return
243 fi
244
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100245 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100246 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
247 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100248 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100249 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100250 return
251 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100252
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100253 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200254 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100255 while [ $# -gt 0 ]
256 do
257 case $1 in
258 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200259 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100260 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100261 return
262 fi
263 ;;
264
265 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200266 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100267 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100268 return
269 fi
270 ;;
271
272 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200273 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100274 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100275 return
276 fi
277 ;;
278
279 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200280 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100281 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100282 return
283 fi
284 ;;
285
286 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200287 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100288 exit 1
289 esac
290 shift 2
291 done
292
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100293 # check valgrind's results
294 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200295 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100296 fail "Server has memory errors"
297 return
298 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200299 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100300 fail "Client has memory errors"
301 return
302 fi
303 fi
304
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100305 # if we're here, everything is ok
306 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200307 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100308}
309
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100310cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200311 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200312 kill $SRV_PID >/dev/null 2>&1
313 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100314 exit 1
315}
316
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100317#
318# MAIN
319#
320
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100321get_options "$@"
322
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100323# sanity checks, avoid an avalanche of errors
324if [ ! -x "$P_SRV" ]; then
325 echo "Command '$P_SRV' is not an executable file"
326 exit 1
327fi
328if [ ! -x "$P_CLI" ]; then
329 echo "Command '$P_CLI' is not an executable file"
330 exit 1
331fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100332if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
333 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100334 exit 1
335fi
336
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200337# used by watchdog
338MAIN_PID="$$"
339
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200340# be more patient with valgrind
341if [ "$MEMCHECK" -gt 0 ]; then
342 START_DELAY=3
343 DOG_DELAY=30
344else
345 START_DELAY=1
346 DOG_DELAY=10
347fi
348
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200349# Pick a "unique" port in the range 10000-19999.
350PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200351PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200352
353# fix commands to use this port
354P_SRV="$P_SRV server_port=$PORT"
355P_CLI="$P_CLI server_port=$PORT"
356O_SRV="$O_SRV -accept $PORT"
357O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200358G_SRV="$G_SRV -p $PORT"
359G_CLI="$G_CLI -p $PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200360
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200361# Also pick a unique name for intermediate files
362SRV_OUT="srv_out.$$"
363CLI_OUT="cli_out.$$"
364SESSION="session.$$"
365
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200366SKIP_NEXT="NO"
367
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100368trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100369
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200370# Basic test
371
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200372# Checks that:
373# - things work with all ciphersuites active (used with config-full in all.sh)
374# - the expected (highest security) parameters are selected
375# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200376run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200377 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200378 "$P_CLI" \
379 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200380 -s "Protocol is TLSv1.2" \
381 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
382 -s "client hello v3, signature_algorithm ext: 6" \
383 -s "ECDHE curve: secp521r1" \
384 -S "error" \
385 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200386
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100387# Test for SSLv2 ClientHello
388
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200389requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200390run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100391 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100392 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100393 0 \
394 -S "parse client hello v2" \
395 -S "ssl_handshake returned"
396
397# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200398requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200399run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200400 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100401 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100402 0 \
403 -s "parse client hello v2" \
404 -S "ssl_handshake returned"
405
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100406# Tests for Truncated HMAC extension
407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200408run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200409 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100410 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100411 0 \
412 -s "dumping 'computed mac' (20 bytes)"
413
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200414run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200415 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100416 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100417 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100418 -s "dumping 'computed mac' (10 bytes)"
419
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100420# Tests for Session Tickets
421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200422run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200423 "$P_SRV debug_level=3 tickets=1" \
424 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100425 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100426 -c "client hello, adding session ticket extension" \
427 -s "found session ticket extension" \
428 -s "server hello, adding session ticket extension" \
429 -c "found session_ticket extension" \
430 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100431 -S "session successfully restored from cache" \
432 -s "session successfully restored from ticket" \
433 -s "a session has been resumed" \
434 -c "a session has been resumed"
435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200436run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200437 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
438 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100439 0 \
440 -c "client hello, adding session ticket extension" \
441 -s "found session ticket extension" \
442 -s "server hello, adding session ticket extension" \
443 -c "found session_ticket extension" \
444 -c "parse new session ticket" \
445 -S "session successfully restored from cache" \
446 -s "session successfully restored from ticket" \
447 -s "a session has been resumed" \
448 -c "a session has been resumed"
449
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200450run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200451 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
452 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100453 0 \
454 -c "client hello, adding session ticket extension" \
455 -s "found session ticket extension" \
456 -s "server hello, adding session ticket extension" \
457 -c "found session_ticket extension" \
458 -c "parse new session ticket" \
459 -S "session successfully restored from cache" \
460 -S "session successfully restored from ticket" \
461 -S "a session has been resumed" \
462 -C "a session has been resumed"
463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200464run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100465 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200466 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100467 0 \
468 -c "client hello, adding session ticket extension" \
469 -c "found session_ticket extension" \
470 -c "parse new session ticket" \
471 -c "a session has been resumed"
472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200473run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200474 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200475 "( $O_CLI -sess_out $SESSION; \
476 $O_CLI -sess_in $SESSION; \
477 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100478 0 \
479 -s "found session ticket extension" \
480 -s "server hello, adding session ticket extension" \
481 -S "session successfully restored from cache" \
482 -s "session successfully restored from ticket" \
483 -s "a session has been resumed"
484
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100485# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200487run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200488 "$P_SRV debug_level=3 tickets=0" \
489 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100490 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100491 -c "client hello, adding session ticket extension" \
492 -s "found session ticket extension" \
493 -S "server hello, adding session ticket extension" \
494 -C "found session_ticket extension" \
495 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100496 -s "session successfully restored from cache" \
497 -S "session successfully restored from ticket" \
498 -s "a session has been resumed" \
499 -c "a session has been resumed"
500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200501run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200502 "$P_SRV debug_level=3 tickets=1" \
503 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100504 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100505 -C "client hello, adding session ticket extension" \
506 -S "found session ticket extension" \
507 -S "server hello, adding session ticket extension" \
508 -C "found session_ticket extension" \
509 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100510 -s "session successfully restored from cache" \
511 -S "session successfully restored from ticket" \
512 -s "a session has been resumed" \
513 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200515run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200516 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
517 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100518 0 \
519 -S "session successfully restored from cache" \
520 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100521 -S "a session has been resumed" \
522 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200524run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200525 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
526 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100527 0 \
528 -s "session successfully restored from cache" \
529 -S "session successfully restored from ticket" \
530 -s "a session has been resumed" \
531 -c "a session has been resumed"
532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200533run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200534 "$P_SRV debug_level=3 tickets=0" \
535 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100536 0 \
537 -s "session successfully restored from cache" \
538 -S "session successfully restored from ticket" \
539 -s "a session has been resumed" \
540 -c "a session has been resumed"
541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200542run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200543 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
544 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100545 0 \
546 -S "session successfully restored from cache" \
547 -S "session successfully restored from ticket" \
548 -S "a session has been resumed" \
549 -C "a session has been resumed"
550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200551run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200552 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
553 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100554 0 \
555 -s "session successfully restored from cache" \
556 -S "session successfully restored from ticket" \
557 -s "a session has been resumed" \
558 -c "a session has been resumed"
559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200560run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200561 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200562 "( $O_CLI -sess_out $SESSION; \
563 $O_CLI -sess_in $SESSION; \
564 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100565 0 \
566 -s "found session ticket extension" \
567 -S "server hello, adding session ticket extension" \
568 -s "session successfully restored from cache" \
569 -S "session successfully restored from ticket" \
570 -s "a session has been resumed"
571
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200572run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100573 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200574 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100575 0 \
576 -C "found session_ticket extension" \
577 -C "parse new session ticket" \
578 -c "a session has been resumed"
579
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100580# Tests for Max Fragment Length extension
581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200582run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200583 "$P_SRV debug_level=3" \
584 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100585 0 \
586 -C "client hello, adding max_fragment_length extension" \
587 -S "found max fragment length extension" \
588 -S "server hello, max_fragment_length extension" \
589 -C "found max_fragment_length extension"
590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200591run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200592 "$P_SRV debug_level=3" \
593 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100594 0 \
595 -c "client hello, adding max_fragment_length extension" \
596 -s "found max fragment length extension" \
597 -s "server hello, max_fragment_length extension" \
598 -c "found max_fragment_length extension"
599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200600run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200601 "$P_SRV debug_level=3 max_frag_len=4096" \
602 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100603 0 \
604 -C "client hello, adding max_fragment_length extension" \
605 -S "found max fragment length extension" \
606 -S "server hello, max_fragment_length extension" \
607 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200609requires_gnutls
610run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200611 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200612 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200613 0 \
614 -c "client hello, adding max_fragment_length extension" \
615 -c "found max_fragment_length extension"
616
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100617# Tests for renegotiation
618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200619run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200620 "$P_SRV debug_level=3 exchanges=2" \
621 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100622 0 \
623 -C "client hello, adding renegotiation extension" \
624 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
625 -S "found renegotiation extension" \
626 -s "server hello, secure renegotiation extension" \
627 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100628 -C "=> renegotiate" \
629 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100630 -S "write hello request"
631
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200632run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200633 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
634 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100635 0 \
636 -c "client hello, adding renegotiation extension" \
637 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
638 -s "found renegotiation extension" \
639 -s "server hello, secure renegotiation extension" \
640 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100641 -c "=> renegotiate" \
642 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100643 -S "write hello request"
644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200645run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200646 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
647 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100648 0 \
649 -c "client hello, adding renegotiation extension" \
650 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
651 -s "found renegotiation extension" \
652 -s "server hello, secure renegotiation extension" \
653 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100654 -c "=> renegotiate" \
655 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100656 -s "write hello request"
657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200658run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200659 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
660 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100661 0 \
662 -c "client hello, adding renegotiation extension" \
663 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
664 -s "found renegotiation extension" \
665 -s "server hello, secure renegotiation extension" \
666 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100667 -c "=> renegotiate" \
668 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100669 -s "write hello request"
670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200671run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200672 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
673 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100674 1 \
675 -c "client hello, adding renegotiation extension" \
676 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
677 -S "found renegotiation extension" \
678 -s "server hello, secure renegotiation extension" \
679 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100680 -c "=> renegotiate" \
681 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200682 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200683 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200684 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100685
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200686run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200687 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
688 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100689 0 \
690 -C "client hello, adding renegotiation extension" \
691 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
692 -S "found renegotiation extension" \
693 -s "server hello, secure renegotiation extension" \
694 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100695 -C "=> renegotiate" \
696 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100697 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200698 -S "SSL - An unexpected message was received from our peer" \
699 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200701run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200702 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200703 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200704 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200705 0 \
706 -C "client hello, adding renegotiation extension" \
707 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
708 -S "found renegotiation extension" \
709 -s "server hello, secure renegotiation extension" \
710 -c "found renegotiation extension" \
711 -C "=> renegotiate" \
712 -S "=> renegotiate" \
713 -s "write hello request" \
714 -S "SSL - An unexpected message was received from our peer" \
715 -S "failed"
716
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200717# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200718run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200719 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200720 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200721 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200722 0 \
723 -C "client hello, adding renegotiation extension" \
724 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
725 -S "found renegotiation extension" \
726 -s "server hello, secure renegotiation extension" \
727 -c "found renegotiation extension" \
728 -C "=> renegotiate" \
729 -S "=> renegotiate" \
730 -s "write hello request" \
731 -S "SSL - An unexpected message was received from our peer" \
732 -S "failed"
733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200734run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200735 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200736 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200737 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200738 0 \
739 -C "client hello, adding renegotiation extension" \
740 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
741 -S "found renegotiation extension" \
742 -s "server hello, secure renegotiation extension" \
743 -c "found renegotiation extension" \
744 -C "=> renegotiate" \
745 -S "=> renegotiate" \
746 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200747 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200749run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200750 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200751 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200752 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200753 0 \
754 -c "client hello, adding renegotiation extension" \
755 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
756 -s "found renegotiation extension" \
757 -s "server hello, secure renegotiation extension" \
758 -c "found renegotiation extension" \
759 -c "=> renegotiate" \
760 -s "=> renegotiate" \
761 -s "write hello request" \
762 -S "SSL - An unexpected message was received from our peer" \
763 -S "failed"
764
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200765run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200766 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
767 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200768 0 \
769 -c "client hello, adding renegotiation extension" \
770 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
771 -s "found renegotiation extension" \
772 -s "server hello, secure renegotiation extension" \
773 -c "found renegotiation extension" \
774 -c "=> renegotiate" \
775 -s "=> renegotiate" \
776 -S "write hello request"
777
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200778run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200779 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
780 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200781 0 \
782 -c "client hello, adding renegotiation extension" \
783 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
784 -s "found renegotiation extension" \
785 -s "server hello, secure renegotiation extension" \
786 -c "found renegotiation extension" \
787 -c "=> renegotiate" \
788 -s "=> renegotiate" \
789 -s "write hello request"
790
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200791run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200792 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200793 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200794 0 \
795 -c "client hello, adding renegotiation extension" \
796 -c "found renegotiation extension" \
797 -c "=> renegotiate" \
798 -C "ssl_handshake returned" \
799 -C "error" \
800 -c "HTTP/1.0 200 [Oo][Kk]"
801
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200802run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200803 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200804 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200805 0 \
806 -c "client hello, adding renegotiation extension" \
807 -c "found renegotiation extension" \
808 -c "=> renegotiate" \
809 -C "ssl_handshake returned" \
810 -C "error" \
811 -c "HTTP/1.0 200 [Oo][Kk]"
812
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100813# Tests for auth_mode
814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200815run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100816 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100817 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200818 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100819 1 \
820 -c "x509_verify_cert() returned" \
821 -c "! self-signed or not signed by a trusted CA" \
822 -c "! ssl_handshake returned" \
823 -c "X509 - Certificate verification failed"
824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200825run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100826 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100827 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200828 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100829 0 \
830 -c "x509_verify_cert() returned" \
831 -c "! self-signed or not signed by a trusted CA" \
832 -C "! ssl_handshake returned" \
833 -C "X509 - Certificate verification failed"
834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200835run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100836 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100837 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200838 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100839 0 \
840 -C "x509_verify_cert() returned" \
841 -C "! self-signed or not signed by a trusted CA" \
842 -C "! ssl_handshake returned" \
843 -C "X509 - Certificate verification failed"
844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200845run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200846 "$P_SRV debug_level=3 auth_mode=required" \
847 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100848 key_file=data_files/server5.key" \
849 1 \
850 -S "skip write certificate request" \
851 -C "skip parse certificate request" \
852 -c "got a certificate request" \
853 -C "skip write certificate" \
854 -C "skip write certificate verify" \
855 -S "skip parse certificate verify" \
856 -s "x509_verify_cert() returned" \
857 -S "! self-signed or not signed by a trusted CA" \
858 -s "! ssl_handshake returned" \
859 -c "! ssl_handshake returned" \
860 -s "X509 - Certificate verification failed"
861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200862run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200863 "$P_SRV debug_level=3 auth_mode=optional" \
864 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100865 key_file=data_files/server5.key" \
866 0 \
867 -S "skip write certificate request" \
868 -C "skip parse certificate request" \
869 -c "got a certificate request" \
870 -C "skip write certificate" \
871 -C "skip write certificate verify" \
872 -S "skip parse certificate verify" \
873 -s "x509_verify_cert() returned" \
874 -s "! self-signed or not signed by a trusted CA" \
875 -S "! ssl_handshake returned" \
876 -C "! ssl_handshake returned" \
877 -S "X509 - Certificate verification failed"
878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200879run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200880 "$P_SRV debug_level=3 auth_mode=none" \
881 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100882 key_file=data_files/server5.key" \
883 0 \
884 -s "skip write certificate request" \
885 -C "skip parse certificate request" \
886 -c "got no certificate request" \
887 -c "skip write certificate" \
888 -c "skip write certificate verify" \
889 -s "skip parse certificate verify" \
890 -S "x509_verify_cert() returned" \
891 -S "! self-signed or not signed by a trusted CA" \
892 -S "! ssl_handshake returned" \
893 -C "! ssl_handshake returned" \
894 -S "X509 - Certificate verification failed"
895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200896run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200897 "$P_SRV debug_level=3 auth_mode=optional" \
898 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100899 0 \
900 -S "skip write certificate request" \
901 -C "skip parse certificate request" \
902 -c "got a certificate request" \
903 -C "skip write certificate$" \
904 -C "got no certificate to send" \
905 -S "SSLv3 client has no certificate" \
906 -c "skip write certificate verify" \
907 -s "skip parse certificate verify" \
908 -s "! no client certificate sent" \
909 -S "! ssl_handshake returned" \
910 -C "! ssl_handshake returned" \
911 -S "X509 - Certificate verification failed"
912
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200913run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200914 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100915 "$O_CLI" \
916 0 \
917 -S "skip write certificate request" \
918 -s "skip parse certificate verify" \
919 -s "! no client certificate sent" \
920 -S "! ssl_handshake returned" \
921 -S "X509 - Certificate verification failed"
922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200923run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100924 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200925 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100926 0 \
927 -C "skip parse certificate request" \
928 -c "got a certificate request" \
929 -C "skip write certificate$" \
930 -c "skip write certificate verify" \
931 -C "! ssl_handshake returned"
932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200933run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200934 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
935 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100936 0 \
937 -S "skip write certificate request" \
938 -C "skip parse certificate request" \
939 -c "got a certificate request" \
940 -C "skip write certificate$" \
941 -c "skip write certificate verify" \
942 -c "got no certificate to send" \
943 -s "SSLv3 client has no certificate" \
944 -s "skip parse certificate verify" \
945 -s "! no client certificate sent" \
946 -S "! ssl_handshake returned" \
947 -C "! ssl_handshake returned" \
948 -S "X509 - Certificate verification failed"
949
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100950# tests for SNI
951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200952run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200953 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100954 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100955 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100956 server_name=localhost" \
957 0 \
958 -S "parse ServerName extension" \
959 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
960 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
961
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200962run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200963 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100964 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100965 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 +0100966 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100967 server_name=localhost" \
968 0 \
969 -s "parse ServerName extension" \
970 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
971 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200973run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200974 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100975 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100976 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 +0100977 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100978 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100979 0 \
980 -s "parse ServerName extension" \
981 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100982 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200984run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200985 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100986 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100987 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 +0100988 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100989 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100990 1 \
991 -s "parse ServerName extension" \
992 -s "ssl_sni_wrapper() returned" \
993 -s "ssl_handshake returned" \
994 -c "ssl_handshake returned" \
995 -c "SSL - A fatal alert message was received from our peer"
996
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +0100997# Tests for non-blocking I/O: exercise a variety of handshake flows
998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200999run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001000 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1001 "$P_CLI nbio=2 tickets=0" \
1002 0 \
1003 -S "ssl_handshake returned" \
1004 -C "ssl_handshake returned" \
1005 -c "Read from server: .* bytes read"
1006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001007run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001008 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1009 "$P_CLI nbio=2 tickets=0" \
1010 0 \
1011 -S "ssl_handshake returned" \
1012 -C "ssl_handshake returned" \
1013 -c "Read from server: .* bytes read"
1014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001015run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001016 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1017 "$P_CLI nbio=2 tickets=1" \
1018 0 \
1019 -S "ssl_handshake returned" \
1020 -C "ssl_handshake returned" \
1021 -c "Read from server: .* bytes read"
1022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001023run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001024 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1025 "$P_CLI nbio=2 tickets=1" \
1026 0 \
1027 -S "ssl_handshake returned" \
1028 -C "ssl_handshake returned" \
1029 -c "Read from server: .* bytes read"
1030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001031run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001032 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1033 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1034 0 \
1035 -S "ssl_handshake returned" \
1036 -C "ssl_handshake returned" \
1037 -c "Read from server: .* bytes read"
1038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001039run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001040 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1041 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1042 0 \
1043 -S "ssl_handshake returned" \
1044 -C "ssl_handshake returned" \
1045 -c "Read from server: .* bytes read"
1046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001047run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001048 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1049 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1050 0 \
1051 -S "ssl_handshake returned" \
1052 -C "ssl_handshake returned" \
1053 -c "Read from server: .* bytes read"
1054
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001055# Tests for version negotiation
1056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001057run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001058 "$P_SRV" \
1059 "$P_CLI" \
1060 0 \
1061 -S "ssl_handshake returned" \
1062 -C "ssl_handshake returned" \
1063 -s "Protocol is TLSv1.2" \
1064 -c "Protocol is TLSv1.2"
1065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001066run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001067 "$P_SRV" \
1068 "$P_CLI max_version=tls1_1" \
1069 0 \
1070 -S "ssl_handshake returned" \
1071 -C "ssl_handshake returned" \
1072 -s "Protocol is TLSv1.1" \
1073 -c "Protocol is TLSv1.1"
1074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001075run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001076 "$P_SRV max_version=tls1_1" \
1077 "$P_CLI" \
1078 0 \
1079 -S "ssl_handshake returned" \
1080 -C "ssl_handshake returned" \
1081 -s "Protocol is TLSv1.1" \
1082 -c "Protocol is TLSv1.1"
1083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001084run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001085 "$P_SRV max_version=tls1_1" \
1086 "$P_CLI max_version=tls1_1" \
1087 0 \
1088 -S "ssl_handshake returned" \
1089 -C "ssl_handshake returned" \
1090 -s "Protocol is TLSv1.1" \
1091 -c "Protocol is TLSv1.1"
1092
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001093run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001094 "$P_SRV min_version=tls1_1" \
1095 "$P_CLI max_version=tls1_1" \
1096 0 \
1097 -S "ssl_handshake returned" \
1098 -C "ssl_handshake returned" \
1099 -s "Protocol is TLSv1.1" \
1100 -c "Protocol is TLSv1.1"
1101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001102run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001103 "$P_SRV max_version=tls1_1" \
1104 "$P_CLI min_version=tls1_1" \
1105 0 \
1106 -S "ssl_handshake returned" \
1107 -C "ssl_handshake returned" \
1108 -s "Protocol is TLSv1.1" \
1109 -c "Protocol is TLSv1.1"
1110
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001111run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001112 "$P_SRV max_version=tls1_1" \
1113 "$P_CLI min_version=tls1_2" \
1114 1 \
1115 -s "ssl_handshake returned" \
1116 -c "ssl_handshake returned" \
1117 -c "SSL - Handshake protocol not within min/max boundaries"
1118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001119run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001120 "$P_SRV min_version=tls1_2" \
1121 "$P_CLI max_version=tls1_1" \
1122 1 \
1123 -s "ssl_handshake returned" \
1124 -c "ssl_handshake returned" \
1125 -s "SSL - Handshake protocol not within min/max boundaries"
1126
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001127# Tests for ALPN extension
1128
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001129if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1130
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001131run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001132 "$P_SRV debug_level=3" \
1133 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001134 0 \
1135 -C "client hello, adding alpn extension" \
1136 -S "found alpn extension" \
1137 -C "got an alert message, type: \\[2:120]" \
1138 -S "server hello, adding alpn extension" \
1139 -C "found alpn extension " \
1140 -C "Application Layer Protocol is" \
1141 -S "Application Layer Protocol is"
1142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001143run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001144 "$P_SRV debug_level=3" \
1145 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001146 0 \
1147 -c "client hello, adding alpn extension" \
1148 -s "found alpn extension" \
1149 -C "got an alert message, type: \\[2:120]" \
1150 -S "server hello, adding alpn extension" \
1151 -C "found alpn extension " \
1152 -c "Application Layer Protocol is (none)" \
1153 -S "Application Layer Protocol is"
1154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001155run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001156 "$P_SRV debug_level=3 alpn=abc,1234" \
1157 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001158 0 \
1159 -C "client hello, adding alpn extension" \
1160 -S "found alpn extension" \
1161 -C "got an alert message, type: \\[2:120]" \
1162 -S "server hello, adding alpn extension" \
1163 -C "found alpn extension " \
1164 -C "Application Layer Protocol is" \
1165 -s "Application Layer Protocol is (none)"
1166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001167run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001168 "$P_SRV debug_level=3 alpn=abc,1234" \
1169 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001170 0 \
1171 -c "client hello, adding alpn extension" \
1172 -s "found alpn extension" \
1173 -C "got an alert message, type: \\[2:120]" \
1174 -s "server hello, adding alpn extension" \
1175 -c "found alpn extension" \
1176 -c "Application Layer Protocol is abc" \
1177 -s "Application Layer Protocol is abc"
1178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001179run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001180 "$P_SRV debug_level=3 alpn=abc,1234" \
1181 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001182 0 \
1183 -c "client hello, adding alpn extension" \
1184 -s "found alpn extension" \
1185 -C "got an alert message, type: \\[2:120]" \
1186 -s "server hello, adding alpn extension" \
1187 -c "found alpn extension" \
1188 -c "Application Layer Protocol is abc" \
1189 -s "Application Layer Protocol is abc"
1190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001191run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001192 "$P_SRV debug_level=3 alpn=abc,1234" \
1193 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001194 0 \
1195 -c "client hello, adding alpn extension" \
1196 -s "found alpn extension" \
1197 -C "got an alert message, type: \\[2:120]" \
1198 -s "server hello, adding alpn extension" \
1199 -c "found alpn extension" \
1200 -c "Application Layer Protocol is 1234" \
1201 -s "Application Layer Protocol is 1234"
1202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001203run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001204 "$P_SRV debug_level=3 alpn=abc,123" \
1205 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001206 1 \
1207 -c "client hello, adding alpn extension" \
1208 -s "found alpn extension" \
1209 -c "got an alert message, type: \\[2:120]" \
1210 -S "server hello, adding alpn extension" \
1211 -C "found alpn extension" \
1212 -C "Application Layer Protocol is 1234" \
1213 -S "Application Layer Protocol is 1234"
1214
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001215fi
1216
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001217# Tests for keyUsage in leaf certificates, part 1:
1218# server-side certificate/suite selection
1219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001220run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001221 "$P_SRV key_file=data_files/server2.key \
1222 crt_file=data_files/server2.ku-ds.crt" \
1223 "$P_CLI" \
1224 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001225 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001226
1227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001228run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001229 "$P_SRV key_file=data_files/server2.key \
1230 crt_file=data_files/server2.ku-ke.crt" \
1231 "$P_CLI" \
1232 0 \
1233 -c "Ciphersuite is TLS-RSA-WITH-"
1234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001235run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001236 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001237 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001238 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001239 1 \
1240 -C "Ciphersuite is "
1241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001242run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001243 "$P_SRV key_file=data_files/server5.key \
1244 crt_file=data_files/server5.ku-ds.crt" \
1245 "$P_CLI" \
1246 0 \
1247 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1248
1249
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001250run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001251 "$P_SRV key_file=data_files/server5.key \
1252 crt_file=data_files/server5.ku-ka.crt" \
1253 "$P_CLI" \
1254 0 \
1255 -c "Ciphersuite is TLS-ECDH-"
1256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001257run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001258 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001259 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001260 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001261 1 \
1262 -C "Ciphersuite is "
1263
1264# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001265# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001267run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001268 "$O_SRV -key data_files/server2.key \
1269 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001270 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001271 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1272 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001273 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001274 -C "Processing of the Certificate handshake message failed" \
1275 -c "Ciphersuite is TLS-"
1276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001277run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001278 "$O_SRV -key data_files/server2.key \
1279 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001280 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001281 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1282 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001283 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001284 -C "Processing of the Certificate handshake message failed" \
1285 -c "Ciphersuite is TLS-"
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001288 "$O_SRV -key data_files/server2.key \
1289 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001290 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001291 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1292 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001293 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001294 -C "Processing of the Certificate handshake message failed" \
1295 -c "Ciphersuite is TLS-"
1296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001297run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001298 "$O_SRV -key data_files/server2.key \
1299 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001300 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001301 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1302 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001303 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001304 -c "Processing of the Certificate handshake message failed" \
1305 -C "Ciphersuite is TLS-"
1306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001307run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001308 "$O_SRV -key data_files/server2.key \
1309 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001310 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001311 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1312 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001313 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001314 -C "Processing of the Certificate handshake message failed" \
1315 -c "Ciphersuite is TLS-"
1316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001317run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001318 "$O_SRV -key data_files/server2.key \
1319 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001320 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001321 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1322 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001323 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001324 -c "Processing of the Certificate handshake message failed" \
1325 -C "Ciphersuite is TLS-"
1326
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001327# Tests for keyUsage in leaf certificates, part 3:
1328# server-side checking of client cert
1329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001330run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001331 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001332 "$O_CLI -key data_files/server2.key \
1333 -cert data_files/server2.ku-ds.crt" \
1334 0 \
1335 -S "bad certificate (usage extensions)" \
1336 -S "Processing of the Certificate handshake message failed"
1337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001338run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001339 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001340 "$O_CLI -key data_files/server2.key \
1341 -cert data_files/server2.ku-ke.crt" \
1342 0 \
1343 -s "bad certificate (usage extensions)" \
1344 -S "Processing of the Certificate handshake message failed"
1345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001348 "$O_CLI -key data_files/server2.key \
1349 -cert data_files/server2.ku-ke.crt" \
1350 1 \
1351 -s "bad certificate (usage extensions)" \
1352 -s "Processing of the Certificate handshake message failed"
1353
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001354run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001355 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001356 "$O_CLI -key data_files/server5.key \
1357 -cert data_files/server5.ku-ds.crt" \
1358 0 \
1359 -S "bad certificate (usage extensions)" \
1360 -S "Processing of the Certificate handshake message failed"
1361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001362run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001363 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001364 "$O_CLI -key data_files/server5.key \
1365 -cert data_files/server5.ku-ka.crt" \
1366 0 \
1367 -s "bad certificate (usage extensions)" \
1368 -S "Processing of the Certificate handshake message failed"
1369
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001370# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001372run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001373 "$P_SRV key_file=data_files/server5.key \
1374 crt_file=data_files/server5.eku-srv.crt" \
1375 "$P_CLI" \
1376 0
1377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001378run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001379 "$P_SRV key_file=data_files/server5.key \
1380 crt_file=data_files/server5.eku-srv.crt" \
1381 "$P_CLI" \
1382 0
1383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001384run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001385 "$P_SRV key_file=data_files/server5.key \
1386 crt_file=data_files/server5.eku-cs_any.crt" \
1387 "$P_CLI" \
1388 0
1389
1390# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001391run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001392 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1393 crt_file=data_files/server5.eku-cli.crt" \
1394 "$P_CLI psk=badbad" \
1395 1
1396
1397# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001399run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001400 "$O_SRV -key data_files/server5.key \
1401 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001402 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001403 0 \
1404 -C "bad certificate (usage extensions)" \
1405 -C "Processing of the Certificate handshake message failed" \
1406 -c "Ciphersuite is TLS-"
1407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001408run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001409 "$O_SRV -key data_files/server5.key \
1410 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001411 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001412 0 \
1413 -C "bad certificate (usage extensions)" \
1414 -C "Processing of the Certificate handshake message failed" \
1415 -c "Ciphersuite is TLS-"
1416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001417run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001418 "$O_SRV -key data_files/server5.key \
1419 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001420 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001421 0 \
1422 -C "bad certificate (usage extensions)" \
1423 -C "Processing of the Certificate handshake message failed" \
1424 -c "Ciphersuite is TLS-"
1425
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001426run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001427 "$O_SRV -key data_files/server5.key \
1428 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001429 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001430 1 \
1431 -c "bad certificate (usage extensions)" \
1432 -c "Processing of the Certificate handshake message failed" \
1433 -C "Ciphersuite is TLS-"
1434
1435# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001437run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001438 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001439 "$O_CLI -key data_files/server5.key \
1440 -cert data_files/server5.eku-cli.crt" \
1441 0 \
1442 -S "bad certificate (usage extensions)" \
1443 -S "Processing of the Certificate handshake message failed"
1444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001445run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001446 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001447 "$O_CLI -key data_files/server5.key \
1448 -cert data_files/server5.eku-srv_cli.crt" \
1449 0 \
1450 -S "bad certificate (usage extensions)" \
1451 -S "Processing of the Certificate handshake message failed"
1452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001453run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001454 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001455 "$O_CLI -key data_files/server5.key \
1456 -cert data_files/server5.eku-cs_any.crt" \
1457 0 \
1458 -S "bad certificate (usage extensions)" \
1459 -S "Processing of the Certificate handshake message failed"
1460
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001461run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001462 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001463 "$O_CLI -key data_files/server5.key \
1464 -cert data_files/server5.eku-cs.crt" \
1465 0 \
1466 -s "bad certificate (usage extensions)" \
1467 -S "Processing of the Certificate handshake message failed"
1468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001469run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001470 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001471 "$O_CLI -key data_files/server5.key \
1472 -cert data_files/server5.eku-cs.crt" \
1473 1 \
1474 -s "bad certificate (usage extensions)" \
1475 -s "Processing of the Certificate handshake message failed"
1476
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001477# Tests for DHM parameters loading
1478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001479run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001480 "$P_SRV" \
1481 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1482 debug_level=3" \
1483 0 \
1484 -c "value of 'DHM: P ' (2048 bits)" \
1485 -c "value of 'DHM: G ' (2048 bits)"
1486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001487run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001488 "$P_SRV dhm_file=data_files/dhparams.pem" \
1489 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1490 debug_level=3" \
1491 0 \
1492 -c "value of 'DHM: P ' (1024 bits)" \
1493 -c "value of 'DHM: G ' (2 bits)"
1494
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001495# Tests for PSK callback
1496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001497run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001498 "$P_SRV psk=abc123 psk_identity=foo" \
1499 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1500 psk_identity=foo psk=abc123" \
1501 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001502 -S "SSL - The server has no ciphersuites in common" \
1503 -S "SSL - Unknown identity received" \
1504 -S "SSL - Verification of the message MAC failed"
1505
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001506run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001507 "$P_SRV" \
1508 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1509 psk_identity=foo psk=abc123" \
1510 1 \
1511 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001512 -S "SSL - Unknown identity received" \
1513 -S "SSL - Verification of the message MAC failed"
1514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001515run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001516 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1517 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1518 psk_identity=foo psk=abc123" \
1519 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001520 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001521 -s "SSL - Unknown identity received" \
1522 -S "SSL - Verification of the message MAC failed"
1523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001524run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001525 "$P_SRV psk_list=abc,dead,def,beef" \
1526 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1527 psk_identity=abc psk=dead" \
1528 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001529 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001530 -S "SSL - Unknown identity received" \
1531 -S "SSL - Verification of the message MAC failed"
1532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001533run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001534 "$P_SRV psk_list=abc,dead,def,beef" \
1535 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1536 psk_identity=def psk=beef" \
1537 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001538 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001539 -S "SSL - Unknown identity received" \
1540 -S "SSL - Verification of the message MAC failed"
1541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001542run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001543 "$P_SRV psk_list=abc,dead,def,beef" \
1544 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1545 psk_identity=ghi psk=beef" \
1546 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001547 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001548 -s "SSL - Unknown identity received" \
1549 -S "SSL - Verification of the message MAC failed"
1550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001551run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001552 "$P_SRV psk_list=abc,dead,def,beef" \
1553 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1554 psk_identity=abc psk=beef" \
1555 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001556 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001557 -S "SSL - Unknown identity received" \
1558 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001559
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001560# Tests for ciphersuites per version
1561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001562run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001563 "$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" \
1564 "$P_CLI force_version=ssl3" \
1565 0 \
1566 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001568run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001569 "$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" \
1570 "$P_CLI force_version=tls1" \
1571 0 \
1572 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001574run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001575 "$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" \
1576 "$P_CLI force_version=tls1_1" \
1577 0 \
1578 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001580run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001581 "$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" \
1582 "$P_CLI force_version=tls1_2" \
1583 0 \
1584 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1585
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001586# Tests for ssl_get_bytes_avail()
1587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001588run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001589 "$P_SRV" \
1590 "$P_CLI request_size=100" \
1591 0 \
1592 -s "Read from client: 100 bytes read$"
1593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001594run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001595 "$P_SRV" \
1596 "$P_CLI request_size=500" \
1597 0 \
1598 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001599
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001600# Tests for small packets
1601
1602run_test "Small packet SSLv3 BlockCipher" \
1603 "$P_SRV" \
1604 "$P_CLI request_size=1 force_version=ssl3 \
1605 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1606 0 \
1607 -s "Read from client: 1 bytes read"
1608
1609run_test "Small packet SSLv3 StreamCipher" \
1610 "$P_SRV" \
1611 "$P_CLI request_size=1 force_version=ssl3 \
1612 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1613 0 \
1614 -s "Read from client: 1 bytes read"
1615
1616run_test "Small packet TLS 1.0 BlockCipher" \
1617 "$P_SRV" \
1618 "$P_CLI request_size=1 force_version=tls1 \
1619 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1620 0 \
1621 -s "Read from client: 1 bytes read"
1622
1623run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1624 "$P_SRV" \
1625 "$P_CLI request_size=1 force_version=tls1 \
1626 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1627 trunc_hmac=1" \
1628 0 \
1629 -s "Read from client: 1 bytes read"
1630
1631run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1632 "$P_SRV" \
1633 "$P_CLI request_size=1 force_version=tls1 \
1634 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1635 trunc_hmac=1" \
1636 0 \
1637 -s "Read from client: 1 bytes read"
1638
1639run_test "Small packet TLS 1.1 BlockCipher" \
1640 "$P_SRV" \
1641 "$P_CLI request_size=1 force_version=tls1_1 \
1642 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1643 0 \
1644 -s "Read from client: 1 bytes read"
1645
1646run_test "Small packet TLS 1.1 StreamCipher" \
1647 "$P_SRV" \
1648 "$P_CLI request_size=1 force_version=tls1_1 \
1649 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1650 0 \
1651 -s "Read from client: 1 bytes read"
1652
1653run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1654 "$P_SRV" \
1655 "$P_CLI request_size=1 force_version=tls1_1 \
1656 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1657 trunc_hmac=1" \
1658 0 \
1659 -s "Read from client: 1 bytes read"
1660
1661run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1662 "$P_SRV" \
1663 "$P_CLI request_size=1 force_version=tls1_1 \
1664 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1665 trunc_hmac=1" \
1666 0 \
1667 -s "Read from client: 1 bytes read"
1668
1669run_test "Small packet TLS 1.2 BlockCipher" \
1670 "$P_SRV" \
1671 "$P_CLI request_size=1 force_version=tls1_2 \
1672 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1673 0 \
1674 -s "Read from client: 1 bytes read"
1675
1676run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1677 "$P_SRV" \
1678 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1679 0 \
1680 -s "Read from client: 1 bytes read"
1681
1682run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1683 "$P_SRV" \
1684 "$P_CLI request_size=1 force_version=tls1_2 \
1685 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1686 trunc_hmac=1" \
1687 0 \
1688 -s "Read from client: 1 bytes read"
1689
1690run_test "Small packet TLS 1.2 StreamCipher" \
1691 "$P_SRV" \
1692 "$P_CLI request_size=1 force_version=tls1_2 \
1693 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1694 0 \
1695 -s "Read from client: 1 bytes read"
1696
1697run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1698 "$P_SRV" \
1699 "$P_CLI request_size=1 force_version=tls1_2 \
1700 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1701 trunc_hmac=1" \
1702 0 \
1703 -s "Read from client: 1 bytes read"
1704
1705run_test "Small packet TLS 1.2 AEAD" \
1706 "$P_SRV" \
1707 "$P_CLI request_size=1 force_version=tls1_2 \
1708 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1709 0 \
1710 -s "Read from client: 1 bytes read"
1711
1712run_test "Small packet TLS 1.2 AEAD shorter tag" \
1713 "$P_SRV" \
1714 "$P_CLI request_size=1 force_version=tls1_2 \
1715 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1716 0 \
1717 -s "Read from client: 1 bytes read"
1718
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001719# Test for large packets
1720
1721run_test "Large packet SSLv3 BlockCipher" \
1722 "$P_SRV" \
1723 "$P_CLI request_size=16384 force_version=ssl3 \
1724 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1725 0 \
1726 -s "Read from client: 16384 bytes read"
1727
1728run_test "Large packet SSLv3 StreamCipher" \
1729 "$P_SRV" \
1730 "$P_CLI request_size=16384 force_version=ssl3 \
1731 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1732 0 \
1733 -s "Read from client: 16384 bytes read"
1734
1735run_test "Large packet TLS 1.0 BlockCipher" \
1736 "$P_SRV" \
1737 "$P_CLI request_size=16384 force_version=tls1 \
1738 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1739 0 \
1740 -s "Read from client: 16384 bytes read"
1741
1742run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1743 "$P_SRV" \
1744 "$P_CLI request_size=16384 force_version=tls1 \
1745 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1746 trunc_hmac=1" \
1747 0 \
1748 -s "Read from client: 16384 bytes read"
1749
1750run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1751 "$P_SRV" \
1752 "$P_CLI request_size=16384 force_version=tls1 \
1753 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1754 trunc_hmac=1" \
1755 0 \
1756 -s "Read from client: 16384 bytes read"
1757
1758run_test "Large packet TLS 1.1 BlockCipher" \
1759 "$P_SRV" \
1760 "$P_CLI request_size=16384 force_version=tls1_1 \
1761 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1762 0 \
1763 -s "Read from client: 16384 bytes read"
1764
1765run_test "Large packet TLS 1.1 StreamCipher" \
1766 "$P_SRV" \
1767 "$P_CLI request_size=16384 force_version=tls1_1 \
1768 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1769 0 \
1770 -s "Read from client: 16384 bytes read"
1771
1772run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1773 "$P_SRV" \
1774 "$P_CLI request_size=16384 force_version=tls1_1 \
1775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1776 trunc_hmac=1" \
1777 0 \
1778 -s "Read from client: 16384 bytes read"
1779
1780run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1781 "$P_SRV" \
1782 "$P_CLI request_size=16384 force_version=tls1_1 \
1783 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1784 trunc_hmac=1" \
1785 0 \
1786 -s "Read from client: 16384 bytes read"
1787
1788run_test "Large packet TLS 1.2 BlockCipher" \
1789 "$P_SRV" \
1790 "$P_CLI request_size=16384 force_version=tls1_2 \
1791 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1792 0 \
1793 -s "Read from client: 16384 bytes read"
1794
1795run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1796 "$P_SRV" \
1797 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1798 0 \
1799 -s "Read from client: 16384 bytes read"
1800
1801run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1802 "$P_SRV" \
1803 "$P_CLI request_size=16384 force_version=tls1_2 \
1804 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1805 trunc_hmac=1" \
1806 0 \
1807 -s "Read from client: 16384 bytes read"
1808
1809run_test "Large packet TLS 1.2 StreamCipher" \
1810 "$P_SRV" \
1811 "$P_CLI request_size=16384 force_version=tls1_2 \
1812 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1813 0 \
1814 -s "Read from client: 16384 bytes read"
1815
1816run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1817 "$P_SRV" \
1818 "$P_CLI request_size=16384 force_version=tls1_2 \
1819 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1820 trunc_hmac=1" \
1821 0 \
1822 -s "Read from client: 16384 bytes read"
1823
1824run_test "Large packet TLS 1.2 AEAD" \
1825 "$P_SRV" \
1826 "$P_CLI request_size=16384 force_version=tls1_2 \
1827 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1828 0 \
1829 -s "Read from client: 16384 bytes read"
1830
1831run_test "Large packet TLS 1.2 AEAD shorter tag" \
1832 "$P_SRV" \
1833 "$P_CLI request_size=16384 force_version=tls1_2 \
1834 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1835 0 \
1836 -s "Read from client: 16384 bytes read"
1837
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001838# Final report
1839
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001840echo "------------------------------------------------------------------------"
1841
1842if [ $FAILS = 0 ]; then
1843 echo -n "PASSED"
1844else
1845 echo -n "FAILED"
1846fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02001847PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001848echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001849
1850exit $FAILS