blob: a37ea93832af938290f1727962aa7c062e2de614 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
21O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
23G_CLI="$GNUTLS_CLI"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010037 printf " -h|--help\tPrint this help.\n"
38 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
39 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
40 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
78 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020083# skip next test if GnuTLS isn't available
84requires_gnutls() {
85 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
86 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
87 GNUTLS_AVAILABLE="YES"
88 else
89 GNUTLS_AVAILABLE="NO"
90 fi
91 fi
92 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
93 SKIP_NEXT="YES"
94 fi
95}
96
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010097# print_name <name>
98print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010099 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200100 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100101 for i in `seq 1 $LEN`; do printf '.'; done
102 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100103
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200104 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100105}
106
107# fail <message>
108fail() {
109 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100110 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100111
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200112 mv $SRV_OUT o-srv-${TESTS}.log
113 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100114 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100115
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200116 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
117 echo " ! server output:"
118 cat o-srv-${TESTS}.log
119 echo " ! ============================================================"
120 echo " ! client output:"
121 cat o-cli-${TESTS}.log
122 fi
123
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200124 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100125}
126
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100127# is_polar <cmd_line>
128is_polar() {
129 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
130}
131
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100132# has_mem_err <log_file_name>
133has_mem_err() {
134 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
135 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
136 then
137 return 1 # false: does not have errors
138 else
139 return 0 # true: has errors
140 fi
141}
142
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200143# wait for server to start: two versions depending on lsof availability
144wait_server_start() {
145 if which lsof >/dev/null; then
146 # make sure we don't loop forever
147 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
148 WATCHDOG_PID=$!
149
150 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100151 until lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null;
152 do :; done
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200153
154 kill $WATCHDOG_PID
155 wait $WATCHDOG_PID
156 else
157 sleep "$START_DELAY"
158 fi
159}
160
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200161# wait for client to terminate and set CLI_EXIT
162# must be called right after starting the client
163wait_client_done() {
164 CLI_PID=$!
165
166 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
167 WATCHDOG_PID=$!
168
169 wait $CLI_PID
170 CLI_EXIT=$?
171
172 kill $WATCHDOG_PID
173 wait $WATCHDOG_PID
174
175 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
176}
177
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100178# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100179# Options: -s pattern pattern that must be present in server output
180# -c pattern pattern that must be present in client output
181# -S pattern pattern that must be absent in server output
182# -C pattern pattern that must be absent in client output
183run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100184 NAME="$1"
185 SRV_CMD="$2"
186 CLI_CMD="$3"
187 CLI_EXPECT="$4"
188 shift 4
189
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100190 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
191 else
192 return
193 fi
194
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100195 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100196
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200197 # should we skip?
198 if [ "X$SKIP_NEXT" = "XYES" ]; then
199 SKIP_NEXT="NO"
200 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200201 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200202 return
203 fi
204
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100205 # prepend valgrind to our commands if active
206 if [ "$MEMCHECK" -gt 0 ]; then
207 if is_polar "$SRV_CMD"; then
208 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
209 fi
210 if is_polar "$CLI_CMD"; then
211 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
212 fi
213 fi
214
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100215 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200216 echo "$SRV_CMD" > $SRV_OUT
217 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100218 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200219 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200220
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200221 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200222 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
223 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100224
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200225 # kill the server
226 kill $SRV_PID
227 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100228
229 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200230 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100231 # expected client exit to incorrectly succeed in case of catastrophic
232 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100233 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200234 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100235 else
236 fail "server failed to start"
237 return
238 fi
239 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100240 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200241 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100242 else
243 fail "client failed to start"
244 return
245 fi
246 fi
247
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100248 # check server exit code
249 if [ $? != 0 ]; then
250 fail "server fail"
251 return
252 fi
253
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100254 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100255 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
256 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100257 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100258 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100259 return
260 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100261
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100262 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200263 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100264 while [ $# -gt 0 ]
265 do
266 case $1 in
267 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200268 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100269 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100270 return
271 fi
272 ;;
273
274 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200275 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100276 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100277 return
278 fi
279 ;;
280
281 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200282 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100283 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100284 return
285 fi
286 ;;
287
288 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200289 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100290 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100291 return
292 fi
293 ;;
294
295 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200296 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100297 exit 1
298 esac
299 shift 2
300 done
301
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100302 # check valgrind's results
303 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200304 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100305 fail "Server has memory errors"
306 return
307 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200308 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100309 fail "Client has memory errors"
310 return
311 fi
312 fi
313
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100314 # if we're here, everything is ok
315 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200316 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100317}
318
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100319cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200320 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200321 kill $SRV_PID >/dev/null 2>&1
322 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100323 exit 1
324}
325
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100326#
327# MAIN
328#
329
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100330get_options "$@"
331
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100332# sanity checks, avoid an avalanche of errors
333if [ ! -x "$P_SRV" ]; then
334 echo "Command '$P_SRV' is not an executable file"
335 exit 1
336fi
337if [ ! -x "$P_CLI" ]; then
338 echo "Command '$P_CLI' is not an executable file"
339 exit 1
340fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100341if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
342 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100343 exit 1
344fi
345
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200346# used by watchdog
347MAIN_PID="$$"
348
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200349# be more patient with valgrind
350if [ "$MEMCHECK" -gt 0 ]; then
351 START_DELAY=3
352 DOG_DELAY=30
353else
354 START_DELAY=1
355 DOG_DELAY=10
356fi
357
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200358# Pick a "unique" port in the range 10000-19999.
359PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200360PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200361
362# fix commands to use this port
363P_SRV="$P_SRV server_port=$PORT"
364P_CLI="$P_CLI server_port=$PORT"
365O_SRV="$O_SRV -accept $PORT"
366O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200367G_SRV="$G_SRV -p $PORT"
368G_CLI="$G_CLI -p $PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200369
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200370# Also pick a unique name for intermediate files
371SRV_OUT="srv_out.$$"
372CLI_OUT="cli_out.$$"
373SESSION="session.$$"
374
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200375SKIP_NEXT="NO"
376
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100377trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100378
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200379# Basic test
380
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200381# Checks that:
382# - things work with all ciphersuites active (used with config-full in all.sh)
383# - the expected (highest security) parameters are selected
384# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200385run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200386 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200387 "$P_CLI" \
388 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200389 -s "Protocol is TLSv1.2" \
390 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
391 -s "client hello v3, signature_algorithm ext: 6" \
392 -s "ECDHE curve: secp521r1" \
393 -S "error" \
394 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200395
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100396# Test for SSLv2 ClientHello
397
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200398requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200399run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100400 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100401 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100402 0 \
403 -S "parse client hello v2" \
404 -S "ssl_handshake returned"
405
406# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200407requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200408run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200409 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100410 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100411 0 \
412 -s "parse client hello v2" \
413 -S "ssl_handshake returned"
414
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100415# Tests for Truncated HMAC extension
416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200417run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200418 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100419 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100420 0 \
421 -s "dumping 'computed mac' (20 bytes)"
422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200423run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200424 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100425 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100427 -s "dumping 'computed mac' (10 bytes)"
428
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100429# Tests for Session Tickets
430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200431run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200432 "$P_SRV debug_level=3 tickets=1" \
433 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100434 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100435 -c "client hello, adding session ticket extension" \
436 -s "found session ticket extension" \
437 -s "server hello, adding session ticket extension" \
438 -c "found session_ticket extension" \
439 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100440 -S "session successfully restored from cache" \
441 -s "session successfully restored from ticket" \
442 -s "a session has been resumed" \
443 -c "a session has been resumed"
444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200445run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200446 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
447 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100448 0 \
449 -c "client hello, adding session ticket extension" \
450 -s "found session ticket extension" \
451 -s "server hello, adding session ticket extension" \
452 -c "found session_ticket extension" \
453 -c "parse new session ticket" \
454 -S "session successfully restored from cache" \
455 -s "session successfully restored from ticket" \
456 -s "a session has been resumed" \
457 -c "a session has been resumed"
458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200459run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200460 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
461 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100462 0 \
463 -c "client hello, adding session ticket extension" \
464 -s "found session ticket extension" \
465 -s "server hello, adding session ticket extension" \
466 -c "found session_ticket extension" \
467 -c "parse new session ticket" \
468 -S "session successfully restored from cache" \
469 -S "session successfully restored from ticket" \
470 -S "a session has been resumed" \
471 -C "a session has been resumed"
472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200473run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100474 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200475 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100476 0 \
477 -c "client hello, adding session ticket extension" \
478 -c "found session_ticket extension" \
479 -c "parse new session ticket" \
480 -c "a session has been resumed"
481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200482run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200483 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200484 "( $O_CLI -sess_out $SESSION; \
485 $O_CLI -sess_in $SESSION; \
486 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100487 0 \
488 -s "found session ticket extension" \
489 -s "server hello, adding session ticket extension" \
490 -S "session successfully restored from cache" \
491 -s "session successfully restored from ticket" \
492 -s "a session has been resumed"
493
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100494# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200496run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200497 "$P_SRV debug_level=3 tickets=0" \
498 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100499 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100500 -c "client hello, adding session ticket extension" \
501 -s "found session ticket extension" \
502 -S "server hello, adding session ticket extension" \
503 -C "found session_ticket extension" \
504 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100505 -s "session successfully restored from cache" \
506 -S "session successfully restored from ticket" \
507 -s "a session has been resumed" \
508 -c "a session has been resumed"
509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200510run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200511 "$P_SRV debug_level=3 tickets=1" \
512 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100513 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100514 -C "client hello, adding session ticket extension" \
515 -S "found session ticket extension" \
516 -S "server hello, adding session ticket extension" \
517 -C "found session_ticket extension" \
518 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100519 -s "session successfully restored from cache" \
520 -S "session successfully restored from ticket" \
521 -s "a session has been resumed" \
522 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200524run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200525 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
526 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100527 0 \
528 -S "session successfully restored from cache" \
529 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100530 -S "a session has been resumed" \
531 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200533run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200534 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
535 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100536 0 \
537 -s "session successfully restored from cache" \
538 -S "session successfully restored from ticket" \
539 -s "a session has been resumed" \
540 -c "a session has been resumed"
541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200542run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200543 "$P_SRV debug_level=3 tickets=0" \
544 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100545 0 \
546 -s "session successfully restored from cache" \
547 -S "session successfully restored from ticket" \
548 -s "a session has been resumed" \
549 -c "a session has been resumed"
550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200551run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200552 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
553 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100554 0 \
555 -S "session successfully restored from cache" \
556 -S "session successfully restored from ticket" \
557 -S "a session has been resumed" \
558 -C "a session has been resumed"
559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200560run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200561 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
562 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100563 0 \
564 -s "session successfully restored from cache" \
565 -S "session successfully restored from ticket" \
566 -s "a session has been resumed" \
567 -c "a session has been resumed"
568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200569run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200570 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200571 "( $O_CLI -sess_out $SESSION; \
572 $O_CLI -sess_in $SESSION; \
573 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100574 0 \
575 -s "found session ticket extension" \
576 -S "server hello, adding session ticket extension" \
577 -s "session successfully restored from cache" \
578 -S "session successfully restored from ticket" \
579 -s "a session has been resumed"
580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200581run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100582 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200583 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100584 0 \
585 -C "found session_ticket extension" \
586 -C "parse new session ticket" \
587 -c "a session has been resumed"
588
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100589# Tests for Max Fragment Length extension
590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200591run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200592 "$P_SRV debug_level=3" \
593 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100594 0 \
595 -C "client hello, adding max_fragment_length extension" \
596 -S "found max fragment length extension" \
597 -S "server hello, max_fragment_length extension" \
598 -C "found max_fragment_length extension"
599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200600run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200601 "$P_SRV debug_level=3" \
602 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100603 0 \
604 -c "client hello, adding max_fragment_length extension" \
605 -s "found max fragment length extension" \
606 -s "server hello, max_fragment_length extension" \
607 -c "found max_fragment_length extension"
608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200609run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200610 "$P_SRV debug_level=3 max_frag_len=4096" \
611 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100612 0 \
613 -C "client hello, adding max_fragment_length extension" \
614 -S "found max fragment length extension" \
615 -S "server hello, max_fragment_length extension" \
616 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100617
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200618requires_gnutls
619run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200620 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200621 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200622 0 \
623 -c "client hello, adding max_fragment_length extension" \
624 -c "found max_fragment_length extension"
625
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100626# Tests for renegotiation
627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200628run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200629 "$P_SRV debug_level=3 exchanges=2" \
630 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100631 0 \
632 -C "client hello, adding renegotiation extension" \
633 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
634 -S "found renegotiation extension" \
635 -s "server hello, secure renegotiation extension" \
636 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100637 -C "=> renegotiate" \
638 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100639 -S "write hello request"
640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200641run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200642 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
643 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100644 0 \
645 -c "client hello, adding renegotiation extension" \
646 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
647 -s "found renegotiation extension" \
648 -s "server hello, secure renegotiation extension" \
649 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100650 -c "=> renegotiate" \
651 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100652 -S "write hello request"
653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200654run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200655 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
656 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100657 0 \
658 -c "client hello, adding renegotiation extension" \
659 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
660 -s "found renegotiation extension" \
661 -s "server hello, secure renegotiation extension" \
662 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100663 -c "=> renegotiate" \
664 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100665 -s "write hello request"
666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200667run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200668 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
669 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100670 0 \
671 -c "client hello, adding renegotiation extension" \
672 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
673 -s "found renegotiation extension" \
674 -s "server hello, secure renegotiation extension" \
675 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100676 -c "=> renegotiate" \
677 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100678 -s "write hello request"
679
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200680run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200681 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
682 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100683 1 \
684 -c "client hello, adding renegotiation extension" \
685 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
686 -S "found renegotiation extension" \
687 -s "server hello, secure renegotiation extension" \
688 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100689 -c "=> renegotiate" \
690 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200691 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200692 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200693 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200695run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200696 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
697 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100698 0 \
699 -C "client hello, adding renegotiation extension" \
700 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
701 -S "found renegotiation extension" \
702 -s "server hello, secure renegotiation extension" \
703 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100704 -C "=> renegotiate" \
705 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100706 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200707 -S "SSL - An unexpected message was received from our peer" \
708 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100709
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200710run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200711 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200712 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200713 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200714 0 \
715 -C "client hello, adding renegotiation extension" \
716 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
717 -S "found renegotiation extension" \
718 -s "server hello, secure renegotiation extension" \
719 -c "found renegotiation extension" \
720 -C "=> renegotiate" \
721 -S "=> renegotiate" \
722 -s "write hello request" \
723 -S "SSL - An unexpected message was received from our peer" \
724 -S "failed"
725
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200726# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200727run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200728 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200729 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200730 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200731 0 \
732 -C "client hello, adding renegotiation extension" \
733 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
734 -S "found renegotiation extension" \
735 -s "server hello, secure renegotiation extension" \
736 -c "found renegotiation extension" \
737 -C "=> renegotiate" \
738 -S "=> renegotiate" \
739 -s "write hello request" \
740 -S "SSL - An unexpected message was received from our peer" \
741 -S "failed"
742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200743run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200744 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200745 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200746 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200747 0 \
748 -C "client hello, adding renegotiation extension" \
749 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
750 -S "found renegotiation extension" \
751 -s "server hello, secure renegotiation extension" \
752 -c "found renegotiation extension" \
753 -C "=> renegotiate" \
754 -S "=> renegotiate" \
755 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200756 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200757
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200758run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200759 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200760 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200761 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200762 0 \
763 -c "client hello, adding renegotiation extension" \
764 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
765 -s "found renegotiation extension" \
766 -s "server hello, secure renegotiation extension" \
767 -c "found renegotiation extension" \
768 -c "=> renegotiate" \
769 -s "=> renegotiate" \
770 -s "write hello request" \
771 -S "SSL - An unexpected message was received from our peer" \
772 -S "failed"
773
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200774run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200775 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
776 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200777 0 \
778 -c "client hello, adding renegotiation extension" \
779 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
780 -s "found renegotiation extension" \
781 -s "server hello, secure renegotiation extension" \
782 -c "found renegotiation extension" \
783 -c "=> renegotiate" \
784 -s "=> renegotiate" \
785 -S "write hello request"
786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200787run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200788 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
789 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200790 0 \
791 -c "client hello, adding renegotiation extension" \
792 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
793 -s "found renegotiation extension" \
794 -s "server hello, secure renegotiation extension" \
795 -c "found renegotiation extension" \
796 -c "=> renegotiate" \
797 -s "=> renegotiate" \
798 -s "write hello request"
799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200800run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200801 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200802 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200803 0 \
804 -c "client hello, adding renegotiation extension" \
805 -c "found renegotiation extension" \
806 -c "=> renegotiate" \
807 -C "ssl_handshake returned" \
808 -C "error" \
809 -c "HTTP/1.0 200 [Oo][Kk]"
810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200811run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200812 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200813 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200814 0 \
815 -c "client hello, adding renegotiation extension" \
816 -c "found renegotiation extension" \
817 -c "=> renegotiate" \
818 -C "ssl_handshake returned" \
819 -C "error" \
820 -c "HTTP/1.0 200 [Oo][Kk]"
821
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100822# Tests for auth_mode
823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200824run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100825 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100826 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200827 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100828 1 \
829 -c "x509_verify_cert() returned" \
830 -c "! self-signed or not signed by a trusted CA" \
831 -c "! ssl_handshake returned" \
832 -c "X509 - Certificate verification failed"
833
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200834run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100835 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100836 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200837 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100838 0 \
839 -c "x509_verify_cert() returned" \
840 -c "! self-signed or not signed by a trusted CA" \
841 -C "! ssl_handshake returned" \
842 -C "X509 - Certificate verification failed"
843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200844run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100845 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100846 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200847 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100848 0 \
849 -C "x509_verify_cert() returned" \
850 -C "! self-signed or not signed by a trusted CA" \
851 -C "! ssl_handshake returned" \
852 -C "X509 - Certificate verification failed"
853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200854run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200855 "$P_SRV debug_level=3 auth_mode=required" \
856 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100857 key_file=data_files/server5.key" \
858 1 \
859 -S "skip write certificate request" \
860 -C "skip parse certificate request" \
861 -c "got a certificate request" \
862 -C "skip write certificate" \
863 -C "skip write certificate verify" \
864 -S "skip parse certificate verify" \
865 -s "x509_verify_cert() returned" \
866 -S "! self-signed or not signed by a trusted CA" \
867 -s "! ssl_handshake returned" \
868 -c "! ssl_handshake returned" \
869 -s "X509 - Certificate verification failed"
870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200871run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200872 "$P_SRV debug_level=3 auth_mode=optional" \
873 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100874 key_file=data_files/server5.key" \
875 0 \
876 -S "skip write certificate request" \
877 -C "skip parse certificate request" \
878 -c "got a certificate request" \
879 -C "skip write certificate" \
880 -C "skip write certificate verify" \
881 -S "skip parse certificate verify" \
882 -s "x509_verify_cert() returned" \
883 -s "! self-signed or not signed by a trusted CA" \
884 -S "! ssl_handshake returned" \
885 -C "! ssl_handshake returned" \
886 -S "X509 - Certificate verification failed"
887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200888run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200889 "$P_SRV debug_level=3 auth_mode=none" \
890 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100891 key_file=data_files/server5.key" \
892 0 \
893 -s "skip write certificate request" \
894 -C "skip parse certificate request" \
895 -c "got no certificate request" \
896 -c "skip write certificate" \
897 -c "skip write certificate verify" \
898 -s "skip parse certificate verify" \
899 -S "x509_verify_cert() returned" \
900 -S "! self-signed or not signed by a trusted CA" \
901 -S "! ssl_handshake returned" \
902 -C "! ssl_handshake returned" \
903 -S "X509 - Certificate verification failed"
904
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200905run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200906 "$P_SRV debug_level=3 auth_mode=optional" \
907 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100908 0 \
909 -S "skip write certificate request" \
910 -C "skip parse certificate request" \
911 -c "got a certificate request" \
912 -C "skip write certificate$" \
913 -C "got no certificate to send" \
914 -S "SSLv3 client has no certificate" \
915 -c "skip write certificate verify" \
916 -s "skip parse certificate verify" \
917 -s "! no client certificate sent" \
918 -S "! ssl_handshake returned" \
919 -C "! ssl_handshake returned" \
920 -S "X509 - Certificate verification failed"
921
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200922run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200923 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100924 "$O_CLI" \
925 0 \
926 -S "skip write certificate request" \
927 -s "skip parse certificate verify" \
928 -s "! no client certificate sent" \
929 -S "! ssl_handshake returned" \
930 -S "X509 - Certificate verification failed"
931
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200932run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100933 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200934 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100935 0 \
936 -C "skip parse certificate request" \
937 -c "got a certificate request" \
938 -C "skip write certificate$" \
939 -c "skip write certificate verify" \
940 -C "! ssl_handshake returned"
941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200942run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200943 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
944 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100945 0 \
946 -S "skip write certificate request" \
947 -C "skip parse certificate request" \
948 -c "got a certificate request" \
949 -C "skip write certificate$" \
950 -c "skip write certificate verify" \
951 -c "got no certificate to send" \
952 -s "SSLv3 client has no certificate" \
953 -s "skip parse certificate verify" \
954 -s "! no client certificate sent" \
955 -S "! ssl_handshake returned" \
956 -C "! ssl_handshake returned" \
957 -S "X509 - Certificate verification failed"
958
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +0100959# Tests for certificate selection based on SHA verson
960
961run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
962 "$P_SRV crt_file=data_files/server5.crt \
963 key_file=data_files/server5.key \
964 crt_file2=data_files/server5-sha1.crt \
965 key_file2=data_files/server5.key" \
966 "$P_CLI force_version=tls1_2" \
967 0 \
968 -c "signed using.*ECDSA with SHA256" \
969 -C "signed using.*ECDSA with SHA1"
970
971run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
972 "$P_SRV crt_file=data_files/server5.crt \
973 key_file=data_files/server5.key \
974 crt_file2=data_files/server5-sha1.crt \
975 key_file2=data_files/server5.key" \
976 "$P_CLI force_version=tls1_1" \
977 0 \
978 -C "signed using.*ECDSA with SHA256" \
979 -c "signed using.*ECDSA with SHA1"
980
981run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
982 "$P_SRV crt_file=data_files/server5.crt \
983 key_file=data_files/server5.key \
984 crt_file2=data_files/server5-sha1.crt \
985 key_file2=data_files/server5.key" \
986 "$P_CLI force_version=tls1" \
987 0 \
988 -C "signed using.*ECDSA with SHA256" \
989 -c "signed using.*ECDSA with SHA1"
990
991run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
992 "$P_SRV crt_file=data_files/server5.crt \
993 key_file=data_files/server5.key \
994 crt_file2=data_files/server6.crt \
995 key_file2=data_files/server6.key" \
996 "$P_CLI force_version=tls1_1" \
997 0 \
998 -c "serial number.*09" \
999 -c "signed using.*ECDSA with SHA256" \
1000 -C "signed using.*ECDSA with SHA1"
1001
1002run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1003 "$P_SRV crt_file=data_files/server6.crt \
1004 key_file=data_files/server6.key \
1005 crt_file2=data_files/server5.crt \
1006 key_file2=data_files/server5.key" \
1007 "$P_CLI force_version=tls1_1" \
1008 0 \
1009 -c "serial number.*0A" \
1010 -c "signed using.*ECDSA with SHA256" \
1011 -C "signed using.*ECDSA with SHA1"
1012
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001013# tests for SNI
1014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001015run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001016 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001017 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001018 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001019 server_name=localhost" \
1020 0 \
1021 -S "parse ServerName extension" \
1022 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1023 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1024
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001025run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001026 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001027 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001028 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 +01001029 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001030 server_name=localhost" \
1031 0 \
1032 -s "parse ServerName extension" \
1033 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1034 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001036run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001037 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001038 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001039 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 +01001040 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001041 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001042 0 \
1043 -s "parse ServerName extension" \
1044 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001045 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001047run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001048 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001049 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001050 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 +01001051 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001052 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001053 1 \
1054 -s "parse ServerName extension" \
1055 -s "ssl_sni_wrapper() returned" \
1056 -s "ssl_handshake returned" \
1057 -c "ssl_handshake returned" \
1058 -c "SSL - A fatal alert message was received from our peer"
1059
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001060# Tests for non-blocking I/O: exercise a variety of handshake flows
1061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001062run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001063 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1064 "$P_CLI nbio=2 tickets=0" \
1065 0 \
1066 -S "ssl_handshake returned" \
1067 -C "ssl_handshake returned" \
1068 -c "Read from server: .* bytes read"
1069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001070run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001071 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1072 "$P_CLI nbio=2 tickets=0" \
1073 0 \
1074 -S "ssl_handshake returned" \
1075 -C "ssl_handshake returned" \
1076 -c "Read from server: .* bytes read"
1077
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001078run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001079 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1080 "$P_CLI nbio=2 tickets=1" \
1081 0 \
1082 -S "ssl_handshake returned" \
1083 -C "ssl_handshake returned" \
1084 -c "Read from server: .* bytes read"
1085
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001086run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001087 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1088 "$P_CLI nbio=2 tickets=1" \
1089 0 \
1090 -S "ssl_handshake returned" \
1091 -C "ssl_handshake returned" \
1092 -c "Read from server: .* bytes read"
1093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001094run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001095 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1096 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1097 0 \
1098 -S "ssl_handshake returned" \
1099 -C "ssl_handshake returned" \
1100 -c "Read from server: .* bytes read"
1101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001102run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001103 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1104 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1105 0 \
1106 -S "ssl_handshake returned" \
1107 -C "ssl_handshake returned" \
1108 -c "Read from server: .* bytes read"
1109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001110run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001111 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1112 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1113 0 \
1114 -S "ssl_handshake returned" \
1115 -C "ssl_handshake returned" \
1116 -c "Read from server: .* bytes read"
1117
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001118# Tests for version negotiation
1119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001120run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001121 "$P_SRV" \
1122 "$P_CLI" \
1123 0 \
1124 -S "ssl_handshake returned" \
1125 -C "ssl_handshake returned" \
1126 -s "Protocol is TLSv1.2" \
1127 -c "Protocol is TLSv1.2"
1128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001129run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001130 "$P_SRV" \
1131 "$P_CLI max_version=tls1_1" \
1132 0 \
1133 -S "ssl_handshake returned" \
1134 -C "ssl_handshake returned" \
1135 -s "Protocol is TLSv1.1" \
1136 -c "Protocol is TLSv1.1"
1137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001138run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001139 "$P_SRV max_version=tls1_1" \
1140 "$P_CLI" \
1141 0 \
1142 -S "ssl_handshake returned" \
1143 -C "ssl_handshake returned" \
1144 -s "Protocol is TLSv1.1" \
1145 -c "Protocol is TLSv1.1"
1146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001147run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001148 "$P_SRV max_version=tls1_1" \
1149 "$P_CLI max_version=tls1_1" \
1150 0 \
1151 -S "ssl_handshake returned" \
1152 -C "ssl_handshake returned" \
1153 -s "Protocol is TLSv1.1" \
1154 -c "Protocol is TLSv1.1"
1155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001156run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001157 "$P_SRV min_version=tls1_1" \
1158 "$P_CLI max_version=tls1_1" \
1159 0 \
1160 -S "ssl_handshake returned" \
1161 -C "ssl_handshake returned" \
1162 -s "Protocol is TLSv1.1" \
1163 -c "Protocol is TLSv1.1"
1164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001165run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001166 "$P_SRV max_version=tls1_1" \
1167 "$P_CLI min_version=tls1_1" \
1168 0 \
1169 -S "ssl_handshake returned" \
1170 -C "ssl_handshake returned" \
1171 -s "Protocol is TLSv1.1" \
1172 -c "Protocol is TLSv1.1"
1173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001174run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001175 "$P_SRV max_version=tls1_1" \
1176 "$P_CLI min_version=tls1_2" \
1177 1 \
1178 -s "ssl_handshake returned" \
1179 -c "ssl_handshake returned" \
1180 -c "SSL - Handshake protocol not within min/max boundaries"
1181
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001182run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001183 "$P_SRV min_version=tls1_2" \
1184 "$P_CLI max_version=tls1_1" \
1185 1 \
1186 -s "ssl_handshake returned" \
1187 -c "ssl_handshake returned" \
1188 -s "SSL - Handshake protocol not within min/max boundaries"
1189
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001190# Tests for ALPN extension
1191
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001192if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1193
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001194run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001195 "$P_SRV debug_level=3" \
1196 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001197 0 \
1198 -C "client hello, adding alpn extension" \
1199 -S "found alpn extension" \
1200 -C "got an alert message, type: \\[2:120]" \
1201 -S "server hello, adding alpn extension" \
1202 -C "found alpn extension " \
1203 -C "Application Layer Protocol is" \
1204 -S "Application Layer Protocol is"
1205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001206run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001207 "$P_SRV debug_level=3" \
1208 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001209 0 \
1210 -c "client hello, adding alpn extension" \
1211 -s "found alpn extension" \
1212 -C "got an alert message, type: \\[2:120]" \
1213 -S "server hello, adding alpn extension" \
1214 -C "found alpn extension " \
1215 -c "Application Layer Protocol is (none)" \
1216 -S "Application Layer Protocol is"
1217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001218run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001219 "$P_SRV debug_level=3 alpn=abc,1234" \
1220 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001221 0 \
1222 -C "client hello, adding alpn extension" \
1223 -S "found alpn extension" \
1224 -C "got an alert message, type: \\[2:120]" \
1225 -S "server hello, adding alpn extension" \
1226 -C "found alpn extension " \
1227 -C "Application Layer Protocol is" \
1228 -s "Application Layer Protocol is (none)"
1229
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001230run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001231 "$P_SRV debug_level=3 alpn=abc,1234" \
1232 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001233 0 \
1234 -c "client hello, adding alpn extension" \
1235 -s "found alpn extension" \
1236 -C "got an alert message, type: \\[2:120]" \
1237 -s "server hello, adding alpn extension" \
1238 -c "found alpn extension" \
1239 -c "Application Layer Protocol is abc" \
1240 -s "Application Layer Protocol is abc"
1241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001242run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001243 "$P_SRV debug_level=3 alpn=abc,1234" \
1244 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001245 0 \
1246 -c "client hello, adding alpn extension" \
1247 -s "found alpn extension" \
1248 -C "got an alert message, type: \\[2:120]" \
1249 -s "server hello, adding alpn extension" \
1250 -c "found alpn extension" \
1251 -c "Application Layer Protocol is abc" \
1252 -s "Application Layer Protocol is abc"
1253
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001254run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001255 "$P_SRV debug_level=3 alpn=abc,1234" \
1256 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001257 0 \
1258 -c "client hello, adding alpn extension" \
1259 -s "found alpn extension" \
1260 -C "got an alert message, type: \\[2:120]" \
1261 -s "server hello, adding alpn extension" \
1262 -c "found alpn extension" \
1263 -c "Application Layer Protocol is 1234" \
1264 -s "Application Layer Protocol is 1234"
1265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001266run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001267 "$P_SRV debug_level=3 alpn=abc,123" \
1268 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001269 1 \
1270 -c "client hello, adding alpn extension" \
1271 -s "found alpn extension" \
1272 -c "got an alert message, type: \\[2:120]" \
1273 -S "server hello, adding alpn extension" \
1274 -C "found alpn extension" \
1275 -C "Application Layer Protocol is 1234" \
1276 -S "Application Layer Protocol is 1234"
1277
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001278fi
1279
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001280# Tests for keyUsage in leaf certificates, part 1:
1281# server-side certificate/suite selection
1282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001283run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001284 "$P_SRV key_file=data_files/server2.key \
1285 crt_file=data_files/server2.ku-ds.crt" \
1286 "$P_CLI" \
1287 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001288 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001289
1290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001291run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001292 "$P_SRV key_file=data_files/server2.key \
1293 crt_file=data_files/server2.ku-ke.crt" \
1294 "$P_CLI" \
1295 0 \
1296 -c "Ciphersuite is TLS-RSA-WITH-"
1297
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001298run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001299 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001300 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001301 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001302 1 \
1303 -C "Ciphersuite is "
1304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001305run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001306 "$P_SRV key_file=data_files/server5.key \
1307 crt_file=data_files/server5.ku-ds.crt" \
1308 "$P_CLI" \
1309 0 \
1310 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1311
1312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001313run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001314 "$P_SRV key_file=data_files/server5.key \
1315 crt_file=data_files/server5.ku-ka.crt" \
1316 "$P_CLI" \
1317 0 \
1318 -c "Ciphersuite is TLS-ECDH-"
1319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001320run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001321 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001322 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001323 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001324 1 \
1325 -C "Ciphersuite is "
1326
1327# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001328# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001330run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001331 "$O_SRV -key data_files/server2.key \
1332 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001333 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001334 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1335 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001336 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001337 -C "Processing of the Certificate handshake message failed" \
1338 -c "Ciphersuite is TLS-"
1339
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001340run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001341 "$O_SRV -key data_files/server2.key \
1342 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001343 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001344 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1345 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001346 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001347 -C "Processing of the Certificate handshake message failed" \
1348 -c "Ciphersuite is TLS-"
1349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001350run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001351 "$O_SRV -key data_files/server2.key \
1352 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001353 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001354 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1355 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001356 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001357 -C "Processing of the Certificate handshake message failed" \
1358 -c "Ciphersuite is TLS-"
1359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001360run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001361 "$O_SRV -key data_files/server2.key \
1362 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001363 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001364 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1365 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001366 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001367 -c "Processing of the Certificate handshake message failed" \
1368 -C "Ciphersuite is TLS-"
1369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001370run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001371 "$O_SRV -key data_files/server2.key \
1372 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001373 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001374 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1375 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001376 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001377 -C "Processing of the Certificate handshake message failed" \
1378 -c "Ciphersuite is TLS-"
1379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001380run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001381 "$O_SRV -key data_files/server2.key \
1382 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001383 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001384 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1385 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001386 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001387 -c "Processing of the Certificate handshake message failed" \
1388 -C "Ciphersuite is TLS-"
1389
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001390# Tests for keyUsage in leaf certificates, part 3:
1391# server-side checking of client cert
1392
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001393run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001394 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001395 "$O_CLI -key data_files/server2.key \
1396 -cert data_files/server2.ku-ds.crt" \
1397 0 \
1398 -S "bad certificate (usage extensions)" \
1399 -S "Processing of the Certificate handshake message failed"
1400
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001401run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001402 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001403 "$O_CLI -key data_files/server2.key \
1404 -cert data_files/server2.ku-ke.crt" \
1405 0 \
1406 -s "bad certificate (usage extensions)" \
1407 -S "Processing of the Certificate handshake message failed"
1408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001409run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001410 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001411 "$O_CLI -key data_files/server2.key \
1412 -cert data_files/server2.ku-ke.crt" \
1413 1 \
1414 -s "bad certificate (usage extensions)" \
1415 -s "Processing of the Certificate handshake message failed"
1416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001417run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001418 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001419 "$O_CLI -key data_files/server5.key \
1420 -cert data_files/server5.ku-ds.crt" \
1421 0 \
1422 -S "bad certificate (usage extensions)" \
1423 -S "Processing of the Certificate handshake message failed"
1424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001425run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001426 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001427 "$O_CLI -key data_files/server5.key \
1428 -cert data_files/server5.ku-ka.crt" \
1429 0 \
1430 -s "bad certificate (usage extensions)" \
1431 -S "Processing of the Certificate handshake message failed"
1432
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001433# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1434
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001435run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001436 "$P_SRV key_file=data_files/server5.key \
1437 crt_file=data_files/server5.eku-srv.crt" \
1438 "$P_CLI" \
1439 0
1440
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001441run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001442 "$P_SRV key_file=data_files/server5.key \
1443 crt_file=data_files/server5.eku-srv.crt" \
1444 "$P_CLI" \
1445 0
1446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001447run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001448 "$P_SRV key_file=data_files/server5.key \
1449 crt_file=data_files/server5.eku-cs_any.crt" \
1450 "$P_CLI" \
1451 0
1452
1453# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001454run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001455 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1456 crt_file=data_files/server5.eku-cli.crt" \
1457 "$P_CLI psk=badbad" \
1458 1
1459
1460# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001462run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001463 "$O_SRV -key data_files/server5.key \
1464 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001465 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001466 0 \
1467 -C "bad certificate (usage extensions)" \
1468 -C "Processing of the Certificate handshake message failed" \
1469 -c "Ciphersuite is TLS-"
1470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001471run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001472 "$O_SRV -key data_files/server5.key \
1473 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001474 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001475 0 \
1476 -C "bad certificate (usage extensions)" \
1477 -C "Processing of the Certificate handshake message failed" \
1478 -c "Ciphersuite is TLS-"
1479
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001480run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001481 "$O_SRV -key data_files/server5.key \
1482 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001483 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001484 0 \
1485 -C "bad certificate (usage extensions)" \
1486 -C "Processing of the Certificate handshake message failed" \
1487 -c "Ciphersuite is TLS-"
1488
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001489run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001490 "$O_SRV -key data_files/server5.key \
1491 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001492 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001493 1 \
1494 -c "bad certificate (usage extensions)" \
1495 -c "Processing of the Certificate handshake message failed" \
1496 -C "Ciphersuite is TLS-"
1497
1498# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1499
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001500run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001501 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001502 "$O_CLI -key data_files/server5.key \
1503 -cert data_files/server5.eku-cli.crt" \
1504 0 \
1505 -S "bad certificate (usage extensions)" \
1506 -S "Processing of the Certificate handshake message failed"
1507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001508run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001509 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001510 "$O_CLI -key data_files/server5.key \
1511 -cert data_files/server5.eku-srv_cli.crt" \
1512 0 \
1513 -S "bad certificate (usage extensions)" \
1514 -S "Processing of the Certificate handshake message failed"
1515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001516run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001517 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001518 "$O_CLI -key data_files/server5.key \
1519 -cert data_files/server5.eku-cs_any.crt" \
1520 0 \
1521 -S "bad certificate (usage extensions)" \
1522 -S "Processing of the Certificate handshake message failed"
1523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001524run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001526 "$O_CLI -key data_files/server5.key \
1527 -cert data_files/server5.eku-cs.crt" \
1528 0 \
1529 -s "bad certificate (usage extensions)" \
1530 -S "Processing of the Certificate handshake message failed"
1531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001532run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001533 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001534 "$O_CLI -key data_files/server5.key \
1535 -cert data_files/server5.eku-cs.crt" \
1536 1 \
1537 -s "bad certificate (usage extensions)" \
1538 -s "Processing of the Certificate handshake message failed"
1539
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001540# Tests for DHM parameters loading
1541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001542run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001543 "$P_SRV" \
1544 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1545 debug_level=3" \
1546 0 \
1547 -c "value of 'DHM: P ' (2048 bits)" \
1548 -c "value of 'DHM: G ' (2048 bits)"
1549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001550run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001551 "$P_SRV dhm_file=data_files/dhparams.pem" \
1552 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1553 debug_level=3" \
1554 0 \
1555 -c "value of 'DHM: P ' (1024 bits)" \
1556 -c "value of 'DHM: G ' (2 bits)"
1557
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001558# Tests for PSK callback
1559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001560run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001561 "$P_SRV psk=abc123 psk_identity=foo" \
1562 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1563 psk_identity=foo psk=abc123" \
1564 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01001565 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001566 -S "SSL - Unknown identity received" \
1567 -S "SSL - Verification of the message MAC failed"
1568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001569run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001570 "$P_SRV" \
1571 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1572 psk_identity=foo psk=abc123" \
1573 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01001574 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001575 -S "SSL - Unknown identity received" \
1576 -S "SSL - Verification of the message MAC failed"
1577
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001578run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001579 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1580 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1581 psk_identity=foo psk=abc123" \
1582 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01001583 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001584 -s "SSL - Unknown identity received" \
1585 -S "SSL - Verification of the message MAC failed"
1586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001587run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001588 "$P_SRV psk_list=abc,dead,def,beef" \
1589 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1590 psk_identity=abc psk=dead" \
1591 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01001592 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001593 -S "SSL - Unknown identity received" \
1594 -S "SSL - Verification of the message MAC failed"
1595
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001596run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001597 "$P_SRV psk_list=abc,dead,def,beef" \
1598 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1599 psk_identity=def psk=beef" \
1600 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01001601 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001602 -S "SSL - Unknown identity received" \
1603 -S "SSL - Verification of the message MAC failed"
1604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001605run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001606 "$P_SRV psk_list=abc,dead,def,beef" \
1607 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1608 psk_identity=ghi psk=beef" \
1609 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01001610 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001611 -s "SSL - Unknown identity received" \
1612 -S "SSL - Verification of the message MAC failed"
1613
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001614run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001615 "$P_SRV psk_list=abc,dead,def,beef" \
1616 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1617 psk_identity=abc psk=beef" \
1618 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01001619 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001620 -S "SSL - Unknown identity received" \
1621 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001622
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001623# Tests for ciphersuites per version
1624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001625run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001626 "$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" \
1627 "$P_CLI force_version=ssl3" \
1628 0 \
1629 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001631run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001632 "$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" \
1633 "$P_CLI force_version=tls1" \
1634 0 \
1635 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001637run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001638 "$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" \
1639 "$P_CLI force_version=tls1_1" \
1640 0 \
1641 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001643run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001644 "$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" \
1645 "$P_CLI force_version=tls1_2" \
1646 0 \
1647 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1648
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001649# Tests for ssl_get_bytes_avail()
1650
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001651run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001652 "$P_SRV" \
1653 "$P_CLI request_size=100" \
1654 0 \
1655 -s "Read from client: 100 bytes read$"
1656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001657run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001658 "$P_SRV" \
1659 "$P_CLI request_size=500" \
1660 0 \
1661 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001662
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001663# Tests for small packets
1664
1665run_test "Small packet SSLv3 BlockCipher" \
1666 "$P_SRV" \
1667 "$P_CLI request_size=1 force_version=ssl3 \
1668 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1669 0 \
1670 -s "Read from client: 1 bytes read"
1671
1672run_test "Small packet SSLv3 StreamCipher" \
1673 "$P_SRV" \
1674 "$P_CLI request_size=1 force_version=ssl3 \
1675 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1676 0 \
1677 -s "Read from client: 1 bytes read"
1678
1679run_test "Small packet TLS 1.0 BlockCipher" \
1680 "$P_SRV" \
1681 "$P_CLI request_size=1 force_version=tls1 \
1682 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1683 0 \
1684 -s "Read from client: 1 bytes read"
1685
1686run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1687 "$P_SRV" \
1688 "$P_CLI request_size=1 force_version=tls1 \
1689 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1690 trunc_hmac=1" \
1691 0 \
1692 -s "Read from client: 1 bytes read"
1693
1694run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1695 "$P_SRV" \
1696 "$P_CLI request_size=1 force_version=tls1 \
1697 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1698 trunc_hmac=1" \
1699 0 \
1700 -s "Read from client: 1 bytes read"
1701
1702run_test "Small packet TLS 1.1 BlockCipher" \
1703 "$P_SRV" \
1704 "$P_CLI request_size=1 force_version=tls1_1 \
1705 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1706 0 \
1707 -s "Read from client: 1 bytes read"
1708
1709run_test "Small packet TLS 1.1 StreamCipher" \
1710 "$P_SRV" \
1711 "$P_CLI request_size=1 force_version=tls1_1 \
1712 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1713 0 \
1714 -s "Read from client: 1 bytes read"
1715
1716run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1717 "$P_SRV" \
1718 "$P_CLI request_size=1 force_version=tls1_1 \
1719 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1720 trunc_hmac=1" \
1721 0 \
1722 -s "Read from client: 1 bytes read"
1723
1724run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1725 "$P_SRV" \
1726 "$P_CLI request_size=1 force_version=tls1_1 \
1727 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1728 trunc_hmac=1" \
1729 0 \
1730 -s "Read from client: 1 bytes read"
1731
1732run_test "Small packet TLS 1.2 BlockCipher" \
1733 "$P_SRV" \
1734 "$P_CLI request_size=1 force_version=tls1_2 \
1735 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1736 0 \
1737 -s "Read from client: 1 bytes read"
1738
1739run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1740 "$P_SRV" \
1741 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1742 0 \
1743 -s "Read from client: 1 bytes read"
1744
1745run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1746 "$P_SRV" \
1747 "$P_CLI request_size=1 force_version=tls1_2 \
1748 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1749 trunc_hmac=1" \
1750 0 \
1751 -s "Read from client: 1 bytes read"
1752
1753run_test "Small packet TLS 1.2 StreamCipher" \
1754 "$P_SRV" \
1755 "$P_CLI request_size=1 force_version=tls1_2 \
1756 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1757 0 \
1758 -s "Read from client: 1 bytes read"
1759
1760run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1761 "$P_SRV" \
1762 "$P_CLI request_size=1 force_version=tls1_2 \
1763 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1764 trunc_hmac=1" \
1765 0 \
1766 -s "Read from client: 1 bytes read"
1767
1768run_test "Small packet TLS 1.2 AEAD" \
1769 "$P_SRV" \
1770 "$P_CLI request_size=1 force_version=tls1_2 \
1771 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1772 0 \
1773 -s "Read from client: 1 bytes read"
1774
1775run_test "Small packet TLS 1.2 AEAD shorter tag" \
1776 "$P_SRV" \
1777 "$P_CLI request_size=1 force_version=tls1_2 \
1778 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1779 0 \
1780 -s "Read from client: 1 bytes read"
1781
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001782# Test for large packets
1783
1784run_test "Large packet SSLv3 BlockCipher" \
1785 "$P_SRV" \
1786 "$P_CLI request_size=16384 force_version=ssl3 \
1787 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1788 0 \
1789 -s "Read from client: 16384 bytes read"
1790
1791run_test "Large packet SSLv3 StreamCipher" \
1792 "$P_SRV" \
1793 "$P_CLI request_size=16384 force_version=ssl3 \
1794 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1795 0 \
1796 -s "Read from client: 16384 bytes read"
1797
1798run_test "Large packet TLS 1.0 BlockCipher" \
1799 "$P_SRV" \
1800 "$P_CLI request_size=16384 force_version=tls1 \
1801 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1802 0 \
1803 -s "Read from client: 16384 bytes read"
1804
1805run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1806 "$P_SRV" \
1807 "$P_CLI request_size=16384 force_version=tls1 \
1808 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1809 trunc_hmac=1" \
1810 0 \
1811 -s "Read from client: 16384 bytes read"
1812
1813run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1814 "$P_SRV" \
1815 "$P_CLI request_size=16384 force_version=tls1 \
1816 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1817 trunc_hmac=1" \
1818 0 \
1819 -s "Read from client: 16384 bytes read"
1820
1821run_test "Large packet TLS 1.1 BlockCipher" \
1822 "$P_SRV" \
1823 "$P_CLI request_size=16384 force_version=tls1_1 \
1824 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1825 0 \
1826 -s "Read from client: 16384 bytes read"
1827
1828run_test "Large packet TLS 1.1 StreamCipher" \
1829 "$P_SRV" \
1830 "$P_CLI request_size=16384 force_version=tls1_1 \
1831 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1832 0 \
1833 -s "Read from client: 16384 bytes read"
1834
1835run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1836 "$P_SRV" \
1837 "$P_CLI request_size=16384 force_version=tls1_1 \
1838 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1839 trunc_hmac=1" \
1840 0 \
1841 -s "Read from client: 16384 bytes read"
1842
1843run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1844 "$P_SRV" \
1845 "$P_CLI request_size=16384 force_version=tls1_1 \
1846 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1847 trunc_hmac=1" \
1848 0 \
1849 -s "Read from client: 16384 bytes read"
1850
1851run_test "Large packet TLS 1.2 BlockCipher" \
1852 "$P_SRV" \
1853 "$P_CLI request_size=16384 force_version=tls1_2 \
1854 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1855 0 \
1856 -s "Read from client: 16384 bytes read"
1857
1858run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1859 "$P_SRV" \
1860 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1861 0 \
1862 -s "Read from client: 16384 bytes read"
1863
1864run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1865 "$P_SRV" \
1866 "$P_CLI request_size=16384 force_version=tls1_2 \
1867 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1868 trunc_hmac=1" \
1869 0 \
1870 -s "Read from client: 16384 bytes read"
1871
1872run_test "Large packet TLS 1.2 StreamCipher" \
1873 "$P_SRV" \
1874 "$P_CLI request_size=16384 force_version=tls1_2 \
1875 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1876 0 \
1877 -s "Read from client: 16384 bytes read"
1878
1879run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1880 "$P_SRV" \
1881 "$P_CLI request_size=16384 force_version=tls1_2 \
1882 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1883 trunc_hmac=1" \
1884 0 \
1885 -s "Read from client: 16384 bytes read"
1886
1887run_test "Large packet TLS 1.2 AEAD" \
1888 "$P_SRV" \
1889 "$P_CLI request_size=16384 force_version=tls1_2 \
1890 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1891 0 \
1892 -s "Read from client: 16384 bytes read"
1893
1894run_test "Large packet TLS 1.2 AEAD shorter tag" \
1895 "$P_SRV" \
1896 "$P_CLI request_size=16384 force_version=tls1_2 \
1897 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1898 0 \
1899 -s "Read from client: 16384 bytes read"
1900
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001901# Final report
1902
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001903echo "------------------------------------------------------------------------"
1904
1905if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01001906 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001907else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01001908 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001909fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02001910PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001911echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001912
1913exit $FAILS