blob: b0dcad95ff8bb28531fe3035b696fee3bd6c2b74 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
21O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
23G_CLI="$GNUTLS_CLI"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010037 echo -e " -h|--help\tPrint this help."
38 echo -e " -m|--memcheck\tCheck memory leaks and errors."
39 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
40 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
78 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020083# skip next test if OpenSSL doesn't support FALLBACK_SCSV
84requires_openssl_with_fallback_scsv() {
85 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
86 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
87 then
88 OPENSSL_HAS_FBSCSV="YES"
89 else
90 OPENSSL_HAS_FBSCSV="NO"
91 fi
92 fi
93 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
94 SKIP_NEXT="YES"
95 fi
96}
97
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020098# skip next test if GnuTLS isn't available
99requires_gnutls() {
100 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
101 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
102 GNUTLS_AVAILABLE="YES"
103 else
104 GNUTLS_AVAILABLE="NO"
105 fi
106 fi
107 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
108 SKIP_NEXT="YES"
109 fi
110}
111
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100112# print_name <name>
113print_name() {
114 echo -n "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200115 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100116 for i in `seq 1 $LEN`; do echo -n '.'; done
117 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100118
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200119 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100120}
121
122# fail <message>
123fail() {
124 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100125 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100126
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200127 mv $SRV_OUT o-srv-${TESTS}.log
128 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100129 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100130
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200131 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
132 echo " ! server output:"
133 cat o-srv-${TESTS}.log
134 echo " ! ============================================================"
135 echo " ! client output:"
136 cat o-cli-${TESTS}.log
137 fi
138
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200139 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100140}
141
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100142# is_polar <cmd_line>
143is_polar() {
144 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
145}
146
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100147# has_mem_err <log_file_name>
148has_mem_err() {
149 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
150 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
151 then
152 return 1 # false: does not have errors
153 else
154 return 0 # true: has errors
155 fi
156}
157
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200158# wait for server to start: two versions depending on lsof availability
159wait_server_start() {
160 if which lsof >/dev/null; then
161 # make sure we don't loop forever
162 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
163 WATCHDOG_PID=$!
164
165 # make a tight loop, server usually takes less than 1 sec to start
166 until lsof -nbi TCP:"$PORT" | grep LISTEN >/dev/null; do :; done
167
168 kill $WATCHDOG_PID
169 wait $WATCHDOG_PID
170 else
171 sleep "$START_DELAY"
172 fi
173}
174
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200175# wait for client to terminate and set CLI_EXIT
176# must be called right after starting the client
177wait_client_done() {
178 CLI_PID=$!
179
180 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
181 WATCHDOG_PID=$!
182
183 wait $CLI_PID
184 CLI_EXIT=$?
185
186 kill $WATCHDOG_PID
187 wait $WATCHDOG_PID
188
189 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
190}
191
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100192# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100193# Options: -s pattern pattern that must be present in server output
194# -c pattern pattern that must be present in client output
195# -S pattern pattern that must be absent in server output
196# -C pattern pattern that must be absent in client output
197run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100198 NAME="$1"
199 SRV_CMD="$2"
200 CLI_CMD="$3"
201 CLI_EXPECT="$4"
202 shift 4
203
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100204 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
205 else
206 return
207 fi
208
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100209 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100210
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200211 # should we skip?
212 if [ "X$SKIP_NEXT" = "XYES" ]; then
213 SKIP_NEXT="NO"
214 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200215 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200216 return
217 fi
218
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100219 # prepend valgrind to our commands if active
220 if [ "$MEMCHECK" -gt 0 ]; then
221 if is_polar "$SRV_CMD"; then
222 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
223 fi
224 if is_polar "$CLI_CMD"; then
225 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
226 fi
227 fi
228
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100229 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200230 echo "$SRV_CMD" > $SRV_OUT
231 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100232 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200233 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200234
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200235 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200236 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
237 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100238
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200239 # kill the server
240 kill $SRV_PID
241 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100242
243 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200244 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100245 # expected client exit to incorrectly succeed in case of catastrophic
246 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100247 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200248 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100249 else
250 fail "server failed to start"
251 return
252 fi
253 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100254 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200255 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100256 else
257 fail "client failed to start"
258 return
259 fi
260 fi
261
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100262 # check server exit code
263 if [ $? != 0 ]; then
264 fail "server fail"
265 return
266 fi
267
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100268 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100269 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
270 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100271 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100272 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100273 return
274 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100275
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100276 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200277 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100278 while [ $# -gt 0 ]
279 do
280 case $1 in
281 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200282 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
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 :; else
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 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200296 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100297 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100298 return
299 fi
300 ;;
301
302 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200303 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100304 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100305 return
306 fi
307 ;;
308
309 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200310 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100311 exit 1
312 esac
313 shift 2
314 done
315
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100316 # check valgrind's results
317 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200318 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100319 fail "Server has memory errors"
320 return
321 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200322 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100323 fail "Client has memory errors"
324 return
325 fi
326 fi
327
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100328 # if we're here, everything is ok
329 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200330 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100331}
332
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100333cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200334 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200335 kill $SRV_PID >/dev/null 2>&1
336 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100337 exit 1
338}
339
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100340#
341# MAIN
342#
343
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100344get_options "$@"
345
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100346# sanity checks, avoid an avalanche of errors
347if [ ! -x "$P_SRV" ]; then
348 echo "Command '$P_SRV' is not an executable file"
349 exit 1
350fi
351if [ ! -x "$P_CLI" ]; then
352 echo "Command '$P_CLI' is not an executable file"
353 exit 1
354fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100355if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
356 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100357 exit 1
358fi
359
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200360# used by watchdog
361MAIN_PID="$$"
362
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200363# be more patient with valgrind
364if [ "$MEMCHECK" -gt 0 ]; then
365 START_DELAY=3
366 DOG_DELAY=30
367else
368 START_DELAY=1
369 DOG_DELAY=10
370fi
371
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200372# Pick a "unique" port in the range 10000-19999.
373PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200374PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200375
376# fix commands to use this port
377P_SRV="$P_SRV server_port=$PORT"
378P_CLI="$P_CLI server_port=$PORT"
379O_SRV="$O_SRV -accept $PORT"
380O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200381G_SRV="$G_SRV -p $PORT"
382G_CLI="$G_CLI -p $PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200383
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200384# Also pick a unique name for intermediate files
385SRV_OUT="srv_out.$$"
386CLI_OUT="cli_out.$$"
387SESSION="session.$$"
388
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200389SKIP_NEXT="NO"
390
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100391trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100392
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200393# Basic test
394
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200395# Checks that:
396# - things work with all ciphersuites active (used with config-full in all.sh)
397# - the expected (highest security) parameters are selected
398# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200399run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200400 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200401 "$P_CLI" \
402 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200403 -s "Protocol is TLSv1.2" \
404 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
405 -s "client hello v3, signature_algorithm ext: 6" \
406 -s "ECDHE curve: secp521r1" \
407 -S "error" \
408 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200409
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100410# Test for SSLv2 ClientHello
411
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200412requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200413run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100414 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100415 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100416 0 \
417 -S "parse client hello v2" \
418 -S "ssl_handshake returned"
419
420# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200421requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200422run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200423 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100424 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100425 0 \
426 -s "parse client hello v2" \
427 -S "ssl_handshake returned"
428
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100429# Tests for Truncated HMAC extension
430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200431run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200432 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100433 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100434 0 \
435 -s "dumping 'computed mac' (20 bytes)"
436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200437run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200438 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100439 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100440 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100441 -s "dumping 'computed mac' (10 bytes)"
442
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200443# Tests for FALLBACK_SCSV
444
445run_test "Fallback SCSV: default" \
446 "$P_SRV" \
447 "$P_CLI debug_level=3 force_version=tls1_1" \
448 0 \
449 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200450 -S "received FALLBACK_SCSV" \
451 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200452 -C "is a fatal alert message (msg 86)"
453
454run_test "Fallback SCSV: explicitly disabled" \
455 "$P_SRV" \
456 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
457 0 \
458 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200459 -S "received FALLBACK_SCSV" \
460 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200461 -C "is a fatal alert message (msg 86)"
462
463run_test "Fallback SCSV: enabled" \
464 "$P_SRV" \
465 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200466 1 \
467 -c "adding FALLBACK_SCSV" \
468 -s "received FALLBACK_SCSV" \
469 -s "inapropriate fallback" \
470 -c "is a fatal alert message (msg 86)"
471
472run_test "Fallback SCSV: enabled, max version" \
473 "$P_SRV" \
474 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200475 0 \
476 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200477 -s "received FALLBACK_SCSV" \
478 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200479 -C "is a fatal alert message (msg 86)"
480
481requires_openssl_with_fallback_scsv
482run_test "Fallback SCSV: default, openssl server" \
483 "$O_SRV" \
484 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
485 0 \
486 -C "adding FALLBACK_SCSV" \
487 -C "is a fatal alert message (msg 86)"
488
489requires_openssl_with_fallback_scsv
490run_test "Fallback SCSV: enabled, openssl server" \
491 "$O_SRV" \
492 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
493 1 \
494 -c "adding FALLBACK_SCSV" \
495 -c "is a fatal alert message (msg 86)"
496
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200497requires_openssl_with_fallback_scsv
498run_test "Fallback SCSV: disabled, openssl client" \
499 "$P_SRV" \
500 "$O_CLI -tls1_1" \
501 0 \
502 -S "received FALLBACK_SCSV" \
503 -S "inapropriate fallback"
504
505requires_openssl_with_fallback_scsv
506run_test "Fallback SCSV: enabled, openssl client" \
507 "$P_SRV" \
508 "$O_CLI -tls1_1 -fallback_scsv" \
509 1 \
510 -s "received FALLBACK_SCSV" \
511 -s "inapropriate fallback"
512
513requires_openssl_with_fallback_scsv
514run_test "Fallback SCSV: enabled, max version, openssl client" \
515 "$P_SRV" \
516 "$O_CLI -fallback_scsv" \
517 0 \
518 -s "received FALLBACK_SCSV" \
519 -S "inapropriate fallback"
520
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100521# Tests for Session Tickets
522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200523run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200524 "$P_SRV debug_level=3 tickets=1" \
525 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100526 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100527 -c "client hello, adding session ticket extension" \
528 -s "found session ticket extension" \
529 -s "server hello, adding session ticket extension" \
530 -c "found session_ticket extension" \
531 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100532 -S "session successfully restored from cache" \
533 -s "session successfully restored from ticket" \
534 -s "a session has been resumed" \
535 -c "a session has been resumed"
536
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200537run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200538 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
539 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100540 0 \
541 -c "client hello, adding session ticket extension" \
542 -s "found session ticket extension" \
543 -s "server hello, adding session ticket extension" \
544 -c "found session_ticket extension" \
545 -c "parse new session ticket" \
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 tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200552 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
553 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100554 0 \
555 -c "client hello, adding session ticket extension" \
556 -s "found session ticket extension" \
557 -s "server hello, adding session ticket extension" \
558 -c "found session_ticket extension" \
559 -c "parse new session ticket" \
560 -S "session successfully restored from cache" \
561 -S "session successfully restored from ticket" \
562 -S "a session has been resumed" \
563 -C "a session has been resumed"
564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200565run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100566 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200567 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100568 0 \
569 -c "client hello, adding session ticket extension" \
570 -c "found session_ticket extension" \
571 -c "parse new session ticket" \
572 -c "a session has been resumed"
573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200574run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200575 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200576 "( $O_CLI -sess_out $SESSION; \
577 $O_CLI -sess_in $SESSION; \
578 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100579 0 \
580 -s "found session ticket extension" \
581 -s "server hello, adding session ticket extension" \
582 -S "session successfully restored from cache" \
583 -s "session successfully restored from ticket" \
584 -s "a session has been resumed"
585
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100586# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200588run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200589 "$P_SRV debug_level=3 tickets=0" \
590 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100591 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100592 -c "client hello, adding session ticket extension" \
593 -s "found session ticket extension" \
594 -S "server hello, adding session ticket extension" \
595 -C "found session_ticket extension" \
596 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100597 -s "session successfully restored from cache" \
598 -S "session successfully restored from ticket" \
599 -s "a session has been resumed" \
600 -c "a session has been resumed"
601
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200602run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200603 "$P_SRV debug_level=3 tickets=1" \
604 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100605 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100606 -C "client hello, adding session ticket extension" \
607 -S "found session ticket extension" \
608 -S "server hello, adding session ticket extension" \
609 -C "found session_ticket extension" \
610 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100611 -s "session successfully restored from cache" \
612 -S "session successfully restored from ticket" \
613 -s "a session has been resumed" \
614 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200616run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200617 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
618 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100619 0 \
620 -S "session successfully restored from cache" \
621 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100622 -S "a session has been resumed" \
623 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200625run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200626 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
627 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100628 0 \
629 -s "session successfully restored from cache" \
630 -S "session successfully restored from ticket" \
631 -s "a session has been resumed" \
632 -c "a session has been resumed"
633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200634run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200635 "$P_SRV debug_level=3 tickets=0" \
636 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100637 0 \
638 -s "session successfully restored from cache" \
639 -S "session successfully restored from ticket" \
640 -s "a session has been resumed" \
641 -c "a session has been resumed"
642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200643run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200644 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
645 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100646 0 \
647 -S "session successfully restored from cache" \
648 -S "session successfully restored from ticket" \
649 -S "a session has been resumed" \
650 -C "a session has been resumed"
651
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200652run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200653 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
654 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100655 0 \
656 -s "session successfully restored from cache" \
657 -S "session successfully restored from ticket" \
658 -s "a session has been resumed" \
659 -c "a session has been resumed"
660
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200661run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200662 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200663 "( $O_CLI -sess_out $SESSION; \
664 $O_CLI -sess_in $SESSION; \
665 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100666 0 \
667 -s "found session ticket extension" \
668 -S "server hello, adding session ticket extension" \
669 -s "session successfully restored from cache" \
670 -S "session successfully restored from ticket" \
671 -s "a session has been resumed"
672
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200673run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100674 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200675 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100676 0 \
677 -C "found session_ticket extension" \
678 -C "parse new session ticket" \
679 -c "a session has been resumed"
680
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100681# Tests for Max Fragment Length extension
682
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200683run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200684 "$P_SRV debug_level=3" \
685 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100686 0 \
687 -C "client hello, adding max_fragment_length extension" \
688 -S "found max fragment length extension" \
689 -S "server hello, max_fragment_length extension" \
690 -C "found max_fragment_length extension"
691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200692run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200693 "$P_SRV debug_level=3" \
694 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100695 0 \
696 -c "client hello, adding max_fragment_length extension" \
697 -s "found max fragment length extension" \
698 -s "server hello, max_fragment_length extension" \
699 -c "found max_fragment_length extension"
700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200701run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200702 "$P_SRV debug_level=3 max_frag_len=4096" \
703 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100704 0 \
705 -C "client hello, adding max_fragment_length extension" \
706 -S "found max fragment length extension" \
707 -S "server hello, max_fragment_length extension" \
708 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100709
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200710requires_gnutls
711run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200712 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200713 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200714 0 \
715 -c "client hello, adding max_fragment_length extension" \
716 -c "found max_fragment_length extension"
717
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100718# Tests for renegotiation
719
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200720run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200721 "$P_SRV debug_level=3 exchanges=2" \
722 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100723 0 \
724 -C "client hello, adding renegotiation extension" \
725 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
726 -S "found renegotiation extension" \
727 -s "server hello, secure renegotiation extension" \
728 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100729 -C "=> renegotiate" \
730 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100731 -S "write hello request"
732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200733run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200734 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
735 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100736 0 \
737 -c "client hello, adding renegotiation extension" \
738 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
739 -s "found renegotiation extension" \
740 -s "server hello, secure renegotiation extension" \
741 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100742 -c "=> renegotiate" \
743 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100744 -S "write hello request"
745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200746run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200747 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
748 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100749 0 \
750 -c "client hello, adding renegotiation extension" \
751 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
752 -s "found renegotiation extension" \
753 -s "server hello, secure renegotiation extension" \
754 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100755 -c "=> renegotiate" \
756 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100757 -s "write hello request"
758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200759run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200760 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
761 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100762 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" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100768 -c "=> renegotiate" \
769 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100770 -s "write hello request"
771
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200772run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200773 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
774 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100775 1 \
776 -c "client hello, adding renegotiation extension" \
777 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
778 -S "found renegotiation extension" \
779 -s "server hello, secure renegotiation extension" \
780 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100781 -c "=> renegotiate" \
782 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200783 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200784 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200785 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200787run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200788 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
789 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100790 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" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100796 -C "=> renegotiate" \
797 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100798 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200799 -S "SSL - An unexpected message was received from our peer" \
800 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100801
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200802run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200803 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200804 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200805 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200806 0 \
807 -C "client hello, adding renegotiation extension" \
808 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
809 -S "found renegotiation extension" \
810 -s "server hello, secure renegotiation extension" \
811 -c "found renegotiation extension" \
812 -C "=> renegotiate" \
813 -S "=> renegotiate" \
814 -s "write hello request" \
815 -S "SSL - An unexpected message was received from our peer" \
816 -S "failed"
817
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200818# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200819run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200820 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200821 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200822 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200823 0 \
824 -C "client hello, adding renegotiation extension" \
825 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
826 -S "found renegotiation extension" \
827 -s "server hello, secure renegotiation extension" \
828 -c "found renegotiation extension" \
829 -C "=> renegotiate" \
830 -S "=> renegotiate" \
831 -s "write hello request" \
832 -S "SSL - An unexpected message was received from our peer" \
833 -S "failed"
834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200835run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200836 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200837 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200838 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200839 0 \
840 -C "client hello, adding renegotiation extension" \
841 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
842 -S "found renegotiation extension" \
843 -s "server hello, secure renegotiation extension" \
844 -c "found renegotiation extension" \
845 -C "=> renegotiate" \
846 -S "=> renegotiate" \
847 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200848 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200850run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200851 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200852 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200853 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200854 0 \
855 -c "client hello, adding renegotiation extension" \
856 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
857 -s "found renegotiation extension" \
858 -s "server hello, secure renegotiation extension" \
859 -c "found renegotiation extension" \
860 -c "=> renegotiate" \
861 -s "=> renegotiate" \
862 -s "write hello request" \
863 -S "SSL - An unexpected message was received from our peer" \
864 -S "failed"
865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200866run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200867 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
868 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200869 0 \
870 -c "client hello, adding renegotiation extension" \
871 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
872 -s "found renegotiation extension" \
873 -s "server hello, secure renegotiation extension" \
874 -c "found renegotiation extension" \
875 -c "=> renegotiate" \
876 -s "=> renegotiate" \
877 -S "write hello request"
878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200879run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200880 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
881 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200882 0 \
883 -c "client hello, adding renegotiation extension" \
884 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
885 -s "found renegotiation extension" \
886 -s "server hello, secure renegotiation extension" \
887 -c "found renegotiation extension" \
888 -c "=> renegotiate" \
889 -s "=> renegotiate" \
890 -s "write hello request"
891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200892run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200893 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200894 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200895 0 \
896 -c "client hello, adding renegotiation extension" \
897 -c "found renegotiation extension" \
898 -c "=> renegotiate" \
899 -C "ssl_handshake returned" \
900 -C "error" \
901 -c "HTTP/1.0 200 [Oo][Kk]"
902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200903run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200904 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200905 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200906 0 \
907 -c "client hello, adding renegotiation extension" \
908 -c "found renegotiation extension" \
909 -c "=> renegotiate" \
910 -C "ssl_handshake returned" \
911 -C "error" \
912 -c "HTTP/1.0 200 [Oo][Kk]"
913
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100914# Tests for auth_mode
915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200916run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100917 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100918 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200919 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100920 1 \
921 -c "x509_verify_cert() returned" \
922 -c "! self-signed or not signed by a trusted CA" \
923 -c "! ssl_handshake returned" \
924 -c "X509 - Certificate verification failed"
925
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200926run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100927 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100928 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200929 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100930 0 \
931 -c "x509_verify_cert() returned" \
932 -c "! self-signed or not signed by a trusted CA" \
933 -C "! ssl_handshake returned" \
934 -C "X509 - Certificate verification failed"
935
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200936run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100937 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100938 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200939 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100940 0 \
941 -C "x509_verify_cert() returned" \
942 -C "! self-signed or not signed by a trusted CA" \
943 -C "! ssl_handshake returned" \
944 -C "X509 - Certificate verification failed"
945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200946run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200947 "$P_SRV debug_level=3 auth_mode=required" \
948 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100949 key_file=data_files/server5.key" \
950 1 \
951 -S "skip write certificate request" \
952 -C "skip parse certificate request" \
953 -c "got a certificate request" \
954 -C "skip write certificate" \
955 -C "skip write certificate verify" \
956 -S "skip parse certificate verify" \
957 -s "x509_verify_cert() returned" \
958 -S "! self-signed or not signed by a trusted CA" \
959 -s "! ssl_handshake returned" \
960 -c "! ssl_handshake returned" \
961 -s "X509 - Certificate verification failed"
962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200963run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200964 "$P_SRV debug_level=3 auth_mode=optional" \
965 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100966 key_file=data_files/server5.key" \
967 0 \
968 -S "skip write certificate request" \
969 -C "skip parse certificate request" \
970 -c "got a certificate request" \
971 -C "skip write certificate" \
972 -C "skip write certificate verify" \
973 -S "skip parse certificate verify" \
974 -s "x509_verify_cert() returned" \
975 -s "! self-signed or not signed by a trusted CA" \
976 -S "! ssl_handshake returned" \
977 -C "! ssl_handshake returned" \
978 -S "X509 - Certificate verification failed"
979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200980run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200981 "$P_SRV debug_level=3 auth_mode=none" \
982 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100983 key_file=data_files/server5.key" \
984 0 \
985 -s "skip write certificate request" \
986 -C "skip parse certificate request" \
987 -c "got no certificate request" \
988 -c "skip write certificate" \
989 -c "skip write certificate verify" \
990 -s "skip parse certificate verify" \
991 -S "x509_verify_cert() returned" \
992 -S "! self-signed or not signed by a trusted CA" \
993 -S "! ssl_handshake returned" \
994 -C "! ssl_handshake returned" \
995 -S "X509 - Certificate verification failed"
996
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200997run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200998 "$P_SRV debug_level=3 auth_mode=optional" \
999 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001000 0 \
1001 -S "skip write certificate request" \
1002 -C "skip parse certificate request" \
1003 -c "got a certificate request" \
1004 -C "skip write certificate$" \
1005 -C "got no certificate to send" \
1006 -S "SSLv3 client has no certificate" \
1007 -c "skip write certificate verify" \
1008 -s "skip parse certificate verify" \
1009 -s "! no client certificate sent" \
1010 -S "! ssl_handshake returned" \
1011 -C "! ssl_handshake returned" \
1012 -S "X509 - Certificate verification failed"
1013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001014run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001015 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001016 "$O_CLI" \
1017 0 \
1018 -S "skip write certificate request" \
1019 -s "skip parse certificate verify" \
1020 -s "! no client certificate sent" \
1021 -S "! ssl_handshake returned" \
1022 -S "X509 - Certificate verification failed"
1023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001024run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001025 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001026 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001027 0 \
1028 -C "skip parse certificate request" \
1029 -c "got a certificate request" \
1030 -C "skip write certificate$" \
1031 -c "skip write certificate verify" \
1032 -C "! ssl_handshake returned"
1033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001034run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001035 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1036 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001037 0 \
1038 -S "skip write certificate request" \
1039 -C "skip parse certificate request" \
1040 -c "got a certificate request" \
1041 -C "skip write certificate$" \
1042 -c "skip write certificate verify" \
1043 -c "got no certificate to send" \
1044 -s "SSLv3 client has no certificate" \
1045 -s "skip parse certificate verify" \
1046 -s "! no client certificate sent" \
1047 -S "! ssl_handshake returned" \
1048 -C "! ssl_handshake returned" \
1049 -S "X509 - Certificate verification failed"
1050
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001051# tests for SNI
1052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001053run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001054 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001055 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001056 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001057 server_name=localhost" \
1058 0 \
1059 -S "parse ServerName extension" \
1060 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1061 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001063run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001064 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001065 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001066 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 +01001067 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001068 server_name=localhost" \
1069 0 \
1070 -s "parse ServerName extension" \
1071 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1072 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001074run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001075 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001076 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001077 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 +01001078 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001079 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001080 0 \
1081 -s "parse ServerName extension" \
1082 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001083 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001085run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001086 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001087 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001088 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 +01001089 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001090 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001091 1 \
1092 -s "parse ServerName extension" \
1093 -s "ssl_sni_wrapper() returned" \
1094 -s "ssl_handshake returned" \
1095 -c "ssl_handshake returned" \
1096 -c "SSL - A fatal alert message was received from our peer"
1097
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001098# Tests for non-blocking I/O: exercise a variety of handshake flows
1099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001100run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001101 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1102 "$P_CLI nbio=2 tickets=0" \
1103 0 \
1104 -S "ssl_handshake returned" \
1105 -C "ssl_handshake returned" \
1106 -c "Read from server: .* bytes read"
1107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001108run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001109 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1110 "$P_CLI nbio=2 tickets=0" \
1111 0 \
1112 -S "ssl_handshake returned" \
1113 -C "ssl_handshake returned" \
1114 -c "Read from server: .* bytes read"
1115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001116run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001117 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1118 "$P_CLI nbio=2 tickets=1" \
1119 0 \
1120 -S "ssl_handshake returned" \
1121 -C "ssl_handshake returned" \
1122 -c "Read from server: .* bytes read"
1123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001124run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001125 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1126 "$P_CLI nbio=2 tickets=1" \
1127 0 \
1128 -S "ssl_handshake returned" \
1129 -C "ssl_handshake returned" \
1130 -c "Read from server: .* bytes read"
1131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001132run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001133 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1134 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1135 0 \
1136 -S "ssl_handshake returned" \
1137 -C "ssl_handshake returned" \
1138 -c "Read from server: .* bytes read"
1139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001140run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001141 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1142 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1143 0 \
1144 -S "ssl_handshake returned" \
1145 -C "ssl_handshake returned" \
1146 -c "Read from server: .* bytes read"
1147
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001148run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001149 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1150 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1151 0 \
1152 -S "ssl_handshake returned" \
1153 -C "ssl_handshake returned" \
1154 -c "Read from server: .* bytes read"
1155
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001156# Tests for version negotiation
1157
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001158run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001159 "$P_SRV" \
1160 "$P_CLI" \
1161 0 \
1162 -S "ssl_handshake returned" \
1163 -C "ssl_handshake returned" \
1164 -s "Protocol is TLSv1.2" \
1165 -c "Protocol is TLSv1.2"
1166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001167run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001168 "$P_SRV" \
1169 "$P_CLI max_version=tls1_1" \
1170 0 \
1171 -S "ssl_handshake returned" \
1172 -C "ssl_handshake returned" \
1173 -s "Protocol is TLSv1.1" \
1174 -c "Protocol is TLSv1.1"
1175
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001176run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001177 "$P_SRV max_version=tls1_1" \
1178 "$P_CLI" \
1179 0 \
1180 -S "ssl_handshake returned" \
1181 -C "ssl_handshake returned" \
1182 -s "Protocol is TLSv1.1" \
1183 -c "Protocol is TLSv1.1"
1184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001185run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001186 "$P_SRV max_version=tls1_1" \
1187 "$P_CLI max_version=tls1_1" \
1188 0 \
1189 -S "ssl_handshake returned" \
1190 -C "ssl_handshake returned" \
1191 -s "Protocol is TLSv1.1" \
1192 -c "Protocol is TLSv1.1"
1193
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001194run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001195 "$P_SRV min_version=tls1_1" \
1196 "$P_CLI max_version=tls1_1" \
1197 0 \
1198 -S "ssl_handshake returned" \
1199 -C "ssl_handshake returned" \
1200 -s "Protocol is TLSv1.1" \
1201 -c "Protocol is TLSv1.1"
1202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001203run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001204 "$P_SRV max_version=tls1_1" \
1205 "$P_CLI min_version=tls1_1" \
1206 0 \
1207 -S "ssl_handshake returned" \
1208 -C "ssl_handshake returned" \
1209 -s "Protocol is TLSv1.1" \
1210 -c "Protocol is TLSv1.1"
1211
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001212run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001213 "$P_SRV max_version=tls1_1" \
1214 "$P_CLI min_version=tls1_2" \
1215 1 \
1216 -s "ssl_handshake returned" \
1217 -c "ssl_handshake returned" \
1218 -c "SSL - Handshake protocol not within min/max boundaries"
1219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001220run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001221 "$P_SRV min_version=tls1_2" \
1222 "$P_CLI max_version=tls1_1" \
1223 1 \
1224 -s "ssl_handshake returned" \
1225 -c "ssl_handshake returned" \
1226 -s "SSL - Handshake protocol not within min/max boundaries"
1227
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001228# Tests for ALPN extension
1229
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001230if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1231
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001232run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001233 "$P_SRV debug_level=3" \
1234 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001235 0 \
1236 -C "client hello, adding alpn extension" \
1237 -S "found alpn extension" \
1238 -C "got an alert message, type: \\[2:120]" \
1239 -S "server hello, adding alpn extension" \
1240 -C "found alpn extension " \
1241 -C "Application Layer Protocol is" \
1242 -S "Application Layer Protocol is"
1243
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001244run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001245 "$P_SRV debug_level=3" \
1246 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001247 0 \
1248 -c "client hello, adding alpn extension" \
1249 -s "found alpn extension" \
1250 -C "got an alert message, type: \\[2:120]" \
1251 -S "server hello, adding alpn extension" \
1252 -C "found alpn extension " \
1253 -c "Application Layer Protocol is (none)" \
1254 -S "Application Layer Protocol is"
1255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_SRV debug_level=3 alpn=abc,1234" \
1258 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001259 0 \
1260 -C "client hello, adding alpn extension" \
1261 -S "found alpn extension" \
1262 -C "got an alert message, type: \\[2:120]" \
1263 -S "server hello, adding alpn extension" \
1264 -C "found alpn extension " \
1265 -C "Application Layer Protocol is" \
1266 -s "Application Layer Protocol is (none)"
1267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001268run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001269 "$P_SRV debug_level=3 alpn=abc,1234" \
1270 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001271 0 \
1272 -c "client hello, adding alpn extension" \
1273 -s "found alpn extension" \
1274 -C "got an alert message, type: \\[2:120]" \
1275 -s "server hello, adding alpn extension" \
1276 -c "found alpn extension" \
1277 -c "Application Layer Protocol is abc" \
1278 -s "Application Layer Protocol is abc"
1279
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001280run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001281 "$P_SRV debug_level=3 alpn=abc,1234" \
1282 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001283 0 \
1284 -c "client hello, adding alpn extension" \
1285 -s "found alpn extension" \
1286 -C "got an alert message, type: \\[2:120]" \
1287 -s "server hello, adding alpn extension" \
1288 -c "found alpn extension" \
1289 -c "Application Layer Protocol is abc" \
1290 -s "Application Layer Protocol is abc"
1291
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001292run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001293 "$P_SRV debug_level=3 alpn=abc,1234" \
1294 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001295 0 \
1296 -c "client hello, adding alpn extension" \
1297 -s "found alpn extension" \
1298 -C "got an alert message, type: \\[2:120]" \
1299 -s "server hello, adding alpn extension" \
1300 -c "found alpn extension" \
1301 -c "Application Layer Protocol is 1234" \
1302 -s "Application Layer Protocol is 1234"
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001305 "$P_SRV debug_level=3 alpn=abc,123" \
1306 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001307 1 \
1308 -c "client hello, adding alpn extension" \
1309 -s "found alpn extension" \
1310 -c "got an alert message, type: \\[2:120]" \
1311 -S "server hello, adding alpn extension" \
1312 -C "found alpn extension" \
1313 -C "Application Layer Protocol is 1234" \
1314 -S "Application Layer Protocol is 1234"
1315
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001316fi
1317
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001318# Tests for keyUsage in leaf certificates, part 1:
1319# server-side certificate/suite selection
1320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001321run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001322 "$P_SRV key_file=data_files/server2.key \
1323 crt_file=data_files/server2.ku-ds.crt" \
1324 "$P_CLI" \
1325 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001326 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001327
1328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001329run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001330 "$P_SRV key_file=data_files/server2.key \
1331 crt_file=data_files/server2.ku-ke.crt" \
1332 "$P_CLI" \
1333 0 \
1334 -c "Ciphersuite is TLS-RSA-WITH-"
1335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001336run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001337 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001338 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001339 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001340 1 \
1341 -C "Ciphersuite is "
1342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001343run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001344 "$P_SRV key_file=data_files/server5.key \
1345 crt_file=data_files/server5.ku-ds.crt" \
1346 "$P_CLI" \
1347 0 \
1348 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1349
1350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001351run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001352 "$P_SRV key_file=data_files/server5.key \
1353 crt_file=data_files/server5.ku-ka.crt" \
1354 "$P_CLI" \
1355 0 \
1356 -c "Ciphersuite is TLS-ECDH-"
1357
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001358run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001359 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001360 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001361 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001362 1 \
1363 -C "Ciphersuite is "
1364
1365# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001366# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001367
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001368run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001369 "$O_SRV -key data_files/server2.key \
1370 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001371 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001372 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1373 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001374 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001375 -C "Processing of the Certificate handshake message failed" \
1376 -c "Ciphersuite is TLS-"
1377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001378run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001379 "$O_SRV -key data_files/server2.key \
1380 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001382 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1383 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001384 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001385 -C "Processing of the Certificate handshake message failed" \
1386 -c "Ciphersuite is TLS-"
1387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001388run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001389 "$O_SRV -key data_files/server2.key \
1390 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001391 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001392 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1393 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001394 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001395 -C "Processing of the Certificate handshake message failed" \
1396 -c "Ciphersuite is TLS-"
1397
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001398run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001399 "$O_SRV -key data_files/server2.key \
1400 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001401 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001402 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1403 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001404 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001405 -c "Processing of the Certificate handshake message failed" \
1406 -C "Ciphersuite is TLS-"
1407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001408run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001409 "$O_SRV -key data_files/server2.key \
1410 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001411 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001412 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1413 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001414 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001415 -C "Processing of the Certificate handshake message failed" \
1416 -c "Ciphersuite is TLS-"
1417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001418run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001419 "$O_SRV -key data_files/server2.key \
1420 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001421 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001422 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1423 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001424 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001425 -c "Processing of the Certificate handshake message failed" \
1426 -C "Ciphersuite is TLS-"
1427
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001428# Tests for keyUsage in leaf certificates, part 3:
1429# server-side checking of client cert
1430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001431run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001432 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001433 "$O_CLI -key data_files/server2.key \
1434 -cert data_files/server2.ku-ds.crt" \
1435 0 \
1436 -S "bad certificate (usage extensions)" \
1437 -S "Processing of the Certificate handshake message failed"
1438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001439run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001440 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001441 "$O_CLI -key data_files/server2.key \
1442 -cert data_files/server2.ku-ke.crt" \
1443 0 \
1444 -s "bad certificate (usage extensions)" \
1445 -S "Processing of the Certificate handshake message failed"
1446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001447run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001448 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001449 "$O_CLI -key data_files/server2.key \
1450 -cert data_files/server2.ku-ke.crt" \
1451 1 \
1452 -s "bad certificate (usage extensions)" \
1453 -s "Processing of the Certificate handshake message failed"
1454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001455run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001456 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001457 "$O_CLI -key data_files/server5.key \
1458 -cert data_files/server5.ku-ds.crt" \
1459 0 \
1460 -S "bad certificate (usage extensions)" \
1461 -S "Processing of the Certificate handshake message failed"
1462
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001463run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001464 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001465 "$O_CLI -key data_files/server5.key \
1466 -cert data_files/server5.ku-ka.crt" \
1467 0 \
1468 -s "bad certificate (usage extensions)" \
1469 -S "Processing of the Certificate handshake message failed"
1470
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001471# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001473run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001474 "$P_SRV key_file=data_files/server5.key \
1475 crt_file=data_files/server5.eku-srv.crt" \
1476 "$P_CLI" \
1477 0
1478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001479run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001480 "$P_SRV key_file=data_files/server5.key \
1481 crt_file=data_files/server5.eku-srv.crt" \
1482 "$P_CLI" \
1483 0
1484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001485run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001486 "$P_SRV key_file=data_files/server5.key \
1487 crt_file=data_files/server5.eku-cs_any.crt" \
1488 "$P_CLI" \
1489 0
1490
1491# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001492run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001493 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1494 crt_file=data_files/server5.eku-cli.crt" \
1495 "$P_CLI psk=badbad" \
1496 1
1497
1498# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1499
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001500run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001501 "$O_SRV -key data_files/server5.key \
1502 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001503 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001504 0 \
1505 -C "bad certificate (usage extensions)" \
1506 -C "Processing of the Certificate handshake message failed" \
1507 -c "Ciphersuite is TLS-"
1508
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001509run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001510 "$O_SRV -key data_files/server5.key \
1511 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001512 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001513 0 \
1514 -C "bad certificate (usage extensions)" \
1515 -C "Processing of the Certificate handshake message failed" \
1516 -c "Ciphersuite is TLS-"
1517
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001518run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001519 "$O_SRV -key data_files/server5.key \
1520 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001521 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001522 0 \
1523 -C "bad certificate (usage extensions)" \
1524 -C "Processing of the Certificate handshake message failed" \
1525 -c "Ciphersuite is TLS-"
1526
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001527run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001528 "$O_SRV -key data_files/server5.key \
1529 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001530 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001531 1 \
1532 -c "bad certificate (usage extensions)" \
1533 -c "Processing of the Certificate handshake message failed" \
1534 -C "Ciphersuite is TLS-"
1535
1536# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001538run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001539 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001540 "$O_CLI -key data_files/server5.key \
1541 -cert data_files/server5.eku-cli.crt" \
1542 0 \
1543 -S "bad certificate (usage extensions)" \
1544 -S "Processing of the Certificate handshake message failed"
1545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001546run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001547 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001548 "$O_CLI -key data_files/server5.key \
1549 -cert data_files/server5.eku-srv_cli.crt" \
1550 0 \
1551 -S "bad certificate (usage extensions)" \
1552 -S "Processing of the Certificate handshake message failed"
1553
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001554run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001555 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001556 "$O_CLI -key data_files/server5.key \
1557 -cert data_files/server5.eku-cs_any.crt" \
1558 0 \
1559 -S "bad certificate (usage extensions)" \
1560 -S "Processing of the Certificate handshake message failed"
1561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001562run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001563 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001564 "$O_CLI -key data_files/server5.key \
1565 -cert data_files/server5.eku-cs.crt" \
1566 0 \
1567 -s "bad certificate (usage extensions)" \
1568 -S "Processing of the Certificate handshake message failed"
1569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001570run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001571 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001572 "$O_CLI -key data_files/server5.key \
1573 -cert data_files/server5.eku-cs.crt" \
1574 1 \
1575 -s "bad certificate (usage extensions)" \
1576 -s "Processing of the Certificate handshake message failed"
1577
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001578# Tests for DHM parameters loading
1579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001580run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001581 "$P_SRV" \
1582 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1583 debug_level=3" \
1584 0 \
1585 -c "value of 'DHM: P ' (2048 bits)" \
1586 -c "value of 'DHM: G ' (2048 bits)"
1587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001588run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001589 "$P_SRV dhm_file=data_files/dhparams.pem" \
1590 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1591 debug_level=3" \
1592 0 \
1593 -c "value of 'DHM: P ' (1024 bits)" \
1594 -c "value of 'DHM: G ' (2 bits)"
1595
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001596# Tests for PSK callback
1597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001598run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001599 "$P_SRV psk=abc123 psk_identity=foo" \
1600 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1601 psk_identity=foo psk=abc123" \
1602 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001603 -S "SSL - The server has no ciphersuites in common" \
1604 -S "SSL - Unknown identity received" \
1605 -S "SSL - Verification of the message MAC failed"
1606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001607run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001608 "$P_SRV" \
1609 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1610 psk_identity=foo psk=abc123" \
1611 1 \
1612 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001613 -S "SSL - Unknown identity received" \
1614 -S "SSL - Verification of the message MAC failed"
1615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001616run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001617 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1618 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1619 psk_identity=foo psk=abc123" \
1620 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001621 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001622 -s "SSL - Unknown identity received" \
1623 -S "SSL - Verification of the message MAC failed"
1624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001625run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001626 "$P_SRV psk_list=abc,dead,def,beef" \
1627 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1628 psk_identity=abc psk=dead" \
1629 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001630 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001631 -S "SSL - Unknown identity received" \
1632 -S "SSL - Verification of the message MAC failed"
1633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001634run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001635 "$P_SRV psk_list=abc,dead,def,beef" \
1636 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1637 psk_identity=def psk=beef" \
1638 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001639 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001640 -S "SSL - Unknown identity received" \
1641 -S "SSL - Verification of the message MAC failed"
1642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001643run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001644 "$P_SRV psk_list=abc,dead,def,beef" \
1645 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1646 psk_identity=ghi psk=beef" \
1647 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001648 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001649 -s "SSL - Unknown identity received" \
1650 -S "SSL - Verification of the message MAC failed"
1651
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001652run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001653 "$P_SRV psk_list=abc,dead,def,beef" \
1654 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1655 psk_identity=abc psk=beef" \
1656 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001657 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001658 -S "SSL - Unknown identity received" \
1659 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001660
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001661# Tests for ciphersuites per version
1662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001663run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001664 "$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" \
1665 "$P_CLI force_version=ssl3" \
1666 0 \
1667 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001669run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001670 "$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" \
1671 "$P_CLI force_version=tls1" \
1672 0 \
1673 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001675run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001676 "$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" \
1677 "$P_CLI force_version=tls1_1" \
1678 0 \
1679 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001681run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001682 "$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" \
1683 "$P_CLI force_version=tls1_2" \
1684 0 \
1685 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1686
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001687# Tests for ssl_get_bytes_avail()
1688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001689run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001690 "$P_SRV" \
1691 "$P_CLI request_size=100" \
1692 0 \
1693 -s "Read from client: 100 bytes read$"
1694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001695run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001696 "$P_SRV" \
1697 "$P_CLI request_size=500" \
1698 0 \
1699 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001700
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001701# Tests for small packets
1702
1703run_test "Small packet SSLv3 BlockCipher" \
1704 "$P_SRV" \
1705 "$P_CLI request_size=1 force_version=ssl3 \
1706 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1707 0 \
1708 -s "Read from client: 1 bytes read"
1709
1710run_test "Small packet SSLv3 StreamCipher" \
1711 "$P_SRV" \
1712 "$P_CLI request_size=1 force_version=ssl3 \
1713 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1714 0 \
1715 -s "Read from client: 1 bytes read"
1716
1717run_test "Small packet TLS 1.0 BlockCipher" \
1718 "$P_SRV" \
1719 "$P_CLI request_size=1 force_version=tls1 \
1720 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1721 0 \
1722 -s "Read from client: 1 bytes read"
1723
1724run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1725 "$P_SRV" \
1726 "$P_CLI request_size=1 force_version=tls1 \
1727 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1728 trunc_hmac=1" \
1729 0 \
1730 -s "Read from client: 1 bytes read"
1731
1732run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1733 "$P_SRV" \
1734 "$P_CLI request_size=1 force_version=tls1 \
1735 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1736 trunc_hmac=1" \
1737 0 \
1738 -s "Read from client: 1 bytes read"
1739
1740run_test "Small packet TLS 1.1 BlockCipher" \
1741 "$P_SRV" \
1742 "$P_CLI request_size=1 force_version=tls1_1 \
1743 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1744 0 \
1745 -s "Read from client: 1 bytes read"
1746
1747run_test "Small packet TLS 1.1 StreamCipher" \
1748 "$P_SRV" \
1749 "$P_CLI request_size=1 force_version=tls1_1 \
1750 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1751 0 \
1752 -s "Read from client: 1 bytes read"
1753
1754run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1755 "$P_SRV" \
1756 "$P_CLI request_size=1 force_version=tls1_1 \
1757 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1758 trunc_hmac=1" \
1759 0 \
1760 -s "Read from client: 1 bytes read"
1761
1762run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1763 "$P_SRV" \
1764 "$P_CLI request_size=1 force_version=tls1_1 \
1765 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1766 trunc_hmac=1" \
1767 0 \
1768 -s "Read from client: 1 bytes read"
1769
1770run_test "Small packet TLS 1.2 BlockCipher" \
1771 "$P_SRV" \
1772 "$P_CLI request_size=1 force_version=tls1_2 \
1773 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1774 0 \
1775 -s "Read from client: 1 bytes read"
1776
1777run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1778 "$P_SRV" \
1779 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1780 0 \
1781 -s "Read from client: 1 bytes read"
1782
1783run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1784 "$P_SRV" \
1785 "$P_CLI request_size=1 force_version=tls1_2 \
1786 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1787 trunc_hmac=1" \
1788 0 \
1789 -s "Read from client: 1 bytes read"
1790
1791run_test "Small packet TLS 1.2 StreamCipher" \
1792 "$P_SRV" \
1793 "$P_CLI request_size=1 force_version=tls1_2 \
1794 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1795 0 \
1796 -s "Read from client: 1 bytes read"
1797
1798run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1799 "$P_SRV" \
1800 "$P_CLI request_size=1 force_version=tls1_2 \
1801 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1802 trunc_hmac=1" \
1803 0 \
1804 -s "Read from client: 1 bytes read"
1805
1806run_test "Small packet TLS 1.2 AEAD" \
1807 "$P_SRV" \
1808 "$P_CLI request_size=1 force_version=tls1_2 \
1809 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1810 0 \
1811 -s "Read from client: 1 bytes read"
1812
1813run_test "Small packet TLS 1.2 AEAD shorter tag" \
1814 "$P_SRV" \
1815 "$P_CLI request_size=1 force_version=tls1_2 \
1816 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1817 0 \
1818 -s "Read from client: 1 bytes read"
1819
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001820# Test for large packets
1821
1822run_test "Large packet SSLv3 BlockCipher" \
1823 "$P_SRV" \
1824 "$P_CLI request_size=16384 force_version=ssl3 \
1825 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1826 0 \
1827 -s "Read from client: 16384 bytes read"
1828
1829run_test "Large packet SSLv3 StreamCipher" \
1830 "$P_SRV" \
1831 "$P_CLI request_size=16384 force_version=ssl3 \
1832 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1833 0 \
1834 -s "Read from client: 16384 bytes read"
1835
1836run_test "Large packet TLS 1.0 BlockCipher" \
1837 "$P_SRV" \
1838 "$P_CLI request_size=16384 force_version=tls1 \
1839 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1840 0 \
1841 -s "Read from client: 16384 bytes read"
1842
1843run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1844 "$P_SRV" \
1845 "$P_CLI request_size=16384 force_version=tls1 \
1846 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1847 trunc_hmac=1" \
1848 0 \
1849 -s "Read from client: 16384 bytes read"
1850
1851run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1852 "$P_SRV" \
1853 "$P_CLI request_size=16384 force_version=tls1 \
1854 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1855 trunc_hmac=1" \
1856 0 \
1857 -s "Read from client: 16384 bytes read"
1858
1859run_test "Large packet TLS 1.1 BlockCipher" \
1860 "$P_SRV" \
1861 "$P_CLI request_size=16384 force_version=tls1_1 \
1862 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1863 0 \
1864 -s "Read from client: 16384 bytes read"
1865
1866run_test "Large packet TLS 1.1 StreamCipher" \
1867 "$P_SRV" \
1868 "$P_CLI request_size=16384 force_version=tls1_1 \
1869 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1870 0 \
1871 -s "Read from client: 16384 bytes read"
1872
1873run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1874 "$P_SRV" \
1875 "$P_CLI request_size=16384 force_version=tls1_1 \
1876 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1877 trunc_hmac=1" \
1878 0 \
1879 -s "Read from client: 16384 bytes read"
1880
1881run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1882 "$P_SRV" \
1883 "$P_CLI request_size=16384 force_version=tls1_1 \
1884 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1885 trunc_hmac=1" \
1886 0 \
1887 -s "Read from client: 16384 bytes read"
1888
1889run_test "Large packet TLS 1.2 BlockCipher" \
1890 "$P_SRV" \
1891 "$P_CLI request_size=16384 force_version=tls1_2 \
1892 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1893 0 \
1894 -s "Read from client: 16384 bytes read"
1895
1896run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1897 "$P_SRV" \
1898 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1899 0 \
1900 -s "Read from client: 16384 bytes read"
1901
1902run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1903 "$P_SRV" \
1904 "$P_CLI request_size=16384 force_version=tls1_2 \
1905 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1906 trunc_hmac=1" \
1907 0 \
1908 -s "Read from client: 16384 bytes read"
1909
1910run_test "Large packet TLS 1.2 StreamCipher" \
1911 "$P_SRV" \
1912 "$P_CLI request_size=16384 force_version=tls1_2 \
1913 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1914 0 \
1915 -s "Read from client: 16384 bytes read"
1916
1917run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1918 "$P_SRV" \
1919 "$P_CLI request_size=16384 force_version=tls1_2 \
1920 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1921 trunc_hmac=1" \
1922 0 \
1923 -s "Read from client: 16384 bytes read"
1924
1925run_test "Large packet TLS 1.2 AEAD" \
1926 "$P_SRV" \
1927 "$P_CLI request_size=16384 force_version=tls1_2 \
1928 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1929 0 \
1930 -s "Read from client: 16384 bytes read"
1931
1932run_test "Large packet TLS 1.2 AEAD shorter tag" \
1933 "$P_SRV" \
1934 "$P_CLI request_size=16384 force_version=tls1_2 \
1935 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1936 0 \
1937 -s "Read from client: 16384 bytes read"
1938
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001939# Final report
1940
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001941echo "------------------------------------------------------------------------"
1942
1943if [ $FAILS = 0 ]; then
1944 echo -n "PASSED"
1945else
1946 echo -n "FAILED"
1947fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02001948PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001949echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001950
1951exit $FAILS