blob: f94808d2cc60e93aa2e5658dceca8f6d7b11e2cd [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é-Gonnardf46f1282014-12-11 11:51:28 +010037 printf " -h|--help\tPrint this help.\n"
38 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
39 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
40 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
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() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010099 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200100 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100101 for i in `seq 1 $LEN`; do printf '.'; done
102 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100103
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200104 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100105}
106
107# fail <message>
108fail() {
109 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100110 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100111
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200112 mv $SRV_OUT o-srv-${TESTS}.log
113 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100114 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100115
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200116 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
117 echo " ! server output:"
118 cat o-srv-${TESTS}.log
119 echo " ! ============================================================"
120 echo " ! client output:"
121 cat o-cli-${TESTS}.log
122 fi
123
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200124 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100125}
126
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100127# is_polar <cmd_line>
128is_polar() {
129 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
130}
131
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100132# has_mem_err <log_file_name>
133has_mem_err() {
134 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
135 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
136 then
137 return 1 # false: does not have errors
138 else
139 return 0 # true: has errors
140 fi
141}
142
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200143# wait for server to start: two versions depending on lsof availability
144wait_server_start() {
145 if which lsof >/dev/null; then
146 # make sure we don't loop forever
147 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
148 WATCHDOG_PID=$!
149
150 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100151 until lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null;
152 do :; done
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200153
154 kill $WATCHDOG_PID
155 wait $WATCHDOG_PID
156 else
157 sleep "$START_DELAY"
158 fi
159}
160
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200161# wait for client to terminate and set CLI_EXIT
162# must be called right after starting the client
163wait_client_done() {
164 CLI_PID=$!
165
166 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
167 WATCHDOG_PID=$!
168
169 wait $CLI_PID
170 CLI_EXIT=$?
171
172 kill $WATCHDOG_PID
173 wait $WATCHDOG_PID
174
175 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
176}
177
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100178# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100179# Options: -s pattern pattern that must be present in server output
180# -c pattern pattern that must be present in client output
181# -S pattern pattern that must be absent in server output
182# -C pattern pattern that must be absent in client output
183run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100184 NAME="$1"
185 SRV_CMD="$2"
186 CLI_CMD="$3"
187 CLI_EXPECT="$4"
188 shift 4
189
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100190 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
191 else
192 return
193 fi
194
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100195 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100196
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200197 # should we skip?
198 if [ "X$SKIP_NEXT" = "XYES" ]; then
199 SKIP_NEXT="NO"
200 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200201 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200202 return
203 fi
204
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100205 # prepend valgrind to our commands if active
206 if [ "$MEMCHECK" -gt 0 ]; then
207 if is_polar "$SRV_CMD"; then
208 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
209 fi
210 if is_polar "$CLI_CMD"; then
211 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
212 fi
213 fi
214
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100215 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200216 echo "$SRV_CMD" > $SRV_OUT
217 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100218 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200219 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200220
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200221 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200222 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
223 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100224
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200225 # kill the server
226 kill $SRV_PID
227 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100228
229 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200230 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100231 # expected client exit to incorrectly succeed in case of catastrophic
232 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100233 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200234 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100235 else
236 fail "server failed to start"
237 return
238 fi
239 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100240 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200241 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100242 else
243 fail "client failed to start"
244 return
245 fi
246 fi
247
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100248 # check server exit code
249 if [ $? != 0 ]; then
250 fail "server fail"
251 return
252 fi
253
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100254 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100255 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
256 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100257 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100258 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100259 return
260 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100261
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100262 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200263 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100264 while [ $# -gt 0 ]
265 do
266 case $1 in
267 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200268 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100269 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100270 return
271 fi
272 ;;
273
274 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200275 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100276 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100277 return
278 fi
279 ;;
280
281 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200282 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100283 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100284 return
285 fi
286 ;;
287
288 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200289 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100290 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100291 return
292 fi
293 ;;
294
295 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200296 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100297 exit 1
298 esac
299 shift 2
300 done
301
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100302 # check valgrind's results
303 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200304 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100305 fail "Server has memory errors"
306 return
307 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200308 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100309 fail "Client has memory errors"
310 return
311 fi
312 fi
313
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100314 # if we're here, everything is ok
315 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200316 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100317}
318
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100319cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200320 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200321 kill $SRV_PID >/dev/null 2>&1
322 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100323 exit 1
324}
325
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100326#
327# MAIN
328#
329
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100330get_options "$@"
331
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100332# sanity checks, avoid an avalanche of errors
333if [ ! -x "$P_SRV" ]; then
334 echo "Command '$P_SRV' is not an executable file"
335 exit 1
336fi
337if [ ! -x "$P_CLI" ]; then
338 echo "Command '$P_CLI' is not an executable file"
339 exit 1
340fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100341if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
342 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100343 exit 1
344fi
345
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200346# used by watchdog
347MAIN_PID="$$"
348
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200349# be more patient with valgrind
350if [ "$MEMCHECK" -gt 0 ]; then
351 START_DELAY=3
352 DOG_DELAY=30
353else
354 START_DELAY=1
355 DOG_DELAY=10
356fi
357
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200358# Pick a "unique" port in the range 10000-19999.
359PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200360PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200361
362# fix commands to use this port
363P_SRV="$P_SRV server_port=$PORT"
364P_CLI="$P_CLI server_port=$PORT"
365O_SRV="$O_SRV -accept $PORT"
366O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200367G_SRV="$G_SRV -p $PORT"
368G_CLI="$G_CLI -p $PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200369
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200370# Also pick a unique name for intermediate files
371SRV_OUT="srv_out.$$"
372CLI_OUT="cli_out.$$"
373SESSION="session.$$"
374
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200375SKIP_NEXT="NO"
376
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100377trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100378
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200379# Basic test
380
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200381# Checks that:
382# - things work with all ciphersuites active (used with config-full in all.sh)
383# - the expected (highest security) parameters are selected
384# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200385run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200386 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200387 "$P_CLI" \
388 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200389 -s "Protocol is TLSv1.2" \
390 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
391 -s "client hello v3, signature_algorithm ext: 6" \
392 -s "ECDHE curve: secp521r1" \
393 -S "error" \
394 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200395
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100396# Test for SSLv2 ClientHello
397
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: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100400 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100401 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100402 0 \
403 -S "parse client hello v2" \
404 -S "ssl_handshake returned"
405
406# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200407requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200408run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200409 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100410 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100411 0 \
412 -s "parse client hello v2" \
413 -S "ssl_handshake returned"
414
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100415# Tests for Truncated HMAC extension
416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200417run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200418 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100419 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100420 0 \
421 -s "dumping 'computed mac' (20 bytes)"
422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200423run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200424 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100425 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100427 -s "dumping 'computed mac' (10 bytes)"
428
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100429# Tests for Session Tickets
430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200431run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200432 "$P_SRV debug_level=3 tickets=1" \
433 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100434 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100435 -c "client hello, adding session ticket extension" \
436 -s "found session ticket extension" \
437 -s "server hello, adding session ticket extension" \
438 -c "found session_ticket extension" \
439 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100440 -S "session successfully restored from cache" \
441 -s "session successfully restored from ticket" \
442 -s "a session has been resumed" \
443 -c "a session has been resumed"
444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200445run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200446 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
447 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100448 0 \
449 -c "client hello, adding session ticket extension" \
450 -s "found session ticket extension" \
451 -s "server hello, adding session ticket extension" \
452 -c "found session_ticket extension" \
453 -c "parse new session ticket" \
454 -S "session successfully restored from cache" \
455 -s "session successfully restored from ticket" \
456 -s "a session has been resumed" \
457 -c "a session has been resumed"
458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200459run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200460 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
461 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100462 0 \
463 -c "client hello, adding session ticket extension" \
464 -s "found session ticket extension" \
465 -s "server hello, adding session ticket extension" \
466 -c "found session_ticket extension" \
467 -c "parse new session ticket" \
468 -S "session successfully restored from cache" \
469 -S "session successfully restored from ticket" \
470 -S "a session has been resumed" \
471 -C "a session has been resumed"
472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200473run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100474 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200475 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100476 0 \
477 -c "client hello, adding session ticket extension" \
478 -c "found session_ticket extension" \
479 -c "parse new session ticket" \
480 -c "a session has been resumed"
481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200482run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200483 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200484 "( $O_CLI -sess_out $SESSION; \
485 $O_CLI -sess_in $SESSION; \
486 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100487 0 \
488 -s "found session ticket extension" \
489 -s "server hello, adding session ticket extension" \
490 -S "session successfully restored from cache" \
491 -s "session successfully restored from ticket" \
492 -s "a session has been resumed"
493
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100494# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200496run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200497 "$P_SRV debug_level=3 tickets=0" \
498 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100499 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100500 -c "client hello, adding session ticket extension" \
501 -s "found session ticket extension" \
502 -S "server hello, adding session ticket extension" \
503 -C "found session_ticket extension" \
504 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100505 -s "session successfully restored from cache" \
506 -S "session successfully restored from ticket" \
507 -s "a session has been resumed" \
508 -c "a session has been resumed"
509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200510run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200511 "$P_SRV debug_level=3 tickets=1" \
512 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100513 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100514 -C "client hello, adding session ticket extension" \
515 -S "found session ticket extension" \
516 -S "server hello, adding session ticket extension" \
517 -C "found session_ticket extension" \
518 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100519 -s "session successfully restored from cache" \
520 -S "session successfully restored from ticket" \
521 -s "a session has been resumed" \
522 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200524run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200525 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
526 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100527 0 \
528 -S "session successfully restored from cache" \
529 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100530 -S "a session has been resumed" \
531 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200533run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200534 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
535 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
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: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200543 "$P_SRV debug_level=3 tickets=0" \
544 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
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: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200552 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
553 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +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: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200561 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
562 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100563 0 \
564 -s "session successfully restored from cache" \
565 -S "session successfully restored from ticket" \
566 -s "a session has been resumed" \
567 -c "a session has been resumed"
568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200569run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200570 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200571 "( $O_CLI -sess_out $SESSION; \
572 $O_CLI -sess_in $SESSION; \
573 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100574 0 \
575 -s "found session ticket extension" \
576 -S "server hello, adding session ticket extension" \
577 -s "session successfully restored from cache" \
578 -S "session successfully restored from ticket" \
579 -s "a session has been resumed"
580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200581run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100582 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200583 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100584 0 \
585 -C "found session_ticket extension" \
586 -C "parse new session ticket" \
587 -c "a session has been resumed"
588
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100589# Tests for Max Fragment Length extension
590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200591run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200592 "$P_SRV debug_level=3" \
593 "$P_CLI debug_level=3" \
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 client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200601 "$P_SRV debug_level=3" \
602 "$P_CLI debug_level=3 max_frag_len=4096" \
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"
608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200609run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200610 "$P_SRV debug_level=3 max_frag_len=4096" \
611 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100612 0 \
613 -C "client hello, adding max_fragment_length extension" \
614 -S "found max fragment length extension" \
615 -S "server hello, max_fragment_length extension" \
616 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100617
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200618requires_gnutls
619run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200620 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200621 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200622 0 \
623 -c "client hello, adding max_fragment_length extension" \
624 -c "found max_fragment_length extension"
625
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100626# Tests for renegotiation
627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200628run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200629 "$P_SRV debug_level=3 exchanges=2" \
630 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100631 0 \
632 -C "client hello, adding renegotiation extension" \
633 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
634 -S "found renegotiation extension" \
635 -s "server hello, secure renegotiation extension" \
636 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100637 -C "=> renegotiate" \
638 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100639 -S "write hello request"
640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200641run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200642 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
643 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100644 0 \
645 -c "client hello, adding renegotiation extension" \
646 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
647 -s "found renegotiation extension" \
648 -s "server hello, secure renegotiation extension" \
649 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100650 -c "=> renegotiate" \
651 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100652 -S "write hello request"
653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200654run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200655 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
656 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100657 0 \
658 -c "client hello, adding renegotiation extension" \
659 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
660 -s "found renegotiation extension" \
661 -s "server hello, secure renegotiation extension" \
662 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100663 -c "=> renegotiate" \
664 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100665 -s "write hello request"
666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200667run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200668 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
669 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100670 0 \
671 -c "client hello, adding renegotiation extension" \
672 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
673 -s "found renegotiation extension" \
674 -s "server hello, secure renegotiation extension" \
675 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100676 -c "=> renegotiate" \
677 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100678 -s "write hello request"
679
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200680run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200681 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
682 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100683 1 \
684 -c "client hello, adding renegotiation extension" \
685 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
686 -S "found renegotiation extension" \
687 -s "server hello, secure renegotiation extension" \
688 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100689 -c "=> renegotiate" \
690 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200691 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200692 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200693 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200695run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200696 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
697 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100698 0 \
699 -C "client hello, adding renegotiation extension" \
700 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
701 -S "found renegotiation extension" \
702 -s "server hello, secure renegotiation extension" \
703 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100704 -C "=> renegotiate" \
705 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100706 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200707 -S "SSL - An unexpected message was received from our peer" \
708 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100709
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200710run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200711 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200712 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200713 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200714 0 \
715 -C "client hello, adding renegotiation extension" \
716 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
717 -S "found renegotiation extension" \
718 -s "server hello, secure renegotiation extension" \
719 -c "found renegotiation extension" \
720 -C "=> renegotiate" \
721 -S "=> renegotiate" \
722 -s "write hello request" \
723 -S "SSL - An unexpected message was received from our peer" \
724 -S "failed"
725
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200726# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200727run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200728 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200729 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200730 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200731 0 \
732 -C "client hello, adding renegotiation extension" \
733 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
734 -S "found renegotiation extension" \
735 -s "server hello, secure renegotiation extension" \
736 -c "found renegotiation extension" \
737 -C "=> renegotiate" \
738 -S "=> renegotiate" \
739 -s "write hello request" \
740 -S "SSL - An unexpected message was received from our peer" \
741 -S "failed"
742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200743run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200744 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200745 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200746 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200747 0 \
748 -C "client hello, adding renegotiation extension" \
749 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
750 -S "found renegotiation extension" \
751 -s "server hello, secure renegotiation extension" \
752 -c "found renegotiation extension" \
753 -C "=> renegotiate" \
754 -S "=> renegotiate" \
755 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200756 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200757
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200758run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200759 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200760 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200761 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200762 0 \
763 -c "client hello, adding renegotiation extension" \
764 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
765 -s "found renegotiation extension" \
766 -s "server hello, secure renegotiation extension" \
767 -c "found renegotiation extension" \
768 -c "=> renegotiate" \
769 -s "=> renegotiate" \
770 -s "write hello request" \
771 -S "SSL - An unexpected message was received from our peer" \
772 -S "failed"
773
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200774run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200775 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
776 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200777 0 \
778 -c "client hello, adding renegotiation extension" \
779 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
780 -s "found renegotiation extension" \
781 -s "server hello, secure renegotiation extension" \
782 -c "found renegotiation extension" \
783 -c "=> renegotiate" \
784 -s "=> renegotiate" \
785 -S "write hello request"
786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200787run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200788 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
789 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200790 0 \
791 -c "client hello, adding renegotiation extension" \
792 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
793 -s "found renegotiation extension" \
794 -s "server hello, secure renegotiation extension" \
795 -c "found renegotiation extension" \
796 -c "=> renegotiate" \
797 -s "=> renegotiate" \
798 -s "write hello request"
799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200800run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200801 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200802 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200803 0 \
804 -c "client hello, adding renegotiation extension" \
805 -c "found renegotiation extension" \
806 -c "=> renegotiate" \
807 -C "ssl_handshake returned" \
808 -C "error" \
809 -c "HTTP/1.0 200 [Oo][Kk]"
810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200811run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200812 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200813 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200814 0 \
815 -c "client hello, adding renegotiation extension" \
816 -c "found renegotiation extension" \
817 -c "=> renegotiate" \
818 -C "ssl_handshake returned" \
819 -C "error" \
820 -c "HTTP/1.0 200 [Oo][Kk]"
821
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100822# Tests for auth_mode
823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200824run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100825 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100826 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200827 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100828 1 \
829 -c "x509_verify_cert() returned" \
830 -c "! self-signed or not signed by a trusted CA" \
831 -c "! ssl_handshake returned" \
832 -c "X509 - Certificate verification failed"
833
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200834run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100835 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100836 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200837 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100838 0 \
839 -c "x509_verify_cert() returned" \
840 -c "! self-signed or not signed by a trusted CA" \
841 -C "! ssl_handshake returned" \
842 -C "X509 - Certificate verification failed"
843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200844run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100845 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100846 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200847 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100848 0 \
849 -C "x509_verify_cert() returned" \
850 -C "! self-signed or not signed by a trusted CA" \
851 -C "! ssl_handshake returned" \
852 -C "X509 - Certificate verification failed"
853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200854run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200855 "$P_SRV debug_level=3 auth_mode=required" \
856 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100857 key_file=data_files/server5.key" \
858 1 \
859 -S "skip write certificate request" \
860 -C "skip parse certificate request" \
861 -c "got a certificate request" \
862 -C "skip write certificate" \
863 -C "skip write certificate verify" \
864 -S "skip parse certificate verify" \
865 -s "x509_verify_cert() returned" \
866 -S "! self-signed or not signed by a trusted CA" \
867 -s "! ssl_handshake returned" \
868 -c "! ssl_handshake returned" \
869 -s "X509 - Certificate verification failed"
870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200871run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200872 "$P_SRV debug_level=3 auth_mode=optional" \
873 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100874 key_file=data_files/server5.key" \
875 0 \
876 -S "skip write certificate request" \
877 -C "skip parse certificate request" \
878 -c "got a certificate request" \
879 -C "skip write certificate" \
880 -C "skip write certificate verify" \
881 -S "skip parse certificate verify" \
882 -s "x509_verify_cert() returned" \
883 -s "! self-signed or not signed by a trusted CA" \
884 -S "! ssl_handshake returned" \
885 -C "! ssl_handshake returned" \
886 -S "X509 - Certificate verification failed"
887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200888run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200889 "$P_SRV debug_level=3 auth_mode=none" \
890 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100891 key_file=data_files/server5.key" \
892 0 \
893 -s "skip write certificate request" \
894 -C "skip parse certificate request" \
895 -c "got no certificate request" \
896 -c "skip write certificate" \
897 -c "skip write certificate verify" \
898 -s "skip parse certificate verify" \
899 -S "x509_verify_cert() returned" \
900 -S "! self-signed or not signed by a trusted CA" \
901 -S "! ssl_handshake returned" \
902 -C "! ssl_handshake returned" \
903 -S "X509 - Certificate verification failed"
904
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200905run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200906 "$P_SRV debug_level=3 auth_mode=optional" \
907 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100908 0 \
909 -S "skip write certificate request" \
910 -C "skip parse certificate request" \
911 -c "got a certificate request" \
912 -C "skip write certificate$" \
913 -C "got no certificate to send" \
914 -S "SSLv3 client has no certificate" \
915 -c "skip write certificate verify" \
916 -s "skip parse certificate verify" \
917 -s "! no client certificate sent" \
918 -S "! ssl_handshake returned" \
919 -C "! ssl_handshake returned" \
920 -S "X509 - Certificate verification failed"
921
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200922run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200923 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100924 "$O_CLI" \
925 0 \
926 -S "skip write certificate request" \
927 -s "skip parse certificate verify" \
928 -s "! no client certificate sent" \
929 -S "! ssl_handshake returned" \
930 -S "X509 - Certificate verification failed"
931
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200932run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100933 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200934 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100935 0 \
936 -C "skip parse certificate request" \
937 -c "got a certificate request" \
938 -C "skip write certificate$" \
939 -c "skip write certificate verify" \
940 -C "! ssl_handshake returned"
941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200942run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200943 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
944 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100945 0 \
946 -S "skip write certificate request" \
947 -C "skip parse certificate request" \
948 -c "got a certificate request" \
949 -C "skip write certificate$" \
950 -c "skip write certificate verify" \
951 -c "got no certificate to send" \
952 -s "SSLv3 client has no certificate" \
953 -s "skip parse certificate verify" \
954 -s "! no client certificate sent" \
955 -S "! ssl_handshake returned" \
956 -C "! ssl_handshake returned" \
957 -S "X509 - Certificate verification failed"
958
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100959# tests for SNI
960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200961run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200962 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100963 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100964 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100965 server_name=localhost" \
966 0 \
967 -S "parse ServerName extension" \
968 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
969 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200971run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200972 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100973 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100974 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 +0100975 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100976 server_name=localhost" \
977 0 \
978 -s "parse ServerName extension" \
979 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
980 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200982run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200983 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100984 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100985 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 +0100986 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100987 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100988 0 \
989 -s "parse ServerName extension" \
990 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100991 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200993run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200994 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100995 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100996 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 +0100997 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100998 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100999 1 \
1000 -s "parse ServerName extension" \
1001 -s "ssl_sni_wrapper() returned" \
1002 -s "ssl_handshake returned" \
1003 -c "ssl_handshake returned" \
1004 -c "SSL - A fatal alert message was received from our peer"
1005
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001006# Tests for non-blocking I/O: exercise a variety of handshake flows
1007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001008run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001009 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1010 "$P_CLI nbio=2 tickets=0" \
1011 0 \
1012 -S "ssl_handshake returned" \
1013 -C "ssl_handshake returned" \
1014 -c "Read from server: .* bytes read"
1015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001016run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001017 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1018 "$P_CLI nbio=2 tickets=0" \
1019 0 \
1020 -S "ssl_handshake returned" \
1021 -C "ssl_handshake returned" \
1022 -c "Read from server: .* bytes read"
1023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001024run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001025 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1026 "$P_CLI nbio=2 tickets=1" \
1027 0 \
1028 -S "ssl_handshake returned" \
1029 -C "ssl_handshake returned" \
1030 -c "Read from server: .* bytes read"
1031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001032run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001033 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1034 "$P_CLI nbio=2 tickets=1" \
1035 0 \
1036 -S "ssl_handshake returned" \
1037 -C "ssl_handshake returned" \
1038 -c "Read from server: .* bytes read"
1039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001040run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001041 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1042 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1043 0 \
1044 -S "ssl_handshake returned" \
1045 -C "ssl_handshake returned" \
1046 -c "Read from server: .* bytes read"
1047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001048run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001049 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1050 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1051 0 \
1052 -S "ssl_handshake returned" \
1053 -C "ssl_handshake returned" \
1054 -c "Read from server: .* bytes read"
1055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001056run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001057 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1058 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1059 0 \
1060 -S "ssl_handshake returned" \
1061 -C "ssl_handshake returned" \
1062 -c "Read from server: .* bytes read"
1063
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001064# Tests for version negotiation
1065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001066run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001067 "$P_SRV" \
1068 "$P_CLI" \
1069 0 \
1070 -S "ssl_handshake returned" \
1071 -C "ssl_handshake returned" \
1072 -s "Protocol is TLSv1.2" \
1073 -c "Protocol is TLSv1.2"
1074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001075run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001076 "$P_SRV" \
1077 "$P_CLI max_version=tls1_1" \
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: 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" \
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+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001094 "$P_SRV max_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 max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001103 "$P_SRV min_version=tls1_1" \
1104 "$P_CLI max_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.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001112 "$P_SRV max_version=tls1_1" \
1113 "$P_CLI min_version=tls1_1" \
1114 0 \
1115 -S "ssl_handshake returned" \
1116 -C "ssl_handshake returned" \
1117 -s "Protocol is TLSv1.1" \
1118 -c "Protocol is TLSv1.1"
1119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001120run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001121 "$P_SRV max_version=tls1_1" \
1122 "$P_CLI min_version=tls1_2" \
1123 1 \
1124 -s "ssl_handshake returned" \
1125 -c "ssl_handshake returned" \
1126 -c "SSL - Handshake protocol not within min/max boundaries"
1127
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001128run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001129 "$P_SRV min_version=tls1_2" \
1130 "$P_CLI max_version=tls1_1" \
1131 1 \
1132 -s "ssl_handshake returned" \
1133 -c "ssl_handshake returned" \
1134 -s "SSL - Handshake protocol not within min/max boundaries"
1135
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001136# Tests for ALPN extension
1137
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001138if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001140run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001141 "$P_SRV debug_level=3" \
1142 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001143 0 \
1144 -C "client hello, adding alpn extension" \
1145 -S "found alpn extension" \
1146 -C "got an alert message, type: \\[2:120]" \
1147 -S "server hello, adding alpn extension" \
1148 -C "found alpn extension " \
1149 -C "Application Layer Protocol is" \
1150 -S "Application Layer Protocol is"
1151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001152run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001153 "$P_SRV debug_level=3" \
1154 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001155 0 \
1156 -c "client hello, adding alpn extension" \
1157 -s "found alpn extension" \
1158 -C "got an alert message, type: \\[2:120]" \
1159 -S "server hello, adding alpn extension" \
1160 -C "found alpn extension " \
1161 -c "Application Layer Protocol is (none)" \
1162 -S "Application Layer Protocol is"
1163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001164run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001165 "$P_SRV debug_level=3 alpn=abc,1234" \
1166 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001167 0 \
1168 -C "client hello, adding alpn extension" \
1169 -S "found alpn extension" \
1170 -C "got an alert message, type: \\[2:120]" \
1171 -S "server hello, adding alpn extension" \
1172 -C "found alpn extension " \
1173 -C "Application Layer Protocol is" \
1174 -s "Application Layer Protocol is (none)"
1175
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001176run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001177 "$P_SRV debug_level=3 alpn=abc,1234" \
1178 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001179 0 \
1180 -c "client hello, adding alpn extension" \
1181 -s "found alpn extension" \
1182 -C "got an alert message, type: \\[2:120]" \
1183 -s "server hello, adding alpn extension" \
1184 -c "found alpn extension" \
1185 -c "Application Layer Protocol is abc" \
1186 -s "Application Layer Protocol is abc"
1187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001188run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001189 "$P_SRV debug_level=3 alpn=abc,1234" \
1190 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001191 0 \
1192 -c "client hello, adding alpn extension" \
1193 -s "found alpn extension" \
1194 -C "got an alert message, type: \\[2:120]" \
1195 -s "server hello, adding alpn extension" \
1196 -c "found alpn extension" \
1197 -c "Application Layer Protocol is abc" \
1198 -s "Application Layer Protocol is abc"
1199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001200run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001201 "$P_SRV debug_level=3 alpn=abc,1234" \
1202 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001203 0 \
1204 -c "client hello, adding alpn extension" \
1205 -s "found alpn extension" \
1206 -C "got an alert message, type: \\[2:120]" \
1207 -s "server hello, adding alpn extension" \
1208 -c "found alpn extension" \
1209 -c "Application Layer Protocol is 1234" \
1210 -s "Application Layer Protocol is 1234"
1211
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001212run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001213 "$P_SRV debug_level=3 alpn=abc,123" \
1214 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001215 1 \
1216 -c "client hello, adding alpn extension" \
1217 -s "found alpn extension" \
1218 -c "got an alert message, type: \\[2:120]" \
1219 -S "server hello, adding alpn extension" \
1220 -C "found alpn extension" \
1221 -C "Application Layer Protocol is 1234" \
1222 -S "Application Layer Protocol is 1234"
1223
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001224fi
1225
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001226# Tests for keyUsage in leaf certificates, part 1:
1227# server-side certificate/suite selection
1228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001230 "$P_SRV key_file=data_files/server2.key \
1231 crt_file=data_files/server2.ku-ds.crt" \
1232 "$P_CLI" \
1233 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001234 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001235
1236
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001237run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001238 "$P_SRV key_file=data_files/server2.key \
1239 crt_file=data_files/server2.ku-ke.crt" \
1240 "$P_CLI" \
1241 0 \
1242 -c "Ciphersuite is TLS-RSA-WITH-"
1243
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001244run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001245 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001246 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001247 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001248 1 \
1249 -C "Ciphersuite is "
1250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001251run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001252 "$P_SRV key_file=data_files/server5.key \
1253 crt_file=data_files/server5.ku-ds.crt" \
1254 "$P_CLI" \
1255 0 \
1256 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1257
1258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001259run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001260 "$P_SRV key_file=data_files/server5.key \
1261 crt_file=data_files/server5.ku-ka.crt" \
1262 "$P_CLI" \
1263 0 \
1264 -c "Ciphersuite is TLS-ECDH-"
1265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001266run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001267 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001268 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001269 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001270 1 \
1271 -C "Ciphersuite is "
1272
1273# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001274# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001276run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001277 "$O_SRV -key data_files/server2.key \
1278 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001279 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001280 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1281 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001282 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001283 -C "Processing of the Certificate handshake message failed" \
1284 -c "Ciphersuite is TLS-"
1285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001286run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001287 "$O_SRV -key data_files/server2.key \
1288 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001289 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001290 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1291 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001292 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001293 -C "Processing of the Certificate handshake message failed" \
1294 -c "Ciphersuite is TLS-"
1295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001296run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001297 "$O_SRV -key data_files/server2.key \
1298 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001299 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001300 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1301 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001302 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001303 -C "Processing of the Certificate handshake message failed" \
1304 -c "Ciphersuite is TLS-"
1305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001306run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001307 "$O_SRV -key data_files/server2.key \
1308 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001309 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001310 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1311 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001312 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001313 -c "Processing of the Certificate handshake message failed" \
1314 -C "Ciphersuite is TLS-"
1315
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001316run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001317 "$O_SRV -key data_files/server2.key \
1318 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001319 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001320 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1321 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001322 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001323 -C "Processing of the Certificate handshake message failed" \
1324 -c "Ciphersuite is TLS-"
1325
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001326run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001327 "$O_SRV -key data_files/server2.key \
1328 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001329 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001330 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1331 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001332 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001333 -c "Processing of the Certificate handshake message failed" \
1334 -C "Ciphersuite is TLS-"
1335
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001336# Tests for keyUsage in leaf certificates, part 3:
1337# server-side checking of client cert
1338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001339run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001340 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001341 "$O_CLI -key data_files/server2.key \
1342 -cert data_files/server2.ku-ds.crt" \
1343 0 \
1344 -S "bad certificate (usage extensions)" \
1345 -S "Processing of the Certificate handshake message failed"
1346
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001347run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001348 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001349 "$O_CLI -key data_files/server2.key \
1350 -cert data_files/server2.ku-ke.crt" \
1351 0 \
1352 -s "bad certificate (usage extensions)" \
1353 -S "Processing of the Certificate handshake message failed"
1354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001355run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001356 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001357 "$O_CLI -key data_files/server2.key \
1358 -cert data_files/server2.ku-ke.crt" \
1359 1 \
1360 -s "bad certificate (usage extensions)" \
1361 -s "Processing of the Certificate handshake message failed"
1362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001363run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001365 "$O_CLI -key data_files/server5.key \
1366 -cert data_files/server5.ku-ds.crt" \
1367 0 \
1368 -S "bad certificate (usage extensions)" \
1369 -S "Processing of the Certificate handshake message failed"
1370
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001371run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001372 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001373 "$O_CLI -key data_files/server5.key \
1374 -cert data_files/server5.ku-ka.crt" \
1375 0 \
1376 -s "bad certificate (usage extensions)" \
1377 -S "Processing of the Certificate handshake message failed"
1378
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001379# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001381run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001382 "$P_SRV key_file=data_files/server5.key \
1383 crt_file=data_files/server5.eku-srv.crt" \
1384 "$P_CLI" \
1385 0
1386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001387run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001388 "$P_SRV key_file=data_files/server5.key \
1389 crt_file=data_files/server5.eku-srv.crt" \
1390 "$P_CLI" \
1391 0
1392
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001393run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001394 "$P_SRV key_file=data_files/server5.key \
1395 crt_file=data_files/server5.eku-cs_any.crt" \
1396 "$P_CLI" \
1397 0
1398
1399# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001400run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001401 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1402 crt_file=data_files/server5.eku-cli.crt" \
1403 "$P_CLI psk=badbad" \
1404 1
1405
1406# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001408run_test "extKeyUsage cli: serverAuth -> 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.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: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001418 "$O_SRV -key data_files/server5.key \
1419 -cert data_files/server5.eku-srv_cli.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,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001427 "$O_SRV -key data_files/server5.key \
1428 -cert data_files/server5.eku-cs_any.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 0 \
1431 -C "bad certificate (usage extensions)" \
1432 -C "Processing of the Certificate handshake message failed" \
1433 -c "Ciphersuite is TLS-"
1434
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001435run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001436 "$O_SRV -key data_files/server5.key \
1437 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001438 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001439 1 \
1440 -c "bad certificate (usage extensions)" \
1441 -c "Processing of the Certificate handshake message failed" \
1442 -C "Ciphersuite is TLS-"
1443
1444# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001446run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001447 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001448 "$O_CLI -key data_files/server5.key \
1449 -cert data_files/server5.eku-cli.crt" \
1450 0 \
1451 -S "bad certificate (usage extensions)" \
1452 -S "Processing of the Certificate handshake message failed"
1453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001454run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001455 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001456 "$O_CLI -key data_files/server5.key \
1457 -cert data_files/server5.eku-srv_cli.crt" \
1458 0 \
1459 -S "bad certificate (usage extensions)" \
1460 -S "Processing of the Certificate handshake message failed"
1461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001462run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001463 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001464 "$O_CLI -key data_files/server5.key \
1465 -cert data_files/server5.eku-cs_any.crt" \
1466 0 \
1467 -S "bad certificate (usage extensions)" \
1468 -S "Processing of the Certificate handshake message failed"
1469
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001470run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001471 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001472 "$O_CLI -key data_files/server5.key \
1473 -cert data_files/server5.eku-cs.crt" \
1474 0 \
1475 -s "bad certificate (usage extensions)" \
1476 -S "Processing of the Certificate handshake message failed"
1477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001478run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001479 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001480 "$O_CLI -key data_files/server5.key \
1481 -cert data_files/server5.eku-cs.crt" \
1482 1 \
1483 -s "bad certificate (usage extensions)" \
1484 -s "Processing of the Certificate handshake message failed"
1485
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001486# Tests for DHM parameters loading
1487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001488run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001489 "$P_SRV" \
1490 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1491 debug_level=3" \
1492 0 \
1493 -c "value of 'DHM: P ' (2048 bits)" \
1494 -c "value of 'DHM: G ' (2048 bits)"
1495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001496run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001497 "$P_SRV dhm_file=data_files/dhparams.pem" \
1498 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1499 debug_level=3" \
1500 0 \
1501 -c "value of 'DHM: P ' (1024 bits)" \
1502 -c "value of 'DHM: G ' (2 bits)"
1503
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001504# Tests for PSK callback
1505
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001506run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001507 "$P_SRV psk=abc123 psk_identity=foo" \
1508 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1509 psk_identity=foo psk=abc123" \
1510 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001511 -S "SSL - The server has no ciphersuites in common" \
1512 -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: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001516 "$P_SRV" \
1517 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1518 psk_identity=foo psk=abc123" \
1519 1 \
1520 -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: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001525 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1526 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1527 psk_identity=foo psk=abc123" \
1528 1 \
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: first 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=abc psk=dead" \
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: second id matches" \
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=def psk=beef" \
1546 0 \
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: no match" \
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=ghi 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"
1559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001560run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001561 "$P_SRV psk_list=abc,dead,def,beef" \
1562 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1563 psk_identity=abc psk=beef" \
1564 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001565 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001566 -S "SSL - Unknown identity received" \
1567 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001568
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001569# Tests for ciphersuites per version
1570
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001571run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001572 "$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" \
1573 "$P_CLI force_version=ssl3" \
1574 0 \
1575 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001577run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001578 "$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" \
1579 "$P_CLI force_version=tls1" \
1580 0 \
1581 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001583run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001584 "$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" \
1585 "$P_CLI force_version=tls1_1" \
1586 0 \
1587 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001589run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001590 "$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" \
1591 "$P_CLI force_version=tls1_2" \
1592 0 \
1593 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1594
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001595# Tests for ssl_get_bytes_avail()
1596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001597run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001598 "$P_SRV" \
1599 "$P_CLI request_size=100" \
1600 0 \
1601 -s "Read from client: 100 bytes read$"
1602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001603run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001604 "$P_SRV" \
1605 "$P_CLI request_size=500" \
1606 0 \
1607 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001608
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001609# Tests for small packets
1610
1611run_test "Small packet SSLv3 BlockCipher" \
1612 "$P_SRV" \
1613 "$P_CLI request_size=1 force_version=ssl3 \
1614 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1615 0 \
1616 -s "Read from client: 1 bytes read"
1617
1618run_test "Small packet SSLv3 StreamCipher" \
1619 "$P_SRV" \
1620 "$P_CLI request_size=1 force_version=ssl3 \
1621 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1622 0 \
1623 -s "Read from client: 1 bytes read"
1624
1625run_test "Small packet TLS 1.0 BlockCipher" \
1626 "$P_SRV" \
1627 "$P_CLI request_size=1 force_version=tls1 \
1628 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1629 0 \
1630 -s "Read from client: 1 bytes read"
1631
1632run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1633 "$P_SRV" \
1634 "$P_CLI request_size=1 force_version=tls1 \
1635 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1636 trunc_hmac=1" \
1637 0 \
1638 -s "Read from client: 1 bytes read"
1639
1640run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1641 "$P_SRV" \
1642 "$P_CLI request_size=1 force_version=tls1 \
1643 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1644 trunc_hmac=1" \
1645 0 \
1646 -s "Read from client: 1 bytes read"
1647
1648run_test "Small packet TLS 1.1 BlockCipher" \
1649 "$P_SRV" \
1650 "$P_CLI request_size=1 force_version=tls1_1 \
1651 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1652 0 \
1653 -s "Read from client: 1 bytes read"
1654
1655run_test "Small packet TLS 1.1 StreamCipher" \
1656 "$P_SRV" \
1657 "$P_CLI request_size=1 force_version=tls1_1 \
1658 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1659 0 \
1660 -s "Read from client: 1 bytes read"
1661
1662run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1663 "$P_SRV" \
1664 "$P_CLI request_size=1 force_version=tls1_1 \
1665 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1666 trunc_hmac=1" \
1667 0 \
1668 -s "Read from client: 1 bytes read"
1669
1670run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1671 "$P_SRV" \
1672 "$P_CLI request_size=1 force_version=tls1_1 \
1673 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1674 trunc_hmac=1" \
1675 0 \
1676 -s "Read from client: 1 bytes read"
1677
1678run_test "Small packet TLS 1.2 BlockCipher" \
1679 "$P_SRV" \
1680 "$P_CLI request_size=1 force_version=tls1_2 \
1681 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1682 0 \
1683 -s "Read from client: 1 bytes read"
1684
1685run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1686 "$P_SRV" \
1687 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1688 0 \
1689 -s "Read from client: 1 bytes read"
1690
1691run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1692 "$P_SRV" \
1693 "$P_CLI request_size=1 force_version=tls1_2 \
1694 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1695 trunc_hmac=1" \
1696 0 \
1697 -s "Read from client: 1 bytes read"
1698
1699run_test "Small packet TLS 1.2 StreamCipher" \
1700 "$P_SRV" \
1701 "$P_CLI request_size=1 force_version=tls1_2 \
1702 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1703 0 \
1704 -s "Read from client: 1 bytes read"
1705
1706run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1707 "$P_SRV" \
1708 "$P_CLI request_size=1 force_version=tls1_2 \
1709 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1710 trunc_hmac=1" \
1711 0 \
1712 -s "Read from client: 1 bytes read"
1713
1714run_test "Small packet TLS 1.2 AEAD" \
1715 "$P_SRV" \
1716 "$P_CLI request_size=1 force_version=tls1_2 \
1717 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1718 0 \
1719 -s "Read from client: 1 bytes read"
1720
1721run_test "Small packet TLS 1.2 AEAD shorter tag" \
1722 "$P_SRV" \
1723 "$P_CLI request_size=1 force_version=tls1_2 \
1724 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1725 0 \
1726 -s "Read from client: 1 bytes read"
1727
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001728# Test for large packets
1729
1730run_test "Large packet SSLv3 BlockCipher" \
1731 "$P_SRV" \
1732 "$P_CLI request_size=16384 force_version=ssl3 \
1733 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1734 0 \
1735 -s "Read from client: 16384 bytes read"
1736
1737run_test "Large packet SSLv3 StreamCipher" \
1738 "$P_SRV" \
1739 "$P_CLI request_size=16384 force_version=ssl3 \
1740 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1741 0 \
1742 -s "Read from client: 16384 bytes read"
1743
1744run_test "Large packet TLS 1.0 BlockCipher" \
1745 "$P_SRV" \
1746 "$P_CLI request_size=16384 force_version=tls1 \
1747 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1748 0 \
1749 -s "Read from client: 16384 bytes read"
1750
1751run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1752 "$P_SRV" \
1753 "$P_CLI request_size=16384 force_version=tls1 \
1754 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1755 trunc_hmac=1" \
1756 0 \
1757 -s "Read from client: 16384 bytes read"
1758
1759run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1760 "$P_SRV" \
1761 "$P_CLI request_size=16384 force_version=tls1 \
1762 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1763 trunc_hmac=1" \
1764 0 \
1765 -s "Read from client: 16384 bytes read"
1766
1767run_test "Large packet TLS 1.1 BlockCipher" \
1768 "$P_SRV" \
1769 "$P_CLI request_size=16384 force_version=tls1_1 \
1770 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1771 0 \
1772 -s "Read from client: 16384 bytes read"
1773
1774run_test "Large packet TLS 1.1 StreamCipher" \
1775 "$P_SRV" \
1776 "$P_CLI request_size=16384 force_version=tls1_1 \
1777 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1778 0 \
1779 -s "Read from client: 16384 bytes read"
1780
1781run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1782 "$P_SRV" \
1783 "$P_CLI request_size=16384 force_version=tls1_1 \
1784 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1785 trunc_hmac=1" \
1786 0 \
1787 -s "Read from client: 16384 bytes read"
1788
1789run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1790 "$P_SRV" \
1791 "$P_CLI request_size=16384 force_version=tls1_1 \
1792 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1793 trunc_hmac=1" \
1794 0 \
1795 -s "Read from client: 16384 bytes read"
1796
1797run_test "Large packet TLS 1.2 BlockCipher" \
1798 "$P_SRV" \
1799 "$P_CLI request_size=16384 force_version=tls1_2 \
1800 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1801 0 \
1802 -s "Read from client: 16384 bytes read"
1803
1804run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1805 "$P_SRV" \
1806 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1807 0 \
1808 -s "Read from client: 16384 bytes read"
1809
1810run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1811 "$P_SRV" \
1812 "$P_CLI request_size=16384 force_version=tls1_2 \
1813 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1814 trunc_hmac=1" \
1815 0 \
1816 -s "Read from client: 16384 bytes read"
1817
1818run_test "Large packet TLS 1.2 StreamCipher" \
1819 "$P_SRV" \
1820 "$P_CLI request_size=16384 force_version=tls1_2 \
1821 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1822 0 \
1823 -s "Read from client: 16384 bytes read"
1824
1825run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1826 "$P_SRV" \
1827 "$P_CLI request_size=16384 force_version=tls1_2 \
1828 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1829 trunc_hmac=1" \
1830 0 \
1831 -s "Read from client: 16384 bytes read"
1832
1833run_test "Large packet TLS 1.2 AEAD" \
1834 "$P_SRV" \
1835 "$P_CLI request_size=16384 force_version=tls1_2 \
1836 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1837 0 \
1838 -s "Read from client: 16384 bytes read"
1839
1840run_test "Large packet TLS 1.2 AEAD shorter tag" \
1841 "$P_SRV" \
1842 "$P_CLI request_size=16384 force_version=tls1_2 \
1843 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1844 0 \
1845 -s "Read from client: 16384 bytes read"
1846
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001847# Final report
1848
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001849echo "------------------------------------------------------------------------"
1850
1851if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01001852 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001853else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01001854 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001855fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02001856PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001857echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001858
1859exit $FAILS