blob: 6db8571ff3bdc4f39743200c08ffaba7740b0496 [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
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100250 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100251 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
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100257 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100258 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é-Gonnard699cafa2014-10-27 13:57:03 +0100443# Tests for Encrypt-then-MAC extension
444
445run_test "Encrypt then MAC: default" \
446 "$P_SRV debug_level=3" \
447 "$P_CLI debug_level=3" \
448 0 \
449 -c "client hello, adding encrypt_then_mac extension" \
450 -s "found encrypt then mac extension" \
451 -s "server hello, adding encrypt then mac extension" \
452 -c "found encrypt_then_mac extension" \
453 -c "using encrypt then mac" \
454 -s "using encrypt then mac"
455
456run_test "Encrypt then MAC: client enabled, server disabled" \
457 "$P_SRV debug_level=3 etm=0" \
458 "$P_CLI debug_level=3 etm=1" \
459 0 \
460 -c "client hello, adding encrypt_then_mac extension" \
461 -s "found encrypt then mac extension" \
462 -S "server hello, adding encrypt then mac extension" \
463 -C "found encrypt_then_mac extension" \
464 -C "using encrypt then mac" \
465 -S "using encrypt then mac"
466
467run_test "Encrypt then MAC: client disabled, server enabled" \
468 "$P_SRV debug_level=3 etm=1" \
469 "$P_CLI debug_level=3 etm=0" \
470 0 \
471 -C "client hello, adding encrypt_then_mac extension" \
472 -S "found encrypt then mac extension" \
473 -S "server hello, adding encrypt then mac extension" \
474 -C "found encrypt_then_mac extension" \
475 -C "using encrypt then mac" \
476 -S "using encrypt then mac"
477
478run_test "Encrypt then MAC: client SSLv3, server enabled" \
479 "$P_SRV debug_level=3" \
480 "$P_CLI debug_level=3 force_version=ssl3" \
481 0 \
482 -C "client hello, adding encrypt_then_mac extension" \
483 -S "found encrypt then mac extension" \
484 -S "server hello, adding encrypt then mac extension" \
485 -C "found encrypt_then_mac extension" \
486 -C "using encrypt then mac" \
487 -S "using encrypt then mac"
488
489run_test "Encrypt then MAC: client enabled, server SSLv3" \
490 "$P_SRV debug_level=3 force_version=ssl3" \
491 "$P_CLI debug_level=3" \
492 0 \
493 -c "client hello, adding encrypt_then_mac extension" \
494 -s "found encrypt then mac extension" \
495 -S "server hello, adding encrypt then mac extension" \
496 -C "found encrypt_then_mac extension" \
497 -C "using encrypt then mac" \
498 -S "using encrypt then mac"
499
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200500# Tests for Extended Master Secret extension
501
502run_test "Extended Master Secret: default" \
503 "$P_SRV debug_level=3" \
504 "$P_CLI debug_level=3" \
505 0 \
506 -c "client hello, adding extended_master_secret extension" \
507 -s "found extended master secret extension" \
508 -s "server hello, adding extended master secret extension" \
509 -c "found extended_master_secret extension" \
510 -c "using extended master secret" \
511 -s "using extended master secret"
512
513run_test "Extended Master Secret: client enabled, server disabled" \
514 "$P_SRV debug_level=3 extended_ms=0" \
515 "$P_CLI debug_level=3 extended_ms=1" \
516 0 \
517 -c "client hello, adding extended_master_secret extension" \
518 -s "found extended master secret extension" \
519 -S "server hello, adding extended master secret extension" \
520 -C "found extended_master_secret extension" \
521 -C "using extended master secret" \
522 -S "using extended master secret"
523
524run_test "Extended Master Secret: client disabled, server enabled" \
525 "$P_SRV debug_level=3 extended_ms=1" \
526 "$P_CLI debug_level=3 extended_ms=0" \
527 0 \
528 -C "client hello, adding extended_master_secret extension" \
529 -S "found extended master secret extension" \
530 -S "server hello, adding extended master secret extension" \
531 -C "found extended_master_secret extension" \
532 -C "using extended master secret" \
533 -S "using extended master secret"
534
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200535run_test "Extended Master Secret: client SSLv3, server enabled" \
536 "$P_SRV debug_level=3" \
537 "$P_CLI debug_level=3 force_version=ssl3" \
538 0 \
539 -C "client hello, adding extended_master_secret extension" \
540 -S "found extended master secret extension" \
541 -S "server hello, adding extended master secret extension" \
542 -C "found extended_master_secret extension" \
543 -C "using extended master secret" \
544 -S "using extended master secret"
545
546run_test "Extended Master Secret: client enabled, server SSLv3" \
547 "$P_SRV debug_level=3 force_version=ssl3" \
548 "$P_CLI debug_level=3" \
549 0 \
550 -c "client hello, adding extended_master_secret extension" \
551 -s "found extended master secret extension" \
552 -S "server hello, adding extended master secret extension" \
553 -C "found extended_master_secret extension" \
554 -C "using extended master secret" \
555 -S "using extended master secret"
556
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200557# Tests for FALLBACK_SCSV
558
559run_test "Fallback SCSV: default" \
560 "$P_SRV" \
561 "$P_CLI debug_level=3 force_version=tls1_1" \
562 0 \
563 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200564 -S "received FALLBACK_SCSV" \
565 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200566 -C "is a fatal alert message (msg 86)"
567
568run_test "Fallback SCSV: explicitly disabled" \
569 "$P_SRV" \
570 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
571 0 \
572 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200573 -S "received FALLBACK_SCSV" \
574 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200575 -C "is a fatal alert message (msg 86)"
576
577run_test "Fallback SCSV: enabled" \
578 "$P_SRV" \
579 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200580 1 \
581 -c "adding FALLBACK_SCSV" \
582 -s "received FALLBACK_SCSV" \
583 -s "inapropriate fallback" \
584 -c "is a fatal alert message (msg 86)"
585
586run_test "Fallback SCSV: enabled, max version" \
587 "$P_SRV" \
588 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200589 0 \
590 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200591 -s "received FALLBACK_SCSV" \
592 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200593 -C "is a fatal alert message (msg 86)"
594
595requires_openssl_with_fallback_scsv
596run_test "Fallback SCSV: default, openssl server" \
597 "$O_SRV" \
598 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
599 0 \
600 -C "adding FALLBACK_SCSV" \
601 -C "is a fatal alert message (msg 86)"
602
603requires_openssl_with_fallback_scsv
604run_test "Fallback SCSV: enabled, openssl server" \
605 "$O_SRV" \
606 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
607 1 \
608 -c "adding FALLBACK_SCSV" \
609 -c "is a fatal alert message (msg 86)"
610
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200611requires_openssl_with_fallback_scsv
612run_test "Fallback SCSV: disabled, openssl client" \
613 "$P_SRV" \
614 "$O_CLI -tls1_1" \
615 0 \
616 -S "received FALLBACK_SCSV" \
617 -S "inapropriate fallback"
618
619requires_openssl_with_fallback_scsv
620run_test "Fallback SCSV: enabled, openssl client" \
621 "$P_SRV" \
622 "$O_CLI -tls1_1 -fallback_scsv" \
623 1 \
624 -s "received FALLBACK_SCSV" \
625 -s "inapropriate fallback"
626
627requires_openssl_with_fallback_scsv
628run_test "Fallback SCSV: enabled, max version, openssl client" \
629 "$P_SRV" \
630 "$O_CLI -fallback_scsv" \
631 0 \
632 -s "received FALLBACK_SCSV" \
633 -S "inapropriate fallback"
634
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100635# Tests for Session Tickets
636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200637run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200638 "$P_SRV debug_level=3 tickets=1" \
639 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100640 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100641 -c "client hello, adding session ticket extension" \
642 -s "found session ticket extension" \
643 -s "server hello, adding session ticket extension" \
644 -c "found session_ticket extension" \
645 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100646 -S "session successfully restored from cache" \
647 -s "session successfully restored from ticket" \
648 -s "a session has been resumed" \
649 -c "a session has been resumed"
650
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200651run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200652 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
653 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100654 0 \
655 -c "client hello, adding session ticket extension" \
656 -s "found session ticket extension" \
657 -s "server hello, adding session ticket extension" \
658 -c "found session_ticket extension" \
659 -c "parse new session ticket" \
660 -S "session successfully restored from cache" \
661 -s "session successfully restored from ticket" \
662 -s "a session has been resumed" \
663 -c "a session has been resumed"
664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200665run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200666 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
667 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100668 0 \
669 -c "client hello, adding session ticket extension" \
670 -s "found session ticket extension" \
671 -s "server hello, adding session ticket extension" \
672 -c "found session_ticket extension" \
673 -c "parse new session ticket" \
674 -S "session successfully restored from cache" \
675 -S "session successfully restored from ticket" \
676 -S "a session has been resumed" \
677 -C "a session has been resumed"
678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200679run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100680 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200681 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100682 0 \
683 -c "client hello, adding session ticket extension" \
684 -c "found session_ticket extension" \
685 -c "parse new session ticket" \
686 -c "a session has been resumed"
687
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200688run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200689 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200690 "( $O_CLI -sess_out $SESSION; \
691 $O_CLI -sess_in $SESSION; \
692 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100693 0 \
694 -s "found session ticket extension" \
695 -s "server hello, adding session ticket extension" \
696 -S "session successfully restored from cache" \
697 -s "session successfully restored from ticket" \
698 -s "a session has been resumed"
699
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100700# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100701
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200702run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200703 "$P_SRV debug_level=3 tickets=0" \
704 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100705 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100706 -c "client hello, adding session ticket extension" \
707 -s "found session ticket extension" \
708 -S "server hello, adding session ticket extension" \
709 -C "found session_ticket extension" \
710 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100711 -s "session successfully restored from cache" \
712 -S "session successfully restored from ticket" \
713 -s "a session has been resumed" \
714 -c "a session has been resumed"
715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200716run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200717 "$P_SRV debug_level=3 tickets=1" \
718 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100719 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100720 -C "client hello, adding session ticket extension" \
721 -S "found session ticket extension" \
722 -S "server hello, adding session ticket extension" \
723 -C "found session_ticket extension" \
724 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100725 -s "session successfully restored from cache" \
726 -S "session successfully restored from ticket" \
727 -s "a session has been resumed" \
728 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200730run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200731 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
732 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100733 0 \
734 -S "session successfully restored from cache" \
735 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100736 -S "a session has been resumed" \
737 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200739run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200740 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
741 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100742 0 \
743 -s "session successfully restored from cache" \
744 -S "session successfully restored from ticket" \
745 -s "a session has been resumed" \
746 -c "a session has been resumed"
747
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200748run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200749 "$P_SRV debug_level=3 tickets=0" \
750 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100751 0 \
752 -s "session successfully restored from cache" \
753 -S "session successfully restored from ticket" \
754 -s "a session has been resumed" \
755 -c "a session has been resumed"
756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200757run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200758 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
759 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100760 0 \
761 -S "session successfully restored from cache" \
762 -S "session successfully restored from ticket" \
763 -S "a session has been resumed" \
764 -C "a session has been resumed"
765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200766run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200767 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
768 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100769 0 \
770 -s "session successfully restored from cache" \
771 -S "session successfully restored from ticket" \
772 -s "a session has been resumed" \
773 -c "a session has been resumed"
774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200775run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200776 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200777 "( $O_CLI -sess_out $SESSION; \
778 $O_CLI -sess_in $SESSION; \
779 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100780 0 \
781 -s "found session ticket extension" \
782 -S "server hello, adding session ticket extension" \
783 -s "session successfully restored from cache" \
784 -S "session successfully restored from ticket" \
785 -s "a session has been resumed"
786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200787run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100788 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200789 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100790 0 \
791 -C "found session_ticket extension" \
792 -C "parse new session ticket" \
793 -c "a session has been resumed"
794
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100795# Tests for Max Fragment Length extension
796
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200797run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200798 "$P_SRV debug_level=3" \
799 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100800 0 \
801 -C "client hello, adding max_fragment_length extension" \
802 -S "found max fragment length extension" \
803 -S "server hello, max_fragment_length extension" \
804 -C "found max_fragment_length extension"
805
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200806run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200807 "$P_SRV debug_level=3" \
808 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100809 0 \
810 -c "client hello, adding max_fragment_length extension" \
811 -s "found max fragment length extension" \
812 -s "server hello, max_fragment_length extension" \
813 -c "found max_fragment_length extension"
814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200815run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200816 "$P_SRV debug_level=3 max_frag_len=4096" \
817 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100818 0 \
819 -C "client hello, adding max_fragment_length extension" \
820 -S "found max fragment length extension" \
821 -S "server hello, max_fragment_length extension" \
822 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200824requires_gnutls
825run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200826 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200827 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200828 0 \
829 -c "client hello, adding max_fragment_length extension" \
830 -c "found max_fragment_length extension"
831
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100832# Tests for renegotiation
833
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200834run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200835 "$P_SRV debug_level=3 exchanges=2" \
836 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100837 0 \
838 -C "client hello, adding renegotiation extension" \
839 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
840 -S "found renegotiation extension" \
841 -s "server hello, secure renegotiation extension" \
842 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100843 -C "=> renegotiate" \
844 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100845 -S "write hello request"
846
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200847run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200848 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
849 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100850 0 \
851 -c "client hello, adding renegotiation extension" \
852 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
853 -s "found renegotiation extension" \
854 -s "server hello, secure renegotiation extension" \
855 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100856 -c "=> renegotiate" \
857 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100858 -S "write hello request"
859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200860run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200861 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
862 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100863 0 \
864 -c "client hello, adding renegotiation extension" \
865 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
866 -s "found renegotiation extension" \
867 -s "server hello, secure renegotiation extension" \
868 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100869 -c "=> renegotiate" \
870 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100871 -s "write hello request"
872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200873run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200874 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
875 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100876 0 \
877 -c "client hello, adding renegotiation extension" \
878 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
879 -s "found renegotiation extension" \
880 -s "server hello, secure renegotiation extension" \
881 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100882 -c "=> renegotiate" \
883 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100884 -s "write hello request"
885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200886run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200887 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
888 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100889 1 \
890 -c "client hello, adding renegotiation extension" \
891 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
892 -S "found renegotiation extension" \
893 -s "server hello, secure renegotiation extension" \
894 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100895 -c "=> renegotiate" \
896 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200897 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200898 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200899 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200901run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200902 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
903 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100904 0 \
905 -C "client hello, adding renegotiation extension" \
906 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
907 -S "found renegotiation extension" \
908 -s "server hello, secure renegotiation extension" \
909 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100910 -C "=> renegotiate" \
911 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100912 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200913 -S "SSL - An unexpected message was received from our peer" \
914 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200916run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200917 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200918 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200919 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200920 0 \
921 -C "client hello, adding renegotiation extension" \
922 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
923 -S "found renegotiation extension" \
924 -s "server hello, secure renegotiation extension" \
925 -c "found renegotiation extension" \
926 -C "=> renegotiate" \
927 -S "=> renegotiate" \
928 -s "write hello request" \
929 -S "SSL - An unexpected message was received from our peer" \
930 -S "failed"
931
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200932# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200933run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200934 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200935 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200936 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200937 0 \
938 -C "client hello, adding renegotiation extension" \
939 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
940 -S "found renegotiation extension" \
941 -s "server hello, secure renegotiation extension" \
942 -c "found renegotiation extension" \
943 -C "=> renegotiate" \
944 -S "=> renegotiate" \
945 -s "write hello request" \
946 -S "SSL - An unexpected message was received from our peer" \
947 -S "failed"
948
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200949run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200950 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200951 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200952 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200953 0 \
954 -C "client hello, adding renegotiation extension" \
955 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
956 -S "found renegotiation extension" \
957 -s "server hello, secure renegotiation extension" \
958 -c "found renegotiation extension" \
959 -C "=> renegotiate" \
960 -S "=> renegotiate" \
961 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200962 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200964run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200965 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200966 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200967 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200968 0 \
969 -c "client hello, adding renegotiation extension" \
970 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
971 -s "found renegotiation extension" \
972 -s "server hello, secure renegotiation extension" \
973 -c "found renegotiation extension" \
974 -c "=> renegotiate" \
975 -s "=> renegotiate" \
976 -s "write hello request" \
977 -S "SSL - An unexpected message was received from our peer" \
978 -S "failed"
979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200980run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200981 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
982 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200983 0 \
984 -c "client hello, adding renegotiation extension" \
985 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
986 -s "found renegotiation extension" \
987 -s "server hello, secure renegotiation extension" \
988 -c "found renegotiation extension" \
989 -c "=> renegotiate" \
990 -s "=> renegotiate" \
991 -S "write hello request"
992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200993run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200994 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
995 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200996 0 \
997 -c "client hello, adding renegotiation extension" \
998 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
999 -s "found renegotiation extension" \
1000 -s "server hello, secure renegotiation extension" \
1001 -c "found renegotiation extension" \
1002 -c "=> renegotiate" \
1003 -s "=> renegotiate" \
1004 -s "write hello request"
1005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001006run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001007 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001008 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001009 0 \
1010 -c "client hello, adding renegotiation extension" \
1011 -c "found renegotiation extension" \
1012 -c "=> renegotiate" \
1013 -C "ssl_handshake returned" \
1014 -C "error" \
1015 -c "HTTP/1.0 200 [Oo][Kk]"
1016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001017run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001018 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001019 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001020 0 \
1021 -c "client hello, adding renegotiation extension" \
1022 -c "found renegotiation extension" \
1023 -c "=> renegotiate" \
1024 -C "ssl_handshake returned" \
1025 -C "error" \
1026 -c "HTTP/1.0 200 [Oo][Kk]"
1027
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001028# Tests for auth_mode
1029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001030run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001031 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001032 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001033 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001034 1 \
1035 -c "x509_verify_cert() returned" \
1036 -c "! self-signed or not signed by a trusted CA" \
1037 -c "! ssl_handshake returned" \
1038 -c "X509 - Certificate verification failed"
1039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001040run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001041 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001042 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001043 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001044 0 \
1045 -c "x509_verify_cert() returned" \
1046 -c "! self-signed or not signed by a trusted CA" \
1047 -C "! ssl_handshake returned" \
1048 -C "X509 - Certificate verification failed"
1049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001050run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001051 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001052 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001053 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001054 0 \
1055 -C "x509_verify_cert() returned" \
1056 -C "! self-signed or not signed by a trusted CA" \
1057 -C "! ssl_handshake returned" \
1058 -C "X509 - Certificate verification failed"
1059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001060run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001061 "$P_SRV debug_level=3 auth_mode=required" \
1062 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001063 key_file=data_files/server5.key" \
1064 1 \
1065 -S "skip write certificate request" \
1066 -C "skip parse certificate request" \
1067 -c "got a certificate request" \
1068 -C "skip write certificate" \
1069 -C "skip write certificate verify" \
1070 -S "skip parse certificate verify" \
1071 -s "x509_verify_cert() returned" \
1072 -S "! self-signed or not signed by a trusted CA" \
1073 -s "! ssl_handshake returned" \
1074 -c "! ssl_handshake returned" \
1075 -s "X509 - Certificate verification failed"
1076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001077run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001078 "$P_SRV debug_level=3 auth_mode=optional" \
1079 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001080 key_file=data_files/server5.key" \
1081 0 \
1082 -S "skip write certificate request" \
1083 -C "skip parse certificate request" \
1084 -c "got a certificate request" \
1085 -C "skip write certificate" \
1086 -C "skip write certificate verify" \
1087 -S "skip parse certificate verify" \
1088 -s "x509_verify_cert() returned" \
1089 -s "! self-signed or not signed by a trusted CA" \
1090 -S "! ssl_handshake returned" \
1091 -C "! ssl_handshake returned" \
1092 -S "X509 - Certificate verification failed"
1093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001094run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001095 "$P_SRV debug_level=3 auth_mode=none" \
1096 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001097 key_file=data_files/server5.key" \
1098 0 \
1099 -s "skip write certificate request" \
1100 -C "skip parse certificate request" \
1101 -c "got no certificate request" \
1102 -c "skip write certificate" \
1103 -c "skip write certificate verify" \
1104 -s "skip parse certificate verify" \
1105 -S "x509_verify_cert() returned" \
1106 -S "! self-signed or not signed by a trusted CA" \
1107 -S "! ssl_handshake returned" \
1108 -C "! ssl_handshake returned" \
1109 -S "X509 - Certificate verification failed"
1110
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001111run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001112 "$P_SRV debug_level=3 auth_mode=optional" \
1113 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001114 0 \
1115 -S "skip write certificate request" \
1116 -C "skip parse certificate request" \
1117 -c "got a certificate request" \
1118 -C "skip write certificate$" \
1119 -C "got no certificate to send" \
1120 -S "SSLv3 client has no certificate" \
1121 -c "skip write certificate verify" \
1122 -s "skip parse certificate verify" \
1123 -s "! no client certificate sent" \
1124 -S "! ssl_handshake returned" \
1125 -C "! ssl_handshake returned" \
1126 -S "X509 - Certificate verification failed"
1127
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001128run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001129 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001130 "$O_CLI" \
1131 0 \
1132 -S "skip write certificate request" \
1133 -s "skip parse certificate verify" \
1134 -s "! no client certificate sent" \
1135 -S "! ssl_handshake returned" \
1136 -S "X509 - Certificate verification failed"
1137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001138run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001139 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001140 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001141 0 \
1142 -C "skip parse certificate request" \
1143 -c "got a certificate request" \
1144 -C "skip write certificate$" \
1145 -c "skip write certificate verify" \
1146 -C "! ssl_handshake returned"
1147
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001148run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001149 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1150 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001151 0 \
1152 -S "skip write certificate request" \
1153 -C "skip parse certificate request" \
1154 -c "got a certificate request" \
1155 -C "skip write certificate$" \
1156 -c "skip write certificate verify" \
1157 -c "got no certificate to send" \
1158 -s "SSLv3 client has no certificate" \
1159 -s "skip parse certificate verify" \
1160 -s "! no client certificate sent" \
1161 -S "! ssl_handshake returned" \
1162 -C "! ssl_handshake returned" \
1163 -S "X509 - Certificate verification failed"
1164
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001165# tests for SNI
1166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001167run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001168 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001169 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001170 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001171 server_name=localhost" \
1172 0 \
1173 -S "parse ServerName extension" \
1174 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1175 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001177run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001178 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001179 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001180 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 +01001181 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001182 server_name=localhost" \
1183 0 \
1184 -s "parse ServerName extension" \
1185 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1186 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001188run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001189 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001190 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001191 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 +01001192 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001193 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001194 0 \
1195 -s "parse ServerName extension" \
1196 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001197 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001199run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001200 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001201 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001202 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 +01001203 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001204 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001205 1 \
1206 -s "parse ServerName extension" \
1207 -s "ssl_sni_wrapper() returned" \
1208 -s "ssl_handshake returned" \
1209 -c "ssl_handshake returned" \
1210 -c "SSL - A fatal alert message was received from our peer"
1211
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001212# Tests for non-blocking I/O: exercise a variety of handshake flows
1213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001214run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001215 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1216 "$P_CLI nbio=2 tickets=0" \
1217 0 \
1218 -S "ssl_handshake returned" \
1219 -C "ssl_handshake returned" \
1220 -c "Read from server: .* bytes read"
1221
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001222run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001223 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1224 "$P_CLI nbio=2 tickets=0" \
1225 0 \
1226 -S "ssl_handshake returned" \
1227 -C "ssl_handshake returned" \
1228 -c "Read from server: .* bytes read"
1229
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001230run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001231 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1232 "$P_CLI nbio=2 tickets=1" \
1233 0 \
1234 -S "ssl_handshake returned" \
1235 -C "ssl_handshake returned" \
1236 -c "Read from server: .* bytes read"
1237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001238run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001239 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1240 "$P_CLI nbio=2 tickets=1" \
1241 0 \
1242 -S "ssl_handshake returned" \
1243 -C "ssl_handshake returned" \
1244 -c "Read from server: .* bytes read"
1245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001246run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001247 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1248 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1249 0 \
1250 -S "ssl_handshake returned" \
1251 -C "ssl_handshake returned" \
1252 -c "Read from server: .* bytes read"
1253
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001254run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001255 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1256 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1257 0 \
1258 -S "ssl_handshake returned" \
1259 -C "ssl_handshake returned" \
1260 -c "Read from server: .* bytes read"
1261
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001262run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001263 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1264 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1265 0 \
1266 -S "ssl_handshake returned" \
1267 -C "ssl_handshake returned" \
1268 -c "Read from server: .* bytes read"
1269
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001270# Tests for version negotiation
1271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001272run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001273 "$P_SRV" \
1274 "$P_CLI" \
1275 0 \
1276 -S "ssl_handshake returned" \
1277 -C "ssl_handshake returned" \
1278 -s "Protocol is TLSv1.2" \
1279 -c "Protocol is TLSv1.2"
1280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001281run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001282 "$P_SRV" \
1283 "$P_CLI max_version=tls1_1" \
1284 0 \
1285 -S "ssl_handshake returned" \
1286 -C "ssl_handshake returned" \
1287 -s "Protocol is TLSv1.1" \
1288 -c "Protocol is TLSv1.1"
1289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001290run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001291 "$P_SRV max_version=tls1_1" \
1292 "$P_CLI" \
1293 0 \
1294 -S "ssl_handshake returned" \
1295 -C "ssl_handshake returned" \
1296 -s "Protocol is TLSv1.1" \
1297 -c "Protocol is TLSv1.1"
1298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001299run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001300 "$P_SRV max_version=tls1_1" \
1301 "$P_CLI max_version=tls1_1" \
1302 0 \
1303 -S "ssl_handshake returned" \
1304 -C "ssl_handshake returned" \
1305 -s "Protocol is TLSv1.1" \
1306 -c "Protocol is TLSv1.1"
1307
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001308run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001309 "$P_SRV min_version=tls1_1" \
1310 "$P_CLI max_version=tls1_1" \
1311 0 \
1312 -S "ssl_handshake returned" \
1313 -C "ssl_handshake returned" \
1314 -s "Protocol is TLSv1.1" \
1315 -c "Protocol is TLSv1.1"
1316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001317run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001318 "$P_SRV max_version=tls1_1" \
1319 "$P_CLI min_version=tls1_1" \
1320 0 \
1321 -S "ssl_handshake returned" \
1322 -C "ssl_handshake returned" \
1323 -s "Protocol is TLSv1.1" \
1324 -c "Protocol is TLSv1.1"
1325
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001326run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001327 "$P_SRV max_version=tls1_1" \
1328 "$P_CLI min_version=tls1_2" \
1329 1 \
1330 -s "ssl_handshake returned" \
1331 -c "ssl_handshake returned" \
1332 -c "SSL - Handshake protocol not within min/max boundaries"
1333
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001334run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001335 "$P_SRV min_version=tls1_2" \
1336 "$P_CLI max_version=tls1_1" \
1337 1 \
1338 -s "ssl_handshake returned" \
1339 -c "ssl_handshake returned" \
1340 -s "SSL - Handshake protocol not within min/max boundaries"
1341
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001342# Tests for ALPN extension
1343
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001344if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_SRV debug_level=3" \
1348 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001349 0 \
1350 -C "client hello, adding alpn extension" \
1351 -S "found alpn extension" \
1352 -C "got an alert message, type: \\[2:120]" \
1353 -S "server hello, adding alpn extension" \
1354 -C "found alpn extension " \
1355 -C "Application Layer Protocol is" \
1356 -S "Application Layer Protocol is"
1357
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001358run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001359 "$P_SRV debug_level=3" \
1360 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001361 0 \
1362 -c "client hello, adding alpn extension" \
1363 -s "found alpn extension" \
1364 -C "got an alert message, type: \\[2:120]" \
1365 -S "server hello, adding alpn extension" \
1366 -C "found alpn extension " \
1367 -c "Application Layer Protocol is (none)" \
1368 -S "Application Layer Protocol is"
1369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001370run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001371 "$P_SRV debug_level=3 alpn=abc,1234" \
1372 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001373 0 \
1374 -C "client hello, adding alpn extension" \
1375 -S "found alpn extension" \
1376 -C "got an alert message, type: \\[2:120]" \
1377 -S "server hello, adding alpn extension" \
1378 -C "found alpn extension " \
1379 -C "Application Layer Protocol is" \
1380 -s "Application Layer Protocol is (none)"
1381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001382run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001383 "$P_SRV debug_level=3 alpn=abc,1234" \
1384 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001385 0 \
1386 -c "client hello, adding alpn extension" \
1387 -s "found alpn extension" \
1388 -C "got an alert message, type: \\[2:120]" \
1389 -s "server hello, adding alpn extension" \
1390 -c "found alpn extension" \
1391 -c "Application Layer Protocol is abc" \
1392 -s "Application Layer Protocol is abc"
1393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001394run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001395 "$P_SRV debug_level=3 alpn=abc,1234" \
1396 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001397 0 \
1398 -c "client hello, adding alpn extension" \
1399 -s "found alpn extension" \
1400 -C "got an alert message, type: \\[2:120]" \
1401 -s "server hello, adding alpn extension" \
1402 -c "found alpn extension" \
1403 -c "Application Layer Protocol is abc" \
1404 -s "Application Layer Protocol is abc"
1405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001406run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001407 "$P_SRV debug_level=3 alpn=abc,1234" \
1408 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001409 0 \
1410 -c "client hello, adding alpn extension" \
1411 -s "found alpn extension" \
1412 -C "got an alert message, type: \\[2:120]" \
1413 -s "server hello, adding alpn extension" \
1414 -c "found alpn extension" \
1415 -c "Application Layer Protocol is 1234" \
1416 -s "Application Layer Protocol is 1234"
1417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001418run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001419 "$P_SRV debug_level=3 alpn=abc,123" \
1420 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001421 1 \
1422 -c "client hello, adding alpn extension" \
1423 -s "found alpn extension" \
1424 -c "got an alert message, type: \\[2:120]" \
1425 -S "server hello, adding alpn extension" \
1426 -C "found alpn extension" \
1427 -C "Application Layer Protocol is 1234" \
1428 -S "Application Layer Protocol is 1234"
1429
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001430fi
1431
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001432# Tests for keyUsage in leaf certificates, part 1:
1433# server-side certificate/suite selection
1434
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001435run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001436 "$P_SRV key_file=data_files/server2.key \
1437 crt_file=data_files/server2.ku-ds.crt" \
1438 "$P_CLI" \
1439 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001440 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001441
1442
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001443run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001444 "$P_SRV key_file=data_files/server2.key \
1445 crt_file=data_files/server2.ku-ke.crt" \
1446 "$P_CLI" \
1447 0 \
1448 -c "Ciphersuite is TLS-RSA-WITH-"
1449
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001450run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001451 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001452 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001453 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001454 1 \
1455 -C "Ciphersuite is "
1456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001457run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001458 "$P_SRV key_file=data_files/server5.key \
1459 crt_file=data_files/server5.ku-ds.crt" \
1460 "$P_CLI" \
1461 0 \
1462 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1463
1464
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001465run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001466 "$P_SRV key_file=data_files/server5.key \
1467 crt_file=data_files/server5.ku-ka.crt" \
1468 "$P_CLI" \
1469 0 \
1470 -c "Ciphersuite is TLS-ECDH-"
1471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001472run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001473 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001474 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001475 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001476 1 \
1477 -C "Ciphersuite is "
1478
1479# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001480# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001482run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001483 "$O_SRV -key data_files/server2.key \
1484 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001485 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001486 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1487 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001488 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001489 -C "Processing of the Certificate handshake message failed" \
1490 -c "Ciphersuite is TLS-"
1491
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001492run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001493 "$O_SRV -key data_files/server2.key \
1494 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001495 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001496 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1497 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001498 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001499 -C "Processing of the Certificate handshake message failed" \
1500 -c "Ciphersuite is TLS-"
1501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001502run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001503 "$O_SRV -key data_files/server2.key \
1504 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001505 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001506 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1507 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001508 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001509 -C "Processing of the Certificate handshake message failed" \
1510 -c "Ciphersuite is TLS-"
1511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001512run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001513 "$O_SRV -key data_files/server2.key \
1514 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001515 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001516 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1517 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001518 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001519 -c "Processing of the Certificate handshake message failed" \
1520 -C "Ciphersuite is TLS-"
1521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001522run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001523 "$O_SRV -key data_files/server2.key \
1524 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001526 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1527 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001528 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001529 -C "Processing of the Certificate handshake message failed" \
1530 -c "Ciphersuite is TLS-"
1531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001532run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001533 "$O_SRV -key data_files/server2.key \
1534 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001535 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001536 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1537 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001538 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001539 -c "Processing of the Certificate handshake message failed" \
1540 -C "Ciphersuite is TLS-"
1541
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001542# Tests for keyUsage in leaf certificates, part 3:
1543# server-side checking of client cert
1544
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001545run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001546 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001547 "$O_CLI -key data_files/server2.key \
1548 -cert data_files/server2.ku-ds.crt" \
1549 0 \
1550 -S "bad certificate (usage extensions)" \
1551 -S "Processing of the Certificate handshake message failed"
1552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001553run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001554 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001555 "$O_CLI -key data_files/server2.key \
1556 -cert data_files/server2.ku-ke.crt" \
1557 0 \
1558 -s "bad certificate (usage extensions)" \
1559 -S "Processing of the Certificate handshake message failed"
1560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001561run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001562 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001563 "$O_CLI -key data_files/server2.key \
1564 -cert data_files/server2.ku-ke.crt" \
1565 1 \
1566 -s "bad certificate (usage extensions)" \
1567 -s "Processing of the Certificate handshake message failed"
1568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001569run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001570 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001571 "$O_CLI -key data_files/server5.key \
1572 -cert data_files/server5.ku-ds.crt" \
1573 0 \
1574 -S "bad certificate (usage extensions)" \
1575 -S "Processing of the Certificate handshake message failed"
1576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001577run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001578 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001579 "$O_CLI -key data_files/server5.key \
1580 -cert data_files/server5.ku-ka.crt" \
1581 0 \
1582 -s "bad certificate (usage extensions)" \
1583 -S "Processing of the Certificate handshake message failed"
1584
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001585# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001587run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001588 "$P_SRV key_file=data_files/server5.key \
1589 crt_file=data_files/server5.eku-srv.crt" \
1590 "$P_CLI" \
1591 0
1592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001593run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001594 "$P_SRV key_file=data_files/server5.key \
1595 crt_file=data_files/server5.eku-srv.crt" \
1596 "$P_CLI" \
1597 0
1598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001599run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001600 "$P_SRV key_file=data_files/server5.key \
1601 crt_file=data_files/server5.eku-cs_any.crt" \
1602 "$P_CLI" \
1603 0
1604
1605# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001606run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001607 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1608 crt_file=data_files/server5.eku-cli.crt" \
1609 "$P_CLI psk=badbad" \
1610 1
1611
1612# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1613
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001614run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001615 "$O_SRV -key data_files/server5.key \
1616 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001617 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001618 0 \
1619 -C "bad certificate (usage extensions)" \
1620 -C "Processing of the Certificate handshake message failed" \
1621 -c "Ciphersuite is TLS-"
1622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001623run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001624 "$O_SRV -key data_files/server5.key \
1625 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001626 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001627 0 \
1628 -C "bad certificate (usage extensions)" \
1629 -C "Processing of the Certificate handshake message failed" \
1630 -c "Ciphersuite is TLS-"
1631
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001632run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001633 "$O_SRV -key data_files/server5.key \
1634 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001635 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001636 0 \
1637 -C "bad certificate (usage extensions)" \
1638 -C "Processing of the Certificate handshake message failed" \
1639 -c "Ciphersuite is TLS-"
1640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001641run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001642 "$O_SRV -key data_files/server5.key \
1643 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001644 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001645 1 \
1646 -c "bad certificate (usage extensions)" \
1647 -c "Processing of the Certificate handshake message failed" \
1648 -C "Ciphersuite is TLS-"
1649
1650# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1651
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001652run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001653 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001654 "$O_CLI -key data_files/server5.key \
1655 -cert data_files/server5.eku-cli.crt" \
1656 0 \
1657 -S "bad certificate (usage extensions)" \
1658 -S "Processing of the Certificate handshake message failed"
1659
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001660run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001661 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001662 "$O_CLI -key data_files/server5.key \
1663 -cert data_files/server5.eku-srv_cli.crt" \
1664 0 \
1665 -S "bad certificate (usage extensions)" \
1666 -S "Processing of the Certificate handshake message failed"
1667
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001668run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001669 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001670 "$O_CLI -key data_files/server5.key \
1671 -cert data_files/server5.eku-cs_any.crt" \
1672 0 \
1673 -S "bad certificate (usage extensions)" \
1674 -S "Processing of the Certificate handshake message failed"
1675
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001676run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001677 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001678 "$O_CLI -key data_files/server5.key \
1679 -cert data_files/server5.eku-cs.crt" \
1680 0 \
1681 -s "bad certificate (usage extensions)" \
1682 -S "Processing of the Certificate handshake message failed"
1683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001684run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001685 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001686 "$O_CLI -key data_files/server5.key \
1687 -cert data_files/server5.eku-cs.crt" \
1688 1 \
1689 -s "bad certificate (usage extensions)" \
1690 -s "Processing of the Certificate handshake message failed"
1691
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001692# Tests for DHM parameters loading
1693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001694run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001695 "$P_SRV" \
1696 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1697 debug_level=3" \
1698 0 \
1699 -c "value of 'DHM: P ' (2048 bits)" \
1700 -c "value of 'DHM: G ' (2048 bits)"
1701
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001702run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001703 "$P_SRV dhm_file=data_files/dhparams.pem" \
1704 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1705 debug_level=3" \
1706 0 \
1707 -c "value of 'DHM: P ' (1024 bits)" \
1708 -c "value of 'DHM: G ' (2 bits)"
1709
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001710# Tests for PSK callback
1711
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001712run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001713 "$P_SRV psk=abc123 psk_identity=foo" \
1714 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1715 psk_identity=foo psk=abc123" \
1716 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001717 -S "SSL - The server has no ciphersuites in common" \
1718 -S "SSL - Unknown identity received" \
1719 -S "SSL - Verification of the message MAC failed"
1720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001721run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001722 "$P_SRV" \
1723 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1724 psk_identity=foo psk=abc123" \
1725 1 \
1726 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001727 -S "SSL - Unknown identity received" \
1728 -S "SSL - Verification of the message MAC failed"
1729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001730run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001731 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1732 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1733 psk_identity=foo psk=abc123" \
1734 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001735 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001736 -s "SSL - Unknown identity received" \
1737 -S "SSL - Verification of the message MAC failed"
1738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001739run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001740 "$P_SRV psk_list=abc,dead,def,beef" \
1741 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1742 psk_identity=abc psk=dead" \
1743 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001744 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001745 -S "SSL - Unknown identity received" \
1746 -S "SSL - Verification of the message MAC failed"
1747
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001748run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001749 "$P_SRV psk_list=abc,dead,def,beef" \
1750 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1751 psk_identity=def psk=beef" \
1752 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001753 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001754 -S "SSL - Unknown identity received" \
1755 -S "SSL - Verification of the message MAC failed"
1756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001757run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001758 "$P_SRV psk_list=abc,dead,def,beef" \
1759 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1760 psk_identity=ghi psk=beef" \
1761 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001762 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001763 -s "SSL - Unknown identity received" \
1764 -S "SSL - Verification of the message MAC failed"
1765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001766run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001767 "$P_SRV psk_list=abc,dead,def,beef" \
1768 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1769 psk_identity=abc psk=beef" \
1770 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001771 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001772 -S "SSL - Unknown identity received" \
1773 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001774
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001775# Tests for ciphersuites per version
1776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001778 "$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" \
1779 "$P_CLI force_version=ssl3" \
1780 0 \
1781 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001783run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001784 "$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" \
1785 "$P_CLI force_version=tls1" \
1786 0 \
1787 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001789run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001790 "$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" \
1791 "$P_CLI force_version=tls1_1" \
1792 0 \
1793 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001795run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001796 "$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" \
1797 "$P_CLI force_version=tls1_2" \
1798 0 \
1799 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1800
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001801# Tests for ssl_get_bytes_avail()
1802
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001803run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001804 "$P_SRV" \
1805 "$P_CLI request_size=100" \
1806 0 \
1807 -s "Read from client: 100 bytes read$"
1808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001809run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001810 "$P_SRV" \
1811 "$P_CLI request_size=500" \
1812 0 \
1813 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001814
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001815# Tests for small packets
1816
1817run_test "Small packet SSLv3 BlockCipher" \
1818 "$P_SRV" \
1819 "$P_CLI request_size=1 force_version=ssl3 \
1820 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1821 0 \
1822 -s "Read from client: 1 bytes read"
1823
1824run_test "Small packet SSLv3 StreamCipher" \
1825 "$P_SRV" \
1826 "$P_CLI request_size=1 force_version=ssl3 \
1827 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1828 0 \
1829 -s "Read from client: 1 bytes read"
1830
1831run_test "Small packet TLS 1.0 BlockCipher" \
1832 "$P_SRV" \
1833 "$P_CLI request_size=1 force_version=tls1 \
1834 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1835 0 \
1836 -s "Read from client: 1 bytes read"
1837
1838run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1839 "$P_SRV" \
1840 "$P_CLI request_size=1 force_version=tls1 \
1841 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1842 trunc_hmac=1" \
1843 0 \
1844 -s "Read from client: 1 bytes read"
1845
1846run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1847 "$P_SRV" \
1848 "$P_CLI request_size=1 force_version=tls1 \
1849 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1850 trunc_hmac=1" \
1851 0 \
1852 -s "Read from client: 1 bytes read"
1853
1854run_test "Small packet TLS 1.1 BlockCipher" \
1855 "$P_SRV" \
1856 "$P_CLI request_size=1 force_version=tls1_1 \
1857 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1858 0 \
1859 -s "Read from client: 1 bytes read"
1860
1861run_test "Small packet TLS 1.1 StreamCipher" \
1862 "$P_SRV" \
1863 "$P_CLI request_size=1 force_version=tls1_1 \
1864 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1865 0 \
1866 -s "Read from client: 1 bytes read"
1867
1868run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1869 "$P_SRV" \
1870 "$P_CLI request_size=1 force_version=tls1_1 \
1871 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1872 trunc_hmac=1" \
1873 0 \
1874 -s "Read from client: 1 bytes read"
1875
1876run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1877 "$P_SRV" \
1878 "$P_CLI request_size=1 force_version=tls1_1 \
1879 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1880 trunc_hmac=1" \
1881 0 \
1882 -s "Read from client: 1 bytes read"
1883
1884run_test "Small packet TLS 1.2 BlockCipher" \
1885 "$P_SRV" \
1886 "$P_CLI request_size=1 force_version=tls1_2 \
1887 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1888 0 \
1889 -s "Read from client: 1 bytes read"
1890
1891run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1892 "$P_SRV" \
1893 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1894 0 \
1895 -s "Read from client: 1 bytes read"
1896
1897run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1898 "$P_SRV" \
1899 "$P_CLI request_size=1 force_version=tls1_2 \
1900 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1901 trunc_hmac=1" \
1902 0 \
1903 -s "Read from client: 1 bytes read"
1904
1905run_test "Small packet TLS 1.2 StreamCipher" \
1906 "$P_SRV" \
1907 "$P_CLI request_size=1 force_version=tls1_2 \
1908 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1909 0 \
1910 -s "Read from client: 1 bytes read"
1911
1912run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1913 "$P_SRV" \
1914 "$P_CLI request_size=1 force_version=tls1_2 \
1915 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1916 trunc_hmac=1" \
1917 0 \
1918 -s "Read from client: 1 bytes read"
1919
1920run_test "Small packet TLS 1.2 AEAD" \
1921 "$P_SRV" \
1922 "$P_CLI request_size=1 force_version=tls1_2 \
1923 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1924 0 \
1925 -s "Read from client: 1 bytes read"
1926
1927run_test "Small packet TLS 1.2 AEAD shorter tag" \
1928 "$P_SRV" \
1929 "$P_CLI request_size=1 force_version=tls1_2 \
1930 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1931 0 \
1932 -s "Read from client: 1 bytes read"
1933
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001934# Test for large packets
1935
1936run_test "Large packet SSLv3 BlockCipher" \
1937 "$P_SRV" \
1938 "$P_CLI request_size=16384 force_version=ssl3 \
1939 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1940 0 \
1941 -s "Read from client: 16384 bytes read"
1942
1943run_test "Large packet SSLv3 StreamCipher" \
1944 "$P_SRV" \
1945 "$P_CLI request_size=16384 force_version=ssl3 \
1946 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1947 0 \
1948 -s "Read from client: 16384 bytes read"
1949
1950run_test "Large packet TLS 1.0 BlockCipher" \
1951 "$P_SRV" \
1952 "$P_CLI request_size=16384 force_version=tls1 \
1953 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1954 0 \
1955 -s "Read from client: 16384 bytes read"
1956
1957run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1958 "$P_SRV" \
1959 "$P_CLI request_size=16384 force_version=tls1 \
1960 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1961 trunc_hmac=1" \
1962 0 \
1963 -s "Read from client: 16384 bytes read"
1964
1965run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1966 "$P_SRV" \
1967 "$P_CLI request_size=16384 force_version=tls1 \
1968 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1969 trunc_hmac=1" \
1970 0 \
1971 -s "Read from client: 16384 bytes read"
1972
1973run_test "Large packet TLS 1.1 BlockCipher" \
1974 "$P_SRV" \
1975 "$P_CLI request_size=16384 force_version=tls1_1 \
1976 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1977 0 \
1978 -s "Read from client: 16384 bytes read"
1979
1980run_test "Large packet TLS 1.1 StreamCipher" \
1981 "$P_SRV" \
1982 "$P_CLI request_size=16384 force_version=tls1_1 \
1983 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1984 0 \
1985 -s "Read from client: 16384 bytes read"
1986
1987run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1988 "$P_SRV" \
1989 "$P_CLI request_size=16384 force_version=tls1_1 \
1990 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1991 trunc_hmac=1" \
1992 0 \
1993 -s "Read from client: 16384 bytes read"
1994
1995run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1996 "$P_SRV" \
1997 "$P_CLI request_size=16384 force_version=tls1_1 \
1998 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1999 trunc_hmac=1" \
2000 0 \
2001 -s "Read from client: 16384 bytes read"
2002
2003run_test "Large packet TLS 1.2 BlockCipher" \
2004 "$P_SRV" \
2005 "$P_CLI request_size=16384 force_version=tls1_2 \
2006 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2007 0 \
2008 -s "Read from client: 16384 bytes read"
2009
2010run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2011 "$P_SRV" \
2012 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
2013 0 \
2014 -s "Read from client: 16384 bytes read"
2015
2016run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2017 "$P_SRV" \
2018 "$P_CLI request_size=16384 force_version=tls1_2 \
2019 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2020 trunc_hmac=1" \
2021 0 \
2022 -s "Read from client: 16384 bytes read"
2023
2024run_test "Large packet TLS 1.2 StreamCipher" \
2025 "$P_SRV" \
2026 "$P_CLI request_size=16384 force_version=tls1_2 \
2027 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2028 0 \
2029 -s "Read from client: 16384 bytes read"
2030
2031run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
2032 "$P_SRV" \
2033 "$P_CLI request_size=16384 force_version=tls1_2 \
2034 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2035 trunc_hmac=1" \
2036 0 \
2037 -s "Read from client: 16384 bytes read"
2038
2039run_test "Large packet TLS 1.2 AEAD" \
2040 "$P_SRV" \
2041 "$P_CLI request_size=16384 force_version=tls1_2 \
2042 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2043 0 \
2044 -s "Read from client: 16384 bytes read"
2045
2046run_test "Large packet TLS 1.2 AEAD shorter tag" \
2047 "$P_SRV" \
2048 "$P_CLI request_size=16384 force_version=tls1_2 \
2049 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2050 0 \
2051 -s "Read from client: 16384 bytes read"
2052
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002053# Final report
2054
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002055echo "------------------------------------------------------------------------"
2056
2057if [ $FAILS = 0 ]; then
2058 echo -n "PASSED"
2059else
2060 echo -n "FAILED"
2061fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002062PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002063echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002064
2065exit $FAILS