blob: ab7793a42e48226c9210f4c92ab8589611239ceb [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
21O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
23G_CLI="$GNUTLS_CLI"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010037 echo -e " -h|--help\tPrint this help."
38 echo -e " -m|--memcheck\tCheck memory leaks and errors."
39 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
40 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
78 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020083# skip next test if OpenSSL doesn't support FALLBACK_SCSV
84requires_openssl_with_fallback_scsv() {
85 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
86 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
87 then
88 OPENSSL_HAS_FBSCSV="YES"
89 else
90 OPENSSL_HAS_FBSCSV="NO"
91 fi
92 fi
93 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
94 SKIP_NEXT="YES"
95 fi
96}
97
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020098# skip next test if GnuTLS isn't available
99requires_gnutls() {
100 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
101 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
102 GNUTLS_AVAILABLE="YES"
103 else
104 GNUTLS_AVAILABLE="NO"
105 fi
106 fi
107 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
108 SKIP_NEXT="YES"
109 fi
110}
111
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100112# print_name <name>
113print_name() {
114 echo -n "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200115 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100116 for i in `seq 1 $LEN`; do echo -n '.'; done
117 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100118
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200119 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100120}
121
122# fail <message>
123fail() {
124 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100125 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100126
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200127 mv $SRV_OUT o-srv-${TESTS}.log
128 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100129 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100130
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200131 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
132 echo " ! server output:"
133 cat o-srv-${TESTS}.log
134 echo " ! ============================================================"
135 echo " ! client output:"
136 cat o-cli-${TESTS}.log
137 fi
138
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200139 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100140}
141
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100142# is_polar <cmd_line>
143is_polar() {
144 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
145}
146
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100147# has_mem_err <log_file_name>
148has_mem_err() {
149 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
150 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
151 then
152 return 1 # false: does not have errors
153 else
154 return 0 # true: has errors
155 fi
156}
157
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200158# wait for server to start: two versions depending on lsof availability
159wait_server_start() {
160 if which lsof >/dev/null; then
161 # make sure we don't loop forever
162 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
163 WATCHDOG_PID=$!
164
165 # make a tight loop, server usually takes less than 1 sec to start
166 until lsof -nbi TCP:"$PORT" | grep LISTEN >/dev/null; do :; done
167
168 kill $WATCHDOG_PID
169 wait $WATCHDOG_PID
170 else
171 sleep "$START_DELAY"
172 fi
173}
174
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200175# wait for client to terminate and set CLI_EXIT
176# must be called right after starting the client
177wait_client_done() {
178 CLI_PID=$!
179
180 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
181 WATCHDOG_PID=$!
182
183 wait $CLI_PID
184 CLI_EXIT=$?
185
186 kill $WATCHDOG_PID
187 wait $WATCHDOG_PID
188
189 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
190}
191
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100192# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100193# Options: -s pattern pattern that must be present in server output
194# -c pattern pattern that must be present in client output
195# -S pattern pattern that must be absent in server output
196# -C pattern pattern that must be absent in client output
197run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100198 NAME="$1"
199 SRV_CMD="$2"
200 CLI_CMD="$3"
201 CLI_EXPECT="$4"
202 shift 4
203
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100204 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
205 else
206 return
207 fi
208
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100209 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100210
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200211 # should we skip?
212 if [ "X$SKIP_NEXT" = "XYES" ]; then
213 SKIP_NEXT="NO"
214 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200215 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200216 return
217 fi
218
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100219 # prepend valgrind to our commands if active
220 if [ "$MEMCHECK" -gt 0 ]; then
221 if is_polar "$SRV_CMD"; then
222 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
223 fi
224 if is_polar "$CLI_CMD"; then
225 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
226 fi
227 fi
228
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100229 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200230 echo "$SRV_CMD" > $SRV_OUT
231 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100232 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200233 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200234
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200235 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200236 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
237 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100238
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200239 # kill the server
240 kill $SRV_PID
241 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100242
243 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200244 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100245 # expected client exit to incorrectly succeed in case of catastrophic
246 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100247 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200248 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100249 else
250 fail "server failed to start"
251 return
252 fi
253 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100254 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200255 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100256 else
257 fail "client failed to start"
258 return
259 fi
260 fi
261
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100262 # check server exit code
263 if [ $? != 0 ]; then
264 fail "server fail"
265 return
266 fi
267
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100268 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100269 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
270 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100271 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100272 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100273 return
274 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100275
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100276 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200277 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100278 while [ $# -gt 0 ]
279 do
280 case $1 in
281 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200282 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100283 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100284 return
285 fi
286 ;;
287
288 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200289 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100290 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100291 return
292 fi
293 ;;
294
295 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200296 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100297 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100298 return
299 fi
300 ;;
301
302 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200303 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100304 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100305 return
306 fi
307 ;;
308
309 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200310 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100311 exit 1
312 esac
313 shift 2
314 done
315
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100316 # check valgrind's results
317 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200318 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100319 fail "Server has memory errors"
320 return
321 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200322 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100323 fail "Client has memory errors"
324 return
325 fi
326 fi
327
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100328 # if we're here, everything is ok
329 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200330 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100331}
332
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100333cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200334 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200335 kill $SRV_PID >/dev/null 2>&1
336 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100337 exit 1
338}
339
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100340#
341# MAIN
342#
343
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100344get_options "$@"
345
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100346# sanity checks, avoid an avalanche of errors
347if [ ! -x "$P_SRV" ]; then
348 echo "Command '$P_SRV' is not an executable file"
349 exit 1
350fi
351if [ ! -x "$P_CLI" ]; then
352 echo "Command '$P_CLI' is not an executable file"
353 exit 1
354fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100355if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
356 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100357 exit 1
358fi
359
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200360# used by watchdog
361MAIN_PID="$$"
362
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200363# be more patient with valgrind
364if [ "$MEMCHECK" -gt 0 ]; then
365 START_DELAY=3
366 DOG_DELAY=30
367else
368 START_DELAY=1
369 DOG_DELAY=10
370fi
371
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200372# Pick a "unique" port in the range 10000-19999.
373PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200374PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200375
376# fix commands to use this port
377P_SRV="$P_SRV server_port=$PORT"
378P_CLI="$P_CLI server_port=$PORT"
379O_SRV="$O_SRV -accept $PORT"
380O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200381G_SRV="$G_SRV -p $PORT"
382G_CLI="$G_CLI -p $PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200383
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200384# Also pick a unique name for intermediate files
385SRV_OUT="srv_out.$$"
386CLI_OUT="cli_out.$$"
387SESSION="session.$$"
388
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200389SKIP_NEXT="NO"
390
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100391trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100392
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200393# Basic test
394
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200395# Checks that:
396# - things work with all ciphersuites active (used with config-full in all.sh)
397# - the expected (highest security) parameters are selected
398# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200399run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200400 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200401 "$P_CLI" \
402 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200403 -s "Protocol is TLSv1.2" \
404 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
405 -s "client hello v3, signature_algorithm ext: 6" \
406 -s "ECDHE curve: secp521r1" \
407 -S "error" \
408 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200409
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100410# Test for SSLv2 ClientHello
411
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200412requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200413run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100414 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100415 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100416 0 \
417 -S "parse client hello v2" \
418 -S "ssl_handshake returned"
419
420# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200421requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200422run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200423 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100424 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100425 0 \
426 -s "parse client hello v2" \
427 -S "ssl_handshake returned"
428
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100429# Tests for Truncated HMAC extension
430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200431run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200432 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100433 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100434 0 \
435 -s "dumping 'computed mac' (20 bytes)"
436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200437run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200438 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100439 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100440 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100441 -s "dumping 'computed mac' (10 bytes)"
442
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200443# Tests for FALLBACK_SCSV
444
445run_test "Fallback SCSV: default" \
446 "$P_SRV" \
447 "$P_CLI debug_level=3 force_version=tls1_1" \
448 0 \
449 -C "adding FALLBACK_SCSV" \
450 -C "is a fatal alert message (msg 86)"
451
452run_test "Fallback SCSV: explicitly disabled" \
453 "$P_SRV" \
454 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
455 0 \
456 -C "adding FALLBACK_SCSV" \
457 -C "is a fatal alert message (msg 86)"
458
459run_test "Fallback SCSV: enabled" \
460 "$P_SRV" \
461 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
462 0 \
463 -c "adding FALLBACK_SCSV" \
464 -C "is a fatal alert message (msg 86)"
465
466requires_openssl_with_fallback_scsv
467run_test "Fallback SCSV: default, openssl server" \
468 "$O_SRV" \
469 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
470 0 \
471 -C "adding FALLBACK_SCSV" \
472 -C "is a fatal alert message (msg 86)"
473
474requires_openssl_with_fallback_scsv
475run_test "Fallback SCSV: enabled, openssl server" \
476 "$O_SRV" \
477 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
478 1 \
479 -c "adding FALLBACK_SCSV" \
480 -c "is a fatal alert message (msg 86)"
481
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100482# Tests for Session Tickets
483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200484run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200485 "$P_SRV debug_level=3 tickets=1" \
486 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100487 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100488 -c "client hello, adding session ticket extension" \
489 -s "found session ticket extension" \
490 -s "server hello, adding session ticket extension" \
491 -c "found session_ticket extension" \
492 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100493 -S "session successfully restored from cache" \
494 -s "session successfully restored from ticket" \
495 -s "a session has been resumed" \
496 -c "a session has been resumed"
497
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200498run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200499 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
500 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100501 0 \
502 -c "client hello, adding session ticket extension" \
503 -s "found session ticket extension" \
504 -s "server hello, adding session ticket extension" \
505 -c "found session_ticket extension" \
506 -c "parse new session ticket" \
507 -S "session successfully restored from cache" \
508 -s "session successfully restored from ticket" \
509 -s "a session has been resumed" \
510 -c "a session has been resumed"
511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200512run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200513 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
514 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100515 0 \
516 -c "client hello, adding session ticket extension" \
517 -s "found session ticket extension" \
518 -s "server hello, adding session ticket extension" \
519 -c "found session_ticket extension" \
520 -c "parse new session ticket" \
521 -S "session successfully restored from cache" \
522 -S "session successfully restored from ticket" \
523 -S "a session has been resumed" \
524 -C "a session has been resumed"
525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200526run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100527 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200528 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100529 0 \
530 -c "client hello, adding session ticket extension" \
531 -c "found session_ticket extension" \
532 -c "parse new session ticket" \
533 -c "a session has been resumed"
534
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200535run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200536 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200537 "( $O_CLI -sess_out $SESSION; \
538 $O_CLI -sess_in $SESSION; \
539 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100540 0 \
541 -s "found session ticket extension" \
542 -s "server hello, adding session ticket extension" \
543 -S "session successfully restored from cache" \
544 -s "session successfully restored from ticket" \
545 -s "a session has been resumed"
546
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100547# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200549run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200550 "$P_SRV debug_level=3 tickets=0" \
551 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100552 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100553 -c "client hello, adding session ticket extension" \
554 -s "found session ticket extension" \
555 -S "server hello, adding session ticket extension" \
556 -C "found session_ticket extension" \
557 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100558 -s "session successfully restored from cache" \
559 -S "session successfully restored from ticket" \
560 -s "a session has been resumed" \
561 -c "a session has been resumed"
562
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200563run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200564 "$P_SRV debug_level=3 tickets=1" \
565 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100566 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100567 -C "client hello, adding session ticket extension" \
568 -S "found session ticket extension" \
569 -S "server hello, adding session ticket extension" \
570 -C "found session_ticket extension" \
571 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100572 -s "session successfully restored from cache" \
573 -S "session successfully restored from ticket" \
574 -s "a session has been resumed" \
575 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200577run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200578 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
579 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100580 0 \
581 -S "session successfully restored from cache" \
582 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100583 -S "a session has been resumed" \
584 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200586run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200587 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
588 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100589 0 \
590 -s "session successfully restored from cache" \
591 -S "session successfully restored from ticket" \
592 -s "a session has been resumed" \
593 -c "a session has been resumed"
594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200595run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200596 "$P_SRV debug_level=3 tickets=0" \
597 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100598 0 \
599 -s "session successfully restored from cache" \
600 -S "session successfully restored from ticket" \
601 -s "a session has been resumed" \
602 -c "a session has been resumed"
603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200604run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200605 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
606 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100607 0 \
608 -S "session successfully restored from cache" \
609 -S "session successfully restored from ticket" \
610 -S "a session has been resumed" \
611 -C "a session has been resumed"
612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200613run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200614 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
615 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100616 0 \
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 cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200623 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200624 "( $O_CLI -sess_out $SESSION; \
625 $O_CLI -sess_in $SESSION; \
626 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100627 0 \
628 -s "found session ticket extension" \
629 -S "server hello, adding session ticket extension" \
630 -s "session successfully restored from cache" \
631 -S "session successfully restored from ticket" \
632 -s "a session has been resumed"
633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200634run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100635 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200636 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100637 0 \
638 -C "found session_ticket extension" \
639 -C "parse new session ticket" \
640 -c "a session has been resumed"
641
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100642# Tests for Max Fragment Length extension
643
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200644run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200645 "$P_SRV debug_level=3" \
646 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100647 0 \
648 -C "client hello, adding max_fragment_length extension" \
649 -S "found max fragment length extension" \
650 -S "server hello, max_fragment_length extension" \
651 -C "found max_fragment_length extension"
652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200653run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200654 "$P_SRV debug_level=3" \
655 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100656 0 \
657 -c "client hello, adding max_fragment_length extension" \
658 -s "found max fragment length extension" \
659 -s "server hello, max_fragment_length extension" \
660 -c "found max_fragment_length extension"
661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200662run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200663 "$P_SRV debug_level=3 max_frag_len=4096" \
664 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100665 0 \
666 -C "client hello, adding max_fragment_length extension" \
667 -S "found max fragment length extension" \
668 -S "server hello, max_fragment_length extension" \
669 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200671requires_gnutls
672run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200673 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200674 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200675 0 \
676 -c "client hello, adding max_fragment_length extension" \
677 -c "found max_fragment_length extension"
678
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100679# Tests for renegotiation
680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200681run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200682 "$P_SRV debug_level=3 exchanges=2" \
683 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100684 0 \
685 -C "client hello, adding renegotiation extension" \
686 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
687 -S "found renegotiation extension" \
688 -s "server hello, secure renegotiation extension" \
689 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100690 -C "=> renegotiate" \
691 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100692 -S "write hello request"
693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200694run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200695 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
696 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100697 0 \
698 -c "client hello, adding renegotiation extension" \
699 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
700 -s "found renegotiation extension" \
701 -s "server hello, secure renegotiation extension" \
702 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100703 -c "=> renegotiate" \
704 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100705 -S "write hello request"
706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200707run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200708 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
709 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100710 0 \
711 -c "client hello, adding renegotiation extension" \
712 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
713 -s "found renegotiation extension" \
714 -s "server hello, secure renegotiation extension" \
715 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100716 -c "=> renegotiate" \
717 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100718 -s "write hello request"
719
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200720run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200721 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
722 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100723 0 \
724 -c "client hello, adding renegotiation extension" \
725 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
726 -s "found renegotiation extension" \
727 -s "server hello, secure renegotiation extension" \
728 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100729 -c "=> renegotiate" \
730 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100731 -s "write hello request"
732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200733run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200734 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
735 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100736 1 \
737 -c "client hello, adding renegotiation extension" \
738 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
739 -S "found renegotiation extension" \
740 -s "server hello, secure renegotiation extension" \
741 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100742 -c "=> renegotiate" \
743 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200744 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200745 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200746 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100747
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200748run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200749 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
750 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100751 0 \
752 -C "client hello, adding renegotiation extension" \
753 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
754 -S "found renegotiation extension" \
755 -s "server hello, secure renegotiation extension" \
756 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100757 -C "=> renegotiate" \
758 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100759 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200760 -S "SSL - An unexpected message was received from our peer" \
761 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200763run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200764 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200765 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200766 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200767 0 \
768 -C "client hello, adding renegotiation extension" \
769 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
770 -S "found renegotiation extension" \
771 -s "server hello, secure renegotiation extension" \
772 -c "found renegotiation extension" \
773 -C "=> renegotiate" \
774 -S "=> renegotiate" \
775 -s "write hello request" \
776 -S "SSL - An unexpected message was received from our peer" \
777 -S "failed"
778
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200779# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200780run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200781 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200782 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200783 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200784 0 \
785 -C "client hello, adding renegotiation extension" \
786 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
787 -S "found renegotiation extension" \
788 -s "server hello, secure renegotiation extension" \
789 -c "found renegotiation extension" \
790 -C "=> renegotiate" \
791 -S "=> renegotiate" \
792 -s "write hello request" \
793 -S "SSL - An unexpected message was received from our peer" \
794 -S "failed"
795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200796run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200797 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200798 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200799 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200800 0 \
801 -C "client hello, adding renegotiation extension" \
802 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
803 -S "found renegotiation extension" \
804 -s "server hello, secure renegotiation extension" \
805 -c "found renegotiation extension" \
806 -C "=> renegotiate" \
807 -S "=> renegotiate" \
808 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200809 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200811run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200812 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200813 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200814 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200815 0 \
816 -c "client hello, adding renegotiation extension" \
817 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
818 -s "found renegotiation extension" \
819 -s "server hello, secure renegotiation extension" \
820 -c "found renegotiation extension" \
821 -c "=> renegotiate" \
822 -s "=> renegotiate" \
823 -s "write hello request" \
824 -S "SSL - An unexpected message was received from our peer" \
825 -S "failed"
826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200827run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200828 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
829 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200830 0 \
831 -c "client hello, adding renegotiation extension" \
832 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
833 -s "found renegotiation extension" \
834 -s "server hello, secure renegotiation extension" \
835 -c "found renegotiation extension" \
836 -c "=> renegotiate" \
837 -s "=> renegotiate" \
838 -S "write hello request"
839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200840run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200841 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
842 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200843 0 \
844 -c "client hello, adding renegotiation extension" \
845 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
846 -s "found renegotiation extension" \
847 -s "server hello, secure renegotiation extension" \
848 -c "found renegotiation extension" \
849 -c "=> renegotiate" \
850 -s "=> renegotiate" \
851 -s "write hello request"
852
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200853run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200854 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200855 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200856 0 \
857 -c "client hello, adding renegotiation extension" \
858 -c "found renegotiation extension" \
859 -c "=> renegotiate" \
860 -C "ssl_handshake returned" \
861 -C "error" \
862 -c "HTTP/1.0 200 [Oo][Kk]"
863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200864run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200865 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200866 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200867 0 \
868 -c "client hello, adding renegotiation extension" \
869 -c "found renegotiation extension" \
870 -c "=> renegotiate" \
871 -C "ssl_handshake returned" \
872 -C "error" \
873 -c "HTTP/1.0 200 [Oo][Kk]"
874
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100875# Tests for auth_mode
876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200877run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100878 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100879 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200880 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100881 1 \
882 -c "x509_verify_cert() returned" \
883 -c "! self-signed or not signed by a trusted CA" \
884 -c "! ssl_handshake returned" \
885 -c "X509 - Certificate verification failed"
886
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200887run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100888 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100889 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200890 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100891 0 \
892 -c "x509_verify_cert() returned" \
893 -c "! self-signed or not signed by a trusted CA" \
894 -C "! ssl_handshake returned" \
895 -C "X509 - Certificate verification failed"
896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200897run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100898 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100899 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200900 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100901 0 \
902 -C "x509_verify_cert() returned" \
903 -C "! self-signed or not signed by a trusted CA" \
904 -C "! ssl_handshake returned" \
905 -C "X509 - Certificate verification failed"
906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200907run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200908 "$P_SRV debug_level=3 auth_mode=required" \
909 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100910 key_file=data_files/server5.key" \
911 1 \
912 -S "skip write certificate request" \
913 -C "skip parse certificate request" \
914 -c "got a certificate request" \
915 -C "skip write certificate" \
916 -C "skip write certificate verify" \
917 -S "skip parse certificate verify" \
918 -s "x509_verify_cert() returned" \
919 -S "! self-signed or not signed by a trusted CA" \
920 -s "! ssl_handshake returned" \
921 -c "! ssl_handshake returned" \
922 -s "X509 - Certificate verification failed"
923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200924run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200925 "$P_SRV debug_level=3 auth_mode=optional" \
926 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100927 key_file=data_files/server5.key" \
928 0 \
929 -S "skip write certificate request" \
930 -C "skip parse certificate request" \
931 -c "got a certificate request" \
932 -C "skip write certificate" \
933 -C "skip write certificate verify" \
934 -S "skip parse certificate verify" \
935 -s "x509_verify_cert() returned" \
936 -s "! self-signed or not signed by a trusted CA" \
937 -S "! ssl_handshake returned" \
938 -C "! ssl_handshake returned" \
939 -S "X509 - Certificate verification failed"
940
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200941run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200942 "$P_SRV debug_level=3 auth_mode=none" \
943 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100944 key_file=data_files/server5.key" \
945 0 \
946 -s "skip write certificate request" \
947 -C "skip parse certificate request" \
948 -c "got no certificate request" \
949 -c "skip write certificate" \
950 -c "skip write certificate verify" \
951 -s "skip parse certificate verify" \
952 -S "x509_verify_cert() returned" \
953 -S "! self-signed or not signed by a trusted CA" \
954 -S "! ssl_handshake returned" \
955 -C "! ssl_handshake returned" \
956 -S "X509 - Certificate verification failed"
957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200958run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200959 "$P_SRV debug_level=3 auth_mode=optional" \
960 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100961 0 \
962 -S "skip write certificate request" \
963 -C "skip parse certificate request" \
964 -c "got a certificate request" \
965 -C "skip write certificate$" \
966 -C "got no certificate to send" \
967 -S "SSLv3 client has no certificate" \
968 -c "skip write certificate verify" \
969 -s "skip parse certificate verify" \
970 -s "! no client certificate sent" \
971 -S "! ssl_handshake returned" \
972 -C "! ssl_handshake returned" \
973 -S "X509 - Certificate verification failed"
974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200975run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200976 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100977 "$O_CLI" \
978 0 \
979 -S "skip write certificate request" \
980 -s "skip parse certificate verify" \
981 -s "! no client certificate sent" \
982 -S "! ssl_handshake returned" \
983 -S "X509 - Certificate verification failed"
984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200985run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100986 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200987 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100988 0 \
989 -C "skip parse certificate request" \
990 -c "got a certificate request" \
991 -C "skip write certificate$" \
992 -c "skip write certificate verify" \
993 -C "! ssl_handshake returned"
994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200995run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200996 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
997 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100998 0 \
999 -S "skip write certificate request" \
1000 -C "skip parse certificate request" \
1001 -c "got a certificate request" \
1002 -C "skip write certificate$" \
1003 -c "skip write certificate verify" \
1004 -c "got no certificate to send" \
1005 -s "SSLv3 client has no certificate" \
1006 -s "skip parse certificate verify" \
1007 -s "! no client certificate sent" \
1008 -S "! ssl_handshake returned" \
1009 -C "! ssl_handshake returned" \
1010 -S "X509 - Certificate verification failed"
1011
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001012# tests for SNI
1013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001014run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001015 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001016 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001017 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001018 server_name=localhost" \
1019 0 \
1020 -S "parse ServerName extension" \
1021 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1022 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001024run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001025 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001026 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001027 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 +01001028 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001029 server_name=localhost" \
1030 0 \
1031 -s "parse ServerName extension" \
1032 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1033 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001035run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001036 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001037 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001038 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 +01001039 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001040 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001041 0 \
1042 -s "parse ServerName extension" \
1043 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001044 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001045
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001046run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001047 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001048 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001049 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 +01001050 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001051 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001052 1 \
1053 -s "parse ServerName extension" \
1054 -s "ssl_sni_wrapper() returned" \
1055 -s "ssl_handshake returned" \
1056 -c "ssl_handshake returned" \
1057 -c "SSL - A fatal alert message was received from our peer"
1058
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001059# Tests for non-blocking I/O: exercise a variety of handshake flows
1060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001061run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001062 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1063 "$P_CLI nbio=2 tickets=0" \
1064 0 \
1065 -S "ssl_handshake returned" \
1066 -C "ssl_handshake returned" \
1067 -c "Read from server: .* bytes read"
1068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001069run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001070 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1071 "$P_CLI nbio=2 tickets=0" \
1072 0 \
1073 -S "ssl_handshake returned" \
1074 -C "ssl_handshake returned" \
1075 -c "Read from server: .* bytes read"
1076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001077run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001078 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1079 "$P_CLI nbio=2 tickets=1" \
1080 0 \
1081 -S "ssl_handshake returned" \
1082 -C "ssl_handshake returned" \
1083 -c "Read from server: .* bytes read"
1084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001085run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001086 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1087 "$P_CLI nbio=2 tickets=1" \
1088 0 \
1089 -S "ssl_handshake returned" \
1090 -C "ssl_handshake returned" \
1091 -c "Read from server: .* bytes read"
1092
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001093run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001094 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1095 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1096 0 \
1097 -S "ssl_handshake returned" \
1098 -C "ssl_handshake returned" \
1099 -c "Read from server: .* bytes read"
1100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001101run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001102 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1103 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1104 0 \
1105 -S "ssl_handshake returned" \
1106 -C "ssl_handshake returned" \
1107 -c "Read from server: .* bytes read"
1108
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001109run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001110 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1111 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1112 0 \
1113 -S "ssl_handshake returned" \
1114 -C "ssl_handshake returned" \
1115 -c "Read from server: .* bytes read"
1116
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001117# Tests for version negotiation
1118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001119run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001120 "$P_SRV" \
1121 "$P_CLI" \
1122 0 \
1123 -S "ssl_handshake returned" \
1124 -C "ssl_handshake returned" \
1125 -s "Protocol is TLSv1.2" \
1126 -c "Protocol is TLSv1.2"
1127
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001128run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001129 "$P_SRV" \
1130 "$P_CLI max_version=tls1_1" \
1131 0 \
1132 -S "ssl_handshake returned" \
1133 -C "ssl_handshake returned" \
1134 -s "Protocol is TLSv1.1" \
1135 -c "Protocol is TLSv1.1"
1136
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001137run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001138 "$P_SRV max_version=tls1_1" \
1139 "$P_CLI" \
1140 0 \
1141 -S "ssl_handshake returned" \
1142 -C "ssl_handshake returned" \
1143 -s "Protocol is TLSv1.1" \
1144 -c "Protocol is TLSv1.1"
1145
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001146run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001147 "$P_SRV max_version=tls1_1" \
1148 "$P_CLI max_version=tls1_1" \
1149 0 \
1150 -S "ssl_handshake returned" \
1151 -C "ssl_handshake returned" \
1152 -s "Protocol is TLSv1.1" \
1153 -c "Protocol is TLSv1.1"
1154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001155run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001156 "$P_SRV min_version=tls1_1" \
1157 "$P_CLI max_version=tls1_1" \
1158 0 \
1159 -S "ssl_handshake returned" \
1160 -C "ssl_handshake returned" \
1161 -s "Protocol is TLSv1.1" \
1162 -c "Protocol is TLSv1.1"
1163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001164run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001165 "$P_SRV max_version=tls1_1" \
1166 "$P_CLI min_version=tls1_1" \
1167 0 \
1168 -S "ssl_handshake returned" \
1169 -C "ssl_handshake returned" \
1170 -s "Protocol is TLSv1.1" \
1171 -c "Protocol is TLSv1.1"
1172
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001173run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001174 "$P_SRV max_version=tls1_1" \
1175 "$P_CLI min_version=tls1_2" \
1176 1 \
1177 -s "ssl_handshake returned" \
1178 -c "ssl_handshake returned" \
1179 -c "SSL - Handshake protocol not within min/max boundaries"
1180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001181run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001182 "$P_SRV min_version=tls1_2" \
1183 "$P_CLI max_version=tls1_1" \
1184 1 \
1185 -s "ssl_handshake returned" \
1186 -c "ssl_handshake returned" \
1187 -s "SSL - Handshake protocol not within min/max boundaries"
1188
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001189# Tests for ALPN extension
1190
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001191if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001193run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001194 "$P_SRV debug_level=3" \
1195 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001196 0 \
1197 -C "client hello, adding alpn extension" \
1198 -S "found alpn extension" \
1199 -C "got an alert message, type: \\[2:120]" \
1200 -S "server hello, adding alpn extension" \
1201 -C "found alpn extension " \
1202 -C "Application Layer Protocol is" \
1203 -S "Application Layer Protocol is"
1204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001205run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001206 "$P_SRV debug_level=3" \
1207 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001208 0 \
1209 -c "client hello, adding alpn extension" \
1210 -s "found alpn extension" \
1211 -C "got an alert message, type: \\[2:120]" \
1212 -S "server hello, adding alpn extension" \
1213 -C "found alpn extension " \
1214 -c "Application Layer Protocol is (none)" \
1215 -S "Application Layer Protocol is"
1216
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001217run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001218 "$P_SRV debug_level=3 alpn=abc,1234" \
1219 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001220 0 \
1221 -C "client hello, adding alpn extension" \
1222 -S "found alpn extension" \
1223 -C "got an alert message, type: \\[2:120]" \
1224 -S "server hello, adding alpn extension" \
1225 -C "found alpn extension " \
1226 -C "Application Layer Protocol is" \
1227 -s "Application Layer Protocol is (none)"
1228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001230 "$P_SRV debug_level=3 alpn=abc,1234" \
1231 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001232 0 \
1233 -c "client hello, adding alpn extension" \
1234 -s "found alpn extension" \
1235 -C "got an alert message, type: \\[2:120]" \
1236 -s "server hello, adding alpn extension" \
1237 -c "found alpn extension" \
1238 -c "Application Layer Protocol is abc" \
1239 -s "Application Layer Protocol is abc"
1240
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001241run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001242 "$P_SRV debug_level=3 alpn=abc,1234" \
1243 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001244 0 \
1245 -c "client hello, adding alpn extension" \
1246 -s "found alpn extension" \
1247 -C "got an alert message, type: \\[2:120]" \
1248 -s "server hello, adding alpn extension" \
1249 -c "found alpn extension" \
1250 -c "Application Layer Protocol is abc" \
1251 -s "Application Layer Protocol is abc"
1252
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001253run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001254 "$P_SRV debug_level=3 alpn=abc,1234" \
1255 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001256 0 \
1257 -c "client hello, adding alpn extension" \
1258 -s "found alpn extension" \
1259 -C "got an alert message, type: \\[2:120]" \
1260 -s "server hello, adding alpn extension" \
1261 -c "found alpn extension" \
1262 -c "Application Layer Protocol is 1234" \
1263 -s "Application Layer Protocol is 1234"
1264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001265run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001266 "$P_SRV debug_level=3 alpn=abc,123" \
1267 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001268 1 \
1269 -c "client hello, adding alpn extension" \
1270 -s "found alpn extension" \
1271 -c "got an alert message, type: \\[2:120]" \
1272 -S "server hello, adding alpn extension" \
1273 -C "found alpn extension" \
1274 -C "Application Layer Protocol is 1234" \
1275 -S "Application Layer Protocol is 1234"
1276
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001277fi
1278
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001279# Tests for keyUsage in leaf certificates, part 1:
1280# server-side certificate/suite selection
1281
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001282run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001283 "$P_SRV key_file=data_files/server2.key \
1284 crt_file=data_files/server2.ku-ds.crt" \
1285 "$P_CLI" \
1286 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001287 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001288
1289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001290run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001291 "$P_SRV key_file=data_files/server2.key \
1292 crt_file=data_files/server2.ku-ke.crt" \
1293 "$P_CLI" \
1294 0 \
1295 -c "Ciphersuite is TLS-RSA-WITH-"
1296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001297run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001298 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001299 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001300 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001301 1 \
1302 -C "Ciphersuite is "
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001305 "$P_SRV key_file=data_files/server5.key \
1306 crt_file=data_files/server5.ku-ds.crt" \
1307 "$P_CLI" \
1308 0 \
1309 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1310
1311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001312run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001313 "$P_SRV key_file=data_files/server5.key \
1314 crt_file=data_files/server5.ku-ka.crt" \
1315 "$P_CLI" \
1316 0 \
1317 -c "Ciphersuite is TLS-ECDH-"
1318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001319run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001320 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001321 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001322 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001323 1 \
1324 -C "Ciphersuite is "
1325
1326# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001327# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001329run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001330 "$O_SRV -key data_files/server2.key \
1331 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001332 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001333 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1334 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001335 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001336 -C "Processing of the Certificate handshake message failed" \
1337 -c "Ciphersuite is TLS-"
1338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001339run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001340 "$O_SRV -key data_files/server2.key \
1341 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001342 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001343 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1344 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001345 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001346 -C "Processing of the Certificate handshake message failed" \
1347 -c "Ciphersuite is TLS-"
1348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001349run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001350 "$O_SRV -key data_files/server2.key \
1351 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001352 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001353 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1354 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001355 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001356 -C "Processing of the Certificate handshake message failed" \
1357 -c "Ciphersuite is TLS-"
1358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001359run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001360 "$O_SRV -key data_files/server2.key \
1361 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001362 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001363 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1364 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001365 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001366 -c "Processing of the Certificate handshake message failed" \
1367 -C "Ciphersuite is TLS-"
1368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001369run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001370 "$O_SRV -key data_files/server2.key \
1371 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001372 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001373 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1374 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001375 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001376 -C "Processing of the Certificate handshake message failed" \
1377 -c "Ciphersuite is TLS-"
1378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001379run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001380 "$O_SRV -key data_files/server2.key \
1381 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001382 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001383 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1384 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001385 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001386 -c "Processing of the Certificate handshake message failed" \
1387 -C "Ciphersuite is TLS-"
1388
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001389# Tests for keyUsage in leaf certificates, part 3:
1390# server-side checking of client cert
1391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001392run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001393 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001394 "$O_CLI -key data_files/server2.key \
1395 -cert data_files/server2.ku-ds.crt" \
1396 0 \
1397 -S "bad certificate (usage extensions)" \
1398 -S "Processing of the Certificate handshake message failed"
1399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001400run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001401 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001402 "$O_CLI -key data_files/server2.key \
1403 -cert data_files/server2.ku-ke.crt" \
1404 0 \
1405 -s "bad certificate (usage extensions)" \
1406 -S "Processing of the Certificate handshake message failed"
1407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001408run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001409 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001410 "$O_CLI -key data_files/server2.key \
1411 -cert data_files/server2.ku-ke.crt" \
1412 1 \
1413 -s "bad certificate (usage extensions)" \
1414 -s "Processing of the Certificate handshake message failed"
1415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001416run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001417 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001418 "$O_CLI -key data_files/server5.key \
1419 -cert data_files/server5.ku-ds.crt" \
1420 0 \
1421 -S "bad certificate (usage extensions)" \
1422 -S "Processing of the Certificate handshake message failed"
1423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001424run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001425 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001426 "$O_CLI -key data_files/server5.key \
1427 -cert data_files/server5.ku-ka.crt" \
1428 0 \
1429 -s "bad certificate (usage extensions)" \
1430 -S "Processing of the Certificate handshake message failed"
1431
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001432# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001434run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001435 "$P_SRV key_file=data_files/server5.key \
1436 crt_file=data_files/server5.eku-srv.crt" \
1437 "$P_CLI" \
1438 0
1439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001440run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001441 "$P_SRV key_file=data_files/server5.key \
1442 crt_file=data_files/server5.eku-srv.crt" \
1443 "$P_CLI" \
1444 0
1445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001446run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001447 "$P_SRV key_file=data_files/server5.key \
1448 crt_file=data_files/server5.eku-cs_any.crt" \
1449 "$P_CLI" \
1450 0
1451
1452# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001453run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001454 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1455 crt_file=data_files/server5.eku-cli.crt" \
1456 "$P_CLI psk=badbad" \
1457 1
1458
1459# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1460
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001461run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001462 "$O_SRV -key data_files/server5.key \
1463 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001464 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001465 0 \
1466 -C "bad certificate (usage extensions)" \
1467 -C "Processing of the Certificate handshake message failed" \
1468 -c "Ciphersuite is TLS-"
1469
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001470run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001471 "$O_SRV -key data_files/server5.key \
1472 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001473 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001474 0 \
1475 -C "bad certificate (usage extensions)" \
1476 -C "Processing of the Certificate handshake message failed" \
1477 -c "Ciphersuite is TLS-"
1478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001479run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001480 "$O_SRV -key data_files/server5.key \
1481 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001482 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001483 0 \
1484 -C "bad certificate (usage extensions)" \
1485 -C "Processing of the Certificate handshake message failed" \
1486 -c "Ciphersuite is TLS-"
1487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001488run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001489 "$O_SRV -key data_files/server5.key \
1490 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001491 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001492 1 \
1493 -c "bad certificate (usage extensions)" \
1494 -c "Processing of the Certificate handshake message failed" \
1495 -C "Ciphersuite is TLS-"
1496
1497# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1498
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001499run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001500 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001501 "$O_CLI -key data_files/server5.key \
1502 -cert data_files/server5.eku-cli.crt" \
1503 0 \
1504 -S "bad certificate (usage extensions)" \
1505 -S "Processing of the Certificate handshake message failed"
1506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001508 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001509 "$O_CLI -key data_files/server5.key \
1510 -cert data_files/server5.eku-srv_cli.crt" \
1511 0 \
1512 -S "bad certificate (usage extensions)" \
1513 -S "Processing of the Certificate handshake message failed"
1514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001515run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001516 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001517 "$O_CLI -key data_files/server5.key \
1518 -cert data_files/server5.eku-cs_any.crt" \
1519 0 \
1520 -S "bad certificate (usage extensions)" \
1521 -S "Processing of the Certificate handshake message failed"
1522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001523run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001524 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001525 "$O_CLI -key data_files/server5.key \
1526 -cert data_files/server5.eku-cs.crt" \
1527 0 \
1528 -s "bad certificate (usage extensions)" \
1529 -S "Processing of the Certificate handshake message failed"
1530
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001531run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001532 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001533 "$O_CLI -key data_files/server5.key \
1534 -cert data_files/server5.eku-cs.crt" \
1535 1 \
1536 -s "bad certificate (usage extensions)" \
1537 -s "Processing of the Certificate handshake message failed"
1538
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001539# Tests for DHM parameters loading
1540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001541run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001542 "$P_SRV" \
1543 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1544 debug_level=3" \
1545 0 \
1546 -c "value of 'DHM: P ' (2048 bits)" \
1547 -c "value of 'DHM: G ' (2048 bits)"
1548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001549run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001550 "$P_SRV dhm_file=data_files/dhparams.pem" \
1551 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1552 debug_level=3" \
1553 0 \
1554 -c "value of 'DHM: P ' (1024 bits)" \
1555 -c "value of 'DHM: G ' (2 bits)"
1556
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001557# Tests for PSK callback
1558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001559run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001560 "$P_SRV psk=abc123 psk_identity=foo" \
1561 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1562 psk_identity=foo psk=abc123" \
1563 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001564 -S "SSL - The server has no ciphersuites in common" \
1565 -S "SSL - Unknown identity received" \
1566 -S "SSL - Verification of the message MAC failed"
1567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001568run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001569 "$P_SRV" \
1570 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1571 psk_identity=foo psk=abc123" \
1572 1 \
1573 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001574 -S "SSL - Unknown identity received" \
1575 -S "SSL - Verification of the message MAC failed"
1576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001577run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001578 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1579 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1580 psk_identity=foo psk=abc123" \
1581 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001582 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001583 -s "SSL - Unknown identity received" \
1584 -S "SSL - Verification of the message MAC failed"
1585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001586run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001587 "$P_SRV psk_list=abc,dead,def,beef" \
1588 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1589 psk_identity=abc psk=dead" \
1590 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001591 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001592 -S "SSL - Unknown identity received" \
1593 -S "SSL - Verification of the message MAC failed"
1594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001595run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001596 "$P_SRV psk_list=abc,dead,def,beef" \
1597 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1598 psk_identity=def psk=beef" \
1599 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001600 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001601 -S "SSL - Unknown identity received" \
1602 -S "SSL - Verification of the message MAC failed"
1603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001604run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001605 "$P_SRV psk_list=abc,dead,def,beef" \
1606 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1607 psk_identity=ghi psk=beef" \
1608 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001609 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001610 -s "SSL - Unknown identity received" \
1611 -S "SSL - Verification of the message MAC failed"
1612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001613run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001614 "$P_SRV psk_list=abc,dead,def,beef" \
1615 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1616 psk_identity=abc psk=beef" \
1617 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001618 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001619 -S "SSL - Unknown identity received" \
1620 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001621
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001622# Tests for ciphersuites per version
1623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001624run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001625 "$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" \
1626 "$P_CLI force_version=ssl3" \
1627 0 \
1628 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1629
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001630run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001631 "$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" \
1632 "$P_CLI force_version=tls1" \
1633 0 \
1634 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001636run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001637 "$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" \
1638 "$P_CLI force_version=tls1_1" \
1639 0 \
1640 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001642run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001643 "$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" \
1644 "$P_CLI force_version=tls1_2" \
1645 0 \
1646 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1647
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001648# Tests for ssl_get_bytes_avail()
1649
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001650run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001651 "$P_SRV" \
1652 "$P_CLI request_size=100" \
1653 0 \
1654 -s "Read from client: 100 bytes read$"
1655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001656run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001657 "$P_SRV" \
1658 "$P_CLI request_size=500" \
1659 0 \
1660 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001661
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001662# Tests for small packets
1663
1664run_test "Small packet SSLv3 BlockCipher" \
1665 "$P_SRV" \
1666 "$P_CLI request_size=1 force_version=ssl3 \
1667 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1668 0 \
1669 -s "Read from client: 1 bytes read"
1670
1671run_test "Small packet SSLv3 StreamCipher" \
1672 "$P_SRV" \
1673 "$P_CLI request_size=1 force_version=ssl3 \
1674 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1675 0 \
1676 -s "Read from client: 1 bytes read"
1677
1678run_test "Small packet TLS 1.0 BlockCipher" \
1679 "$P_SRV" \
1680 "$P_CLI request_size=1 force_version=tls1 \
1681 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1682 0 \
1683 -s "Read from client: 1 bytes read"
1684
1685run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1686 "$P_SRV" \
1687 "$P_CLI request_size=1 force_version=tls1 \
1688 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1689 trunc_hmac=1" \
1690 0 \
1691 -s "Read from client: 1 bytes read"
1692
1693run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1694 "$P_SRV" \
1695 "$P_CLI request_size=1 force_version=tls1 \
1696 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1697 trunc_hmac=1" \
1698 0 \
1699 -s "Read from client: 1 bytes read"
1700
1701run_test "Small packet TLS 1.1 BlockCipher" \
1702 "$P_SRV" \
1703 "$P_CLI request_size=1 force_version=tls1_1 \
1704 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1705 0 \
1706 -s "Read from client: 1 bytes read"
1707
1708run_test "Small packet TLS 1.1 StreamCipher" \
1709 "$P_SRV" \
1710 "$P_CLI request_size=1 force_version=tls1_1 \
1711 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1712 0 \
1713 -s "Read from client: 1 bytes read"
1714
1715run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1716 "$P_SRV" \
1717 "$P_CLI request_size=1 force_version=tls1_1 \
1718 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1719 trunc_hmac=1" \
1720 0 \
1721 -s "Read from client: 1 bytes read"
1722
1723run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1724 "$P_SRV" \
1725 "$P_CLI request_size=1 force_version=tls1_1 \
1726 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1727 trunc_hmac=1" \
1728 0 \
1729 -s "Read from client: 1 bytes read"
1730
1731run_test "Small packet TLS 1.2 BlockCipher" \
1732 "$P_SRV" \
1733 "$P_CLI request_size=1 force_version=tls1_2 \
1734 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1735 0 \
1736 -s "Read from client: 1 bytes read"
1737
1738run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1739 "$P_SRV" \
1740 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1741 0 \
1742 -s "Read from client: 1 bytes read"
1743
1744run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1745 "$P_SRV" \
1746 "$P_CLI request_size=1 force_version=tls1_2 \
1747 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1748 trunc_hmac=1" \
1749 0 \
1750 -s "Read from client: 1 bytes read"
1751
1752run_test "Small packet TLS 1.2 StreamCipher" \
1753 "$P_SRV" \
1754 "$P_CLI request_size=1 force_version=tls1_2 \
1755 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1756 0 \
1757 -s "Read from client: 1 bytes read"
1758
1759run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1760 "$P_SRV" \
1761 "$P_CLI request_size=1 force_version=tls1_2 \
1762 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1763 trunc_hmac=1" \
1764 0 \
1765 -s "Read from client: 1 bytes read"
1766
1767run_test "Small packet TLS 1.2 AEAD" \
1768 "$P_SRV" \
1769 "$P_CLI request_size=1 force_version=tls1_2 \
1770 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1771 0 \
1772 -s "Read from client: 1 bytes read"
1773
1774run_test "Small packet TLS 1.2 AEAD shorter tag" \
1775 "$P_SRV" \
1776 "$P_CLI request_size=1 force_version=tls1_2 \
1777 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1778 0 \
1779 -s "Read from client: 1 bytes read"
1780
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001781# Test for large packets
1782
1783run_test "Large packet SSLv3 BlockCipher" \
1784 "$P_SRV" \
1785 "$P_CLI request_size=16384 force_version=ssl3 \
1786 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1787 0 \
1788 -s "Read from client: 16384 bytes read"
1789
1790run_test "Large packet SSLv3 StreamCipher" \
1791 "$P_SRV" \
1792 "$P_CLI request_size=16384 force_version=ssl3 \
1793 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1794 0 \
1795 -s "Read from client: 16384 bytes read"
1796
1797run_test "Large packet TLS 1.0 BlockCipher" \
1798 "$P_SRV" \
1799 "$P_CLI request_size=16384 force_version=tls1 \
1800 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1801 0 \
1802 -s "Read from client: 16384 bytes read"
1803
1804run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1805 "$P_SRV" \
1806 "$P_CLI request_size=16384 force_version=tls1 \
1807 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1808 trunc_hmac=1" \
1809 0 \
1810 -s "Read from client: 16384 bytes read"
1811
1812run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1813 "$P_SRV" \
1814 "$P_CLI request_size=16384 force_version=tls1 \
1815 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1816 trunc_hmac=1" \
1817 0 \
1818 -s "Read from client: 16384 bytes read"
1819
1820run_test "Large packet TLS 1.1 BlockCipher" \
1821 "$P_SRV" \
1822 "$P_CLI request_size=16384 force_version=tls1_1 \
1823 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1824 0 \
1825 -s "Read from client: 16384 bytes read"
1826
1827run_test "Large packet TLS 1.1 StreamCipher" \
1828 "$P_SRV" \
1829 "$P_CLI request_size=16384 force_version=tls1_1 \
1830 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1831 0 \
1832 -s "Read from client: 16384 bytes read"
1833
1834run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1835 "$P_SRV" \
1836 "$P_CLI request_size=16384 force_version=tls1_1 \
1837 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1838 trunc_hmac=1" \
1839 0 \
1840 -s "Read from client: 16384 bytes read"
1841
1842run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1843 "$P_SRV" \
1844 "$P_CLI request_size=16384 force_version=tls1_1 \
1845 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1846 trunc_hmac=1" \
1847 0 \
1848 -s "Read from client: 16384 bytes read"
1849
1850run_test "Large packet TLS 1.2 BlockCipher" \
1851 "$P_SRV" \
1852 "$P_CLI request_size=16384 force_version=tls1_2 \
1853 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1854 0 \
1855 -s "Read from client: 16384 bytes read"
1856
1857run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1858 "$P_SRV" \
1859 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1860 0 \
1861 -s "Read from client: 16384 bytes read"
1862
1863run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1864 "$P_SRV" \
1865 "$P_CLI request_size=16384 force_version=tls1_2 \
1866 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1867 trunc_hmac=1" \
1868 0 \
1869 -s "Read from client: 16384 bytes read"
1870
1871run_test "Large packet TLS 1.2 StreamCipher" \
1872 "$P_SRV" \
1873 "$P_CLI request_size=16384 force_version=tls1_2 \
1874 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1875 0 \
1876 -s "Read from client: 16384 bytes read"
1877
1878run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1879 "$P_SRV" \
1880 "$P_CLI request_size=16384 force_version=tls1_2 \
1881 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1882 trunc_hmac=1" \
1883 0 \
1884 -s "Read from client: 16384 bytes read"
1885
1886run_test "Large packet TLS 1.2 AEAD" \
1887 "$P_SRV" \
1888 "$P_CLI request_size=16384 force_version=tls1_2 \
1889 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1890 0 \
1891 -s "Read from client: 16384 bytes read"
1892
1893run_test "Large packet TLS 1.2 AEAD shorter tag" \
1894 "$P_SRV" \
1895 "$P_CLI request_size=16384 force_version=tls1_2 \
1896 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1897 0 \
1898 -s "Read from client: 16384 bytes read"
1899
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001900# Final report
1901
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001902echo "------------------------------------------------------------------------"
1903
1904if [ $FAILS = 0 ]; then
1905 echo -n "PASSED"
1906else
1907 echo -n "FAILED"
1908fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02001909PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001910echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001911
1912exit $FAILS