blob: 964eaadd50c10a2361c947d2ddd641dc83067c72 [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é-Gonnard3ff78232015-01-08 11:15:09 +0100429# Tests for CBC 1/n-1 record splitting
430
431run_test "CBC Record splitting: TLS 1.2, no splitting" \
432 "$P_SRV" \
433 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
434 request_size=123 force_version=tls1_2" \
435 0 \
436 -s "Read from client: 123 bytes read" \
437 -S "Read from client: 1 bytes read" \
438 -S "122 bytes read"
439
440run_test "CBC Record splitting: TLS 1.1, no splitting" \
441 "$P_SRV" \
442 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
443 request_size=123 force_version=tls1_1" \
444 0 \
445 -s "Read from client: 123 bytes read" \
446 -S "Read from client: 1 bytes read" \
447 -S "122 bytes read"
448
449run_test "CBC Record splitting: TLS 1.0, splitting" \
450 "$P_SRV" \
451 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
452 request_size=123 force_version=tls1" \
453 0 \
454 -S "Read from client: 123 bytes read" \
455 -s "Read from client: 1 bytes read" \
456 -s "122 bytes read"
457
458run_test "CBC Record splitting: SSLv3, splitting" \
459 "$P_SRV" \
460 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
461 request_size=123 force_version=ssl3" \
462 0 \
463 -S "Read from client: 123 bytes read" \
464 -s "Read from client: 1 bytes read" \
465 -s "122 bytes read"
466
467run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
468 "$P_SRV" \
469 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
470 request_size=123 force_version=tls1" \
471 0 \
472 -s "Read from client: 123 bytes read" \
473 -S "Read from client: 1 bytes read" \
474 -S "122 bytes read"
475
476run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
477 "$P_SRV" \
478 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
479 request_size=123 force_version=tls1 recsplit=0" \
480 0 \
481 -s "Read from client: 123 bytes read" \
482 -S "Read from client: 1 bytes read" \
483 -S "122 bytes read"
484
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100485# Tests for Session Tickets
486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200487run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200488 "$P_SRV debug_level=3 tickets=1" \
489 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100490 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100491 -c "client hello, adding session ticket extension" \
492 -s "found session ticket extension" \
493 -s "server hello, adding session ticket extension" \
494 -c "found session_ticket extension" \
495 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100496 -S "session successfully restored from cache" \
497 -s "session successfully restored from ticket" \
498 -s "a session has been resumed" \
499 -c "a session has been resumed"
500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200501run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200502 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
503 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100504 0 \
505 -c "client hello, adding session ticket extension" \
506 -s "found session ticket extension" \
507 -s "server hello, adding session ticket extension" \
508 -c "found session_ticket extension" \
509 -c "parse new session ticket" \
510 -S "session successfully restored from cache" \
511 -s "session successfully restored from ticket" \
512 -s "a session has been resumed" \
513 -c "a session has been resumed"
514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200515run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200516 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
517 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100518 0 \
519 -c "client hello, adding session ticket extension" \
520 -s "found session ticket extension" \
521 -s "server hello, adding session ticket extension" \
522 -c "found session_ticket extension" \
523 -c "parse new session ticket" \
524 -S "session successfully restored from cache" \
525 -S "session successfully restored from ticket" \
526 -S "a session has been resumed" \
527 -C "a session has been resumed"
528
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200529run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100530 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200531 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100532 0 \
533 -c "client hello, adding session ticket extension" \
534 -c "found session_ticket extension" \
535 -c "parse new session ticket" \
536 -c "a session has been resumed"
537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200538run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200539 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200540 "( $O_CLI -sess_out $SESSION; \
541 $O_CLI -sess_in $SESSION; \
542 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100543 0 \
544 -s "found session ticket extension" \
545 -s "server hello, adding session ticket extension" \
546 -S "session successfully restored from cache" \
547 -s "session successfully restored from ticket" \
548 -s "a session has been resumed"
549
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100550# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200552run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200553 "$P_SRV debug_level=3 tickets=0" \
554 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100555 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100556 -c "client hello, adding session ticket extension" \
557 -s "found session ticket extension" \
558 -S "server hello, adding session ticket extension" \
559 -C "found session_ticket extension" \
560 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100561 -s "session successfully restored from cache" \
562 -S "session successfully restored from ticket" \
563 -s "a session has been resumed" \
564 -c "a session has been resumed"
565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200566run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200567 "$P_SRV debug_level=3 tickets=1" \
568 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100569 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100570 -C "client hello, adding session ticket extension" \
571 -S "found session ticket extension" \
572 -S "server hello, adding session ticket extension" \
573 -C "found session_ticket extension" \
574 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100575 -s "session successfully restored from cache" \
576 -S "session successfully restored from ticket" \
577 -s "a session has been resumed" \
578 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200580run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200581 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
582 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100583 0 \
584 -S "session successfully restored from cache" \
585 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100586 -S "a session has been resumed" \
587 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200589run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200590 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
591 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100592 0 \
593 -s "session successfully restored from cache" \
594 -S "session successfully restored from ticket" \
595 -s "a session has been resumed" \
596 -c "a session has been resumed"
597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200598run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200599 "$P_SRV debug_level=3 tickets=0" \
600 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100601 0 \
602 -s "session successfully restored from cache" \
603 -S "session successfully restored from ticket" \
604 -s "a session has been resumed" \
605 -c "a session has been resumed"
606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200607run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200608 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
609 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100610 0 \
611 -S "session successfully restored from cache" \
612 -S "session successfully restored from ticket" \
613 -S "a session has been resumed" \
614 -C "a session has been resumed"
615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200616run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200617 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
618 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100619 0 \
620 -s "session successfully restored from cache" \
621 -S "session successfully restored from ticket" \
622 -s "a session has been resumed" \
623 -c "a session has been resumed"
624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200625run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200626 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200627 "( $O_CLI -sess_out $SESSION; \
628 $O_CLI -sess_in $SESSION; \
629 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100630 0 \
631 -s "found session ticket extension" \
632 -S "server hello, adding session ticket extension" \
633 -s "session successfully restored from cache" \
634 -S "session successfully restored from ticket" \
635 -s "a session has been resumed"
636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200637run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100638 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200639 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100640 0 \
641 -C "found session_ticket extension" \
642 -C "parse new session ticket" \
643 -c "a session has been resumed"
644
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100645# Tests for Max Fragment Length extension
646
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200647run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200648 "$P_SRV debug_level=3" \
649 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100650 0 \
651 -C "client hello, adding max_fragment_length extension" \
652 -S "found max fragment length extension" \
653 -S "server hello, max_fragment_length extension" \
654 -C "found max_fragment_length extension"
655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200656run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200657 "$P_SRV debug_level=3" \
658 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100659 0 \
660 -c "client hello, adding max_fragment_length extension" \
661 -s "found max fragment length extension" \
662 -s "server hello, max_fragment_length extension" \
663 -c "found max_fragment_length extension"
664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200665run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200666 "$P_SRV debug_level=3 max_frag_len=4096" \
667 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100668 0 \
669 -C "client hello, adding max_fragment_length extension" \
670 -S "found max fragment length extension" \
671 -S "server hello, max_fragment_length extension" \
672 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200674requires_gnutls
675run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200676 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200677 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200678 0 \
679 -c "client hello, adding max_fragment_length extension" \
680 -c "found max_fragment_length extension"
681
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100682# Tests for renegotiation
683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200684run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200685 "$P_SRV debug_level=3 exchanges=2" \
686 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100687 0 \
688 -C "client hello, adding renegotiation extension" \
689 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
690 -S "found renegotiation extension" \
691 -s "server hello, secure renegotiation extension" \
692 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100693 -C "=> renegotiate" \
694 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100695 -S "write hello request"
696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200697run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200698 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
699 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100700 0 \
701 -c "client hello, adding renegotiation extension" \
702 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
703 -s "found renegotiation extension" \
704 -s "server hello, secure renegotiation extension" \
705 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100706 -c "=> renegotiate" \
707 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100708 -S "write hello request"
709
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200710run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200711 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
712 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100713 0 \
714 -c "client hello, adding renegotiation extension" \
715 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
716 -s "found renegotiation extension" \
717 -s "server hello, secure renegotiation extension" \
718 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100719 -c "=> renegotiate" \
720 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100721 -s "write hello request"
722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200723run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200724 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
725 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100726 0 \
727 -c "client hello, adding renegotiation extension" \
728 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
729 -s "found renegotiation extension" \
730 -s "server hello, secure renegotiation extension" \
731 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100732 -c "=> renegotiate" \
733 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100734 -s "write hello request"
735
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200736run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200737 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
738 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100739 1 \
740 -c "client hello, adding renegotiation extension" \
741 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
742 -S "found renegotiation extension" \
743 -s "server hello, secure renegotiation extension" \
744 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100745 -c "=> renegotiate" \
746 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200747 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200748 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200749 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200751run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200752 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
753 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100754 0 \
755 -C "client hello, adding renegotiation extension" \
756 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
757 -S "found renegotiation extension" \
758 -s "server hello, secure renegotiation extension" \
759 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100760 -C "=> renegotiate" \
761 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100762 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200763 -S "SSL - An unexpected message was received from our peer" \
764 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200766run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200767 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200768 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200769 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200770 0 \
771 -C "client hello, adding renegotiation extension" \
772 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
773 -S "found renegotiation extension" \
774 -s "server hello, secure renegotiation extension" \
775 -c "found renegotiation extension" \
776 -C "=> renegotiate" \
777 -S "=> renegotiate" \
778 -s "write hello request" \
779 -S "SSL - An unexpected message was received from our peer" \
780 -S "failed"
781
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200782# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200783run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200784 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200785 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200786 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200787 0 \
788 -C "client hello, adding renegotiation extension" \
789 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
790 -S "found renegotiation extension" \
791 -s "server hello, secure renegotiation extension" \
792 -c "found renegotiation extension" \
793 -C "=> renegotiate" \
794 -S "=> renegotiate" \
795 -s "write hello request" \
796 -S "SSL - An unexpected message was received from our peer" \
797 -S "failed"
798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200799run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200800 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200801 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200802 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200803 0 \
804 -C "client hello, adding renegotiation extension" \
805 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
806 -S "found renegotiation extension" \
807 -s "server hello, secure renegotiation extension" \
808 -c "found renegotiation extension" \
809 -C "=> renegotiate" \
810 -S "=> renegotiate" \
811 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200812 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200814run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200815 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200816 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200817 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200818 0 \
819 -c "client hello, adding renegotiation extension" \
820 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
821 -s "found renegotiation extension" \
822 -s "server hello, secure renegotiation extension" \
823 -c "found renegotiation extension" \
824 -c "=> renegotiate" \
825 -s "=> renegotiate" \
826 -s "write hello request" \
827 -S "SSL - An unexpected message was received from our peer" \
828 -S "failed"
829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200830run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200831 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
832 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200833 0 \
834 -c "client hello, adding renegotiation extension" \
835 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
836 -s "found renegotiation extension" \
837 -s "server hello, secure renegotiation extension" \
838 -c "found renegotiation extension" \
839 -c "=> renegotiate" \
840 -s "=> renegotiate" \
841 -S "write hello request"
842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200843run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200844 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
845 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200846 0 \
847 -c "client hello, adding renegotiation extension" \
848 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
849 -s "found renegotiation extension" \
850 -s "server hello, secure renegotiation extension" \
851 -c "found renegotiation extension" \
852 -c "=> renegotiate" \
853 -s "=> renegotiate" \
854 -s "write hello request"
855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200856run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200857 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200858 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200859 0 \
860 -c "client hello, adding renegotiation extension" \
861 -c "found renegotiation extension" \
862 -c "=> renegotiate" \
863 -C "ssl_handshake returned" \
864 -C "error" \
865 -c "HTTP/1.0 200 [Oo][Kk]"
866
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200867run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200868 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200869 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200870 0 \
871 -c "client hello, adding renegotiation extension" \
872 -c "found renegotiation extension" \
873 -c "=> renegotiate" \
874 -C "ssl_handshake returned" \
875 -C "error" \
876 -c "HTTP/1.0 200 [Oo][Kk]"
877
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100878# Tests for auth_mode
879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200880run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100881 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100882 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200883 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100884 1 \
885 -c "x509_verify_cert() returned" \
886 -c "! self-signed or not signed by a trusted CA" \
887 -c "! ssl_handshake returned" \
888 -c "X509 - Certificate verification failed"
889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200890run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100891 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100892 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200893 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100894 0 \
895 -c "x509_verify_cert() returned" \
896 -c "! self-signed or not signed by a trusted CA" \
897 -C "! ssl_handshake returned" \
898 -C "X509 - Certificate verification failed"
899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200900run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100901 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100902 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200903 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100904 0 \
905 -C "x509_verify_cert() returned" \
906 -C "! self-signed or not signed by a trusted CA" \
907 -C "! ssl_handshake returned" \
908 -C "X509 - Certificate verification failed"
909
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200910run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200911 "$P_SRV debug_level=3 auth_mode=required" \
912 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100913 key_file=data_files/server5.key" \
914 1 \
915 -S "skip write certificate request" \
916 -C "skip parse certificate request" \
917 -c "got a certificate request" \
918 -C "skip write certificate" \
919 -C "skip write certificate verify" \
920 -S "skip parse certificate verify" \
921 -s "x509_verify_cert() returned" \
922 -S "! self-signed or not signed by a trusted CA" \
923 -s "! ssl_handshake returned" \
924 -c "! ssl_handshake returned" \
925 -s "X509 - Certificate verification failed"
926
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200927run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200928 "$P_SRV debug_level=3 auth_mode=optional" \
929 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100930 key_file=data_files/server5.key" \
931 0 \
932 -S "skip write certificate request" \
933 -C "skip parse certificate request" \
934 -c "got a certificate request" \
935 -C "skip write certificate" \
936 -C "skip write certificate verify" \
937 -S "skip parse certificate verify" \
938 -s "x509_verify_cert() returned" \
939 -s "! self-signed or not signed by a trusted CA" \
940 -S "! ssl_handshake returned" \
941 -C "! ssl_handshake returned" \
942 -S "X509 - Certificate verification failed"
943
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200944run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200945 "$P_SRV debug_level=3 auth_mode=none" \
946 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100947 key_file=data_files/server5.key" \
948 0 \
949 -s "skip write certificate request" \
950 -C "skip parse certificate request" \
951 -c "got no certificate request" \
952 -c "skip write certificate" \
953 -c "skip write certificate verify" \
954 -s "skip parse certificate verify" \
955 -S "x509_verify_cert() returned" \
956 -S "! self-signed or not signed by a trusted CA" \
957 -S "! ssl_handshake returned" \
958 -C "! ssl_handshake returned" \
959 -S "X509 - Certificate verification failed"
960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200961run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200962 "$P_SRV debug_level=3 auth_mode=optional" \
963 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100964 0 \
965 -S "skip write certificate request" \
966 -C "skip parse certificate request" \
967 -c "got a certificate request" \
968 -C "skip write certificate$" \
969 -C "got no certificate to send" \
970 -S "SSLv3 client has no certificate" \
971 -c "skip write certificate verify" \
972 -s "skip parse certificate verify" \
973 -s "! no client certificate sent" \
974 -S "! ssl_handshake returned" \
975 -C "! ssl_handshake returned" \
976 -S "X509 - Certificate verification failed"
977
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200978run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200979 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100980 "$O_CLI" \
981 0 \
982 -S "skip write certificate request" \
983 -s "skip parse certificate verify" \
984 -s "! no client certificate sent" \
985 -S "! ssl_handshake returned" \
986 -S "X509 - Certificate verification failed"
987
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200988run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100989 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200990 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100991 0 \
992 -C "skip parse certificate request" \
993 -c "got a certificate request" \
994 -C "skip write certificate$" \
995 -c "skip write certificate verify" \
996 -C "! ssl_handshake returned"
997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200998run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200999 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1000 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001001 0 \
1002 -S "skip write certificate request" \
1003 -C "skip parse certificate request" \
1004 -c "got a certificate request" \
1005 -C "skip write certificate$" \
1006 -c "skip write certificate verify" \
1007 -c "got no certificate to send" \
1008 -s "SSLv3 client has no certificate" \
1009 -s "skip parse certificate verify" \
1010 -s "! no client certificate sent" \
1011 -S "! ssl_handshake returned" \
1012 -C "! ssl_handshake returned" \
1013 -S "X509 - Certificate verification failed"
1014
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001015# tests for SNI
1016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001017run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001018 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001019 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001020 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001021 server_name=localhost" \
1022 0 \
1023 -S "parse ServerName extension" \
1024 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1025 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001027run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001028 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001029 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001030 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 +01001031 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001032 server_name=localhost" \
1033 0 \
1034 -s "parse ServerName extension" \
1035 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1036 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001038run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001039 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001040 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001041 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 +01001042 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001043 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001044 0 \
1045 -s "parse ServerName extension" \
1046 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001047 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001048
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001049run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001050 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001051 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001052 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 +01001053 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001054 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001055 1 \
1056 -s "parse ServerName extension" \
1057 -s "ssl_sni_wrapper() returned" \
1058 -s "ssl_handshake returned" \
1059 -c "ssl_handshake returned" \
1060 -c "SSL - A fatal alert message was received from our peer"
1061
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001062# Tests for non-blocking I/O: exercise a variety of handshake flows
1063
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001064run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001065 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1066 "$P_CLI nbio=2 tickets=0" \
1067 0 \
1068 -S "ssl_handshake returned" \
1069 -C "ssl_handshake returned" \
1070 -c "Read from server: .* bytes read"
1071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001072run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001073 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1074 "$P_CLI nbio=2 tickets=0" \
1075 0 \
1076 -S "ssl_handshake returned" \
1077 -C "ssl_handshake returned" \
1078 -c "Read from server: .* bytes read"
1079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001080run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001081 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1082 "$P_CLI nbio=2 tickets=1" \
1083 0 \
1084 -S "ssl_handshake returned" \
1085 -C "ssl_handshake returned" \
1086 -c "Read from server: .* bytes read"
1087
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001088run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001089 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1090 "$P_CLI nbio=2 tickets=1" \
1091 0 \
1092 -S "ssl_handshake returned" \
1093 -C "ssl_handshake returned" \
1094 -c "Read from server: .* bytes read"
1095
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001096run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001097 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1098 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1099 0 \
1100 -S "ssl_handshake returned" \
1101 -C "ssl_handshake returned" \
1102 -c "Read from server: .* bytes read"
1103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001104run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001105 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1106 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1107 0 \
1108 -S "ssl_handshake returned" \
1109 -C "ssl_handshake returned" \
1110 -c "Read from server: .* bytes read"
1111
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001112run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001113 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1114 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1115 0 \
1116 -S "ssl_handshake returned" \
1117 -C "ssl_handshake returned" \
1118 -c "Read from server: .* bytes read"
1119
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001120# Tests for version negotiation
1121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001122run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001123 "$P_SRV" \
1124 "$P_CLI" \
1125 0 \
1126 -S "ssl_handshake returned" \
1127 -C "ssl_handshake returned" \
1128 -s "Protocol is TLSv1.2" \
1129 -c "Protocol is TLSv1.2"
1130
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001131run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001132 "$P_SRV" \
1133 "$P_CLI max_version=tls1_1" \
1134 0 \
1135 -S "ssl_handshake returned" \
1136 -C "ssl_handshake returned" \
1137 -s "Protocol is TLSv1.1" \
1138 -c "Protocol is TLSv1.1"
1139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001140run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001141 "$P_SRV max_version=tls1_1" \
1142 "$P_CLI" \
1143 0 \
1144 -S "ssl_handshake returned" \
1145 -C "ssl_handshake returned" \
1146 -s "Protocol is TLSv1.1" \
1147 -c "Protocol is TLSv1.1"
1148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001149run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001150 "$P_SRV max_version=tls1_1" \
1151 "$P_CLI max_version=tls1_1" \
1152 0 \
1153 -S "ssl_handshake returned" \
1154 -C "ssl_handshake returned" \
1155 -s "Protocol is TLSv1.1" \
1156 -c "Protocol is TLSv1.1"
1157
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001158run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001159 "$P_SRV min_version=tls1_1" \
1160 "$P_CLI max_version=tls1_1" \
1161 0 \
1162 -S "ssl_handshake returned" \
1163 -C "ssl_handshake returned" \
1164 -s "Protocol is TLSv1.1" \
1165 -c "Protocol is TLSv1.1"
1166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001167run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001168 "$P_SRV max_version=tls1_1" \
1169 "$P_CLI min_version=tls1_1" \
1170 0 \
1171 -S "ssl_handshake returned" \
1172 -C "ssl_handshake returned" \
1173 -s "Protocol is TLSv1.1" \
1174 -c "Protocol is TLSv1.1"
1175
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001176run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001177 "$P_SRV max_version=tls1_1" \
1178 "$P_CLI min_version=tls1_2" \
1179 1 \
1180 -s "ssl_handshake returned" \
1181 -c "ssl_handshake returned" \
1182 -c "SSL - Handshake protocol not within min/max boundaries"
1183
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001184run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001185 "$P_SRV min_version=tls1_2" \
1186 "$P_CLI max_version=tls1_1" \
1187 1 \
1188 -s "ssl_handshake returned" \
1189 -c "ssl_handshake returned" \
1190 -s "SSL - Handshake protocol not within min/max boundaries"
1191
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001192# Tests for ALPN extension
1193
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001194if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001196run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001197 "$P_SRV debug_level=3" \
1198 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001199 0 \
1200 -C "client hello, adding alpn extension" \
1201 -S "found alpn extension" \
1202 -C "got an alert message, type: \\[2:120]" \
1203 -S "server hello, adding alpn extension" \
1204 -C "found alpn extension " \
1205 -C "Application Layer Protocol is" \
1206 -S "Application Layer Protocol is"
1207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001208run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001209 "$P_SRV debug_level=3" \
1210 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001211 0 \
1212 -c "client hello, adding alpn extension" \
1213 -s "found alpn extension" \
1214 -C "got an alert message, type: \\[2:120]" \
1215 -S "server hello, adding alpn extension" \
1216 -C "found alpn extension " \
1217 -c "Application Layer Protocol is (none)" \
1218 -S "Application Layer Protocol is"
1219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001220run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001221 "$P_SRV debug_level=3 alpn=abc,1234" \
1222 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001223 0 \
1224 -C "client hello, adding alpn extension" \
1225 -S "found alpn extension" \
1226 -C "got an alert message, type: \\[2:120]" \
1227 -S "server hello, adding alpn extension" \
1228 -C "found alpn extension " \
1229 -C "Application Layer Protocol is" \
1230 -s "Application Layer Protocol is (none)"
1231
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001232run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001233 "$P_SRV debug_level=3 alpn=abc,1234" \
1234 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001235 0 \
1236 -c "client hello, adding alpn extension" \
1237 -s "found alpn extension" \
1238 -C "got an alert message, type: \\[2:120]" \
1239 -s "server hello, adding alpn extension" \
1240 -c "found alpn extension" \
1241 -c "Application Layer Protocol is abc" \
1242 -s "Application Layer Protocol is abc"
1243
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001244run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001245 "$P_SRV debug_level=3 alpn=abc,1234" \
1246 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001247 0 \
1248 -c "client hello, adding alpn extension" \
1249 -s "found alpn extension" \
1250 -C "got an alert message, type: \\[2:120]" \
1251 -s "server hello, adding alpn extension" \
1252 -c "found alpn extension" \
1253 -c "Application Layer Protocol is abc" \
1254 -s "Application Layer Protocol is abc"
1255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_SRV debug_level=3 alpn=abc,1234" \
1258 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001259 0 \
1260 -c "client hello, adding alpn extension" \
1261 -s "found alpn extension" \
1262 -C "got an alert message, type: \\[2:120]" \
1263 -s "server hello, adding alpn extension" \
1264 -c "found alpn extension" \
1265 -c "Application Layer Protocol is 1234" \
1266 -s "Application Layer Protocol is 1234"
1267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001268run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001269 "$P_SRV debug_level=3 alpn=abc,123" \
1270 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001271 1 \
1272 -c "client hello, adding alpn extension" \
1273 -s "found alpn extension" \
1274 -c "got an alert message, type: \\[2:120]" \
1275 -S "server hello, adding alpn extension" \
1276 -C "found alpn extension" \
1277 -C "Application Layer Protocol is 1234" \
1278 -S "Application Layer Protocol is 1234"
1279
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001280fi
1281
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001282# Tests for keyUsage in leaf certificates, part 1:
1283# server-side certificate/suite selection
1284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001285run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001286 "$P_SRV key_file=data_files/server2.key \
1287 crt_file=data_files/server2.ku-ds.crt" \
1288 "$P_CLI" \
1289 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001290 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001291
1292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001293run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001294 "$P_SRV key_file=data_files/server2.key \
1295 crt_file=data_files/server2.ku-ke.crt" \
1296 "$P_CLI" \
1297 0 \
1298 -c "Ciphersuite is TLS-RSA-WITH-"
1299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001300run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001301 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001302 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001303 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001304 1 \
1305 -C "Ciphersuite is "
1306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001307run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001308 "$P_SRV key_file=data_files/server5.key \
1309 crt_file=data_files/server5.ku-ds.crt" \
1310 "$P_CLI" \
1311 0 \
1312 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1313
1314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001315run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001316 "$P_SRV key_file=data_files/server5.key \
1317 crt_file=data_files/server5.ku-ka.crt" \
1318 "$P_CLI" \
1319 0 \
1320 -c "Ciphersuite is TLS-ECDH-"
1321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001322run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001323 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001324 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001325 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001326 1 \
1327 -C "Ciphersuite is "
1328
1329# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001330# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001331
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001332run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001333 "$O_SRV -key data_files/server2.key \
1334 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001335 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001336 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1337 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001338 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001339 -C "Processing of the Certificate handshake message failed" \
1340 -c "Ciphersuite is TLS-"
1341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001342run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001343 "$O_SRV -key data_files/server2.key \
1344 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001345 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001346 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1347 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001348 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001349 -C "Processing of the Certificate handshake message failed" \
1350 -c "Ciphersuite is TLS-"
1351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001352run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001353 "$O_SRV -key data_files/server2.key \
1354 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001355 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001356 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1357 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001358 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001359 -C "Processing of the Certificate handshake message failed" \
1360 -c "Ciphersuite is TLS-"
1361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001362run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001363 "$O_SRV -key data_files/server2.key \
1364 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001365 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001366 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1367 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001368 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001369 -c "Processing of the Certificate handshake message failed" \
1370 -C "Ciphersuite is TLS-"
1371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001372run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001373 "$O_SRV -key data_files/server2.key \
1374 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001375 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001376 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1377 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001378 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001379 -C "Processing of the Certificate handshake message failed" \
1380 -c "Ciphersuite is TLS-"
1381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001382run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001383 "$O_SRV -key data_files/server2.key \
1384 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001385 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001386 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1387 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001388 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001389 -c "Processing of the Certificate handshake message failed" \
1390 -C "Ciphersuite is TLS-"
1391
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001392# Tests for keyUsage in leaf certificates, part 3:
1393# server-side checking of client cert
1394
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001395run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001396 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001397 "$O_CLI -key data_files/server2.key \
1398 -cert data_files/server2.ku-ds.crt" \
1399 0 \
1400 -S "bad certificate (usage extensions)" \
1401 -S "Processing of the Certificate handshake message failed"
1402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001403run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001404 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001405 "$O_CLI -key data_files/server2.key \
1406 -cert data_files/server2.ku-ke.crt" \
1407 0 \
1408 -s "bad certificate (usage extensions)" \
1409 -S "Processing of the Certificate handshake message failed"
1410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001411run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001412 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001413 "$O_CLI -key data_files/server2.key \
1414 -cert data_files/server2.ku-ke.crt" \
1415 1 \
1416 -s "bad certificate (usage extensions)" \
1417 -s "Processing of the Certificate handshake message failed"
1418
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001419run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001420 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001421 "$O_CLI -key data_files/server5.key \
1422 -cert data_files/server5.ku-ds.crt" \
1423 0 \
1424 -S "bad certificate (usage extensions)" \
1425 -S "Processing of the Certificate handshake message failed"
1426
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001427run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001428 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001429 "$O_CLI -key data_files/server5.key \
1430 -cert data_files/server5.ku-ka.crt" \
1431 0 \
1432 -s "bad certificate (usage extensions)" \
1433 -S "Processing of the Certificate handshake message failed"
1434
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001435# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001437run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001438 "$P_SRV key_file=data_files/server5.key \
1439 crt_file=data_files/server5.eku-srv.crt" \
1440 "$P_CLI" \
1441 0
1442
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001443run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001444 "$P_SRV key_file=data_files/server5.key \
1445 crt_file=data_files/server5.eku-srv.crt" \
1446 "$P_CLI" \
1447 0
1448
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001449run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001450 "$P_SRV key_file=data_files/server5.key \
1451 crt_file=data_files/server5.eku-cs_any.crt" \
1452 "$P_CLI" \
1453 0
1454
1455# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001456run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001457 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1458 crt_file=data_files/server5.eku-cli.crt" \
1459 "$P_CLI psk=badbad" \
1460 1
1461
1462# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001464run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001465 "$O_SRV -key data_files/server5.key \
1466 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001467 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001468 0 \
1469 -C "bad certificate (usage extensions)" \
1470 -C "Processing of the Certificate handshake message failed" \
1471 -c "Ciphersuite is TLS-"
1472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001473run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001474 "$O_SRV -key data_files/server5.key \
1475 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001476 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001477 0 \
1478 -C "bad certificate (usage extensions)" \
1479 -C "Processing of the Certificate handshake message failed" \
1480 -c "Ciphersuite is TLS-"
1481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001482run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001483 "$O_SRV -key data_files/server5.key \
1484 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001485 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001486 0 \
1487 -C "bad certificate (usage extensions)" \
1488 -C "Processing of the Certificate handshake message failed" \
1489 -c "Ciphersuite is TLS-"
1490
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001491run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001492 "$O_SRV -key data_files/server5.key \
1493 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001494 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001495 1 \
1496 -c "bad certificate (usage extensions)" \
1497 -c "Processing of the Certificate handshake message failed" \
1498 -C "Ciphersuite is TLS-"
1499
1500# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001502run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001503 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001504 "$O_CLI -key data_files/server5.key \
1505 -cert data_files/server5.eku-cli.crt" \
1506 0 \
1507 -S "bad certificate (usage extensions)" \
1508 -S "Processing of the Certificate handshake message failed"
1509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001510run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001511 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001512 "$O_CLI -key data_files/server5.key \
1513 -cert data_files/server5.eku-srv_cli.crt" \
1514 0 \
1515 -S "bad certificate (usage extensions)" \
1516 -S "Processing of the Certificate handshake message failed"
1517
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001518run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001519 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001520 "$O_CLI -key data_files/server5.key \
1521 -cert data_files/server5.eku-cs_any.crt" \
1522 0 \
1523 -S "bad certificate (usage extensions)" \
1524 -S "Processing of the Certificate handshake message failed"
1525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001526run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001527 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001528 "$O_CLI -key data_files/server5.key \
1529 -cert data_files/server5.eku-cs.crt" \
1530 0 \
1531 -s "bad certificate (usage extensions)" \
1532 -S "Processing of the Certificate handshake message failed"
1533
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001534run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001535 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001536 "$O_CLI -key data_files/server5.key \
1537 -cert data_files/server5.eku-cs.crt" \
1538 1 \
1539 -s "bad certificate (usage extensions)" \
1540 -s "Processing of the Certificate handshake message failed"
1541
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001542# Tests for DHM parameters loading
1543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001544run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001545 "$P_SRV" \
1546 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1547 debug_level=3" \
1548 0 \
1549 -c "value of 'DHM: P ' (2048 bits)" \
1550 -c "value of 'DHM: G ' (2048 bits)"
1551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001552run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001553 "$P_SRV dhm_file=data_files/dhparams.pem" \
1554 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1555 debug_level=3" \
1556 0 \
1557 -c "value of 'DHM: P ' (1024 bits)" \
1558 -c "value of 'DHM: G ' (2 bits)"
1559
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001560# Tests for PSK callback
1561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001562run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001563 "$P_SRV psk=abc123 psk_identity=foo" \
1564 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1565 psk_identity=foo psk=abc123" \
1566 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001567 -S "SSL - The server has no ciphersuites in common" \
1568 -S "SSL - Unknown identity received" \
1569 -S "SSL - Verification of the message MAC failed"
1570
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001571run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001572 "$P_SRV" \
1573 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1574 psk_identity=foo psk=abc123" \
1575 1 \
1576 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001577 -S "SSL - Unknown identity received" \
1578 -S "SSL - Verification of the message MAC failed"
1579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001580run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001581 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1582 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1583 psk_identity=foo psk=abc123" \
1584 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001585 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001586 -s "SSL - Unknown identity received" \
1587 -S "SSL - Verification of the message MAC failed"
1588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001589run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001590 "$P_SRV psk_list=abc,dead,def,beef" \
1591 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1592 psk_identity=abc psk=dead" \
1593 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001594 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001595 -S "SSL - Unknown identity received" \
1596 -S "SSL - Verification of the message MAC failed"
1597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001598run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001599 "$P_SRV psk_list=abc,dead,def,beef" \
1600 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1601 psk_identity=def psk=beef" \
1602 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001603 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001604 -S "SSL - Unknown identity received" \
1605 -S "SSL - Verification of the message MAC failed"
1606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001607run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001608 "$P_SRV psk_list=abc,dead,def,beef" \
1609 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1610 psk_identity=ghi psk=beef" \
1611 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001612 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001613 -s "SSL - Unknown identity received" \
1614 -S "SSL - Verification of the message MAC failed"
1615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001616run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001617 "$P_SRV psk_list=abc,dead,def,beef" \
1618 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1619 psk_identity=abc psk=beef" \
1620 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001621 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001622 -S "SSL - Unknown identity received" \
1623 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001624
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001625# Tests for ciphersuites per version
1626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001627run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001628 "$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" \
1629 "$P_CLI force_version=ssl3" \
1630 0 \
1631 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1632
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001633run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001634 "$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" \
1635 "$P_CLI force_version=tls1" \
1636 0 \
1637 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001639run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001640 "$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" \
1641 "$P_CLI force_version=tls1_1" \
1642 0 \
1643 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001645run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001646 "$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" \
1647 "$P_CLI force_version=tls1_2" \
1648 0 \
1649 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1650
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001651# Tests for ssl_get_bytes_avail()
1652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001653run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001654 "$P_SRV" \
1655 "$P_CLI request_size=100" \
1656 0 \
1657 -s "Read from client: 100 bytes read$"
1658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001659run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001660 "$P_SRV" \
1661 "$P_CLI request_size=500" \
1662 0 \
1663 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001664
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001665# Tests for small packets
1666
1667run_test "Small packet SSLv3 BlockCipher" \
1668 "$P_SRV" \
1669 "$P_CLI request_size=1 force_version=ssl3 \
1670 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1671 0 \
1672 -s "Read from client: 1 bytes read"
1673
1674run_test "Small packet SSLv3 StreamCipher" \
1675 "$P_SRV" \
1676 "$P_CLI request_size=1 force_version=ssl3 \
1677 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1678 0 \
1679 -s "Read from client: 1 bytes read"
1680
1681run_test "Small packet TLS 1.0 BlockCipher" \
1682 "$P_SRV" \
1683 "$P_CLI request_size=1 force_version=tls1 \
1684 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1685 0 \
1686 -s "Read from client: 1 bytes read"
1687
1688run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1689 "$P_SRV" \
1690 "$P_CLI request_size=1 force_version=tls1 \
1691 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1692 trunc_hmac=1" \
1693 0 \
1694 -s "Read from client: 1 bytes read"
1695
1696run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1697 "$P_SRV" \
1698 "$P_CLI request_size=1 force_version=tls1 \
1699 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1700 trunc_hmac=1" \
1701 0 \
1702 -s "Read from client: 1 bytes read"
1703
1704run_test "Small packet TLS 1.1 BlockCipher" \
1705 "$P_SRV" \
1706 "$P_CLI request_size=1 force_version=tls1_1 \
1707 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1708 0 \
1709 -s "Read from client: 1 bytes read"
1710
1711run_test "Small packet TLS 1.1 StreamCipher" \
1712 "$P_SRV" \
1713 "$P_CLI request_size=1 force_version=tls1_1 \
1714 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1715 0 \
1716 -s "Read from client: 1 bytes read"
1717
1718run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1719 "$P_SRV" \
1720 "$P_CLI request_size=1 force_version=tls1_1 \
1721 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1722 trunc_hmac=1" \
1723 0 \
1724 -s "Read from client: 1 bytes read"
1725
1726run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1727 "$P_SRV" \
1728 "$P_CLI request_size=1 force_version=tls1_1 \
1729 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1730 trunc_hmac=1" \
1731 0 \
1732 -s "Read from client: 1 bytes read"
1733
1734run_test "Small packet TLS 1.2 BlockCipher" \
1735 "$P_SRV" \
1736 "$P_CLI request_size=1 force_version=tls1_2 \
1737 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1738 0 \
1739 -s "Read from client: 1 bytes read"
1740
1741run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1742 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01001743 "$P_CLI request_size=1 force_version=tls1_2 \
1744 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001745 0 \
1746 -s "Read from client: 1 bytes read"
1747
1748run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1749 "$P_SRV" \
1750 "$P_CLI request_size=1 force_version=tls1_2 \
1751 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1752 trunc_hmac=1" \
1753 0 \
1754 -s "Read from client: 1 bytes read"
1755
1756run_test "Small packet TLS 1.2 StreamCipher" \
1757 "$P_SRV" \
1758 "$P_CLI request_size=1 force_version=tls1_2 \
1759 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1760 0 \
1761 -s "Read from client: 1 bytes read"
1762
1763run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1764 "$P_SRV" \
1765 "$P_CLI request_size=1 force_version=tls1_2 \
1766 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1767 trunc_hmac=1" \
1768 0 \
1769 -s "Read from client: 1 bytes read"
1770
1771run_test "Small packet TLS 1.2 AEAD" \
1772 "$P_SRV" \
1773 "$P_CLI request_size=1 force_version=tls1_2 \
1774 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1775 0 \
1776 -s "Read from client: 1 bytes read"
1777
1778run_test "Small packet TLS 1.2 AEAD shorter tag" \
1779 "$P_SRV" \
1780 "$P_CLI request_size=1 force_version=tls1_2 \
1781 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1782 0 \
1783 -s "Read from client: 1 bytes read"
1784
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001785# Test for large packets
1786
1787run_test "Large packet SSLv3 BlockCipher" \
1788 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01001789 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001790 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1791 0 \
1792 -s "Read from client: 16384 bytes read"
1793
1794run_test "Large packet SSLv3 StreamCipher" \
1795 "$P_SRV" \
1796 "$P_CLI request_size=16384 force_version=ssl3 \
1797 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1798 0 \
1799 -s "Read from client: 16384 bytes read"
1800
1801run_test "Large packet TLS 1.0 BlockCipher" \
1802 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01001803 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001804 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1805 0 \
1806 -s "Read from client: 16384 bytes read"
1807
1808run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1809 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01001810 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001811 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1812 trunc_hmac=1" \
1813 0 \
1814 -s "Read from client: 16384 bytes read"
1815
1816run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1817 "$P_SRV" \
1818 "$P_CLI request_size=16384 force_version=tls1 \
1819 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1820 trunc_hmac=1" \
1821 0 \
1822 -s "Read from client: 16384 bytes read"
1823
1824run_test "Large packet TLS 1.1 BlockCipher" \
1825 "$P_SRV" \
1826 "$P_CLI request_size=16384 force_version=tls1_1 \
1827 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1828 0 \
1829 -s "Read from client: 16384 bytes read"
1830
1831run_test "Large packet TLS 1.1 StreamCipher" \
1832 "$P_SRV" \
1833 "$P_CLI request_size=16384 force_version=tls1_1 \
1834 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1835 0 \
1836 -s "Read from client: 16384 bytes read"
1837
1838run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1839 "$P_SRV" \
1840 "$P_CLI request_size=16384 force_version=tls1_1 \
1841 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1842 trunc_hmac=1" \
1843 0 \
1844 -s "Read from client: 16384 bytes read"
1845
1846run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1847 "$P_SRV" \
1848 "$P_CLI request_size=16384 force_version=tls1_1 \
1849 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1850 trunc_hmac=1" \
1851 0 \
1852 -s "Read from client: 16384 bytes read"
1853
1854run_test "Large packet TLS 1.2 BlockCipher" \
1855 "$P_SRV" \
1856 "$P_CLI request_size=16384 force_version=tls1_2 \
1857 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1858 0 \
1859 -s "Read from client: 16384 bytes read"
1860
1861run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1862 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01001863 "$P_CLI request_size=16384 force_version=tls1_2 \
1864 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001865 0 \
1866 -s "Read from client: 16384 bytes read"
1867
1868run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1869 "$P_SRV" \
1870 "$P_CLI request_size=16384 force_version=tls1_2 \
1871 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1872 trunc_hmac=1" \
1873 0 \
1874 -s "Read from client: 16384 bytes read"
1875
1876run_test "Large packet TLS 1.2 StreamCipher" \
1877 "$P_SRV" \
1878 "$P_CLI request_size=16384 force_version=tls1_2 \
1879 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1880 0 \
1881 -s "Read from client: 16384 bytes read"
1882
1883run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1884 "$P_SRV" \
1885 "$P_CLI request_size=16384 force_version=tls1_2 \
1886 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1887 trunc_hmac=1" \
1888 0 \
1889 -s "Read from client: 16384 bytes read"
1890
1891run_test "Large packet TLS 1.2 AEAD" \
1892 "$P_SRV" \
1893 "$P_CLI request_size=16384 force_version=tls1_2 \
1894 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1895 0 \
1896 -s "Read from client: 16384 bytes read"
1897
1898run_test "Large packet TLS 1.2 AEAD shorter tag" \
1899 "$P_SRV" \
1900 "$P_CLI request_size=16384 force_version=tls1_2 \
1901 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1902 0 \
1903 -s "Read from client: 16384 bytes read"
1904
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001905# Final report
1906
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001907echo "------------------------------------------------------------------------"
1908
1909if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01001910 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001911else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01001912 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001913fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02001914PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001915echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001916
1917exit $FAILS