blob: eeac11bc8935b16e2a8acc87511590cfeae58871 [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é-Gonnard367381f2014-10-20 18:40:56 +0200443# Tests for Extended Master Secret extension
444
445run_test "Extended Master Secret: default" \
446 "$P_SRV debug_level=3" \
447 "$P_CLI debug_level=3" \
448 0 \
449 -c "client hello, adding extended_master_secret extension" \
450 -s "found extended master secret extension" \
451 -s "server hello, adding extended master secret extension" \
452 -c "found extended_master_secret extension" \
453 -c "using extended master secret" \
454 -s "using extended master secret"
455
456run_test "Extended Master Secret: client enabled, server disabled" \
457 "$P_SRV debug_level=3 extended_ms=0" \
458 "$P_CLI debug_level=3 extended_ms=1" \
459 0 \
460 -c "client hello, adding extended_master_secret extension" \
461 -s "found extended master secret extension" \
462 -S "server hello, adding extended master secret extension" \
463 -C "found extended_master_secret extension" \
464 -C "using extended master secret" \
465 -S "using extended master secret"
466
467run_test "Extended Master Secret: client disabled, server enabled" \
468 "$P_SRV debug_level=3 extended_ms=1" \
469 "$P_CLI debug_level=3 extended_ms=0" \
470 0 \
471 -C "client hello, adding extended_master_secret extension" \
472 -S "found extended master secret extension" \
473 -S "server hello, adding extended master secret extension" \
474 -C "found extended_master_secret extension" \
475 -C "using extended master secret" \
476 -S "using extended master secret"
477
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200478# Tests for FALLBACK_SCSV
479
480run_test "Fallback SCSV: default" \
481 "$P_SRV" \
482 "$P_CLI debug_level=3 force_version=tls1_1" \
483 0 \
484 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200485 -S "received FALLBACK_SCSV" \
486 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200487 -C "is a fatal alert message (msg 86)"
488
489run_test "Fallback SCSV: explicitly disabled" \
490 "$P_SRV" \
491 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
492 0 \
493 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200494 -S "received FALLBACK_SCSV" \
495 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200496 -C "is a fatal alert message (msg 86)"
497
498run_test "Fallback SCSV: enabled" \
499 "$P_SRV" \
500 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200501 1 \
502 -c "adding FALLBACK_SCSV" \
503 -s "received FALLBACK_SCSV" \
504 -s "inapropriate fallback" \
505 -c "is a fatal alert message (msg 86)"
506
507run_test "Fallback SCSV: enabled, max version" \
508 "$P_SRV" \
509 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200510 0 \
511 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200512 -s "received FALLBACK_SCSV" \
513 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200514 -C "is a fatal alert message (msg 86)"
515
516requires_openssl_with_fallback_scsv
517run_test "Fallback SCSV: default, openssl server" \
518 "$O_SRV" \
519 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
520 0 \
521 -C "adding FALLBACK_SCSV" \
522 -C "is a fatal alert message (msg 86)"
523
524requires_openssl_with_fallback_scsv
525run_test "Fallback SCSV: enabled, openssl server" \
526 "$O_SRV" \
527 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
528 1 \
529 -c "adding FALLBACK_SCSV" \
530 -c "is a fatal alert message (msg 86)"
531
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200532requires_openssl_with_fallback_scsv
533run_test "Fallback SCSV: disabled, openssl client" \
534 "$P_SRV" \
535 "$O_CLI -tls1_1" \
536 0 \
537 -S "received FALLBACK_SCSV" \
538 -S "inapropriate fallback"
539
540requires_openssl_with_fallback_scsv
541run_test "Fallback SCSV: enabled, openssl client" \
542 "$P_SRV" \
543 "$O_CLI -tls1_1 -fallback_scsv" \
544 1 \
545 -s "received FALLBACK_SCSV" \
546 -s "inapropriate fallback"
547
548requires_openssl_with_fallback_scsv
549run_test "Fallback SCSV: enabled, max version, openssl client" \
550 "$P_SRV" \
551 "$O_CLI -fallback_scsv" \
552 0 \
553 -s "received FALLBACK_SCSV" \
554 -S "inapropriate fallback"
555
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100556# Tests for Session Tickets
557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200558run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200559 "$P_SRV debug_level=3 tickets=1" \
560 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100561 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100562 -c "client hello, adding session ticket extension" \
563 -s "found session ticket extension" \
564 -s "server hello, adding session ticket extension" \
565 -c "found session_ticket extension" \
566 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100567 -S "session successfully restored from cache" \
568 -s "session successfully restored from ticket" \
569 -s "a session has been resumed" \
570 -c "a session has been resumed"
571
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200572run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200573 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
574 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100575 0 \
576 -c "client hello, adding session ticket extension" \
577 -s "found session ticket extension" \
578 -s "server hello, adding session ticket extension" \
579 -c "found session_ticket extension" \
580 -c "parse new session ticket" \
581 -S "session successfully restored from cache" \
582 -s "session successfully restored from ticket" \
583 -s "a session has been resumed" \
584 -c "a session has been resumed"
585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200586run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200587 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
588 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100589 0 \
590 -c "client hello, adding session ticket extension" \
591 -s "found session ticket extension" \
592 -s "server hello, adding session ticket extension" \
593 -c "found session_ticket extension" \
594 -c "parse new session ticket" \
595 -S "session successfully restored from cache" \
596 -S "session successfully restored from ticket" \
597 -S "a session has been resumed" \
598 -C "a session has been resumed"
599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200600run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100601 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200602 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100603 0 \
604 -c "client hello, adding session ticket extension" \
605 -c "found session_ticket extension" \
606 -c "parse new session ticket" \
607 -c "a session has been resumed"
608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200609run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200610 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200611 "( $O_CLI -sess_out $SESSION; \
612 $O_CLI -sess_in $SESSION; \
613 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100614 0 \
615 -s "found session ticket extension" \
616 -s "server hello, adding session ticket extension" \
617 -S "session successfully restored from cache" \
618 -s "session successfully restored from ticket" \
619 -s "a session has been resumed"
620
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100621# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200623run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200624 "$P_SRV debug_level=3 tickets=0" \
625 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100626 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100627 -c "client hello, adding session ticket extension" \
628 -s "found session ticket extension" \
629 -S "server hello, adding session ticket extension" \
630 -C "found session_ticket extension" \
631 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100632 -s "session successfully restored from cache" \
633 -S "session successfully restored from ticket" \
634 -s "a session has been resumed" \
635 -c "a session has been resumed"
636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200637run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200638 "$P_SRV debug_level=3 tickets=1" \
639 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100640 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100641 -C "client hello, adding session ticket extension" \
642 -S "found session ticket extension" \
643 -S "server hello, adding session ticket extension" \
644 -C "found session_ticket extension" \
645 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100646 -s "session successfully restored from cache" \
647 -S "session successfully restored from ticket" \
648 -s "a session has been resumed" \
649 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100650
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200651run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200652 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
653 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100654 0 \
655 -S "session successfully restored from cache" \
656 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100657 -S "a session has been resumed" \
658 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100659
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200660run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200661 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
662 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100663 0 \
664 -s "session successfully restored from cache" \
665 -S "session successfully restored from ticket" \
666 -s "a session has been resumed" \
667 -c "a session has been resumed"
668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200669run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200670 "$P_SRV debug_level=3 tickets=0" \
671 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100672 0 \
673 -s "session successfully restored from cache" \
674 -S "session successfully restored from ticket" \
675 -s "a session has been resumed" \
676 -c "a session has been resumed"
677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200678run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200679 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
680 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100681 0 \
682 -S "session successfully restored from cache" \
683 -S "session successfully restored from ticket" \
684 -S "a session has been resumed" \
685 -C "a session has been resumed"
686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200687run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200688 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
689 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100690 0 \
691 -s "session successfully restored from cache" \
692 -S "session successfully restored from ticket" \
693 -s "a session has been resumed" \
694 -c "a session has been resumed"
695
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200696run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200697 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200698 "( $O_CLI -sess_out $SESSION; \
699 $O_CLI -sess_in $SESSION; \
700 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100701 0 \
702 -s "found session ticket extension" \
703 -S "server hello, adding session ticket extension" \
704 -s "session successfully restored from cache" \
705 -S "session successfully restored from ticket" \
706 -s "a session has been resumed"
707
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200708run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100709 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200710 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100711 0 \
712 -C "found session_ticket extension" \
713 -C "parse new session ticket" \
714 -c "a session has been resumed"
715
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100716# Tests for Max Fragment Length extension
717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200718run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200719 "$P_SRV debug_level=3" \
720 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100721 0 \
722 -C "client hello, adding max_fragment_length extension" \
723 -S "found max fragment length extension" \
724 -S "server hello, max_fragment_length extension" \
725 -C "found max_fragment_length extension"
726
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200727run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200728 "$P_SRV debug_level=3" \
729 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100730 0 \
731 -c "client hello, adding max_fragment_length extension" \
732 -s "found max fragment length extension" \
733 -s "server hello, max_fragment_length extension" \
734 -c "found max_fragment_length extension"
735
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200736run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200737 "$P_SRV debug_level=3 max_frag_len=4096" \
738 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100739 0 \
740 -C "client hello, adding max_fragment_length extension" \
741 -S "found max fragment length extension" \
742 -S "server hello, max_fragment_length extension" \
743 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200745requires_gnutls
746run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200747 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200748 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200749 0 \
750 -c "client hello, adding max_fragment_length extension" \
751 -c "found max_fragment_length extension"
752
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100753# Tests for renegotiation
754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200755run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200756 "$P_SRV debug_level=3 exchanges=2" \
757 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100758 0 \
759 -C "client hello, adding renegotiation extension" \
760 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
761 -S "found renegotiation extension" \
762 -s "server hello, secure renegotiation extension" \
763 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100764 -C "=> renegotiate" \
765 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100766 -S "write hello request"
767
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200768run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200769 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
770 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100771 0 \
772 -c "client hello, adding renegotiation extension" \
773 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
774 -s "found renegotiation extension" \
775 -s "server hello, secure renegotiation extension" \
776 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100777 -c "=> renegotiate" \
778 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100779 -S "write hello request"
780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200781run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200782 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
783 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100784 0 \
785 -c "client hello, adding renegotiation extension" \
786 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
787 -s "found renegotiation extension" \
788 -s "server hello, secure renegotiation extension" \
789 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100790 -c "=> renegotiate" \
791 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100792 -s "write hello request"
793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200794run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200795 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
796 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100797 0 \
798 -c "client hello, adding renegotiation extension" \
799 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
800 -s "found renegotiation extension" \
801 -s "server hello, secure renegotiation extension" \
802 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100803 -c "=> renegotiate" \
804 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100805 -s "write hello request"
806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200807run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200808 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
809 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100810 1 \
811 -c "client hello, adding renegotiation extension" \
812 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
813 -S "found renegotiation extension" \
814 -s "server hello, secure renegotiation extension" \
815 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100816 -c "=> renegotiate" \
817 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200818 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200819 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200820 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100821
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200822run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200823 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
824 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100825 0 \
826 -C "client hello, adding renegotiation extension" \
827 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
828 -S "found renegotiation extension" \
829 -s "server hello, secure renegotiation extension" \
830 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100831 -C "=> renegotiate" \
832 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100833 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200834 -S "SSL - An unexpected message was received from our peer" \
835 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200837run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200838 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200839 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200840 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200841 0 \
842 -C "client hello, adding renegotiation extension" \
843 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
844 -S "found renegotiation extension" \
845 -s "server hello, secure renegotiation extension" \
846 -c "found renegotiation extension" \
847 -C "=> renegotiate" \
848 -S "=> renegotiate" \
849 -s "write hello request" \
850 -S "SSL - An unexpected message was received from our peer" \
851 -S "failed"
852
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200853# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200854run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200855 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200856 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200857 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200858 0 \
859 -C "client hello, adding renegotiation extension" \
860 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
861 -S "found renegotiation extension" \
862 -s "server hello, secure renegotiation extension" \
863 -c "found renegotiation extension" \
864 -C "=> renegotiate" \
865 -S "=> renegotiate" \
866 -s "write hello request" \
867 -S "SSL - An unexpected message was received from our peer" \
868 -S "failed"
869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200870run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200871 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200872 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200873 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200874 0 \
875 -C "client hello, adding renegotiation extension" \
876 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
877 -S "found renegotiation extension" \
878 -s "server hello, secure renegotiation extension" \
879 -c "found renegotiation extension" \
880 -C "=> renegotiate" \
881 -S "=> renegotiate" \
882 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200883 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200884
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200885run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200886 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200887 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200888 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200889 0 \
890 -c "client hello, adding renegotiation extension" \
891 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
892 -s "found renegotiation extension" \
893 -s "server hello, secure renegotiation extension" \
894 -c "found renegotiation extension" \
895 -c "=> renegotiate" \
896 -s "=> renegotiate" \
897 -s "write hello request" \
898 -S "SSL - An unexpected message was received from our peer" \
899 -S "failed"
900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200901run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200902 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
903 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200904 0 \
905 -c "client hello, adding renegotiation extension" \
906 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
907 -s "found renegotiation extension" \
908 -s "server hello, secure renegotiation extension" \
909 -c "found renegotiation extension" \
910 -c "=> renegotiate" \
911 -s "=> renegotiate" \
912 -S "write hello request"
913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200914run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200915 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
916 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200917 0 \
918 -c "client hello, adding renegotiation extension" \
919 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
920 -s "found renegotiation extension" \
921 -s "server hello, secure renegotiation extension" \
922 -c "found renegotiation extension" \
923 -c "=> renegotiate" \
924 -s "=> renegotiate" \
925 -s "write hello request"
926
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200927run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200928 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200929 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200930 0 \
931 -c "client hello, adding renegotiation extension" \
932 -c "found renegotiation extension" \
933 -c "=> renegotiate" \
934 -C "ssl_handshake returned" \
935 -C "error" \
936 -c "HTTP/1.0 200 [Oo][Kk]"
937
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200938run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200939 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200940 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200941 0 \
942 -c "client hello, adding renegotiation extension" \
943 -c "found renegotiation extension" \
944 -c "=> renegotiate" \
945 -C "ssl_handshake returned" \
946 -C "error" \
947 -c "HTTP/1.0 200 [Oo][Kk]"
948
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100949# Tests for auth_mode
950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200951run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100952 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100953 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200954 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100955 1 \
956 -c "x509_verify_cert() returned" \
957 -c "! self-signed or not signed by a trusted CA" \
958 -c "! ssl_handshake returned" \
959 -c "X509 - Certificate verification failed"
960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200961run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100962 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100963 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200964 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100965 0 \
966 -c "x509_verify_cert() returned" \
967 -c "! self-signed or not signed by a trusted CA" \
968 -C "! ssl_handshake returned" \
969 -C "X509 - Certificate verification failed"
970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200971run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100972 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100973 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200974 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100975 0 \
976 -C "x509_verify_cert() returned" \
977 -C "! self-signed or not signed by a trusted CA" \
978 -C "! ssl_handshake returned" \
979 -C "X509 - Certificate verification failed"
980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200981run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200982 "$P_SRV debug_level=3 auth_mode=required" \
983 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100984 key_file=data_files/server5.key" \
985 1 \
986 -S "skip write certificate request" \
987 -C "skip parse certificate request" \
988 -c "got a certificate request" \
989 -C "skip write certificate" \
990 -C "skip write certificate verify" \
991 -S "skip parse certificate verify" \
992 -s "x509_verify_cert() returned" \
993 -S "! self-signed or not signed by a trusted CA" \
994 -s "! ssl_handshake returned" \
995 -c "! ssl_handshake returned" \
996 -s "X509 - Certificate verification failed"
997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200998run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200999 "$P_SRV debug_level=3 auth_mode=optional" \
1000 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001001 key_file=data_files/server5.key" \
1002 0 \
1003 -S "skip write certificate request" \
1004 -C "skip parse certificate request" \
1005 -c "got a certificate request" \
1006 -C "skip write certificate" \
1007 -C "skip write certificate verify" \
1008 -S "skip parse certificate verify" \
1009 -s "x509_verify_cert() returned" \
1010 -s "! self-signed or not signed by a trusted CA" \
1011 -S "! ssl_handshake returned" \
1012 -C "! ssl_handshake returned" \
1013 -S "X509 - Certificate verification failed"
1014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001015run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001016 "$P_SRV debug_level=3 auth_mode=none" \
1017 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001018 key_file=data_files/server5.key" \
1019 0 \
1020 -s "skip write certificate request" \
1021 -C "skip parse certificate request" \
1022 -c "got no certificate request" \
1023 -c "skip write certificate" \
1024 -c "skip write certificate verify" \
1025 -s "skip parse certificate verify" \
1026 -S "x509_verify_cert() returned" \
1027 -S "! self-signed or not signed by a trusted CA" \
1028 -S "! ssl_handshake returned" \
1029 -C "! ssl_handshake returned" \
1030 -S "X509 - Certificate verification failed"
1031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001032run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001033 "$P_SRV debug_level=3 auth_mode=optional" \
1034 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001035 0 \
1036 -S "skip write certificate request" \
1037 -C "skip parse certificate request" \
1038 -c "got a certificate request" \
1039 -C "skip write certificate$" \
1040 -C "got no certificate to send" \
1041 -S "SSLv3 client has no certificate" \
1042 -c "skip write certificate verify" \
1043 -s "skip parse certificate verify" \
1044 -s "! no client certificate sent" \
1045 -S "! ssl_handshake returned" \
1046 -C "! ssl_handshake returned" \
1047 -S "X509 - Certificate verification failed"
1048
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001049run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001050 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001051 "$O_CLI" \
1052 0 \
1053 -S "skip write certificate request" \
1054 -s "skip parse certificate verify" \
1055 -s "! no client certificate sent" \
1056 -S "! ssl_handshake returned" \
1057 -S "X509 - Certificate verification failed"
1058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001059run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001060 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001061 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001062 0 \
1063 -C "skip parse certificate request" \
1064 -c "got a certificate request" \
1065 -C "skip write certificate$" \
1066 -c "skip write certificate verify" \
1067 -C "! ssl_handshake returned"
1068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001069run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001070 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1071 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001072 0 \
1073 -S "skip write certificate request" \
1074 -C "skip parse certificate request" \
1075 -c "got a certificate request" \
1076 -C "skip write certificate$" \
1077 -c "skip write certificate verify" \
1078 -c "got no certificate to send" \
1079 -s "SSLv3 client has no certificate" \
1080 -s "skip parse certificate verify" \
1081 -s "! no client certificate sent" \
1082 -S "! ssl_handshake returned" \
1083 -C "! ssl_handshake returned" \
1084 -S "X509 - Certificate verification failed"
1085
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001086# tests for SNI
1087
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001088run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001089 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001090 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001091 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001092 server_name=localhost" \
1093 0 \
1094 -S "parse ServerName extension" \
1095 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1096 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001098run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001099 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001100 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001101 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 +01001102 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001103 server_name=localhost" \
1104 0 \
1105 -s "parse ServerName extension" \
1106 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1107 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1108
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001109run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001110 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001111 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001112 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 +01001113 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001114 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001115 0 \
1116 -s "parse ServerName extension" \
1117 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001118 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001120run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001121 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001122 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001123 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 +01001124 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001125 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001126 1 \
1127 -s "parse ServerName extension" \
1128 -s "ssl_sni_wrapper() returned" \
1129 -s "ssl_handshake returned" \
1130 -c "ssl_handshake returned" \
1131 -c "SSL - A fatal alert message was received from our peer"
1132
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001133# Tests for non-blocking I/O: exercise a variety of handshake flows
1134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001135run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001136 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1137 "$P_CLI nbio=2 tickets=0" \
1138 0 \
1139 -S "ssl_handshake returned" \
1140 -C "ssl_handshake returned" \
1141 -c "Read from server: .* bytes read"
1142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001143run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001144 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1145 "$P_CLI nbio=2 tickets=0" \
1146 0 \
1147 -S "ssl_handshake returned" \
1148 -C "ssl_handshake returned" \
1149 -c "Read from server: .* bytes read"
1150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001151run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001152 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1153 "$P_CLI nbio=2 tickets=1" \
1154 0 \
1155 -S "ssl_handshake returned" \
1156 -C "ssl_handshake returned" \
1157 -c "Read from server: .* bytes read"
1158
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001159run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001160 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1161 "$P_CLI nbio=2 tickets=1" \
1162 0 \
1163 -S "ssl_handshake returned" \
1164 -C "ssl_handshake returned" \
1165 -c "Read from server: .* bytes read"
1166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001167run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001168 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1169 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1170 0 \
1171 -S "ssl_handshake returned" \
1172 -C "ssl_handshake returned" \
1173 -c "Read from server: .* bytes read"
1174
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001175run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001176 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1177 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1178 0 \
1179 -S "ssl_handshake returned" \
1180 -C "ssl_handshake returned" \
1181 -c "Read from server: .* bytes read"
1182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001183run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001184 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1185 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1186 0 \
1187 -S "ssl_handshake returned" \
1188 -C "ssl_handshake returned" \
1189 -c "Read from server: .* bytes read"
1190
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001191# Tests for version negotiation
1192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001193run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001194 "$P_SRV" \
1195 "$P_CLI" \
1196 0 \
1197 -S "ssl_handshake returned" \
1198 -C "ssl_handshake returned" \
1199 -s "Protocol is TLSv1.2" \
1200 -c "Protocol is TLSv1.2"
1201
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001202run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001203 "$P_SRV" \
1204 "$P_CLI max_version=tls1_1" \
1205 0 \
1206 -S "ssl_handshake returned" \
1207 -C "ssl_handshake returned" \
1208 -s "Protocol is TLSv1.1" \
1209 -c "Protocol is TLSv1.1"
1210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001211run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001212 "$P_SRV max_version=tls1_1" \
1213 "$P_CLI" \
1214 0 \
1215 -S "ssl_handshake returned" \
1216 -C "ssl_handshake returned" \
1217 -s "Protocol is TLSv1.1" \
1218 -c "Protocol is TLSv1.1"
1219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001220run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001221 "$P_SRV max_version=tls1_1" \
1222 "$P_CLI max_version=tls1_1" \
1223 0 \
1224 -S "ssl_handshake returned" \
1225 -C "ssl_handshake returned" \
1226 -s "Protocol is TLSv1.1" \
1227 -c "Protocol is TLSv1.1"
1228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001230 "$P_SRV min_version=tls1_1" \
1231 "$P_CLI max_version=tls1_1" \
1232 0 \
1233 -S "ssl_handshake returned" \
1234 -C "ssl_handshake returned" \
1235 -s "Protocol is TLSv1.1" \
1236 -c "Protocol is TLSv1.1"
1237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001238run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001239 "$P_SRV max_version=tls1_1" \
1240 "$P_CLI min_version=tls1_1" \
1241 0 \
1242 -S "ssl_handshake returned" \
1243 -C "ssl_handshake returned" \
1244 -s "Protocol is TLSv1.1" \
1245 -c "Protocol is TLSv1.1"
1246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001247run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001248 "$P_SRV max_version=tls1_1" \
1249 "$P_CLI min_version=tls1_2" \
1250 1 \
1251 -s "ssl_handshake returned" \
1252 -c "ssl_handshake returned" \
1253 -c "SSL - Handshake protocol not within min/max boundaries"
1254
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001255run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001256 "$P_SRV min_version=tls1_2" \
1257 "$P_CLI max_version=tls1_1" \
1258 1 \
1259 -s "ssl_handshake returned" \
1260 -c "ssl_handshake returned" \
1261 -s "SSL - Handshake protocol not within min/max boundaries"
1262
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001263# Tests for ALPN extension
1264
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001265if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001267run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001268 "$P_SRV debug_level=3" \
1269 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001270 0 \
1271 -C "client hello, adding alpn extension" \
1272 -S "found alpn extension" \
1273 -C "got an alert message, type: \\[2:120]" \
1274 -S "server hello, adding alpn extension" \
1275 -C "found alpn extension " \
1276 -C "Application Layer Protocol is" \
1277 -S "Application Layer Protocol is"
1278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001279run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001280 "$P_SRV debug_level=3" \
1281 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001282 0 \
1283 -c "client hello, adding alpn extension" \
1284 -s "found alpn extension" \
1285 -C "got an alert message, type: \\[2:120]" \
1286 -S "server hello, adding alpn extension" \
1287 -C "found alpn extension " \
1288 -c "Application Layer Protocol is (none)" \
1289 -S "Application Layer Protocol is"
1290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001291run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001292 "$P_SRV debug_level=3 alpn=abc,1234" \
1293 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001294 0 \
1295 -C "client hello, adding alpn extension" \
1296 -S "found alpn extension" \
1297 -C "got an alert message, type: \\[2:120]" \
1298 -S "server hello, adding alpn extension" \
1299 -C "found alpn extension " \
1300 -C "Application Layer Protocol is" \
1301 -s "Application Layer Protocol is (none)"
1302
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001303run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001304 "$P_SRV debug_level=3 alpn=abc,1234" \
1305 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001306 0 \
1307 -c "client hello, adding alpn extension" \
1308 -s "found alpn extension" \
1309 -C "got an alert message, type: \\[2:120]" \
1310 -s "server hello, adding alpn extension" \
1311 -c "found alpn extension" \
1312 -c "Application Layer Protocol is abc" \
1313 -s "Application Layer Protocol is abc"
1314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001315run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001316 "$P_SRV debug_level=3 alpn=abc,1234" \
1317 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001318 0 \
1319 -c "client hello, adding alpn extension" \
1320 -s "found alpn extension" \
1321 -C "got an alert message, type: \\[2:120]" \
1322 -s "server hello, adding alpn extension" \
1323 -c "found alpn extension" \
1324 -c "Application Layer Protocol is abc" \
1325 -s "Application Layer Protocol is abc"
1326
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001327run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001328 "$P_SRV debug_level=3 alpn=abc,1234" \
1329 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001330 0 \
1331 -c "client hello, adding alpn extension" \
1332 -s "found alpn extension" \
1333 -C "got an alert message, type: \\[2:120]" \
1334 -s "server hello, adding alpn extension" \
1335 -c "found alpn extension" \
1336 -c "Application Layer Protocol is 1234" \
1337 -s "Application Layer Protocol is 1234"
1338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001339run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001340 "$P_SRV debug_level=3 alpn=abc,123" \
1341 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001342 1 \
1343 -c "client hello, adding alpn extension" \
1344 -s "found alpn extension" \
1345 -c "got an alert message, type: \\[2:120]" \
1346 -S "server hello, adding alpn extension" \
1347 -C "found alpn extension" \
1348 -C "Application Layer Protocol is 1234" \
1349 -S "Application Layer Protocol is 1234"
1350
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001351fi
1352
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001353# Tests for keyUsage in leaf certificates, part 1:
1354# server-side certificate/suite selection
1355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001356run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001357 "$P_SRV key_file=data_files/server2.key \
1358 crt_file=data_files/server2.ku-ds.crt" \
1359 "$P_CLI" \
1360 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001361 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001362
1363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001364run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001365 "$P_SRV key_file=data_files/server2.key \
1366 crt_file=data_files/server2.ku-ke.crt" \
1367 "$P_CLI" \
1368 0 \
1369 -c "Ciphersuite is TLS-RSA-WITH-"
1370
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001371run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001372 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001373 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001374 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001375 1 \
1376 -C "Ciphersuite is "
1377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001378run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001379 "$P_SRV key_file=data_files/server5.key \
1380 crt_file=data_files/server5.ku-ds.crt" \
1381 "$P_CLI" \
1382 0 \
1383 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1384
1385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001386run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001387 "$P_SRV key_file=data_files/server5.key \
1388 crt_file=data_files/server5.ku-ka.crt" \
1389 "$P_CLI" \
1390 0 \
1391 -c "Ciphersuite is TLS-ECDH-"
1392
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001393run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001394 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001395 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001396 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001397 1 \
1398 -C "Ciphersuite is "
1399
1400# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001401# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001403run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001404 "$O_SRV -key data_files/server2.key \
1405 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001406 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001407 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1408 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001409 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001410 -C "Processing of the Certificate handshake message failed" \
1411 -c "Ciphersuite is TLS-"
1412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001413run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001414 "$O_SRV -key data_files/server2.key \
1415 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001416 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001417 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1418 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001419 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001420 -C "Processing of the Certificate handshake message failed" \
1421 -c "Ciphersuite is TLS-"
1422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001423run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001424 "$O_SRV -key data_files/server2.key \
1425 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001426 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001427 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1428 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001429 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001430 -C "Processing of the Certificate handshake message failed" \
1431 -c "Ciphersuite is TLS-"
1432
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001433run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001434 "$O_SRV -key data_files/server2.key \
1435 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001436 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001437 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1438 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001439 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001440 -c "Processing of the Certificate handshake message failed" \
1441 -C "Ciphersuite is TLS-"
1442
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001443run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001444 "$O_SRV -key data_files/server2.key \
1445 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001446 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001447 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1448 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001449 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001450 -C "Processing of the Certificate handshake message failed" \
1451 -c "Ciphersuite is TLS-"
1452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001453run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001454 "$O_SRV -key data_files/server2.key \
1455 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001456 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001457 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1458 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001459 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001460 -c "Processing of the Certificate handshake message failed" \
1461 -C "Ciphersuite is TLS-"
1462
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001463# Tests for keyUsage in leaf certificates, part 3:
1464# server-side checking of client cert
1465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001466run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001467 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001468 "$O_CLI -key data_files/server2.key \
1469 -cert data_files/server2.ku-ds.crt" \
1470 0 \
1471 -S "bad certificate (usage extensions)" \
1472 -S "Processing of the Certificate handshake message failed"
1473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001474run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001475 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001476 "$O_CLI -key data_files/server2.key \
1477 -cert data_files/server2.ku-ke.crt" \
1478 0 \
1479 -s "bad certificate (usage extensions)" \
1480 -S "Processing of the Certificate handshake message failed"
1481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001482run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001483 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001484 "$O_CLI -key data_files/server2.key \
1485 -cert data_files/server2.ku-ke.crt" \
1486 1 \
1487 -s "bad certificate (usage extensions)" \
1488 -s "Processing of the Certificate handshake message failed"
1489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001490run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001491 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001492 "$O_CLI -key data_files/server5.key \
1493 -cert data_files/server5.ku-ds.crt" \
1494 0 \
1495 -S "bad certificate (usage extensions)" \
1496 -S "Processing of the Certificate handshake message failed"
1497
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001498run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001499 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001500 "$O_CLI -key data_files/server5.key \
1501 -cert data_files/server5.ku-ka.crt" \
1502 0 \
1503 -s "bad certificate (usage extensions)" \
1504 -S "Processing of the Certificate handshake message failed"
1505
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001506# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001508run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001509 "$P_SRV key_file=data_files/server5.key \
1510 crt_file=data_files/server5.eku-srv.crt" \
1511 "$P_CLI" \
1512 0
1513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001514run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001515 "$P_SRV key_file=data_files/server5.key \
1516 crt_file=data_files/server5.eku-srv.crt" \
1517 "$P_CLI" \
1518 0
1519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001520run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001521 "$P_SRV key_file=data_files/server5.key \
1522 crt_file=data_files/server5.eku-cs_any.crt" \
1523 "$P_CLI" \
1524 0
1525
1526# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001527run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001528 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1529 crt_file=data_files/server5.eku-cli.crt" \
1530 "$P_CLI psk=badbad" \
1531 1
1532
1533# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1534
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001535run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001536 "$O_SRV -key data_files/server5.key \
1537 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001538 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001539 0 \
1540 -C "bad certificate (usage extensions)" \
1541 -C "Processing of the Certificate handshake message failed" \
1542 -c "Ciphersuite is TLS-"
1543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001544run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001545 "$O_SRV -key data_files/server5.key \
1546 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001547 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001548 0 \
1549 -C "bad certificate (usage extensions)" \
1550 -C "Processing of the Certificate handshake message failed" \
1551 -c "Ciphersuite is TLS-"
1552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001553run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001554 "$O_SRV -key data_files/server5.key \
1555 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001556 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001557 0 \
1558 -C "bad certificate (usage extensions)" \
1559 -C "Processing of the Certificate handshake message failed" \
1560 -c "Ciphersuite is TLS-"
1561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001562run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001563 "$O_SRV -key data_files/server5.key \
1564 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001565 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001566 1 \
1567 -c "bad certificate (usage extensions)" \
1568 -c "Processing of the Certificate handshake message failed" \
1569 -C "Ciphersuite is TLS-"
1570
1571# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001573run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001574 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001575 "$O_CLI -key data_files/server5.key \
1576 -cert data_files/server5.eku-cli.crt" \
1577 0 \
1578 -S "bad certificate (usage extensions)" \
1579 -S "Processing of the Certificate handshake message failed"
1580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001581run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001582 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001583 "$O_CLI -key data_files/server5.key \
1584 -cert data_files/server5.eku-srv_cli.crt" \
1585 0 \
1586 -S "bad certificate (usage extensions)" \
1587 -S "Processing of the Certificate handshake message failed"
1588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001589run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001590 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001591 "$O_CLI -key data_files/server5.key \
1592 -cert data_files/server5.eku-cs_any.crt" \
1593 0 \
1594 -S "bad certificate (usage extensions)" \
1595 -S "Processing of the Certificate handshake message failed"
1596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001597run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001598 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001599 "$O_CLI -key data_files/server5.key \
1600 -cert data_files/server5.eku-cs.crt" \
1601 0 \
1602 -s "bad certificate (usage extensions)" \
1603 -S "Processing of the Certificate handshake message failed"
1604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001605run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001606 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001607 "$O_CLI -key data_files/server5.key \
1608 -cert data_files/server5.eku-cs.crt" \
1609 1 \
1610 -s "bad certificate (usage extensions)" \
1611 -s "Processing of the Certificate handshake message failed"
1612
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001613# Tests for DHM parameters loading
1614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001615run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001616 "$P_SRV" \
1617 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1618 debug_level=3" \
1619 0 \
1620 -c "value of 'DHM: P ' (2048 bits)" \
1621 -c "value of 'DHM: G ' (2048 bits)"
1622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001623run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001624 "$P_SRV dhm_file=data_files/dhparams.pem" \
1625 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1626 debug_level=3" \
1627 0 \
1628 -c "value of 'DHM: P ' (1024 bits)" \
1629 -c "value of 'DHM: G ' (2 bits)"
1630
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001631# Tests for PSK callback
1632
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001633run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001634 "$P_SRV psk=abc123 psk_identity=foo" \
1635 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1636 psk_identity=foo psk=abc123" \
1637 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001638 -S "SSL - The server has no ciphersuites in common" \
1639 -S "SSL - Unknown identity received" \
1640 -S "SSL - Verification of the message MAC failed"
1641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001642run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001643 "$P_SRV" \
1644 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1645 psk_identity=foo psk=abc123" \
1646 1 \
1647 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001648 -S "SSL - Unknown identity received" \
1649 -S "SSL - Verification of the message MAC failed"
1650
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001651run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001652 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1653 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1654 psk_identity=foo psk=abc123" \
1655 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001656 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001657 -s "SSL - Unknown identity received" \
1658 -S "SSL - Verification of the message MAC failed"
1659
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001660run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001661 "$P_SRV psk_list=abc,dead,def,beef" \
1662 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1663 psk_identity=abc psk=dead" \
1664 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001665 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001666 -S "SSL - Unknown identity received" \
1667 -S "SSL - Verification of the message MAC failed"
1668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001669run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001670 "$P_SRV psk_list=abc,dead,def,beef" \
1671 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1672 psk_identity=def psk=beef" \
1673 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001674 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001675 -S "SSL - Unknown identity received" \
1676 -S "SSL - Verification of the message MAC failed"
1677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001678run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001679 "$P_SRV psk_list=abc,dead,def,beef" \
1680 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1681 psk_identity=ghi psk=beef" \
1682 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001683 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001684 -s "SSL - Unknown identity received" \
1685 -S "SSL - Verification of the message MAC failed"
1686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001687run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001688 "$P_SRV psk_list=abc,dead,def,beef" \
1689 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1690 psk_identity=abc psk=beef" \
1691 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001692 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001693 -S "SSL - Unknown identity received" \
1694 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001695
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001696# Tests for ciphersuites per version
1697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001698run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001699 "$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" \
1700 "$P_CLI force_version=ssl3" \
1701 0 \
1702 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1703
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001704run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001705 "$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" \
1706 "$P_CLI force_version=tls1" \
1707 0 \
1708 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1709
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001710run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001711 "$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" \
1712 "$P_CLI force_version=tls1_1" \
1713 0 \
1714 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001716run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001717 "$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" \
1718 "$P_CLI force_version=tls1_2" \
1719 0 \
1720 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1721
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001722# Tests for ssl_get_bytes_avail()
1723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001724run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001725 "$P_SRV" \
1726 "$P_CLI request_size=100" \
1727 0 \
1728 -s "Read from client: 100 bytes read$"
1729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001730run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001731 "$P_SRV" \
1732 "$P_CLI request_size=500" \
1733 0 \
1734 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001735
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001736# Tests for small packets
1737
1738run_test "Small packet SSLv3 BlockCipher" \
1739 "$P_SRV" \
1740 "$P_CLI request_size=1 force_version=ssl3 \
1741 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1742 0 \
1743 -s "Read from client: 1 bytes read"
1744
1745run_test "Small packet SSLv3 StreamCipher" \
1746 "$P_SRV" \
1747 "$P_CLI request_size=1 force_version=ssl3 \
1748 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1749 0 \
1750 -s "Read from client: 1 bytes read"
1751
1752run_test "Small packet TLS 1.0 BlockCipher" \
1753 "$P_SRV" \
1754 "$P_CLI request_size=1 force_version=tls1 \
1755 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1756 0 \
1757 -s "Read from client: 1 bytes read"
1758
1759run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1760 "$P_SRV" \
1761 "$P_CLI request_size=1 force_version=tls1 \
1762 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1763 trunc_hmac=1" \
1764 0 \
1765 -s "Read from client: 1 bytes read"
1766
1767run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1768 "$P_SRV" \
1769 "$P_CLI request_size=1 force_version=tls1 \
1770 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1771 trunc_hmac=1" \
1772 0 \
1773 -s "Read from client: 1 bytes read"
1774
1775run_test "Small packet TLS 1.1 BlockCipher" \
1776 "$P_SRV" \
1777 "$P_CLI request_size=1 force_version=tls1_1 \
1778 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1779 0 \
1780 -s "Read from client: 1 bytes read"
1781
1782run_test "Small packet TLS 1.1 StreamCipher" \
1783 "$P_SRV" \
1784 "$P_CLI request_size=1 force_version=tls1_1 \
1785 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1786 0 \
1787 -s "Read from client: 1 bytes read"
1788
1789run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1790 "$P_SRV" \
1791 "$P_CLI request_size=1 force_version=tls1_1 \
1792 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1793 trunc_hmac=1" \
1794 0 \
1795 -s "Read from client: 1 bytes read"
1796
1797run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1798 "$P_SRV" \
1799 "$P_CLI request_size=1 force_version=tls1_1 \
1800 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1801 trunc_hmac=1" \
1802 0 \
1803 -s "Read from client: 1 bytes read"
1804
1805run_test "Small packet TLS 1.2 BlockCipher" \
1806 "$P_SRV" \
1807 "$P_CLI request_size=1 force_version=tls1_2 \
1808 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1809 0 \
1810 -s "Read from client: 1 bytes read"
1811
1812run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1813 "$P_SRV" \
1814 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1815 0 \
1816 -s "Read from client: 1 bytes read"
1817
1818run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1819 "$P_SRV" \
1820 "$P_CLI request_size=1 force_version=tls1_2 \
1821 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1822 trunc_hmac=1" \
1823 0 \
1824 -s "Read from client: 1 bytes read"
1825
1826run_test "Small packet TLS 1.2 StreamCipher" \
1827 "$P_SRV" \
1828 "$P_CLI request_size=1 force_version=tls1_2 \
1829 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1830 0 \
1831 -s "Read from client: 1 bytes read"
1832
1833run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1834 "$P_SRV" \
1835 "$P_CLI request_size=1 force_version=tls1_2 \
1836 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1837 trunc_hmac=1" \
1838 0 \
1839 -s "Read from client: 1 bytes read"
1840
1841run_test "Small packet TLS 1.2 AEAD" \
1842 "$P_SRV" \
1843 "$P_CLI request_size=1 force_version=tls1_2 \
1844 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1845 0 \
1846 -s "Read from client: 1 bytes read"
1847
1848run_test "Small packet TLS 1.2 AEAD shorter tag" \
1849 "$P_SRV" \
1850 "$P_CLI request_size=1 force_version=tls1_2 \
1851 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1852 0 \
1853 -s "Read from client: 1 bytes read"
1854
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001855# Test for large packets
1856
1857run_test "Large packet SSLv3 BlockCipher" \
1858 "$P_SRV" \
1859 "$P_CLI request_size=16384 force_version=ssl3 \
1860 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1861 0 \
1862 -s "Read from client: 16384 bytes read"
1863
1864run_test "Large packet SSLv3 StreamCipher" \
1865 "$P_SRV" \
1866 "$P_CLI request_size=16384 force_version=ssl3 \
1867 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1868 0 \
1869 -s "Read from client: 16384 bytes read"
1870
1871run_test "Large packet TLS 1.0 BlockCipher" \
1872 "$P_SRV" \
1873 "$P_CLI request_size=16384 force_version=tls1 \
1874 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1875 0 \
1876 -s "Read from client: 16384 bytes read"
1877
1878run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1879 "$P_SRV" \
1880 "$P_CLI request_size=16384 force_version=tls1 \
1881 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1882 trunc_hmac=1" \
1883 0 \
1884 -s "Read from client: 16384 bytes read"
1885
1886run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1887 "$P_SRV" \
1888 "$P_CLI request_size=16384 force_version=tls1 \
1889 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1890 trunc_hmac=1" \
1891 0 \
1892 -s "Read from client: 16384 bytes read"
1893
1894run_test "Large packet TLS 1.1 BlockCipher" \
1895 "$P_SRV" \
1896 "$P_CLI request_size=16384 force_version=tls1_1 \
1897 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1898 0 \
1899 -s "Read from client: 16384 bytes read"
1900
1901run_test "Large packet TLS 1.1 StreamCipher" \
1902 "$P_SRV" \
1903 "$P_CLI request_size=16384 force_version=tls1_1 \
1904 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1905 0 \
1906 -s "Read from client: 16384 bytes read"
1907
1908run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1909 "$P_SRV" \
1910 "$P_CLI request_size=16384 force_version=tls1_1 \
1911 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1912 trunc_hmac=1" \
1913 0 \
1914 -s "Read from client: 16384 bytes read"
1915
1916run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1917 "$P_SRV" \
1918 "$P_CLI request_size=16384 force_version=tls1_1 \
1919 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1920 trunc_hmac=1" \
1921 0 \
1922 -s "Read from client: 16384 bytes read"
1923
1924run_test "Large packet TLS 1.2 BlockCipher" \
1925 "$P_SRV" \
1926 "$P_CLI request_size=16384 force_version=tls1_2 \
1927 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1928 0 \
1929 -s "Read from client: 16384 bytes read"
1930
1931run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1932 "$P_SRV" \
1933 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1934 0 \
1935 -s "Read from client: 16384 bytes read"
1936
1937run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1938 "$P_SRV" \
1939 "$P_CLI request_size=16384 force_version=tls1_2 \
1940 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1941 trunc_hmac=1" \
1942 0 \
1943 -s "Read from client: 16384 bytes read"
1944
1945run_test "Large packet TLS 1.2 StreamCipher" \
1946 "$P_SRV" \
1947 "$P_CLI request_size=16384 force_version=tls1_2 \
1948 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1949 0 \
1950 -s "Read from client: 16384 bytes read"
1951
1952run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1953 "$P_SRV" \
1954 "$P_CLI request_size=16384 force_version=tls1_2 \
1955 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1956 trunc_hmac=1" \
1957 0 \
1958 -s "Read from client: 16384 bytes read"
1959
1960run_test "Large packet TLS 1.2 AEAD" \
1961 "$P_SRV" \
1962 "$P_CLI request_size=16384 force_version=tls1_2 \
1963 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1964 0 \
1965 -s "Read from client: 16384 bytes read"
1966
1967run_test "Large packet TLS 1.2 AEAD shorter tag" \
1968 "$P_SRV" \
1969 "$P_CLI request_size=16384 force_version=tls1_2 \
1970 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1971 0 \
1972 -s "Read from client: 16384 bytes read"
1973
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001974# Final report
1975
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001976echo "------------------------------------------------------------------------"
1977
1978if [ $FAILS = 0 ]; then
1979 echo -n "PASSED"
1980else
1981 echo -n "FAILED"
1982fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02001983PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001984echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001985
1986exit $FAILS