blob: 38bc89b7a9e4810c761c3639a903e41b16867d13 [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é-Gonnardb575b542014-10-24 15:12:31 +0200478run_test "Extended Master Secret: client SSLv3, server enabled" \
479 "$P_SRV debug_level=3" \
480 "$P_CLI debug_level=3 force_version=ssl3" \
481 0 \
482 -C "client hello, adding extended_master_secret extension" \
483 -S "found extended master secret extension" \
484 -S "server hello, adding extended master secret extension" \
485 -C "found extended_master_secret extension" \
486 -C "using extended master secret" \
487 -S "using extended master secret"
488
489run_test "Extended Master Secret: client enabled, server SSLv3" \
490 "$P_SRV debug_level=3 force_version=ssl3" \
491 "$P_CLI debug_level=3" \
492 0 \
493 -c "client hello, adding extended_master_secret extension" \
494 -s "found extended master secret extension" \
495 -S "server hello, adding extended master secret extension" \
496 -C "found extended_master_secret extension" \
497 -C "using extended master secret" \
498 -S "using extended master secret"
499
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200500# Tests for FALLBACK_SCSV
501
502run_test "Fallback SCSV: default" \
503 "$P_SRV" \
504 "$P_CLI debug_level=3 force_version=tls1_1" \
505 0 \
506 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200507 -S "received FALLBACK_SCSV" \
508 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200509 -C "is a fatal alert message (msg 86)"
510
511run_test "Fallback SCSV: explicitly disabled" \
512 "$P_SRV" \
513 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
514 0 \
515 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200516 -S "received FALLBACK_SCSV" \
517 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200518 -C "is a fatal alert message (msg 86)"
519
520run_test "Fallback SCSV: enabled" \
521 "$P_SRV" \
522 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200523 1 \
524 -c "adding FALLBACK_SCSV" \
525 -s "received FALLBACK_SCSV" \
526 -s "inapropriate fallback" \
527 -c "is a fatal alert message (msg 86)"
528
529run_test "Fallback SCSV: enabled, max version" \
530 "$P_SRV" \
531 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200532 0 \
533 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200534 -s "received FALLBACK_SCSV" \
535 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200536 -C "is a fatal alert message (msg 86)"
537
538requires_openssl_with_fallback_scsv
539run_test "Fallback SCSV: default, openssl server" \
540 "$O_SRV" \
541 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
542 0 \
543 -C "adding FALLBACK_SCSV" \
544 -C "is a fatal alert message (msg 86)"
545
546requires_openssl_with_fallback_scsv
547run_test "Fallback SCSV: enabled, openssl server" \
548 "$O_SRV" \
549 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
550 1 \
551 -c "adding FALLBACK_SCSV" \
552 -c "is a fatal alert message (msg 86)"
553
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200554requires_openssl_with_fallback_scsv
555run_test "Fallback SCSV: disabled, openssl client" \
556 "$P_SRV" \
557 "$O_CLI -tls1_1" \
558 0 \
559 -S "received FALLBACK_SCSV" \
560 -S "inapropriate fallback"
561
562requires_openssl_with_fallback_scsv
563run_test "Fallback SCSV: enabled, openssl client" \
564 "$P_SRV" \
565 "$O_CLI -tls1_1 -fallback_scsv" \
566 1 \
567 -s "received FALLBACK_SCSV" \
568 -s "inapropriate fallback"
569
570requires_openssl_with_fallback_scsv
571run_test "Fallback SCSV: enabled, max version, openssl client" \
572 "$P_SRV" \
573 "$O_CLI -fallback_scsv" \
574 0 \
575 -s "received FALLBACK_SCSV" \
576 -S "inapropriate fallback"
577
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100578# Tests for Session Tickets
579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200580run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200581 "$P_SRV debug_level=3 tickets=1" \
582 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100583 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100584 -c "client hello, adding session ticket extension" \
585 -s "found session ticket extension" \
586 -s "server hello, adding session ticket extension" \
587 -c "found session_ticket extension" \
588 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100589 -S "session successfully restored from cache" \
590 -s "session successfully restored from ticket" \
591 -s "a session has been resumed" \
592 -c "a session has been resumed"
593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200594run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200595 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
596 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100597 0 \
598 -c "client hello, adding session ticket extension" \
599 -s "found session ticket extension" \
600 -s "server hello, adding session ticket extension" \
601 -c "found session_ticket extension" \
602 -c "parse new session ticket" \
603 -S "session successfully restored from cache" \
604 -s "session successfully restored from ticket" \
605 -s "a session has been resumed" \
606 -c "a session has been resumed"
607
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200608run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200609 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
610 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100611 0 \
612 -c "client hello, adding session ticket extension" \
613 -s "found session ticket extension" \
614 -s "server hello, adding session ticket extension" \
615 -c "found session_ticket extension" \
616 -c "parse new session ticket" \
617 -S "session successfully restored from cache" \
618 -S "session successfully restored from ticket" \
619 -S "a session has been resumed" \
620 -C "a session has been resumed"
621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200622run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100623 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200624 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100625 0 \
626 -c "client hello, adding session ticket extension" \
627 -c "found session_ticket extension" \
628 -c "parse new session ticket" \
629 -c "a session has been resumed"
630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200631run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200632 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200633 "( $O_CLI -sess_out $SESSION; \
634 $O_CLI -sess_in $SESSION; \
635 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100636 0 \
637 -s "found session ticket extension" \
638 -s "server hello, adding session ticket extension" \
639 -S "session successfully restored from cache" \
640 -s "session successfully restored from ticket" \
641 -s "a session has been resumed"
642
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100643# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200645run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200646 "$P_SRV debug_level=3 tickets=0" \
647 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100648 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100649 -c "client hello, adding session ticket extension" \
650 -s "found session ticket extension" \
651 -S "server hello, adding session ticket extension" \
652 -C "found session_ticket extension" \
653 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100654 -s "session successfully restored from cache" \
655 -S "session successfully restored from ticket" \
656 -s "a session has been resumed" \
657 -c "a session has been resumed"
658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200659run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200660 "$P_SRV debug_level=3 tickets=1" \
661 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100662 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100663 -C "client hello, adding session ticket extension" \
664 -S "found session ticket extension" \
665 -S "server hello, adding session ticket extension" \
666 -C "found session_ticket extension" \
667 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100668 -s "session successfully restored from cache" \
669 -S "session successfully restored from ticket" \
670 -s "a session has been resumed" \
671 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100672
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200673run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200674 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
675 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100676 0 \
677 -S "session successfully restored from cache" \
678 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100679 -S "a session has been resumed" \
680 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200682run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200683 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
684 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100685 0 \
686 -s "session successfully restored from cache" \
687 -S "session successfully restored from ticket" \
688 -s "a session has been resumed" \
689 -c "a session has been resumed"
690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200691run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200692 "$P_SRV debug_level=3 tickets=0" \
693 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100694 0 \
695 -s "session successfully restored from cache" \
696 -S "session successfully restored from ticket" \
697 -s "a session has been resumed" \
698 -c "a session has been resumed"
699
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200700run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200701 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
702 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100703 0 \
704 -S "session successfully restored from cache" \
705 -S "session successfully restored from ticket" \
706 -S "a session has been resumed" \
707 -C "a session has been resumed"
708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200709run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200710 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
711 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100712 0 \
713 -s "session successfully restored from cache" \
714 -S "session successfully restored from ticket" \
715 -s "a session has been resumed" \
716 -c "a session has been resumed"
717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200718run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200719 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200720 "( $O_CLI -sess_out $SESSION; \
721 $O_CLI -sess_in $SESSION; \
722 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100723 0 \
724 -s "found session ticket extension" \
725 -S "server hello, adding session ticket extension" \
726 -s "session successfully restored from cache" \
727 -S "session successfully restored from ticket" \
728 -s "a session has been resumed"
729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200730run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100731 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200732 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100733 0 \
734 -C "found session_ticket extension" \
735 -C "parse new session ticket" \
736 -c "a session has been resumed"
737
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100738# Tests for Max Fragment Length extension
739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200740run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200741 "$P_SRV debug_level=3" \
742 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100743 0 \
744 -C "client hello, adding max_fragment_length extension" \
745 -S "found max fragment length extension" \
746 -S "server hello, max_fragment_length extension" \
747 -C "found max_fragment_length extension"
748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200749run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200750 "$P_SRV debug_level=3" \
751 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100752 0 \
753 -c "client hello, adding max_fragment_length extension" \
754 -s "found max fragment length extension" \
755 -s "server hello, max_fragment_length extension" \
756 -c "found max_fragment_length extension"
757
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200758run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200759 "$P_SRV debug_level=3 max_frag_len=4096" \
760 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100761 0 \
762 -C "client hello, adding max_fragment_length extension" \
763 -S "found max fragment length extension" \
764 -S "server hello, max_fragment_length extension" \
765 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100766
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200767requires_gnutls
768run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200769 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200770 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200771 0 \
772 -c "client hello, adding max_fragment_length extension" \
773 -c "found max_fragment_length extension"
774
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100775# Tests for renegotiation
776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200777run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200778 "$P_SRV debug_level=3 exchanges=2" \
779 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100780 0 \
781 -C "client hello, adding renegotiation extension" \
782 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
783 -S "found renegotiation extension" \
784 -s "server hello, secure renegotiation extension" \
785 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100786 -C "=> renegotiate" \
787 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100788 -S "write hello request"
789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200790run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200791 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
792 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100793 0 \
794 -c "client hello, adding renegotiation extension" \
795 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
796 -s "found renegotiation extension" \
797 -s "server hello, secure renegotiation extension" \
798 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100799 -c "=> renegotiate" \
800 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100801 -S "write hello request"
802
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200803run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200804 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
805 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100806 0 \
807 -c "client hello, adding renegotiation extension" \
808 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
809 -s "found renegotiation extension" \
810 -s "server hello, secure renegotiation extension" \
811 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100812 -c "=> renegotiate" \
813 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100814 -s "write hello request"
815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200816run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200817 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
818 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100819 0 \
820 -c "client hello, adding renegotiation extension" \
821 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
822 -s "found renegotiation extension" \
823 -s "server hello, secure renegotiation extension" \
824 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100825 -c "=> renegotiate" \
826 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100827 -s "write hello request"
828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200829run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200830 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
831 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100832 1 \
833 -c "client hello, adding renegotiation extension" \
834 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
835 -S "found renegotiation extension" \
836 -s "server hello, secure renegotiation extension" \
837 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100838 -c "=> renegotiate" \
839 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200840 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200841 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200842 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200844run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200845 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
846 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100847 0 \
848 -C "client hello, adding renegotiation extension" \
849 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
850 -S "found renegotiation extension" \
851 -s "server hello, secure renegotiation extension" \
852 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100853 -C "=> renegotiate" \
854 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100855 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200856 -S "SSL - An unexpected message was received from our peer" \
857 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200859run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200860 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200861 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200862 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200863 0 \
864 -C "client hello, adding renegotiation extension" \
865 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
866 -S "found renegotiation extension" \
867 -s "server hello, secure renegotiation extension" \
868 -c "found renegotiation extension" \
869 -C "=> renegotiate" \
870 -S "=> renegotiate" \
871 -s "write hello request" \
872 -S "SSL - An unexpected message was received from our peer" \
873 -S "failed"
874
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200875# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200876run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200877 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200878 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200879 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200880 0 \
881 -C "client hello, adding renegotiation extension" \
882 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
883 -S "found renegotiation extension" \
884 -s "server hello, secure renegotiation extension" \
885 -c "found renegotiation extension" \
886 -C "=> renegotiate" \
887 -S "=> renegotiate" \
888 -s "write hello request" \
889 -S "SSL - An unexpected message was received from our peer" \
890 -S "failed"
891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200892run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200893 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200894 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200895 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200896 0 \
897 -C "client hello, adding renegotiation extension" \
898 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
899 -S "found renegotiation extension" \
900 -s "server hello, secure renegotiation extension" \
901 -c "found renegotiation extension" \
902 -C "=> renegotiate" \
903 -S "=> renegotiate" \
904 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200905 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200907run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200908 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200909 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200910 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200911 0 \
912 -c "client hello, adding renegotiation extension" \
913 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
914 -s "found renegotiation extension" \
915 -s "server hello, secure renegotiation extension" \
916 -c "found renegotiation extension" \
917 -c "=> renegotiate" \
918 -s "=> renegotiate" \
919 -s "write hello request" \
920 -S "SSL - An unexpected message was received from our peer" \
921 -S "failed"
922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200923run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200924 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
925 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200926 0 \
927 -c "client hello, adding renegotiation extension" \
928 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
929 -s "found renegotiation extension" \
930 -s "server hello, secure renegotiation extension" \
931 -c "found renegotiation extension" \
932 -c "=> renegotiate" \
933 -s "=> renegotiate" \
934 -S "write hello request"
935
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200936run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200937 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
938 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200939 0 \
940 -c "client hello, adding renegotiation extension" \
941 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
942 -s "found renegotiation extension" \
943 -s "server hello, secure renegotiation extension" \
944 -c "found renegotiation extension" \
945 -c "=> renegotiate" \
946 -s "=> renegotiate" \
947 -s "write hello request"
948
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200949run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200950 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200951 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200952 0 \
953 -c "client hello, adding renegotiation extension" \
954 -c "found renegotiation extension" \
955 -c "=> renegotiate" \
956 -C "ssl_handshake returned" \
957 -C "error" \
958 -c "HTTP/1.0 200 [Oo][Kk]"
959
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200960run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200961 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200962 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200963 0 \
964 -c "client hello, adding renegotiation extension" \
965 -c "found renegotiation extension" \
966 -c "=> renegotiate" \
967 -C "ssl_handshake returned" \
968 -C "error" \
969 -c "HTTP/1.0 200 [Oo][Kk]"
970
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100971# Tests for auth_mode
972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200973run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100974 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100975 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200976 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100977 1 \
978 -c "x509_verify_cert() returned" \
979 -c "! self-signed or not signed by a trusted CA" \
980 -c "! ssl_handshake returned" \
981 -c "X509 - Certificate verification failed"
982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200983run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100984 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100985 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200986 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100987 0 \
988 -c "x509_verify_cert() returned" \
989 -c "! self-signed or not signed by a trusted CA" \
990 -C "! ssl_handshake returned" \
991 -C "X509 - Certificate verification failed"
992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200993run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100994 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100995 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200996 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100997 0 \
998 -C "x509_verify_cert() returned" \
999 -C "! self-signed or not signed by a trusted CA" \
1000 -C "! ssl_handshake returned" \
1001 -C "X509 - Certificate verification failed"
1002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001003run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001004 "$P_SRV debug_level=3 auth_mode=required" \
1005 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001006 key_file=data_files/server5.key" \
1007 1 \
1008 -S "skip write certificate request" \
1009 -C "skip parse certificate request" \
1010 -c "got a certificate request" \
1011 -C "skip write certificate" \
1012 -C "skip write certificate verify" \
1013 -S "skip parse certificate verify" \
1014 -s "x509_verify_cert() returned" \
1015 -S "! self-signed or not signed by a trusted CA" \
1016 -s "! ssl_handshake returned" \
1017 -c "! ssl_handshake returned" \
1018 -s "X509 - Certificate verification failed"
1019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001020run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001021 "$P_SRV debug_level=3 auth_mode=optional" \
1022 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001023 key_file=data_files/server5.key" \
1024 0 \
1025 -S "skip write certificate request" \
1026 -C "skip parse certificate request" \
1027 -c "got a certificate request" \
1028 -C "skip write certificate" \
1029 -C "skip write certificate verify" \
1030 -S "skip parse certificate verify" \
1031 -s "x509_verify_cert() returned" \
1032 -s "! self-signed or not signed by a trusted CA" \
1033 -S "! ssl_handshake returned" \
1034 -C "! ssl_handshake returned" \
1035 -S "X509 - Certificate verification failed"
1036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001037run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001038 "$P_SRV debug_level=3 auth_mode=none" \
1039 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001040 key_file=data_files/server5.key" \
1041 0 \
1042 -s "skip write certificate request" \
1043 -C "skip parse certificate request" \
1044 -c "got no certificate request" \
1045 -c "skip write certificate" \
1046 -c "skip write certificate verify" \
1047 -s "skip parse certificate verify" \
1048 -S "x509_verify_cert() returned" \
1049 -S "! self-signed or not signed by a trusted CA" \
1050 -S "! ssl_handshake returned" \
1051 -C "! ssl_handshake returned" \
1052 -S "X509 - Certificate verification failed"
1053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001054run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001055 "$P_SRV debug_level=3 auth_mode=optional" \
1056 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001057 0 \
1058 -S "skip write certificate request" \
1059 -C "skip parse certificate request" \
1060 -c "got a certificate request" \
1061 -C "skip write certificate$" \
1062 -C "got no certificate to send" \
1063 -S "SSLv3 client has no certificate" \
1064 -c "skip write certificate verify" \
1065 -s "skip parse certificate verify" \
1066 -s "! no client certificate sent" \
1067 -S "! ssl_handshake returned" \
1068 -C "! ssl_handshake returned" \
1069 -S "X509 - Certificate verification failed"
1070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001071run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001072 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001073 "$O_CLI" \
1074 0 \
1075 -S "skip write certificate request" \
1076 -s "skip parse certificate verify" \
1077 -s "! no client certificate sent" \
1078 -S "! ssl_handshake returned" \
1079 -S "X509 - Certificate verification failed"
1080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001081run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001082 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001083 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001084 0 \
1085 -C "skip parse certificate request" \
1086 -c "got a certificate request" \
1087 -C "skip write certificate$" \
1088 -c "skip write certificate verify" \
1089 -C "! ssl_handshake returned"
1090
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001091run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001092 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1093 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001094 0 \
1095 -S "skip write certificate request" \
1096 -C "skip parse certificate request" \
1097 -c "got a certificate request" \
1098 -C "skip write certificate$" \
1099 -c "skip write certificate verify" \
1100 -c "got no certificate to send" \
1101 -s "SSLv3 client has no certificate" \
1102 -s "skip parse certificate verify" \
1103 -s "! no client certificate sent" \
1104 -S "! ssl_handshake returned" \
1105 -C "! ssl_handshake returned" \
1106 -S "X509 - Certificate verification failed"
1107
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001108# tests for SNI
1109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001110run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001111 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001112 crt_file=data_files/server5.crt key_file=data_files/server5.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é-Gonnard96ea2f22014-02-25 12:26:29 +01001114 server_name=localhost" \
1115 0 \
1116 -S "parse ServerName extension" \
1117 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1118 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001120run_test "SNI: matching cert 1" \
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é-Gonnard96ea2f22014-02-25 12:26:29 +01001125 server_name=localhost" \
1126 0 \
1127 -s "parse ServerName extension" \
1128 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1129 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1130
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001131run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001132 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001133 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001134 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 +01001135 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001136 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001137 0 \
1138 -s "parse ServerName extension" \
1139 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001140 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001142run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001143 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001144 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001145 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 +01001146 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001147 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001148 1 \
1149 -s "parse ServerName extension" \
1150 -s "ssl_sni_wrapper() returned" \
1151 -s "ssl_handshake returned" \
1152 -c "ssl_handshake returned" \
1153 -c "SSL - A fatal alert message was received from our peer"
1154
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001155# Tests for non-blocking I/O: exercise a variety of handshake flows
1156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001157run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001158 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1159 "$P_CLI nbio=2 tickets=0" \
1160 0 \
1161 -S "ssl_handshake returned" \
1162 -C "ssl_handshake returned" \
1163 -c "Read from server: .* bytes read"
1164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001165run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001166 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1167 "$P_CLI nbio=2 tickets=0" \
1168 0 \
1169 -S "ssl_handshake returned" \
1170 -C "ssl_handshake returned" \
1171 -c "Read from server: .* bytes read"
1172
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001173run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001174 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1175 "$P_CLI nbio=2 tickets=1" \
1176 0 \
1177 -S "ssl_handshake returned" \
1178 -C "ssl_handshake returned" \
1179 -c "Read from server: .* bytes read"
1180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001181run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001182 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1183 "$P_CLI nbio=2 tickets=1" \
1184 0 \
1185 -S "ssl_handshake returned" \
1186 -C "ssl_handshake returned" \
1187 -c "Read from server: .* bytes read"
1188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001189run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001190 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1191 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1192 0 \
1193 -S "ssl_handshake returned" \
1194 -C "ssl_handshake returned" \
1195 -c "Read from server: .* bytes read"
1196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001197run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001198 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1199 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1200 0 \
1201 -S "ssl_handshake returned" \
1202 -C "ssl_handshake returned" \
1203 -c "Read from server: .* bytes read"
1204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001205run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001206 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1207 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1208 0 \
1209 -S "ssl_handshake returned" \
1210 -C "ssl_handshake returned" \
1211 -c "Read from server: .* bytes read"
1212
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001213# Tests for version negotiation
1214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001215run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001216 "$P_SRV" \
1217 "$P_CLI" \
1218 0 \
1219 -S "ssl_handshake returned" \
1220 -C "ssl_handshake returned" \
1221 -s "Protocol is TLSv1.2" \
1222 -c "Protocol is TLSv1.2"
1223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001224run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001225 "$P_SRV" \
1226 "$P_CLI max_version=tls1_1" \
1227 0 \
1228 -S "ssl_handshake returned" \
1229 -C "ssl_handshake returned" \
1230 -s "Protocol is TLSv1.1" \
1231 -c "Protocol is TLSv1.1"
1232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001233run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001234 "$P_SRV max_version=tls1_1" \
1235 "$P_CLI" \
1236 0 \
1237 -S "ssl_handshake returned" \
1238 -C "ssl_handshake returned" \
1239 -s "Protocol is TLSv1.1" \
1240 -c "Protocol is TLSv1.1"
1241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001242run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001243 "$P_SRV max_version=tls1_1" \
1244 "$P_CLI max_version=tls1_1" \
1245 0 \
1246 -S "ssl_handshake returned" \
1247 -C "ssl_handshake returned" \
1248 -s "Protocol is TLSv1.1" \
1249 -c "Protocol is TLSv1.1"
1250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001251run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001252 "$P_SRV min_version=tls1_1" \
1253 "$P_CLI max_version=tls1_1" \
1254 0 \
1255 -S "ssl_handshake returned" \
1256 -C "ssl_handshake returned" \
1257 -s "Protocol is TLSv1.1" \
1258 -c "Protocol is TLSv1.1"
1259
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001260run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001261 "$P_SRV max_version=tls1_1" \
1262 "$P_CLI min_version=tls1_1" \
1263 0 \
1264 -S "ssl_handshake returned" \
1265 -C "ssl_handshake returned" \
1266 -s "Protocol is TLSv1.1" \
1267 -c "Protocol is TLSv1.1"
1268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001269run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001270 "$P_SRV max_version=tls1_1" \
1271 "$P_CLI min_version=tls1_2" \
1272 1 \
1273 -s "ssl_handshake returned" \
1274 -c "ssl_handshake returned" \
1275 -c "SSL - Handshake protocol not within min/max boundaries"
1276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001277run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001278 "$P_SRV min_version=tls1_2" \
1279 "$P_CLI max_version=tls1_1" \
1280 1 \
1281 -s "ssl_handshake returned" \
1282 -c "ssl_handshake returned" \
1283 -s "SSL - Handshake protocol not within min/max boundaries"
1284
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001285# Tests for ALPN extension
1286
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001287if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1288
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001289run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001290 "$P_SRV debug_level=3" \
1291 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001292 0 \
1293 -C "client hello, adding alpn extension" \
1294 -S "found alpn extension" \
1295 -C "got an alert message, type: \\[2:120]" \
1296 -S "server hello, adding alpn extension" \
1297 -C "found alpn extension " \
1298 -C "Application Layer Protocol is" \
1299 -S "Application Layer Protocol is"
1300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001301run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001302 "$P_SRV debug_level=3" \
1303 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001304 0 \
1305 -c "client hello, adding alpn extension" \
1306 -s "found alpn extension" \
1307 -C "got an alert message, type: \\[2:120]" \
1308 -S "server hello, adding alpn extension" \
1309 -C "found alpn extension " \
1310 -c "Application Layer Protocol is (none)" \
1311 -S "Application Layer Protocol is"
1312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001313run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001314 "$P_SRV debug_level=3 alpn=abc,1234" \
1315 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001316 0 \
1317 -C "client hello, adding alpn extension" \
1318 -S "found alpn extension" \
1319 -C "got an alert message, type: \\[2:120]" \
1320 -S "server hello, adding alpn extension" \
1321 -C "found alpn extension " \
1322 -C "Application Layer Protocol is" \
1323 -s "Application Layer Protocol is (none)"
1324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001325run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001326 "$P_SRV debug_level=3 alpn=abc,1234" \
1327 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001328 0 \
1329 -c "client hello, adding alpn extension" \
1330 -s "found alpn extension" \
1331 -C "got an alert message, type: \\[2:120]" \
1332 -s "server hello, adding alpn extension" \
1333 -c "found alpn extension" \
1334 -c "Application Layer Protocol is abc" \
1335 -s "Application Layer Protocol is abc"
1336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001337run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001338 "$P_SRV debug_level=3 alpn=abc,1234" \
1339 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001340 0 \
1341 -c "client hello, adding alpn extension" \
1342 -s "found alpn extension" \
1343 -C "got an alert message, type: \\[2:120]" \
1344 -s "server hello, adding alpn extension" \
1345 -c "found alpn extension" \
1346 -c "Application Layer Protocol is abc" \
1347 -s "Application Layer Protocol is abc"
1348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001349run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001350 "$P_SRV debug_level=3 alpn=abc,1234" \
1351 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001352 0 \
1353 -c "client hello, adding alpn extension" \
1354 -s "found alpn extension" \
1355 -C "got an alert message, type: \\[2:120]" \
1356 -s "server hello, adding alpn extension" \
1357 -c "found alpn extension" \
1358 -c "Application Layer Protocol is 1234" \
1359 -s "Application Layer Protocol is 1234"
1360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001361run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001362 "$P_SRV debug_level=3 alpn=abc,123" \
1363 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001364 1 \
1365 -c "client hello, adding alpn extension" \
1366 -s "found alpn extension" \
1367 -c "got an alert message, type: \\[2:120]" \
1368 -S "server hello, adding alpn extension" \
1369 -C "found alpn extension" \
1370 -C "Application Layer Protocol is 1234" \
1371 -S "Application Layer Protocol is 1234"
1372
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001373fi
1374
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001375# Tests for keyUsage in leaf certificates, part 1:
1376# server-side certificate/suite selection
1377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001378run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001379 "$P_SRV key_file=data_files/server2.key \
1380 crt_file=data_files/server2.ku-ds.crt" \
1381 "$P_CLI" \
1382 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001383 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001384
1385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001386run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001387 "$P_SRV key_file=data_files/server2.key \
1388 crt_file=data_files/server2.ku-ke.crt" \
1389 "$P_CLI" \
1390 0 \
1391 -c "Ciphersuite is TLS-RSA-WITH-"
1392
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001393run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001394 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001395 crt_file=data_files/server2.ku-ka.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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001400run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001401 "$P_SRV key_file=data_files/server5.key \
1402 crt_file=data_files/server5.ku-ds.crt" \
1403 "$P_CLI" \
1404 0 \
1405 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1406
1407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001408run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001409 "$P_SRV key_file=data_files/server5.key \
1410 crt_file=data_files/server5.ku-ka.crt" \
1411 "$P_CLI" \
1412 0 \
1413 -c "Ciphersuite is TLS-ECDH-"
1414
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001415run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001416 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001417 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001418 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001419 1 \
1420 -C "Ciphersuite is "
1421
1422# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001423# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001425run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001426 "$O_SRV -key data_files/server2.key \
1427 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001428 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001429 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1430 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001431 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001432 -C "Processing of the Certificate handshake message failed" \
1433 -c "Ciphersuite is TLS-"
1434
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001435run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001436 "$O_SRV -key data_files/server2.key \
1437 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001438 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001439 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1440 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001441 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001442 -C "Processing of the Certificate handshake message failed" \
1443 -c "Ciphersuite is TLS-"
1444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001445run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001446 "$O_SRV -key data_files/server2.key \
1447 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001448 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001449 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1450 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001451 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001452 -C "Processing of the Certificate handshake message failed" \
1453 -c "Ciphersuite is TLS-"
1454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001455run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001456 "$O_SRV -key data_files/server2.key \
1457 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001458 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001459 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1460 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001461 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001462 -c "Processing of the Certificate handshake message failed" \
1463 -C "Ciphersuite is TLS-"
1464
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001465run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001466 "$O_SRV -key data_files/server2.key \
1467 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001468 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001469 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1470 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001471 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001472 -C "Processing of the Certificate handshake message failed" \
1473 -c "Ciphersuite is TLS-"
1474
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001475run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001476 "$O_SRV -key data_files/server2.key \
1477 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001478 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001479 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1480 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001481 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001482 -c "Processing of the Certificate handshake message failed" \
1483 -C "Ciphersuite is TLS-"
1484
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001485# Tests for keyUsage in leaf certificates, part 3:
1486# server-side checking of client cert
1487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001488run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001489 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001490 "$O_CLI -key data_files/server2.key \
1491 -cert data_files/server2.ku-ds.crt" \
1492 0 \
1493 -S "bad certificate (usage extensions)" \
1494 -S "Processing of the Certificate handshake message failed"
1495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001496run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001497 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001498 "$O_CLI -key data_files/server2.key \
1499 -cert data_files/server2.ku-ke.crt" \
1500 0 \
1501 -s "bad certificate (usage extensions)" \
1502 -S "Processing of the Certificate handshake message failed"
1503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001504run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001505 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001506 "$O_CLI -key data_files/server2.key \
1507 -cert data_files/server2.ku-ke.crt" \
1508 1 \
1509 -s "bad certificate (usage extensions)" \
1510 -s "Processing of the Certificate handshake message failed"
1511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001512run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001513 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001514 "$O_CLI -key data_files/server5.key \
1515 -cert data_files/server5.ku-ds.crt" \
1516 0 \
1517 -S "bad certificate (usage extensions)" \
1518 -S "Processing of the Certificate handshake message failed"
1519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001520run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001521 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001522 "$O_CLI -key data_files/server5.key \
1523 -cert data_files/server5.ku-ka.crt" \
1524 0 \
1525 -s "bad certificate (usage extensions)" \
1526 -S "Processing of the Certificate handshake message failed"
1527
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001528# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001530run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001531 "$P_SRV key_file=data_files/server5.key \
1532 crt_file=data_files/server5.eku-srv.crt" \
1533 "$P_CLI" \
1534 0
1535
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001536run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001537 "$P_SRV key_file=data_files/server5.key \
1538 crt_file=data_files/server5.eku-srv.crt" \
1539 "$P_CLI" \
1540 0
1541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001542run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001543 "$P_SRV key_file=data_files/server5.key \
1544 crt_file=data_files/server5.eku-cs_any.crt" \
1545 "$P_CLI" \
1546 0
1547
1548# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001549run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001550 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1551 crt_file=data_files/server5.eku-cli.crt" \
1552 "$P_CLI psk=badbad" \
1553 1
1554
1555# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001557run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001558 "$O_SRV -key data_files/server5.key \
1559 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001560 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001561 0 \
1562 -C "bad certificate (usage extensions)" \
1563 -C "Processing of the Certificate handshake message failed" \
1564 -c "Ciphersuite is TLS-"
1565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001566run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001567 "$O_SRV -key data_files/server5.key \
1568 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001569 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001570 0 \
1571 -C "bad certificate (usage extensions)" \
1572 -C "Processing of the Certificate handshake message failed" \
1573 -c "Ciphersuite is TLS-"
1574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001575run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001576 "$O_SRV -key data_files/server5.key \
1577 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001578 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001579 0 \
1580 -C "bad certificate (usage extensions)" \
1581 -C "Processing of the Certificate handshake message failed" \
1582 -c "Ciphersuite is TLS-"
1583
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001584run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001585 "$O_SRV -key data_files/server5.key \
1586 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001587 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001588 1 \
1589 -c "bad certificate (usage extensions)" \
1590 -c "Processing of the Certificate handshake message failed" \
1591 -C "Ciphersuite is TLS-"
1592
1593# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001595run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001596 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001597 "$O_CLI -key data_files/server5.key \
1598 -cert data_files/server5.eku-cli.crt" \
1599 0 \
1600 -S "bad certificate (usage extensions)" \
1601 -S "Processing of the Certificate handshake message failed"
1602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001603run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001604 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001605 "$O_CLI -key data_files/server5.key \
1606 -cert data_files/server5.eku-srv_cli.crt" \
1607 0 \
1608 -S "bad certificate (usage extensions)" \
1609 -S "Processing of the Certificate handshake message failed"
1610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001611run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001612 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001613 "$O_CLI -key data_files/server5.key \
1614 -cert data_files/server5.eku-cs_any.crt" \
1615 0 \
1616 -S "bad certificate (usage extensions)" \
1617 -S "Processing of the Certificate handshake message failed"
1618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001619run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001620 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001621 "$O_CLI -key data_files/server5.key \
1622 -cert data_files/server5.eku-cs.crt" \
1623 0 \
1624 -s "bad certificate (usage extensions)" \
1625 -S "Processing of the Certificate handshake message failed"
1626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001627run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001628 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001629 "$O_CLI -key data_files/server5.key \
1630 -cert data_files/server5.eku-cs.crt" \
1631 1 \
1632 -s "bad certificate (usage extensions)" \
1633 -s "Processing of the Certificate handshake message failed"
1634
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001635# Tests for DHM parameters loading
1636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001637run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001638 "$P_SRV" \
1639 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1640 debug_level=3" \
1641 0 \
1642 -c "value of 'DHM: P ' (2048 bits)" \
1643 -c "value of 'DHM: G ' (2048 bits)"
1644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001645run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001646 "$P_SRV dhm_file=data_files/dhparams.pem" \
1647 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1648 debug_level=3" \
1649 0 \
1650 -c "value of 'DHM: P ' (1024 bits)" \
1651 -c "value of 'DHM: G ' (2 bits)"
1652
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001653# Tests for PSK callback
1654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001655run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001656 "$P_SRV psk=abc123 psk_identity=foo" \
1657 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1658 psk_identity=foo psk=abc123" \
1659 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001660 -S "SSL - The server has no ciphersuites in common" \
1661 -S "SSL - Unknown identity received" \
1662 -S "SSL - Verification of the message MAC failed"
1663
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001664run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001665 "$P_SRV" \
1666 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1667 psk_identity=foo psk=abc123" \
1668 1 \
1669 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001670 -S "SSL - Unknown identity received" \
1671 -S "SSL - Verification of the message MAC failed"
1672
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001673run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001674 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1675 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1676 psk_identity=foo psk=abc123" \
1677 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001678 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001679 -s "SSL - Unknown identity received" \
1680 -S "SSL - Verification of the message MAC failed"
1681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001682run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001683 "$P_SRV psk_list=abc,dead,def,beef" \
1684 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1685 psk_identity=abc psk=dead" \
1686 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001687 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001688 -S "SSL - Unknown identity received" \
1689 -S "SSL - Verification of the message MAC failed"
1690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001691run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001692 "$P_SRV psk_list=abc,dead,def,beef" \
1693 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1694 psk_identity=def psk=beef" \
1695 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001696 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001697 -S "SSL - Unknown identity received" \
1698 -S "SSL - Verification of the message MAC failed"
1699
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001700run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001701 "$P_SRV psk_list=abc,dead,def,beef" \
1702 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1703 psk_identity=ghi psk=beef" \
1704 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001705 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001706 -s "SSL - Unknown identity received" \
1707 -S "SSL - Verification of the message MAC failed"
1708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001709run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001710 "$P_SRV psk_list=abc,dead,def,beef" \
1711 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1712 psk_identity=abc psk=beef" \
1713 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001714 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001715 -S "SSL - Unknown identity received" \
1716 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001717
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001718# Tests for ciphersuites per version
1719
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001720run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001721 "$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" \
1722 "$P_CLI force_version=ssl3" \
1723 0 \
1724 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001726run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001727 "$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" \
1728 "$P_CLI force_version=tls1" \
1729 0 \
1730 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001732run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001733 "$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" \
1734 "$P_CLI force_version=tls1_1" \
1735 0 \
1736 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1737
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001738run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001739 "$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" \
1740 "$P_CLI force_version=tls1_2" \
1741 0 \
1742 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1743
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001744# Tests for ssl_get_bytes_avail()
1745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001746run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001747 "$P_SRV" \
1748 "$P_CLI request_size=100" \
1749 0 \
1750 -s "Read from client: 100 bytes read$"
1751
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001752run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001753 "$P_SRV" \
1754 "$P_CLI request_size=500" \
1755 0 \
1756 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001757
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001758# Tests for small packets
1759
1760run_test "Small packet SSLv3 BlockCipher" \
1761 "$P_SRV" \
1762 "$P_CLI request_size=1 force_version=ssl3 \
1763 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1764 0 \
1765 -s "Read from client: 1 bytes read"
1766
1767run_test "Small packet SSLv3 StreamCipher" \
1768 "$P_SRV" \
1769 "$P_CLI request_size=1 force_version=ssl3 \
1770 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1771 0 \
1772 -s "Read from client: 1 bytes read"
1773
1774run_test "Small packet TLS 1.0 BlockCipher" \
1775 "$P_SRV" \
1776 "$P_CLI request_size=1 force_version=tls1 \
1777 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1778 0 \
1779 -s "Read from client: 1 bytes read"
1780
1781run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1782 "$P_SRV" \
1783 "$P_CLI request_size=1 force_version=tls1 \
1784 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1785 trunc_hmac=1" \
1786 0 \
1787 -s "Read from client: 1 bytes read"
1788
1789run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1790 "$P_SRV" \
1791 "$P_CLI request_size=1 force_version=tls1 \
1792 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1793 trunc_hmac=1" \
1794 0 \
1795 -s "Read from client: 1 bytes read"
1796
1797run_test "Small packet TLS 1.1 BlockCipher" \
1798 "$P_SRV" \
1799 "$P_CLI request_size=1 force_version=tls1_1 \
1800 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1801 0 \
1802 -s "Read from client: 1 bytes read"
1803
1804run_test "Small packet TLS 1.1 StreamCipher" \
1805 "$P_SRV" \
1806 "$P_CLI request_size=1 force_version=tls1_1 \
1807 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1808 0 \
1809 -s "Read from client: 1 bytes read"
1810
1811run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1812 "$P_SRV" \
1813 "$P_CLI request_size=1 force_version=tls1_1 \
1814 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1815 trunc_hmac=1" \
1816 0 \
1817 -s "Read from client: 1 bytes read"
1818
1819run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1820 "$P_SRV" \
1821 "$P_CLI request_size=1 force_version=tls1_1 \
1822 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1823 trunc_hmac=1" \
1824 0 \
1825 -s "Read from client: 1 bytes read"
1826
1827run_test "Small packet TLS 1.2 BlockCipher" \
1828 "$P_SRV" \
1829 "$P_CLI request_size=1 force_version=tls1_2 \
1830 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1831 0 \
1832 -s "Read from client: 1 bytes read"
1833
1834run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1835 "$P_SRV" \
1836 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1837 0 \
1838 -s "Read from client: 1 bytes read"
1839
1840run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1841 "$P_SRV" \
1842 "$P_CLI request_size=1 force_version=tls1_2 \
1843 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1844 trunc_hmac=1" \
1845 0 \
1846 -s "Read from client: 1 bytes read"
1847
1848run_test "Small packet TLS 1.2 StreamCipher" \
1849 "$P_SRV" \
1850 "$P_CLI request_size=1 force_version=tls1_2 \
1851 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1852 0 \
1853 -s "Read from client: 1 bytes read"
1854
1855run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1856 "$P_SRV" \
1857 "$P_CLI request_size=1 force_version=tls1_2 \
1858 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1859 trunc_hmac=1" \
1860 0 \
1861 -s "Read from client: 1 bytes read"
1862
1863run_test "Small packet TLS 1.2 AEAD" \
1864 "$P_SRV" \
1865 "$P_CLI request_size=1 force_version=tls1_2 \
1866 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1867 0 \
1868 -s "Read from client: 1 bytes read"
1869
1870run_test "Small packet TLS 1.2 AEAD shorter tag" \
1871 "$P_SRV" \
1872 "$P_CLI request_size=1 force_version=tls1_2 \
1873 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1874 0 \
1875 -s "Read from client: 1 bytes read"
1876
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001877# Test for large packets
1878
1879run_test "Large packet SSLv3 BlockCipher" \
1880 "$P_SRV" \
1881 "$P_CLI request_size=16384 force_version=ssl3 \
1882 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1883 0 \
1884 -s "Read from client: 16384 bytes read"
1885
1886run_test "Large packet SSLv3 StreamCipher" \
1887 "$P_SRV" \
1888 "$P_CLI request_size=16384 force_version=ssl3 \
1889 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1890 0 \
1891 -s "Read from client: 16384 bytes read"
1892
1893run_test "Large packet TLS 1.0 BlockCipher" \
1894 "$P_SRV" \
1895 "$P_CLI request_size=16384 force_version=tls1 \
1896 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1897 0 \
1898 -s "Read from client: 16384 bytes read"
1899
1900run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1901 "$P_SRV" \
1902 "$P_CLI request_size=16384 force_version=tls1 \
1903 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1904 trunc_hmac=1" \
1905 0 \
1906 -s "Read from client: 16384 bytes read"
1907
1908run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1909 "$P_SRV" \
1910 "$P_CLI request_size=16384 force_version=tls1 \
1911 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1912 trunc_hmac=1" \
1913 0 \
1914 -s "Read from client: 16384 bytes read"
1915
1916run_test "Large packet TLS 1.1 BlockCipher" \
1917 "$P_SRV" \
1918 "$P_CLI request_size=16384 force_version=tls1_1 \
1919 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1920 0 \
1921 -s "Read from client: 16384 bytes read"
1922
1923run_test "Large packet TLS 1.1 StreamCipher" \
1924 "$P_SRV" \
1925 "$P_CLI request_size=16384 force_version=tls1_1 \
1926 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1927 0 \
1928 -s "Read from client: 16384 bytes read"
1929
1930run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1931 "$P_SRV" \
1932 "$P_CLI request_size=16384 force_version=tls1_1 \
1933 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1934 trunc_hmac=1" \
1935 0 \
1936 -s "Read from client: 16384 bytes read"
1937
1938run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1939 "$P_SRV" \
1940 "$P_CLI request_size=16384 force_version=tls1_1 \
1941 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1942 trunc_hmac=1" \
1943 0 \
1944 -s "Read from client: 16384 bytes read"
1945
1946run_test "Large packet TLS 1.2 BlockCipher" \
1947 "$P_SRV" \
1948 "$P_CLI request_size=16384 force_version=tls1_2 \
1949 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1950 0 \
1951 -s "Read from client: 16384 bytes read"
1952
1953run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1954 "$P_SRV" \
1955 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1956 0 \
1957 -s "Read from client: 16384 bytes read"
1958
1959run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1960 "$P_SRV" \
1961 "$P_CLI request_size=16384 force_version=tls1_2 \
1962 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1963 trunc_hmac=1" \
1964 0 \
1965 -s "Read from client: 16384 bytes read"
1966
1967run_test "Large packet TLS 1.2 StreamCipher" \
1968 "$P_SRV" \
1969 "$P_CLI request_size=16384 force_version=tls1_2 \
1970 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1971 0 \
1972 -s "Read from client: 16384 bytes read"
1973
1974run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1975 "$P_SRV" \
1976 "$P_CLI request_size=16384 force_version=tls1_2 \
1977 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1978 trunc_hmac=1" \
1979 0 \
1980 -s "Read from client: 16384 bytes read"
1981
1982run_test "Large packet TLS 1.2 AEAD" \
1983 "$P_SRV" \
1984 "$P_CLI request_size=16384 force_version=tls1_2 \
1985 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1986 0 \
1987 -s "Read from client: 16384 bytes read"
1988
1989run_test "Large packet TLS 1.2 AEAD shorter tag" \
1990 "$P_SRV" \
1991 "$P_CLI request_size=16384 force_version=tls1_2 \
1992 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1993 0 \
1994 -s "Read from client: 16384 bytes read"
1995
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001996# Final report
1997
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001998echo "------------------------------------------------------------------------"
1999
2000if [ $FAILS = 0 ]; then
2001 echo -n "PASSED"
2002else
2003 echo -n "FAILED"
2004fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002005PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002006echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002007
2008exit $FAILS