blob: bb8bd6297f0c5497da8664d95e9aec668613d913 [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é-Gonnardbd47a582015-01-12 13:43:29 +0100396# Tests for rc4 option
397
398run_test "RC4: server disabled, client enabled" \
399 "$P_SRV" \
400 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
401 1 \
402 -s "SSL - The server has no ciphersuites in common"
403
404run_test "RC4: server enabled, client disabled" \
405 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
406 "$P_CLI" \
407 1 \
408 -s "SSL - The server has no ciphersuites in common"
409
410run_test "RC4: both enabled" \
411 "$P_SRV arc4=1" \
412 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
413 0 \
414 -S "SSL - The server has no ciphersuites in common"
415
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100416# Test for SSLv2 ClientHello
417
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200418requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200419run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100420 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100421 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100422 0 \
423 -S "parse client hello v2" \
424 -S "ssl_handshake returned"
425
426# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200427requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200428run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200429 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100430 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100431 0 \
432 -s "parse client hello v2" \
433 -S "ssl_handshake returned"
434
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100435# Tests for Truncated HMAC extension
436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200437run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200438 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100439 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100440 0 \
441 -s "dumping 'computed mac' (20 bytes)"
442
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200443run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200444 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100445 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100446 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100447 -s "dumping 'computed mac' (10 bytes)"
448
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100449# Tests for Session Tickets
450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200451run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200452 "$P_SRV debug_level=3 tickets=1" \
453 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100454 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100455 -c "client hello, adding session ticket extension" \
456 -s "found session ticket extension" \
457 -s "server hello, adding session ticket extension" \
458 -c "found session_ticket extension" \
459 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100460 -S "session successfully restored from cache" \
461 -s "session successfully restored from ticket" \
462 -s "a session has been resumed" \
463 -c "a session has been resumed"
464
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200465run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200466 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
467 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100468 0 \
469 -c "client hello, adding session ticket extension" \
470 -s "found session ticket extension" \
471 -s "server hello, adding session ticket extension" \
472 -c "found session_ticket extension" \
473 -c "parse new session ticket" \
474 -S "session successfully restored from cache" \
475 -s "session successfully restored from ticket" \
476 -s "a session has been resumed" \
477 -c "a session has been resumed"
478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200479run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200480 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
481 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100482 0 \
483 -c "client hello, adding session ticket extension" \
484 -s "found session ticket extension" \
485 -s "server hello, adding session ticket extension" \
486 -c "found session_ticket extension" \
487 -c "parse new session ticket" \
488 -S "session successfully restored from cache" \
489 -S "session successfully restored from ticket" \
490 -S "a session has been resumed" \
491 -C "a session has been resumed"
492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200493run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100494 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200495 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100496 0 \
497 -c "client hello, adding session ticket extension" \
498 -c "found session_ticket extension" \
499 -c "parse new session ticket" \
500 -c "a session has been resumed"
501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200502run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200503 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200504 "( $O_CLI -sess_out $SESSION; \
505 $O_CLI -sess_in $SESSION; \
506 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100507 0 \
508 -s "found session ticket extension" \
509 -s "server hello, adding session ticket extension" \
510 -S "session successfully restored from cache" \
511 -s "session successfully restored from ticket" \
512 -s "a session has been resumed"
513
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100514# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200516run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200517 "$P_SRV debug_level=3 tickets=0" \
518 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100519 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100520 -c "client hello, adding session ticket extension" \
521 -s "found session ticket extension" \
522 -S "server hello, adding session ticket extension" \
523 -C "found session_ticket extension" \
524 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100525 -s "session successfully restored from cache" \
526 -S "session successfully restored from ticket" \
527 -s "a session has been resumed" \
528 -c "a session has been resumed"
529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200530run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200531 "$P_SRV debug_level=3 tickets=1" \
532 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100533 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100534 -C "client hello, adding session ticket extension" \
535 -S "found session ticket extension" \
536 -S "server hello, adding session ticket extension" \
537 -C "found session_ticket extension" \
538 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100539 -s "session successfully restored from cache" \
540 -S "session successfully restored from ticket" \
541 -s "a session has been resumed" \
542 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200544run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200545 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
546 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100547 0 \
548 -S "session successfully restored from cache" \
549 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100550 -S "a session has been resumed" \
551 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200553run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200554 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
555 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100556 0 \
557 -s "session successfully restored from cache" \
558 -S "session successfully restored from ticket" \
559 -s "a session has been resumed" \
560 -c "a session has been resumed"
561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200562run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200563 "$P_SRV debug_level=3 tickets=0" \
564 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100565 0 \
566 -s "session successfully restored from cache" \
567 -S "session successfully restored from ticket" \
568 -s "a session has been resumed" \
569 -c "a session has been resumed"
570
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200571run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200572 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
573 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100574 0 \
575 -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"
579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200580run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200581 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
582 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
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" \
586 -s "a session has been resumed" \
587 -c "a session has been resumed"
588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200589run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200590 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200591 "( $O_CLI -sess_out $SESSION; \
592 $O_CLI -sess_in $SESSION; \
593 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100594 0 \
595 -s "found session ticket extension" \
596 -S "server hello, adding session ticket extension" \
597 -s "session successfully restored from cache" \
598 -S "session successfully restored from ticket" \
599 -s "a session has been resumed"
600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200601run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100602 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200603 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100604 0 \
605 -C "found session_ticket extension" \
606 -C "parse new session ticket" \
607 -c "a session has been resumed"
608
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100609# Tests for Max Fragment Length extension
610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200611run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200612 "$P_SRV debug_level=3" \
613 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100614 0 \
615 -C "client hello, adding max_fragment_length extension" \
616 -S "found max fragment length extension" \
617 -S "server hello, max_fragment_length extension" \
618 -C "found max_fragment_length extension"
619
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200620run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200621 "$P_SRV debug_level=3" \
622 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100623 0 \
624 -c "client hello, adding max_fragment_length extension" \
625 -s "found max fragment length extension" \
626 -s "server hello, max_fragment_length extension" \
627 -c "found max_fragment_length extension"
628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200629run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200630 "$P_SRV debug_level=3 max_frag_len=4096" \
631 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100632 0 \
633 -C "client hello, adding max_fragment_length extension" \
634 -S "found max fragment length extension" \
635 -S "server hello, max_fragment_length extension" \
636 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100637
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200638requires_gnutls
639run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200640 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200641 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200642 0 \
643 -c "client hello, adding max_fragment_length extension" \
644 -c "found max_fragment_length extension"
645
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100646# Tests for renegotiation
647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200648run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200649 "$P_SRV debug_level=3 exchanges=2" \
650 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100651 0 \
652 -C "client hello, adding renegotiation extension" \
653 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
654 -S "found renegotiation extension" \
655 -s "server hello, secure renegotiation extension" \
656 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100657 -C "=> renegotiate" \
658 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100659 -S "write hello request"
660
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200661run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200662 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
663 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100664 0 \
665 -c "client hello, adding renegotiation extension" \
666 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
667 -s "found renegotiation extension" \
668 -s "server hello, secure renegotiation extension" \
669 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100670 -c "=> renegotiate" \
671 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100672 -S "write hello request"
673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200674run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200675 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
676 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100677 0 \
678 -c "client hello, adding renegotiation extension" \
679 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
680 -s "found renegotiation extension" \
681 -s "server hello, secure renegotiation extension" \
682 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100683 -c "=> renegotiate" \
684 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100685 -s "write hello request"
686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200687run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200688 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
689 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100690 0 \
691 -c "client hello, adding renegotiation extension" \
692 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
693 -s "found renegotiation extension" \
694 -s "server hello, secure renegotiation extension" \
695 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100696 -c "=> renegotiate" \
697 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100698 -s "write hello request"
699
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200700run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200701 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
702 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100703 1 \
704 -c "client hello, adding renegotiation extension" \
705 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
706 -S "found renegotiation extension" \
707 -s "server hello, secure renegotiation extension" \
708 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100709 -c "=> renegotiate" \
710 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200711 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200712 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200713 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200715run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200716 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
717 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100718 0 \
719 -C "client hello, adding renegotiation extension" \
720 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
721 -S "found renegotiation extension" \
722 -s "server hello, secure renegotiation extension" \
723 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100724 -C "=> renegotiate" \
725 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100726 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200727 -S "SSL - An unexpected message was received from our peer" \
728 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200730run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200731 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200732 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200733 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200734 0 \
735 -C "client hello, adding renegotiation extension" \
736 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
737 -S "found renegotiation extension" \
738 -s "server hello, secure renegotiation extension" \
739 -c "found renegotiation extension" \
740 -C "=> renegotiate" \
741 -S "=> renegotiate" \
742 -s "write hello request" \
743 -S "SSL - An unexpected message was received from our peer" \
744 -S "failed"
745
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200746# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200747run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200748 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200749 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200750 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200751 0 \
752 -C "client hello, adding renegotiation extension" \
753 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
754 -S "found renegotiation extension" \
755 -s "server hello, secure renegotiation extension" \
756 -c "found renegotiation extension" \
757 -C "=> renegotiate" \
758 -S "=> renegotiate" \
759 -s "write hello request" \
760 -S "SSL - An unexpected message was received from our peer" \
761 -S "failed"
762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200763run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200764 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200765 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200766 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200767 0 \
768 -C "client hello, adding renegotiation extension" \
769 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
770 -S "found renegotiation extension" \
771 -s "server hello, secure renegotiation extension" \
772 -c "found renegotiation extension" \
773 -C "=> renegotiate" \
774 -S "=> renegotiate" \
775 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200776 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200777
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200778run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200779 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200780 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200781 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200782 0 \
783 -c "client hello, adding renegotiation extension" \
784 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
785 -s "found renegotiation extension" \
786 -s "server hello, secure renegotiation extension" \
787 -c "found renegotiation extension" \
788 -c "=> renegotiate" \
789 -s "=> renegotiate" \
790 -s "write hello request" \
791 -S "SSL - An unexpected message was received from our peer" \
792 -S "failed"
793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200794run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200795 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
796 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200797 0 \
798 -c "client hello, adding renegotiation extension" \
799 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
800 -s "found renegotiation extension" \
801 -s "server hello, secure renegotiation extension" \
802 -c "found renegotiation extension" \
803 -c "=> renegotiate" \
804 -s "=> renegotiate" \
805 -S "write hello request"
806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200807run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200808 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
809 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200810 0 \
811 -c "client hello, adding renegotiation extension" \
812 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
813 -s "found renegotiation extension" \
814 -s "server hello, secure renegotiation extension" \
815 -c "found renegotiation extension" \
816 -c "=> renegotiate" \
817 -s "=> renegotiate" \
818 -s "write hello request"
819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200820run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200821 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200822 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200823 0 \
824 -c "client hello, adding renegotiation extension" \
825 -c "found renegotiation extension" \
826 -c "=> renegotiate" \
827 -C "ssl_handshake returned" \
828 -C "error" \
829 -c "HTTP/1.0 200 [Oo][Kk]"
830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200831run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200832 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200833 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200834 0 \
835 -c "client hello, adding renegotiation extension" \
836 -c "found renegotiation extension" \
837 -c "=> renegotiate" \
838 -C "ssl_handshake returned" \
839 -C "error" \
840 -c "HTTP/1.0 200 [Oo][Kk]"
841
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100842# Tests for auth_mode
843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200844run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100845 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100846 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200847 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100848 1 \
849 -c "x509_verify_cert() returned" \
850 -c "! self-signed or not signed by a trusted CA" \
851 -c "! ssl_handshake returned" \
852 -c "X509 - Certificate verification failed"
853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200854run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100855 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100856 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200857 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100858 0 \
859 -c "x509_verify_cert() returned" \
860 -c "! self-signed or not signed by a trusted CA" \
861 -C "! ssl_handshake returned" \
862 -C "X509 - Certificate verification failed"
863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200864run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100865 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100866 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200867 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100868 0 \
869 -C "x509_verify_cert() returned" \
870 -C "! self-signed or not signed by a trusted CA" \
871 -C "! ssl_handshake returned" \
872 -C "X509 - Certificate verification failed"
873
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200874run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200875 "$P_SRV debug_level=3 auth_mode=required" \
876 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100877 key_file=data_files/server5.key" \
878 1 \
879 -S "skip write certificate request" \
880 -C "skip parse certificate request" \
881 -c "got a certificate request" \
882 -C "skip write certificate" \
883 -C "skip write certificate verify" \
884 -S "skip parse certificate verify" \
885 -s "x509_verify_cert() returned" \
886 -S "! self-signed or not signed by a trusted CA" \
887 -s "! ssl_handshake returned" \
888 -c "! ssl_handshake returned" \
889 -s "X509 - Certificate verification failed"
890
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200891run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200892 "$P_SRV debug_level=3 auth_mode=optional" \
893 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100894 key_file=data_files/server5.key" \
895 0 \
896 -S "skip write certificate request" \
897 -C "skip parse certificate request" \
898 -c "got a certificate request" \
899 -C "skip write certificate" \
900 -C "skip write certificate verify" \
901 -S "skip parse certificate verify" \
902 -s "x509_verify_cert() returned" \
903 -s "! self-signed or not signed by a trusted CA" \
904 -S "! ssl_handshake returned" \
905 -C "! ssl_handshake returned" \
906 -S "X509 - Certificate verification failed"
907
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200908run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200909 "$P_SRV debug_level=3 auth_mode=none" \
910 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100911 key_file=data_files/server5.key" \
912 0 \
913 -s "skip write certificate request" \
914 -C "skip parse certificate request" \
915 -c "got no certificate request" \
916 -c "skip write certificate" \
917 -c "skip write certificate verify" \
918 -s "skip parse certificate verify" \
919 -S "x509_verify_cert() returned" \
920 -S "! self-signed or not signed by a trusted CA" \
921 -S "! ssl_handshake returned" \
922 -C "! ssl_handshake returned" \
923 -S "X509 - Certificate verification failed"
924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200925run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200926 "$P_SRV debug_level=3 auth_mode=optional" \
927 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100928 0 \
929 -S "skip write certificate request" \
930 -C "skip parse certificate request" \
931 -c "got a certificate request" \
932 -C "skip write certificate$" \
933 -C "got no certificate to send" \
934 -S "SSLv3 client has no certificate" \
935 -c "skip write certificate verify" \
936 -s "skip parse certificate verify" \
937 -s "! no client certificate sent" \
938 -S "! ssl_handshake returned" \
939 -C "! ssl_handshake returned" \
940 -S "X509 - Certificate verification failed"
941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200942run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200943 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100944 "$O_CLI" \
945 0 \
946 -S "skip write certificate request" \
947 -s "skip parse certificate verify" \
948 -s "! no client certificate sent" \
949 -S "! ssl_handshake returned" \
950 -S "X509 - Certificate verification failed"
951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200952run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100953 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200954 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100955 0 \
956 -C "skip parse certificate request" \
957 -c "got a certificate request" \
958 -C "skip write certificate$" \
959 -c "skip write certificate verify" \
960 -C "! ssl_handshake returned"
961
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200962run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200963 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +0100964 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100965 0 \
966 -S "skip write certificate request" \
967 -C "skip parse certificate request" \
968 -c "got a certificate request" \
969 -C "skip write certificate$" \
970 -c "skip write certificate verify" \
971 -c "got no certificate to send" \
972 -s "SSLv3 client has no certificate" \
973 -s "skip parse certificate verify" \
974 -s "! no client certificate sent" \
975 -S "! ssl_handshake returned" \
976 -C "! ssl_handshake returned" \
977 -S "X509 - Certificate verification failed"
978
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100979# tests for SNI
980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200981run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200982 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100983 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100984 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100985 server_name=localhost" \
986 0 \
987 -S "parse ServerName extension" \
988 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
989 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200991run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200992 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100993 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100994 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 +0100995 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100996 server_name=localhost" \
997 0 \
998 -s "parse ServerName extension" \
999 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1000 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001002run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001003 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001004 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001005 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 +01001006 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001007 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001008 0 \
1009 -s "parse ServerName extension" \
1010 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001011 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001012
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001013run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001014 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001015 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001016 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 +01001017 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001018 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001019 1 \
1020 -s "parse ServerName extension" \
1021 -s "ssl_sni_wrapper() returned" \
1022 -s "ssl_handshake returned" \
1023 -c "ssl_handshake returned" \
1024 -c "SSL - A fatal alert message was received from our peer"
1025
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001026# Tests for non-blocking I/O: exercise a variety of handshake flows
1027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001028run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001029 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1030 "$P_CLI nbio=2 tickets=0" \
1031 0 \
1032 -S "ssl_handshake returned" \
1033 -C "ssl_handshake returned" \
1034 -c "Read from server: .* bytes read"
1035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001036run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001037 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1038 "$P_CLI nbio=2 tickets=0" \
1039 0 \
1040 -S "ssl_handshake returned" \
1041 -C "ssl_handshake returned" \
1042 -c "Read from server: .* bytes read"
1043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001044run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001045 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1046 "$P_CLI nbio=2 tickets=1" \
1047 0 \
1048 -S "ssl_handshake returned" \
1049 -C "ssl_handshake returned" \
1050 -c "Read from server: .* bytes read"
1051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001052run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001053 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1054 "$P_CLI nbio=2 tickets=1" \
1055 0 \
1056 -S "ssl_handshake returned" \
1057 -C "ssl_handshake returned" \
1058 -c "Read from server: .* bytes read"
1059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001060run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001061 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1062 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1063 0 \
1064 -S "ssl_handshake returned" \
1065 -C "ssl_handshake returned" \
1066 -c "Read from server: .* bytes read"
1067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001068run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001069 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1070 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1071 0 \
1072 -S "ssl_handshake returned" \
1073 -C "ssl_handshake returned" \
1074 -c "Read from server: .* bytes read"
1075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001076run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001077 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1078 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1079 0 \
1080 -S "ssl_handshake returned" \
1081 -C "ssl_handshake returned" \
1082 -c "Read from server: .* bytes read"
1083
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001084# Tests for version negotiation
1085
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001086run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001087 "$P_SRV" \
1088 "$P_CLI" \
1089 0 \
1090 -S "ssl_handshake returned" \
1091 -C "ssl_handshake returned" \
1092 -s "Protocol is TLSv1.2" \
1093 -c "Protocol is TLSv1.2"
1094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001095run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001096 "$P_SRV" \
1097 "$P_CLI max_version=tls1_1" \
1098 0 \
1099 -S "ssl_handshake returned" \
1100 -C "ssl_handshake returned" \
1101 -s "Protocol is TLSv1.1" \
1102 -c "Protocol is TLSv1.1"
1103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001104run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001105 "$P_SRV max_version=tls1_1" \
1106 "$P_CLI" \
1107 0 \
1108 -S "ssl_handshake returned" \
1109 -C "ssl_handshake returned" \
1110 -s "Protocol is TLSv1.1" \
1111 -c "Protocol is TLSv1.1"
1112
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001113run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001114 "$P_SRV max_version=tls1_1" \
1115 "$P_CLI max_version=tls1_1" \
1116 0 \
1117 -S "ssl_handshake returned" \
1118 -C "ssl_handshake returned" \
1119 -s "Protocol is TLSv1.1" \
1120 -c "Protocol is TLSv1.1"
1121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001122run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001123 "$P_SRV min_version=tls1_1" \
1124 "$P_CLI max_version=tls1_1" \
1125 0 \
1126 -S "ssl_handshake returned" \
1127 -C "ssl_handshake returned" \
1128 -s "Protocol is TLSv1.1" \
1129 -c "Protocol is TLSv1.1"
1130
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001131run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001132 "$P_SRV max_version=tls1_1" \
1133 "$P_CLI min_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: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001141 "$P_SRV max_version=tls1_1" \
1142 "$P_CLI min_version=tls1_2" \
1143 1 \
1144 -s "ssl_handshake returned" \
1145 -c "ssl_handshake returned" \
1146 -c "SSL - Handshake protocol not within min/max boundaries"
1147
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001148run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001149 "$P_SRV min_version=tls1_2" \
1150 "$P_CLI max_version=tls1_1" \
1151 1 \
1152 -s "ssl_handshake returned" \
1153 -c "ssl_handshake returned" \
1154 -s "SSL - Handshake protocol not within min/max boundaries"
1155
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001156# Tests for ALPN extension
1157
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001158if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1159
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001160run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001161 "$P_SRV debug_level=3" \
1162 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001163 0 \
1164 -C "client hello, adding alpn extension" \
1165 -S "found alpn extension" \
1166 -C "got an alert message, type: \\[2:120]" \
1167 -S "server hello, adding alpn extension" \
1168 -C "found alpn extension " \
1169 -C "Application Layer Protocol is" \
1170 -S "Application Layer Protocol is"
1171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001172run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001173 "$P_SRV debug_level=3" \
1174 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001175 0 \
1176 -c "client hello, adding alpn extension" \
1177 -s "found alpn extension" \
1178 -C "got an alert message, type: \\[2:120]" \
1179 -S "server hello, adding alpn extension" \
1180 -C "found alpn extension " \
1181 -c "Application Layer Protocol is (none)" \
1182 -S "Application Layer Protocol is"
1183
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001184run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001185 "$P_SRV debug_level=3 alpn=abc,1234" \
1186 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001187 0 \
1188 -C "client hello, adding alpn extension" \
1189 -S "found alpn extension" \
1190 -C "got an alert message, type: \\[2:120]" \
1191 -S "server hello, adding alpn extension" \
1192 -C "found alpn extension " \
1193 -C "Application Layer Protocol is" \
1194 -s "Application Layer Protocol is (none)"
1195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001196run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001197 "$P_SRV debug_level=3 alpn=abc,1234" \
1198 "$P_CLI debug_level=3 alpn=abc,1234" \
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 abc" \
1206 -s "Application Layer Protocol is abc"
1207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001208run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001209 "$P_SRV debug_level=3 alpn=abc,1234" \
1210 "$P_CLI debug_level=3 alpn=1234,abc" \
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 abc" \
1218 -s "Application Layer Protocol is abc"
1219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001220run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001221 "$P_SRV debug_level=3 alpn=abc,1234" \
1222 "$P_CLI debug_level=3 alpn=1234,abcde" \
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 1234" \
1230 -s "Application Layer Protocol is 1234"
1231
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001232run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001233 "$P_SRV debug_level=3 alpn=abc,123" \
1234 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001235 1 \
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 1234" \
1242 -S "Application Layer Protocol is 1234"
1243
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001244fi
1245
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001246# Tests for keyUsage in leaf certificates, part 1:
1247# server-side certificate/suite selection
1248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001249run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001250 "$P_SRV key_file=data_files/server2.key \
1251 crt_file=data_files/server2.ku-ds.crt" \
1252 "$P_CLI" \
1253 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001254 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001255
1256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001257run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001258 "$P_SRV key_file=data_files/server2.key \
1259 crt_file=data_files/server2.ku-ke.crt" \
1260 "$P_CLI" \
1261 0 \
1262 -c "Ciphersuite is TLS-RSA-WITH-"
1263
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001264run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001265 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001266 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001267 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001268 1 \
1269 -C "Ciphersuite is "
1270
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001271run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001272 "$P_SRV key_file=data_files/server5.key \
1273 crt_file=data_files/server5.ku-ds.crt" \
1274 "$P_CLI" \
1275 0 \
1276 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1277
1278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001279run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001280 "$P_SRV key_file=data_files/server5.key \
1281 crt_file=data_files/server5.ku-ka.crt" \
1282 "$P_CLI" \
1283 0 \
1284 -c "Ciphersuite is TLS-ECDH-"
1285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001286run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001287 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001288 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001289 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001290 1 \
1291 -C "Ciphersuite is "
1292
1293# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001294# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001296run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001297 "$O_SRV -key data_files/server2.key \
1298 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001299 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001300 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1301 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001302 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001303 -C "Processing of the Certificate handshake message failed" \
1304 -c "Ciphersuite is TLS-"
1305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001306run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001307 "$O_SRV -key data_files/server2.key \
1308 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001309 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001310 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1311 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001312 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001313 -C "Processing of the Certificate handshake message failed" \
1314 -c "Ciphersuite is TLS-"
1315
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001316run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001317 "$O_SRV -key data_files/server2.key \
1318 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001319 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001320 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1321 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001322 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001323 -C "Processing of the Certificate handshake message failed" \
1324 -c "Ciphersuite is TLS-"
1325
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001326run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001327 "$O_SRV -key data_files/server2.key \
1328 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001329 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001330 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1331 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001332 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001333 -c "Processing of the Certificate handshake message failed" \
1334 -C "Ciphersuite is TLS-"
1335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001336run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001337 "$O_SRV -key data_files/server2.key \
1338 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001339 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001340 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1341 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001342 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001343 -C "Processing of the Certificate handshake message failed" \
1344 -c "Ciphersuite is TLS-"
1345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001347 "$O_SRV -key data_files/server2.key \
1348 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001349 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001350 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1351 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001352 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001353 -c "Processing of the Certificate handshake message failed" \
1354 -C "Ciphersuite is TLS-"
1355
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001356# Tests for keyUsage in leaf certificates, part 3:
1357# server-side checking of client cert
1358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001359run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001360 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001361 "$O_CLI -key data_files/server2.key \
1362 -cert data_files/server2.ku-ds.crt" \
1363 0 \
1364 -S "bad certificate (usage extensions)" \
1365 -S "Processing of the Certificate handshake message failed"
1366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001367run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001368 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001369 "$O_CLI -key data_files/server2.key \
1370 -cert data_files/server2.ku-ke.crt" \
1371 0 \
1372 -s "bad certificate (usage extensions)" \
1373 -S "Processing of the Certificate handshake message failed"
1374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001375run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001376 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001377 "$O_CLI -key data_files/server2.key \
1378 -cert data_files/server2.ku-ke.crt" \
1379 1 \
1380 -s "bad certificate (usage extensions)" \
1381 -s "Processing of the Certificate handshake message failed"
1382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001383run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001384 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001385 "$O_CLI -key data_files/server5.key \
1386 -cert data_files/server5.ku-ds.crt" \
1387 0 \
1388 -S "bad certificate (usage extensions)" \
1389 -S "Processing of the Certificate handshake message failed"
1390
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001391run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001392 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001393 "$O_CLI -key data_files/server5.key \
1394 -cert data_files/server5.ku-ka.crt" \
1395 0 \
1396 -s "bad certificate (usage extensions)" \
1397 -S "Processing of the Certificate handshake message failed"
1398
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001399# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1400
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001401run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001402 "$P_SRV key_file=data_files/server5.key \
1403 crt_file=data_files/server5.eku-srv.crt" \
1404 "$P_CLI" \
1405 0
1406
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001407run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001408 "$P_SRV key_file=data_files/server5.key \
1409 crt_file=data_files/server5.eku-srv.crt" \
1410 "$P_CLI" \
1411 0
1412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001413run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001414 "$P_SRV key_file=data_files/server5.key \
1415 crt_file=data_files/server5.eku-cs_any.crt" \
1416 "$P_CLI" \
1417 0
1418
1419# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001420run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001421 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1422 crt_file=data_files/server5.eku-cli.crt" \
1423 "$P_CLI psk=badbad" \
1424 1
1425
1426# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1427
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001428run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001429 "$O_SRV -key data_files/server5.key \
1430 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001431 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001432 0 \
1433 -C "bad certificate (usage extensions)" \
1434 -C "Processing of the Certificate handshake message failed" \
1435 -c "Ciphersuite is TLS-"
1436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001437run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001438 "$O_SRV -key data_files/server5.key \
1439 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001440 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001441 0 \
1442 -C "bad certificate (usage extensions)" \
1443 -C "Processing of the Certificate handshake message failed" \
1444 -c "Ciphersuite is TLS-"
1445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001446run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001447 "$O_SRV -key data_files/server5.key \
1448 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001449 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001450 0 \
1451 -C "bad certificate (usage extensions)" \
1452 -C "Processing of the Certificate handshake message failed" \
1453 -c "Ciphersuite is TLS-"
1454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001455run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001456 "$O_SRV -key data_files/server5.key \
1457 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001458 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001459 1 \
1460 -c "bad certificate (usage extensions)" \
1461 -c "Processing of the Certificate handshake message failed" \
1462 -C "Ciphersuite is TLS-"
1463
1464# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001466run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001467 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001468 "$O_CLI -key data_files/server5.key \
1469 -cert data_files/server5.eku-cli.crt" \
1470 0 \
1471 -S "bad certificate (usage extensions)" \
1472 -S "Processing of the Certificate handshake message failed"
1473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001474run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001475 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001476 "$O_CLI -key data_files/server5.key \
1477 -cert data_files/server5.eku-srv_cli.crt" \
1478 0 \
1479 -S "bad certificate (usage extensions)" \
1480 -S "Processing of the Certificate handshake message failed"
1481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001482run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001483 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001484 "$O_CLI -key data_files/server5.key \
1485 -cert data_files/server5.eku-cs_any.crt" \
1486 0 \
1487 -S "bad certificate (usage extensions)" \
1488 -S "Processing of the Certificate handshake message failed"
1489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001490run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001491 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001492 "$O_CLI -key data_files/server5.key \
1493 -cert data_files/server5.eku-cs.crt" \
1494 0 \
1495 -s "bad certificate (usage extensions)" \
1496 -S "Processing of the Certificate handshake message failed"
1497
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001498run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001499 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001500 "$O_CLI -key data_files/server5.key \
1501 -cert data_files/server5.eku-cs.crt" \
1502 1 \
1503 -s "bad certificate (usage extensions)" \
1504 -s "Processing of the Certificate handshake message failed"
1505
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001506# Tests for DHM parameters loading
1507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001508run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001509 "$P_SRV" \
1510 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1511 debug_level=3" \
1512 0 \
1513 -c "value of 'DHM: P ' (2048 bits)" \
1514 -c "value of 'DHM: G ' (2048 bits)"
1515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001516run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001517 "$P_SRV dhm_file=data_files/dhparams.pem" \
1518 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1519 debug_level=3" \
1520 0 \
1521 -c "value of 'DHM: P ' (1024 bits)" \
1522 -c "value of 'DHM: G ' (2 bits)"
1523
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001524# Tests for PSK callback
1525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001526run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001527 "$P_SRV psk=abc123 psk_identity=foo" \
1528 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1529 psk_identity=foo psk=abc123" \
1530 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001531 -S "SSL - The server has no ciphersuites in common" \
1532 -S "SSL - Unknown identity received" \
1533 -S "SSL - Verification of the message MAC failed"
1534
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001535run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001536 "$P_SRV" \
1537 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1538 psk_identity=foo psk=abc123" \
1539 1 \
1540 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001541 -S "SSL - Unknown identity received" \
1542 -S "SSL - Verification of the message MAC failed"
1543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001544run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001545 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1546 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1547 psk_identity=foo psk=abc123" \
1548 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001549 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001550 -s "SSL - Unknown identity received" \
1551 -S "SSL - Verification of the message MAC failed"
1552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001553run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001554 "$P_SRV psk_list=abc,dead,def,beef" \
1555 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1556 psk_identity=abc psk=dead" \
1557 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001558 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001559 -S "SSL - Unknown identity received" \
1560 -S "SSL - Verification of the message MAC failed"
1561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001562run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001563 "$P_SRV psk_list=abc,dead,def,beef" \
1564 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1565 psk_identity=def psk=beef" \
1566 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001567 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001568 -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 match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001572 "$P_SRV psk_list=abc,dead,def,beef" \
1573 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1574 psk_identity=ghi psk=beef" \
1575 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001576 -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: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001581 "$P_SRV psk_list=abc,dead,def,beef" \
1582 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1583 psk_identity=abc psk=beef" \
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"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001588
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001589# Tests for ciphersuites per version
1590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001591run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001592 "$P_SRV min_version=ssl3 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" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001593 "$P_CLI force_version=ssl3" \
1594 0 \
1595 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001597run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001598 "$P_SRV arc4=1 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" \
1599 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001600 0 \
1601 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001603run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001604 "$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" \
1605 "$P_CLI force_version=tls1_1" \
1606 0 \
1607 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001609run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001610 "$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" \
1611 "$P_CLI force_version=tls1_2" \
1612 0 \
1613 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1614
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001615# Tests for ssl_get_bytes_avail()
1616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001617run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001618 "$P_SRV" \
1619 "$P_CLI request_size=100" \
1620 0 \
1621 -s "Read from client: 100 bytes read$"
1622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001623run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001624 "$P_SRV" \
1625 "$P_CLI request_size=500" \
1626 0 \
1627 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001628
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001629# Tests for small packets
1630
1631run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001632 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001633 "$P_CLI request_size=1 force_version=ssl3 \
1634 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1635 0 \
1636 -s "Read from client: 1 bytes read"
1637
1638run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001639 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001640 "$P_CLI request_size=1 force_version=ssl3 \
1641 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1642 0 \
1643 -s "Read from client: 1 bytes read"
1644
1645run_test "Small packet TLS 1.0 BlockCipher" \
1646 "$P_SRV" \
1647 "$P_CLI request_size=1 force_version=tls1 \
1648 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1649 0 \
1650 -s "Read from client: 1 bytes read"
1651
1652run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1653 "$P_SRV" \
1654 "$P_CLI request_size=1 force_version=tls1 \
1655 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1656 trunc_hmac=1" \
1657 0 \
1658 -s "Read from client: 1 bytes read"
1659
1660run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001661 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001662 "$P_CLI request_size=1 force_version=tls1 \
1663 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1664 trunc_hmac=1" \
1665 0 \
1666 -s "Read from client: 1 bytes read"
1667
1668run_test "Small packet TLS 1.1 BlockCipher" \
1669 "$P_SRV" \
1670 "$P_CLI request_size=1 force_version=tls1_1 \
1671 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1672 0 \
1673 -s "Read from client: 1 bytes read"
1674
1675run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001676 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001677 "$P_CLI request_size=1 force_version=tls1_1 \
1678 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1679 0 \
1680 -s "Read from client: 1 bytes read"
1681
1682run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1683 "$P_SRV" \
1684 "$P_CLI request_size=1 force_version=tls1_1 \
1685 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1686 trunc_hmac=1" \
1687 0 \
1688 -s "Read from client: 1 bytes read"
1689
1690run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001691 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001692 "$P_CLI request_size=1 force_version=tls1_1 \
1693 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1694 trunc_hmac=1" \
1695 0 \
1696 -s "Read from client: 1 bytes read"
1697
1698run_test "Small packet TLS 1.2 BlockCipher" \
1699 "$P_SRV" \
1700 "$P_CLI request_size=1 force_version=tls1_2 \
1701 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1702 0 \
1703 -s "Read from client: 1 bytes read"
1704
1705run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1706 "$P_SRV" \
1707 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1708 0 \
1709 -s "Read from client: 1 bytes read"
1710
1711run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1712 "$P_SRV" \
1713 "$P_CLI request_size=1 force_version=tls1_2 \
1714 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1715 trunc_hmac=1" \
1716 0 \
1717 -s "Read from client: 1 bytes read"
1718
1719run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001720 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001721 "$P_CLI request_size=1 force_version=tls1_2 \
1722 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1723 0 \
1724 -s "Read from client: 1 bytes read"
1725
1726run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001727 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001728 "$P_CLI request_size=1 force_version=tls1_2 \
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 AEAD" \
1735 "$P_SRV" \
1736 "$P_CLI request_size=1 force_version=tls1_2 \
1737 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1738 0 \
1739 -s "Read from client: 1 bytes read"
1740
1741run_test "Small packet TLS 1.2 AEAD shorter tag" \
1742 "$P_SRV" \
1743 "$P_CLI request_size=1 force_version=tls1_2 \
1744 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1745 0 \
1746 -s "Read from client: 1 bytes read"
1747
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001748# Test for large packets
1749
1750run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001751 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001752 "$P_CLI request_size=16384 force_version=ssl3 \
1753 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1754 0 \
1755 -s "Read from client: 16384 bytes read"
1756
1757run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001758 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001759 "$P_CLI request_size=16384 force_version=ssl3 \
1760 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1761 0 \
1762 -s "Read from client: 16384 bytes read"
1763
1764run_test "Large packet TLS 1.0 BlockCipher" \
1765 "$P_SRV" \
1766 "$P_CLI request_size=16384 force_version=tls1 \
1767 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1768 0 \
1769 -s "Read from client: 16384 bytes read"
1770
1771run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1772 "$P_SRV" \
1773 "$P_CLI request_size=16384 force_version=tls1 \
1774 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1775 trunc_hmac=1" \
1776 0 \
1777 -s "Read from client: 16384 bytes read"
1778
1779run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001780 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001781 "$P_CLI request_size=16384 force_version=tls1 \
1782 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1783 trunc_hmac=1" \
1784 0 \
1785 -s "Read from client: 16384 bytes read"
1786
1787run_test "Large packet TLS 1.1 BlockCipher" \
1788 "$P_SRV" \
1789 "$P_CLI request_size=16384 force_version=tls1_1 \
1790 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1791 0 \
1792 -s "Read from client: 16384 bytes read"
1793
1794run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001795 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001796 "$P_CLI request_size=16384 force_version=tls1_1 \
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.1 BlockCipher truncated MAC" \
1802 "$P_SRV" \
1803 "$P_CLI request_size=16384 force_version=tls1_1 \
1804 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1805 trunc_hmac=1" \
1806 0 \
1807 -s "Read from client: 16384 bytes read"
1808
1809run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001810 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001811 "$P_CLI request_size=16384 force_version=tls1_1 \
1812 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1813 trunc_hmac=1" \
1814 0 \
1815 -s "Read from client: 16384 bytes read"
1816
1817run_test "Large packet TLS 1.2 BlockCipher" \
1818 "$P_SRV" \
1819 "$P_CLI request_size=16384 force_version=tls1_2 \
1820 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1821 0 \
1822 -s "Read from client: 16384 bytes read"
1823
1824run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1825 "$P_SRV" \
1826 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1827 0 \
1828 -s "Read from client: 16384 bytes read"
1829
1830run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1831 "$P_SRV" \
1832 "$P_CLI request_size=16384 force_version=tls1_2 \
1833 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1834 trunc_hmac=1" \
1835 0 \
1836 -s "Read from client: 16384 bytes read"
1837
1838run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001839 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001840 "$P_CLI request_size=16384 force_version=tls1_2 \
1841 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1842 0 \
1843 -s "Read from client: 16384 bytes read"
1844
1845run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001846 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001847 "$P_CLI request_size=16384 force_version=tls1_2 \
1848 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1849 trunc_hmac=1" \
1850 0 \
1851 -s "Read from client: 16384 bytes read"
1852
1853run_test "Large packet TLS 1.2 AEAD" \
1854 "$P_SRV" \
1855 "$P_CLI request_size=16384 force_version=tls1_2 \
1856 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1857 0 \
1858 -s "Read from client: 16384 bytes read"
1859
1860run_test "Large packet TLS 1.2 AEAD shorter tag" \
1861 "$P_SRV" \
1862 "$P_CLI request_size=16384 force_version=tls1_2 \
1863 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1864 0 \
1865 -s "Read from client: 16384 bytes read"
1866
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001867# Final report
1868
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001869echo "------------------------------------------------------------------------"
1870
1871if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01001872 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001873else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01001874 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001875fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02001876PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001877echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001878
1879exit $FAILS