blob: 100c24459e96878d9970c5a7650fc99246d61108 [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" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100446 "$P_SRV debug_level=3 \
447 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100448 "$P_CLI debug_level=3" \
449 0 \
450 -c "client hello, adding encrypt_then_mac extension" \
451 -s "found encrypt then mac extension" \
452 -s "server hello, adding encrypt then mac extension" \
453 -c "found encrypt_then_mac extension" \
454 -c "using encrypt then mac" \
455 -s "using encrypt then mac"
456
457run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100458 "$P_SRV debug_level=3 etm=0 \
459 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100460 "$P_CLI debug_level=3 etm=1" \
461 0 \
462 -c "client hello, adding encrypt_then_mac extension" \
463 -s "found encrypt then mac extension" \
464 -S "server hello, adding encrypt then mac extension" \
465 -C "found encrypt_then_mac extension" \
466 -C "using encrypt then mac" \
467 -S "using encrypt then mac"
468
469run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100470 "$P_SRV debug_level=3 etm=1 \
471 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100472 "$P_CLI debug_level=3 etm=0" \
473 0 \
474 -C "client hello, adding encrypt_then_mac extension" \
475 -S "found encrypt then mac extension" \
476 -S "server hello, adding encrypt then mac extension" \
477 -C "found encrypt_then_mac extension" \
478 -C "using encrypt then mac" \
479 -S "using encrypt then mac"
480
481run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100482 "$P_SRV debug_level=3 \
483 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100484 "$P_CLI debug_level=3 force_version=ssl3" \
485 0 \
486 -C "client hello, adding encrypt_then_mac extension" \
487 -S "found encrypt then mac extension" \
488 -S "server hello, adding encrypt then mac extension" \
489 -C "found encrypt_then_mac extension" \
490 -C "using encrypt then mac" \
491 -S "using encrypt then mac"
492
493run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100494 "$P_SRV debug_level=3 force_version=ssl3 \
495 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100496 "$P_CLI debug_level=3" \
497 0 \
498 -c "client hello, adding encrypt_then_mac extension" \
499 -s "found encrypt then mac extension" \
500 -S "server hello, adding encrypt then mac extension" \
501 -C "found encrypt_then_mac extension" \
502 -C "using encrypt then mac" \
503 -S "using encrypt then mac"
504
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200505# Tests for Extended Master Secret extension
506
507run_test "Extended Master Secret: default" \
508 "$P_SRV debug_level=3" \
509 "$P_CLI debug_level=3" \
510 0 \
511 -c "client hello, adding extended_master_secret extension" \
512 -s "found extended master secret extension" \
513 -s "server hello, adding extended master secret extension" \
514 -c "found extended_master_secret extension" \
515 -c "using extended master secret" \
516 -s "using extended master secret"
517
518run_test "Extended Master Secret: client enabled, server disabled" \
519 "$P_SRV debug_level=3 extended_ms=0" \
520 "$P_CLI debug_level=3 extended_ms=1" \
521 0 \
522 -c "client hello, adding extended_master_secret extension" \
523 -s "found extended master secret extension" \
524 -S "server hello, adding extended master secret extension" \
525 -C "found extended_master_secret extension" \
526 -C "using extended master secret" \
527 -S "using extended master secret"
528
529run_test "Extended Master Secret: client disabled, server enabled" \
530 "$P_SRV debug_level=3 extended_ms=1" \
531 "$P_CLI debug_level=3 extended_ms=0" \
532 0 \
533 -C "client hello, adding extended_master_secret extension" \
534 -S "found extended master secret extension" \
535 -S "server hello, adding extended master secret extension" \
536 -C "found extended_master_secret extension" \
537 -C "using extended master secret" \
538 -S "using extended master secret"
539
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200540run_test "Extended Master Secret: client SSLv3, server enabled" \
541 "$P_SRV debug_level=3" \
542 "$P_CLI debug_level=3 force_version=ssl3" \
543 0 \
544 -C "client hello, adding extended_master_secret extension" \
545 -S "found extended master secret extension" \
546 -S "server hello, adding extended master secret extension" \
547 -C "found extended_master_secret extension" \
548 -C "using extended master secret" \
549 -S "using extended master secret"
550
551run_test "Extended Master Secret: client enabled, server SSLv3" \
552 "$P_SRV debug_level=3 force_version=ssl3" \
553 "$P_CLI debug_level=3" \
554 0 \
555 -c "client hello, adding extended_master_secret extension" \
556 -s "found extended master secret extension" \
557 -S "server hello, adding extended master secret extension" \
558 -C "found extended_master_secret extension" \
559 -C "using extended master secret" \
560 -S "using extended master secret"
561
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200562# Tests for FALLBACK_SCSV
563
564run_test "Fallback SCSV: default" \
565 "$P_SRV" \
566 "$P_CLI debug_level=3 force_version=tls1_1" \
567 0 \
568 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200569 -S "received FALLBACK_SCSV" \
570 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200571 -C "is a fatal alert message (msg 86)"
572
573run_test "Fallback SCSV: explicitly disabled" \
574 "$P_SRV" \
575 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
576 0 \
577 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200578 -S "received FALLBACK_SCSV" \
579 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200580 -C "is a fatal alert message (msg 86)"
581
582run_test "Fallback SCSV: enabled" \
583 "$P_SRV" \
584 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200585 1 \
586 -c "adding FALLBACK_SCSV" \
587 -s "received FALLBACK_SCSV" \
588 -s "inapropriate fallback" \
589 -c "is a fatal alert message (msg 86)"
590
591run_test "Fallback SCSV: enabled, max version" \
592 "$P_SRV" \
593 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200594 0 \
595 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200596 -s "received FALLBACK_SCSV" \
597 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200598 -C "is a fatal alert message (msg 86)"
599
600requires_openssl_with_fallback_scsv
601run_test "Fallback SCSV: default, openssl server" \
602 "$O_SRV" \
603 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
604 0 \
605 -C "adding FALLBACK_SCSV" \
606 -C "is a fatal alert message (msg 86)"
607
608requires_openssl_with_fallback_scsv
609run_test "Fallback SCSV: enabled, openssl server" \
610 "$O_SRV" \
611 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
612 1 \
613 -c "adding FALLBACK_SCSV" \
614 -c "is a fatal alert message (msg 86)"
615
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200616requires_openssl_with_fallback_scsv
617run_test "Fallback SCSV: disabled, openssl client" \
618 "$P_SRV" \
619 "$O_CLI -tls1_1" \
620 0 \
621 -S "received FALLBACK_SCSV" \
622 -S "inapropriate fallback"
623
624requires_openssl_with_fallback_scsv
625run_test "Fallback SCSV: enabled, openssl client" \
626 "$P_SRV" \
627 "$O_CLI -tls1_1 -fallback_scsv" \
628 1 \
629 -s "received FALLBACK_SCSV" \
630 -s "inapropriate fallback"
631
632requires_openssl_with_fallback_scsv
633run_test "Fallback SCSV: enabled, max version, openssl client" \
634 "$P_SRV" \
635 "$O_CLI -fallback_scsv" \
636 0 \
637 -s "received FALLBACK_SCSV" \
638 -S "inapropriate fallback"
639
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100640# Tests for Session Tickets
641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200642run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200643 "$P_SRV debug_level=3 tickets=1" \
644 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100645 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100646 -c "client hello, adding session ticket extension" \
647 -s "found session ticket extension" \
648 -s "server hello, adding session ticket extension" \
649 -c "found session_ticket extension" \
650 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100651 -S "session successfully restored from cache" \
652 -s "session successfully restored from ticket" \
653 -s "a session has been resumed" \
654 -c "a session has been resumed"
655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200656run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200657 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
658 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100659 0 \
660 -c "client hello, adding session ticket extension" \
661 -s "found session ticket extension" \
662 -s "server hello, adding session ticket extension" \
663 -c "found session_ticket extension" \
664 -c "parse new session ticket" \
665 -S "session successfully restored from cache" \
666 -s "session successfully restored from ticket" \
667 -s "a session has been resumed" \
668 -c "a session has been resumed"
669
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200670run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200671 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
672 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100673 0 \
674 -c "client hello, adding session ticket extension" \
675 -s "found session ticket extension" \
676 -s "server hello, adding session ticket extension" \
677 -c "found session_ticket extension" \
678 -c "parse new session ticket" \
679 -S "session successfully restored from cache" \
680 -S "session successfully restored from ticket" \
681 -S "a session has been resumed" \
682 -C "a session has been resumed"
683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200684run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100685 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200686 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100687 0 \
688 -c "client hello, adding session ticket extension" \
689 -c "found session_ticket extension" \
690 -c "parse new session ticket" \
691 -c "a session has been resumed"
692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200693run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200694 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200695 "( $O_CLI -sess_out $SESSION; \
696 $O_CLI -sess_in $SESSION; \
697 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100698 0 \
699 -s "found session ticket extension" \
700 -s "server hello, adding session ticket extension" \
701 -S "session successfully restored from cache" \
702 -s "session successfully restored from ticket" \
703 -s "a session has been resumed"
704
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100705# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200707run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200708 "$P_SRV debug_level=3 tickets=0" \
709 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100710 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100711 -c "client hello, adding session ticket extension" \
712 -s "found session ticket extension" \
713 -S "server hello, adding session ticket extension" \
714 -C "found session_ticket extension" \
715 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100716 -s "session successfully restored from cache" \
717 -S "session successfully restored from ticket" \
718 -s "a session has been resumed" \
719 -c "a session has been resumed"
720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200721run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200722 "$P_SRV debug_level=3 tickets=1" \
723 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100724 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100725 -C "client hello, adding session ticket extension" \
726 -S "found session ticket extension" \
727 -S "server hello, adding session ticket extension" \
728 -C "found session_ticket extension" \
729 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100730 -s "session successfully restored from cache" \
731 -S "session successfully restored from ticket" \
732 -s "a session has been resumed" \
733 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200735run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200736 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
737 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100738 0 \
739 -S "session successfully restored from cache" \
740 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100741 -S "a session has been resumed" \
742 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200744run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200745 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
746 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100747 0 \
748 -s "session successfully restored from cache" \
749 -S "session successfully restored from ticket" \
750 -s "a session has been resumed" \
751 -c "a session has been resumed"
752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200753run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200754 "$P_SRV debug_level=3 tickets=0" \
755 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100756 0 \
757 -s "session successfully restored from cache" \
758 -S "session successfully restored from ticket" \
759 -s "a session has been resumed" \
760 -c "a session has been resumed"
761
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200762run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200763 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
764 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100765 0 \
766 -S "session successfully restored from cache" \
767 -S "session successfully restored from ticket" \
768 -S "a session has been resumed" \
769 -C "a session has been resumed"
770
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200771run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200772 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
773 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100774 0 \
775 -s "session successfully restored from cache" \
776 -S "session successfully restored from ticket" \
777 -s "a session has been resumed" \
778 -c "a session has been resumed"
779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200780run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200781 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200782 "( $O_CLI -sess_out $SESSION; \
783 $O_CLI -sess_in $SESSION; \
784 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100785 0 \
786 -s "found session ticket extension" \
787 -S "server hello, adding session ticket extension" \
788 -s "session successfully restored from cache" \
789 -S "session successfully restored from ticket" \
790 -s "a session has been resumed"
791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200792run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100793 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200794 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100795 0 \
796 -C "found session_ticket extension" \
797 -C "parse new session ticket" \
798 -c "a session has been resumed"
799
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100800# Tests for Max Fragment Length extension
801
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200802run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200803 "$P_SRV debug_level=3" \
804 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100805 0 \
806 -C "client hello, adding max_fragment_length extension" \
807 -S "found max fragment length extension" \
808 -S "server hello, max_fragment_length extension" \
809 -C "found max_fragment_length extension"
810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200811run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200812 "$P_SRV debug_level=3" \
813 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100814 0 \
815 -c "client hello, adding max_fragment_length extension" \
816 -s "found max fragment length extension" \
817 -s "server hello, max_fragment_length extension" \
818 -c "found max_fragment_length extension"
819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200820run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200821 "$P_SRV debug_level=3 max_frag_len=4096" \
822 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100823 0 \
824 -C "client hello, adding max_fragment_length extension" \
825 -S "found max fragment length extension" \
826 -S "server hello, max_fragment_length extension" \
827 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200829requires_gnutls
830run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200831 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200832 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200833 0 \
834 -c "client hello, adding max_fragment_length extension" \
835 -c "found max_fragment_length extension"
836
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100837# Tests for renegotiation
838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200839run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200840 "$P_SRV debug_level=3 exchanges=2" \
841 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100842 0 \
843 -C "client hello, adding renegotiation extension" \
844 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
845 -S "found renegotiation extension" \
846 -s "server hello, secure renegotiation extension" \
847 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100848 -C "=> renegotiate" \
849 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100850 -S "write hello request"
851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200852run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200853 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
854 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100855 0 \
856 -c "client hello, adding renegotiation extension" \
857 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
858 -s "found renegotiation extension" \
859 -s "server hello, secure renegotiation extension" \
860 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100861 -c "=> renegotiate" \
862 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100863 -S "write hello request"
864
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200865run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200866 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
867 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100868 0 \
869 -c "client hello, adding renegotiation extension" \
870 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
871 -s "found renegotiation extension" \
872 -s "server hello, secure renegotiation extension" \
873 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100874 -c "=> renegotiate" \
875 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100876 -s "write hello request"
877
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200878run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200879 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
880 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100881 0 \
882 -c "client hello, adding renegotiation extension" \
883 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
884 -s "found renegotiation extension" \
885 -s "server hello, secure renegotiation extension" \
886 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100887 -c "=> renegotiate" \
888 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100889 -s "write hello request"
890
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200891run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200892 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
893 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100894 1 \
895 -c "client hello, adding renegotiation extension" \
896 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
897 -S "found renegotiation extension" \
898 -s "server hello, secure renegotiation extension" \
899 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100900 -c "=> renegotiate" \
901 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200902 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200903 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200904 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100905
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200906run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200907 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
908 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100909 0 \
910 -C "client hello, adding renegotiation extension" \
911 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
912 -S "found renegotiation extension" \
913 -s "server hello, secure renegotiation extension" \
914 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100915 -C "=> renegotiate" \
916 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100917 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200918 -S "SSL - An unexpected message was received from our peer" \
919 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100920
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200921run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200922 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200923 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200924 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200925 0 \
926 -C "client hello, adding renegotiation extension" \
927 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
928 -S "found renegotiation extension" \
929 -s "server hello, secure renegotiation extension" \
930 -c "found renegotiation extension" \
931 -C "=> renegotiate" \
932 -S "=> renegotiate" \
933 -s "write hello request" \
934 -S "SSL - An unexpected message was received from our peer" \
935 -S "failed"
936
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200937# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200938run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200939 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200940 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200941 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200942 0 \
943 -C "client hello, adding renegotiation extension" \
944 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
945 -S "found renegotiation extension" \
946 -s "server hello, secure renegotiation extension" \
947 -c "found renegotiation extension" \
948 -C "=> renegotiate" \
949 -S "=> renegotiate" \
950 -s "write hello request" \
951 -S "SSL - An unexpected message was received from our peer" \
952 -S "failed"
953
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200954run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200955 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200956 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200957 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200958 0 \
959 -C "client hello, adding renegotiation extension" \
960 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
961 -S "found renegotiation extension" \
962 -s "server hello, secure renegotiation extension" \
963 -c "found renegotiation extension" \
964 -C "=> renegotiate" \
965 -S "=> renegotiate" \
966 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200967 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200969run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200970 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200971 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200972 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200973 0 \
974 -c "client hello, adding renegotiation extension" \
975 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
976 -s "found renegotiation extension" \
977 -s "server hello, secure renegotiation extension" \
978 -c "found renegotiation extension" \
979 -c "=> renegotiate" \
980 -s "=> renegotiate" \
981 -s "write hello request" \
982 -S "SSL - An unexpected message was received from our peer" \
983 -S "failed"
984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200985run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200986 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
987 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200988 0 \
989 -c "client hello, adding renegotiation extension" \
990 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
991 -s "found renegotiation extension" \
992 -s "server hello, secure renegotiation extension" \
993 -c "found renegotiation extension" \
994 -c "=> renegotiate" \
995 -s "=> renegotiate" \
996 -S "write hello request"
997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200998run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200999 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1000 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001001 0 \
1002 -c "client hello, adding renegotiation extension" \
1003 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1004 -s "found renegotiation extension" \
1005 -s "server hello, secure renegotiation extension" \
1006 -c "found renegotiation extension" \
1007 -c "=> renegotiate" \
1008 -s "=> renegotiate" \
1009 -s "write hello request"
1010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001011run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001012 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001013 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001014 0 \
1015 -c "client hello, adding renegotiation extension" \
1016 -c "found renegotiation extension" \
1017 -c "=> renegotiate" \
1018 -C "ssl_handshake returned" \
1019 -C "error" \
1020 -c "HTTP/1.0 200 [Oo][Kk]"
1021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001022run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001023 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001024 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001025 0 \
1026 -c "client hello, adding renegotiation extension" \
1027 -c "found renegotiation extension" \
1028 -c "=> renegotiate" \
1029 -C "ssl_handshake returned" \
1030 -C "error" \
1031 -c "HTTP/1.0 200 [Oo][Kk]"
1032
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001033# Tests for auth_mode
1034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001035run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001036 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001037 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001038 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001039 1 \
1040 -c "x509_verify_cert() returned" \
1041 -c "! self-signed or not signed by a trusted CA" \
1042 -c "! ssl_handshake returned" \
1043 -c "X509 - Certificate verification failed"
1044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001045run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001046 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001047 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001048 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001049 0 \
1050 -c "x509_verify_cert() returned" \
1051 -c "! self-signed or not signed by a trusted CA" \
1052 -C "! ssl_handshake returned" \
1053 -C "X509 - Certificate verification failed"
1054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001055run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001056 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001057 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001058 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001059 0 \
1060 -C "x509_verify_cert() returned" \
1061 -C "! self-signed or not signed by a trusted CA" \
1062 -C "! ssl_handshake returned" \
1063 -C "X509 - Certificate verification failed"
1064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001065run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001066 "$P_SRV debug_level=3 auth_mode=required" \
1067 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001068 key_file=data_files/server5.key" \
1069 1 \
1070 -S "skip write certificate request" \
1071 -C "skip parse certificate request" \
1072 -c "got a certificate request" \
1073 -C "skip write certificate" \
1074 -C "skip write certificate verify" \
1075 -S "skip parse certificate verify" \
1076 -s "x509_verify_cert() returned" \
1077 -S "! self-signed or not signed by a trusted CA" \
1078 -s "! ssl_handshake returned" \
1079 -c "! ssl_handshake returned" \
1080 -s "X509 - Certificate verification failed"
1081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001082run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001083 "$P_SRV debug_level=3 auth_mode=optional" \
1084 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001085 key_file=data_files/server5.key" \
1086 0 \
1087 -S "skip write certificate request" \
1088 -C "skip parse certificate request" \
1089 -c "got a certificate request" \
1090 -C "skip write certificate" \
1091 -C "skip write certificate verify" \
1092 -S "skip parse certificate verify" \
1093 -s "x509_verify_cert() returned" \
1094 -s "! self-signed or not signed by a trusted CA" \
1095 -S "! ssl_handshake returned" \
1096 -C "! ssl_handshake returned" \
1097 -S "X509 - Certificate verification failed"
1098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001099run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001100 "$P_SRV debug_level=3 auth_mode=none" \
1101 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001102 key_file=data_files/server5.key" \
1103 0 \
1104 -s "skip write certificate request" \
1105 -C "skip parse certificate request" \
1106 -c "got no certificate request" \
1107 -c "skip write certificate" \
1108 -c "skip write certificate verify" \
1109 -s "skip parse certificate verify" \
1110 -S "x509_verify_cert() returned" \
1111 -S "! self-signed or not signed by a trusted CA" \
1112 -S "! ssl_handshake returned" \
1113 -C "! ssl_handshake returned" \
1114 -S "X509 - Certificate verification failed"
1115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001116run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001117 "$P_SRV debug_level=3 auth_mode=optional" \
1118 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001119 0 \
1120 -S "skip write certificate request" \
1121 -C "skip parse certificate request" \
1122 -c "got a certificate request" \
1123 -C "skip write certificate$" \
1124 -C "got no certificate to send" \
1125 -S "SSLv3 client has no certificate" \
1126 -c "skip write certificate verify" \
1127 -s "skip parse certificate verify" \
1128 -s "! no client certificate sent" \
1129 -S "! ssl_handshake returned" \
1130 -C "! ssl_handshake returned" \
1131 -S "X509 - Certificate verification failed"
1132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001133run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001134 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001135 "$O_CLI" \
1136 0 \
1137 -S "skip write certificate request" \
1138 -s "skip parse certificate verify" \
1139 -s "! no client certificate sent" \
1140 -S "! ssl_handshake returned" \
1141 -S "X509 - Certificate verification failed"
1142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001143run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001144 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001145 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001146 0 \
1147 -C "skip parse certificate request" \
1148 -c "got a certificate request" \
1149 -C "skip write certificate$" \
1150 -c "skip write certificate verify" \
1151 -C "! ssl_handshake returned"
1152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001153run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001154 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1155 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001156 0 \
1157 -S "skip write certificate request" \
1158 -C "skip parse certificate request" \
1159 -c "got a certificate request" \
1160 -C "skip write certificate$" \
1161 -c "skip write certificate verify" \
1162 -c "got no certificate to send" \
1163 -s "SSLv3 client has no certificate" \
1164 -s "skip parse certificate verify" \
1165 -s "! no client certificate sent" \
1166 -S "! ssl_handshake returned" \
1167 -C "! ssl_handshake returned" \
1168 -S "X509 - Certificate verification failed"
1169
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001170# tests for SNI
1171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001172run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001173 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001174 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001175 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001176 server_name=localhost" \
1177 0 \
1178 -S "parse ServerName extension" \
1179 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1180 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1181
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001182run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001183 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001184 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001185 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 +01001186 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001187 server_name=localhost" \
1188 0 \
1189 -s "parse ServerName extension" \
1190 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1191 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001193run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001194 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001195 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001196 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 +01001197 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001198 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001199 0 \
1200 -s "parse ServerName extension" \
1201 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001202 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001204run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001205 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001206 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001207 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 +01001208 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001209 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001210 1 \
1211 -s "parse ServerName extension" \
1212 -s "ssl_sni_wrapper() returned" \
1213 -s "ssl_handshake returned" \
1214 -c "ssl_handshake returned" \
1215 -c "SSL - A fatal alert message was received from our peer"
1216
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001217# Tests for non-blocking I/O: exercise a variety of handshake flows
1218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001219run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001220 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1221 "$P_CLI nbio=2 tickets=0" \
1222 0 \
1223 -S "ssl_handshake returned" \
1224 -C "ssl_handshake returned" \
1225 -c "Read from server: .* bytes read"
1226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001227run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001228 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1229 "$P_CLI nbio=2 tickets=0" \
1230 0 \
1231 -S "ssl_handshake returned" \
1232 -C "ssl_handshake returned" \
1233 -c "Read from server: .* bytes read"
1234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001235run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001236 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1237 "$P_CLI nbio=2 tickets=1" \
1238 0 \
1239 -S "ssl_handshake returned" \
1240 -C "ssl_handshake returned" \
1241 -c "Read from server: .* bytes read"
1242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001243run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001244 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1245 "$P_CLI nbio=2 tickets=1" \
1246 0 \
1247 -S "ssl_handshake returned" \
1248 -C "ssl_handshake returned" \
1249 -c "Read from server: .* bytes read"
1250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001251run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001252 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1253 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1254 0 \
1255 -S "ssl_handshake returned" \
1256 -C "ssl_handshake returned" \
1257 -c "Read from server: .* bytes read"
1258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001259run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001260 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1261 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1262 0 \
1263 -S "ssl_handshake returned" \
1264 -C "ssl_handshake returned" \
1265 -c "Read from server: .* bytes read"
1266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001267run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001268 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1269 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1270 0 \
1271 -S "ssl_handshake returned" \
1272 -C "ssl_handshake returned" \
1273 -c "Read from server: .* bytes read"
1274
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001275# Tests for version negotiation
1276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001277run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001278 "$P_SRV" \
1279 "$P_CLI" \
1280 0 \
1281 -S "ssl_handshake returned" \
1282 -C "ssl_handshake returned" \
1283 -s "Protocol is TLSv1.2" \
1284 -c "Protocol is TLSv1.2"
1285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001286run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001287 "$P_SRV" \
1288 "$P_CLI max_version=tls1_1" \
1289 0 \
1290 -S "ssl_handshake returned" \
1291 -C "ssl_handshake returned" \
1292 -s "Protocol is TLSv1.1" \
1293 -c "Protocol is TLSv1.1"
1294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001295run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001296 "$P_SRV max_version=tls1_1" \
1297 "$P_CLI" \
1298 0 \
1299 -S "ssl_handshake returned" \
1300 -C "ssl_handshake returned" \
1301 -s "Protocol is TLSv1.1" \
1302 -c "Protocol is TLSv1.1"
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001305 "$P_SRV max_version=tls1_1" \
1306 "$P_CLI max_version=tls1_1" \
1307 0 \
1308 -S "ssl_handshake returned" \
1309 -C "ssl_handshake returned" \
1310 -s "Protocol is TLSv1.1" \
1311 -c "Protocol is TLSv1.1"
1312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001313run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001314 "$P_SRV min_version=tls1_1" \
1315 "$P_CLI max_version=tls1_1" \
1316 0 \
1317 -S "ssl_handshake returned" \
1318 -C "ssl_handshake returned" \
1319 -s "Protocol is TLSv1.1" \
1320 -c "Protocol is TLSv1.1"
1321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001322run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001323 "$P_SRV max_version=tls1_1" \
1324 "$P_CLI min_version=tls1_1" \
1325 0 \
1326 -S "ssl_handshake returned" \
1327 -C "ssl_handshake returned" \
1328 -s "Protocol is TLSv1.1" \
1329 -c "Protocol is TLSv1.1"
1330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001331run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001332 "$P_SRV max_version=tls1_1" \
1333 "$P_CLI min_version=tls1_2" \
1334 1 \
1335 -s "ssl_handshake returned" \
1336 -c "ssl_handshake returned" \
1337 -c "SSL - Handshake protocol not within min/max boundaries"
1338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001339run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001340 "$P_SRV min_version=tls1_2" \
1341 "$P_CLI max_version=tls1_1" \
1342 1 \
1343 -s "ssl_handshake returned" \
1344 -c "ssl_handshake returned" \
1345 -s "SSL - Handshake protocol not within min/max boundaries"
1346
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001347# Tests for ALPN extension
1348
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001349if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001351run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001352 "$P_SRV debug_level=3" \
1353 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001354 0 \
1355 -C "client hello, adding alpn extension" \
1356 -S "found alpn extension" \
1357 -C "got an alert message, type: \\[2:120]" \
1358 -S "server hello, adding alpn extension" \
1359 -C "found alpn extension " \
1360 -C "Application Layer Protocol is" \
1361 -S "Application Layer Protocol is"
1362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001363run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_SRV debug_level=3" \
1365 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001366 0 \
1367 -c "client hello, adding alpn extension" \
1368 -s "found alpn extension" \
1369 -C "got an alert message, type: \\[2:120]" \
1370 -S "server hello, adding alpn extension" \
1371 -C "found alpn extension " \
1372 -c "Application Layer Protocol is (none)" \
1373 -S "Application Layer Protocol is"
1374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001375run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001376 "$P_SRV debug_level=3 alpn=abc,1234" \
1377 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001378 0 \
1379 -C "client hello, adding alpn extension" \
1380 -S "found alpn extension" \
1381 -C "got an alert message, type: \\[2:120]" \
1382 -S "server hello, adding alpn extension" \
1383 -C "found alpn extension " \
1384 -C "Application Layer Protocol is" \
1385 -s "Application Layer Protocol is (none)"
1386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001387run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001388 "$P_SRV debug_level=3 alpn=abc,1234" \
1389 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001390 0 \
1391 -c "client hello, adding alpn extension" \
1392 -s "found alpn extension" \
1393 -C "got an alert message, type: \\[2:120]" \
1394 -s "server hello, adding alpn extension" \
1395 -c "found alpn extension" \
1396 -c "Application Layer Protocol is abc" \
1397 -s "Application Layer Protocol is abc"
1398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001399run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001400 "$P_SRV debug_level=3 alpn=abc,1234" \
1401 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001402 0 \
1403 -c "client hello, adding alpn extension" \
1404 -s "found alpn extension" \
1405 -C "got an alert message, type: \\[2:120]" \
1406 -s "server hello, adding alpn extension" \
1407 -c "found alpn extension" \
1408 -c "Application Layer Protocol is abc" \
1409 -s "Application Layer Protocol is abc"
1410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001411run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001412 "$P_SRV debug_level=3 alpn=abc,1234" \
1413 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001414 0 \
1415 -c "client hello, adding alpn extension" \
1416 -s "found alpn extension" \
1417 -C "got an alert message, type: \\[2:120]" \
1418 -s "server hello, adding alpn extension" \
1419 -c "found alpn extension" \
1420 -c "Application Layer Protocol is 1234" \
1421 -s "Application Layer Protocol is 1234"
1422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001423run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001424 "$P_SRV debug_level=3 alpn=abc,123" \
1425 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001426 1 \
1427 -c "client hello, adding alpn extension" \
1428 -s "found alpn extension" \
1429 -c "got an alert message, type: \\[2:120]" \
1430 -S "server hello, adding alpn extension" \
1431 -C "found alpn extension" \
1432 -C "Application Layer Protocol is 1234" \
1433 -S "Application Layer Protocol is 1234"
1434
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001435fi
1436
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001437# Tests for keyUsage in leaf certificates, part 1:
1438# server-side certificate/suite selection
1439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001440run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001441 "$P_SRV key_file=data_files/server2.key \
1442 crt_file=data_files/server2.ku-ds.crt" \
1443 "$P_CLI" \
1444 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001445 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001446
1447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001448run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001449 "$P_SRV key_file=data_files/server2.key \
1450 crt_file=data_files/server2.ku-ke.crt" \
1451 "$P_CLI" \
1452 0 \
1453 -c "Ciphersuite is TLS-RSA-WITH-"
1454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001455run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001456 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001457 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001458 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001459 1 \
1460 -C "Ciphersuite is "
1461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001462run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001463 "$P_SRV key_file=data_files/server5.key \
1464 crt_file=data_files/server5.ku-ds.crt" \
1465 "$P_CLI" \
1466 0 \
1467 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1468
1469
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001470run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001471 "$P_SRV key_file=data_files/server5.key \
1472 crt_file=data_files/server5.ku-ka.crt" \
1473 "$P_CLI" \
1474 0 \
1475 -c "Ciphersuite is TLS-ECDH-"
1476
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001477run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001478 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001479 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001480 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001481 1 \
1482 -C "Ciphersuite is "
1483
1484# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001485# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001487run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001488 "$O_SRV -key data_files/server2.key \
1489 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001490 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001491 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1492 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001493 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001494 -C "Processing of the Certificate handshake message failed" \
1495 -c "Ciphersuite is TLS-"
1496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001497run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001498 "$O_SRV -key data_files/server2.key \
1499 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001500 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001501 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1502 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001503 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001504 -C "Processing of the Certificate handshake message failed" \
1505 -c "Ciphersuite is TLS-"
1506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001508 "$O_SRV -key data_files/server2.key \
1509 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001510 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001511 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1512 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001513 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001514 -C "Processing of the Certificate handshake message failed" \
1515 -c "Ciphersuite is TLS-"
1516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001517run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001518 "$O_SRV -key data_files/server2.key \
1519 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001520 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001521 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1522 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001523 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001524 -c "Processing of the Certificate handshake message failed" \
1525 -C "Ciphersuite is TLS-"
1526
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001527run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001528 "$O_SRV -key data_files/server2.key \
1529 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001530 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001531 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1532 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001533 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001534 -C "Processing of the Certificate handshake message failed" \
1535 -c "Ciphersuite is TLS-"
1536
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001537run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001538 "$O_SRV -key data_files/server2.key \
1539 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001540 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001541 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1542 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001543 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001544 -c "Processing of the Certificate handshake message failed" \
1545 -C "Ciphersuite is TLS-"
1546
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001547# Tests for keyUsage in leaf certificates, part 3:
1548# server-side checking of client cert
1549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001550run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001551 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001552 "$O_CLI -key data_files/server2.key \
1553 -cert data_files/server2.ku-ds.crt" \
1554 0 \
1555 -S "bad certificate (usage extensions)" \
1556 -S "Processing of the Certificate handshake message failed"
1557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001558run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001559 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001560 "$O_CLI -key data_files/server2.key \
1561 -cert data_files/server2.ku-ke.crt" \
1562 0 \
1563 -s "bad certificate (usage extensions)" \
1564 -S "Processing of the Certificate handshake message failed"
1565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001566run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001567 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001568 "$O_CLI -key data_files/server2.key \
1569 -cert data_files/server2.ku-ke.crt" \
1570 1 \
1571 -s "bad certificate (usage extensions)" \
1572 -s "Processing of the Certificate handshake message failed"
1573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001574run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001575 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001576 "$O_CLI -key data_files/server5.key \
1577 -cert data_files/server5.ku-ds.crt" \
1578 0 \
1579 -S "bad certificate (usage extensions)" \
1580 -S "Processing of the Certificate handshake message failed"
1581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001582run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001583 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001584 "$O_CLI -key data_files/server5.key \
1585 -cert data_files/server5.ku-ka.crt" \
1586 0 \
1587 -s "bad certificate (usage extensions)" \
1588 -S "Processing of the Certificate handshake message failed"
1589
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001590# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001592run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001593 "$P_SRV key_file=data_files/server5.key \
1594 crt_file=data_files/server5.eku-srv.crt" \
1595 "$P_CLI" \
1596 0
1597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001598run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001599 "$P_SRV key_file=data_files/server5.key \
1600 crt_file=data_files/server5.eku-srv.crt" \
1601 "$P_CLI" \
1602 0
1603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001604run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001605 "$P_SRV key_file=data_files/server5.key \
1606 crt_file=data_files/server5.eku-cs_any.crt" \
1607 "$P_CLI" \
1608 0
1609
1610# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001611run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001612 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1613 crt_file=data_files/server5.eku-cli.crt" \
1614 "$P_CLI psk=badbad" \
1615 1
1616
1617# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001619run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001620 "$O_SRV -key data_files/server5.key \
1621 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001622 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001623 0 \
1624 -C "bad certificate (usage extensions)" \
1625 -C "Processing of the Certificate handshake message failed" \
1626 -c "Ciphersuite is TLS-"
1627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001628run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001629 "$O_SRV -key data_files/server5.key \
1630 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001631 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001632 0 \
1633 -C "bad certificate (usage extensions)" \
1634 -C "Processing of the Certificate handshake message failed" \
1635 -c "Ciphersuite is TLS-"
1636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001637run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001638 "$O_SRV -key data_files/server5.key \
1639 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001640 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001641 0 \
1642 -C "bad certificate (usage extensions)" \
1643 -C "Processing of the Certificate handshake message failed" \
1644 -c "Ciphersuite is TLS-"
1645
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001646run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001647 "$O_SRV -key data_files/server5.key \
1648 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001649 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001650 1 \
1651 -c "bad certificate (usage extensions)" \
1652 -c "Processing of the Certificate handshake message failed" \
1653 -C "Ciphersuite is TLS-"
1654
1655# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001657run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001658 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001659 "$O_CLI -key data_files/server5.key \
1660 -cert data_files/server5.eku-cli.crt" \
1661 0 \
1662 -S "bad certificate (usage extensions)" \
1663 -S "Processing of the Certificate handshake message failed"
1664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001665run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001666 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001667 "$O_CLI -key data_files/server5.key \
1668 -cert data_files/server5.eku-srv_cli.crt" \
1669 0 \
1670 -S "bad certificate (usage extensions)" \
1671 -S "Processing of the Certificate handshake message failed"
1672
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001673run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001674 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001675 "$O_CLI -key data_files/server5.key \
1676 -cert data_files/server5.eku-cs_any.crt" \
1677 0 \
1678 -S "bad certificate (usage extensions)" \
1679 -S "Processing of the Certificate handshake message failed"
1680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001681run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001682 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001683 "$O_CLI -key data_files/server5.key \
1684 -cert data_files/server5.eku-cs.crt" \
1685 0 \
1686 -s "bad certificate (usage extensions)" \
1687 -S "Processing of the Certificate handshake message failed"
1688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001689run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001690 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001691 "$O_CLI -key data_files/server5.key \
1692 -cert data_files/server5.eku-cs.crt" \
1693 1 \
1694 -s "bad certificate (usage extensions)" \
1695 -s "Processing of the Certificate handshake message failed"
1696
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001697# Tests for DHM parameters loading
1698
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001699run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001700 "$P_SRV" \
1701 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1702 debug_level=3" \
1703 0 \
1704 -c "value of 'DHM: P ' (2048 bits)" \
1705 -c "value of 'DHM: G ' (2048 bits)"
1706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001707run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001708 "$P_SRV dhm_file=data_files/dhparams.pem" \
1709 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1710 debug_level=3" \
1711 0 \
1712 -c "value of 'DHM: P ' (1024 bits)" \
1713 -c "value of 'DHM: G ' (2 bits)"
1714
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001715# Tests for PSK callback
1716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001717run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001718 "$P_SRV psk=abc123 psk_identity=foo" \
1719 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1720 psk_identity=foo psk=abc123" \
1721 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001722 -S "SSL - The server has no ciphersuites in common" \
1723 -S "SSL - Unknown identity received" \
1724 -S "SSL - Verification of the message MAC failed"
1725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001726run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001727 "$P_SRV" \
1728 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1729 psk_identity=foo psk=abc123" \
1730 1 \
1731 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001732 -S "SSL - Unknown identity received" \
1733 -S "SSL - Verification of the message MAC failed"
1734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001735run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001736 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1737 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1738 psk_identity=foo psk=abc123" \
1739 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001740 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001741 -s "SSL - Unknown identity received" \
1742 -S "SSL - Verification of the message MAC failed"
1743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001744run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001745 "$P_SRV psk_list=abc,dead,def,beef" \
1746 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1747 psk_identity=abc psk=dead" \
1748 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001749 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001750 -S "SSL - Unknown identity received" \
1751 -S "SSL - Verification of the message MAC failed"
1752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001753run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001754 "$P_SRV psk_list=abc,dead,def,beef" \
1755 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1756 psk_identity=def psk=beef" \
1757 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001758 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001759 -S "SSL - Unknown identity received" \
1760 -S "SSL - Verification of the message MAC failed"
1761
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001762run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001763 "$P_SRV psk_list=abc,dead,def,beef" \
1764 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1765 psk_identity=ghi psk=beef" \
1766 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001767 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001768 -s "SSL - Unknown identity received" \
1769 -S "SSL - Verification of the message MAC failed"
1770
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001771run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001772 "$P_SRV psk_list=abc,dead,def,beef" \
1773 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1774 psk_identity=abc psk=beef" \
1775 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001776 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001777 -S "SSL - Unknown identity received" \
1778 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001779
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001780# Tests for ciphersuites per version
1781
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001782run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001783 "$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" \
1784 "$P_CLI force_version=ssl3" \
1785 0 \
1786 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001788run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001789 "$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" \
1790 "$P_CLI force_version=tls1" \
1791 0 \
1792 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001794run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001795 "$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" \
1796 "$P_CLI force_version=tls1_1" \
1797 0 \
1798 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001800run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001801 "$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" \
1802 "$P_CLI force_version=tls1_2" \
1803 0 \
1804 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1805
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001806# Tests for ssl_get_bytes_avail()
1807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001808run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001809 "$P_SRV" \
1810 "$P_CLI request_size=100" \
1811 0 \
1812 -s "Read from client: 100 bytes read$"
1813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001814run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001815 "$P_SRV" \
1816 "$P_CLI request_size=500" \
1817 0 \
1818 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001819
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001820# Tests for small packets
1821
1822run_test "Small packet SSLv3 BlockCipher" \
1823 "$P_SRV" \
1824 "$P_CLI request_size=1 force_version=ssl3 \
1825 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1826 0 \
1827 -s "Read from client: 1 bytes read"
1828
1829run_test "Small packet SSLv3 StreamCipher" \
1830 "$P_SRV" \
1831 "$P_CLI request_size=1 force_version=ssl3 \
1832 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1833 0 \
1834 -s "Read from client: 1 bytes read"
1835
1836run_test "Small packet TLS 1.0 BlockCipher" \
1837 "$P_SRV" \
1838 "$P_CLI request_size=1 force_version=tls1 \
1839 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1840 0 \
1841 -s "Read from client: 1 bytes read"
1842
1843run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1844 "$P_SRV" \
1845 "$P_CLI request_size=1 force_version=tls1 \
1846 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1847 trunc_hmac=1" \
1848 0 \
1849 -s "Read from client: 1 bytes read"
1850
1851run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1852 "$P_SRV" \
1853 "$P_CLI request_size=1 force_version=tls1 \
1854 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1855 trunc_hmac=1" \
1856 0 \
1857 -s "Read from client: 1 bytes read"
1858
1859run_test "Small packet TLS 1.1 BlockCipher" \
1860 "$P_SRV" \
1861 "$P_CLI request_size=1 force_version=tls1_1 \
1862 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1863 0 \
1864 -s "Read from client: 1 bytes read"
1865
1866run_test "Small packet TLS 1.1 StreamCipher" \
1867 "$P_SRV" \
1868 "$P_CLI request_size=1 force_version=tls1_1 \
1869 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1870 0 \
1871 -s "Read from client: 1 bytes read"
1872
1873run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1874 "$P_SRV" \
1875 "$P_CLI request_size=1 force_version=tls1_1 \
1876 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1877 trunc_hmac=1" \
1878 0 \
1879 -s "Read from client: 1 bytes read"
1880
1881run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1882 "$P_SRV" \
1883 "$P_CLI request_size=1 force_version=tls1_1 \
1884 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1885 trunc_hmac=1" \
1886 0 \
1887 -s "Read from client: 1 bytes read"
1888
1889run_test "Small packet TLS 1.2 BlockCipher" \
1890 "$P_SRV" \
1891 "$P_CLI request_size=1 force_version=tls1_2 \
1892 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1893 0 \
1894 -s "Read from client: 1 bytes read"
1895
1896run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1897 "$P_SRV" \
1898 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1899 0 \
1900 -s "Read from client: 1 bytes read"
1901
1902run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1903 "$P_SRV" \
1904 "$P_CLI request_size=1 force_version=tls1_2 \
1905 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1906 trunc_hmac=1" \
1907 0 \
1908 -s "Read from client: 1 bytes read"
1909
1910run_test "Small packet TLS 1.2 StreamCipher" \
1911 "$P_SRV" \
1912 "$P_CLI request_size=1 force_version=tls1_2 \
1913 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1914 0 \
1915 -s "Read from client: 1 bytes read"
1916
1917run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1918 "$P_SRV" \
1919 "$P_CLI request_size=1 force_version=tls1_2 \
1920 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1921 trunc_hmac=1" \
1922 0 \
1923 -s "Read from client: 1 bytes read"
1924
1925run_test "Small packet TLS 1.2 AEAD" \
1926 "$P_SRV" \
1927 "$P_CLI request_size=1 force_version=tls1_2 \
1928 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1929 0 \
1930 -s "Read from client: 1 bytes read"
1931
1932run_test "Small packet TLS 1.2 AEAD shorter tag" \
1933 "$P_SRV" \
1934 "$P_CLI request_size=1 force_version=tls1_2 \
1935 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1936 0 \
1937 -s "Read from client: 1 bytes read"
1938
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001939# Test for large packets
1940
1941run_test "Large packet SSLv3 BlockCipher" \
1942 "$P_SRV" \
1943 "$P_CLI request_size=16384 force_version=ssl3 \
1944 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1945 0 \
1946 -s "Read from client: 16384 bytes read"
1947
1948run_test "Large packet SSLv3 StreamCipher" \
1949 "$P_SRV" \
1950 "$P_CLI request_size=16384 force_version=ssl3 \
1951 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1952 0 \
1953 -s "Read from client: 16384 bytes read"
1954
1955run_test "Large packet TLS 1.0 BlockCipher" \
1956 "$P_SRV" \
1957 "$P_CLI request_size=16384 force_version=tls1 \
1958 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1959 0 \
1960 -s "Read from client: 16384 bytes read"
1961
1962run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1963 "$P_SRV" \
1964 "$P_CLI request_size=16384 force_version=tls1 \
1965 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1966 trunc_hmac=1" \
1967 0 \
1968 -s "Read from client: 16384 bytes read"
1969
1970run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1971 "$P_SRV" \
1972 "$P_CLI request_size=16384 force_version=tls1 \
1973 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1974 trunc_hmac=1" \
1975 0 \
1976 -s "Read from client: 16384 bytes read"
1977
1978run_test "Large packet TLS 1.1 BlockCipher" \
1979 "$P_SRV" \
1980 "$P_CLI request_size=16384 force_version=tls1_1 \
1981 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1982 0 \
1983 -s "Read from client: 16384 bytes read"
1984
1985run_test "Large packet TLS 1.1 StreamCipher" \
1986 "$P_SRV" \
1987 "$P_CLI request_size=16384 force_version=tls1_1 \
1988 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1989 0 \
1990 -s "Read from client: 16384 bytes read"
1991
1992run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1993 "$P_SRV" \
1994 "$P_CLI request_size=16384 force_version=tls1_1 \
1995 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1996 trunc_hmac=1" \
1997 0 \
1998 -s "Read from client: 16384 bytes read"
1999
2000run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
2001 "$P_SRV" \
2002 "$P_CLI request_size=16384 force_version=tls1_1 \
2003 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2004 trunc_hmac=1" \
2005 0 \
2006 -s "Read from client: 16384 bytes read"
2007
2008run_test "Large packet TLS 1.2 BlockCipher" \
2009 "$P_SRV" \
2010 "$P_CLI request_size=16384 force_version=tls1_2 \
2011 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2012 0 \
2013 -s "Read from client: 16384 bytes read"
2014
2015run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2016 "$P_SRV" \
2017 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
2018 0 \
2019 -s "Read from client: 16384 bytes read"
2020
2021run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2022 "$P_SRV" \
2023 "$P_CLI request_size=16384 force_version=tls1_2 \
2024 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2025 trunc_hmac=1" \
2026 0 \
2027 -s "Read from client: 16384 bytes read"
2028
2029run_test "Large packet TLS 1.2 StreamCipher" \
2030 "$P_SRV" \
2031 "$P_CLI request_size=16384 force_version=tls1_2 \
2032 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2033 0 \
2034 -s "Read from client: 16384 bytes read"
2035
2036run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
2037 "$P_SRV" \
2038 "$P_CLI request_size=16384 force_version=tls1_2 \
2039 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2040 trunc_hmac=1" \
2041 0 \
2042 -s "Read from client: 16384 bytes read"
2043
2044run_test "Large packet TLS 1.2 AEAD" \
2045 "$P_SRV" \
2046 "$P_CLI request_size=16384 force_version=tls1_2 \
2047 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2048 0 \
2049 -s "Read from client: 16384 bytes read"
2050
2051run_test "Large packet TLS 1.2 AEAD shorter tag" \
2052 "$P_SRV" \
2053 "$P_CLI request_size=16384 force_version=tls1_2 \
2054 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2055 0 \
2056 -s "Read from client: 16384 bytes read"
2057
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002058# Final report
2059
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002060echo "------------------------------------------------------------------------"
2061
2062if [ $FAILS = 0 ]; then
2063 echo -n "PASSED"
2064else
2065 echo -n "FAILED"
2066fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002067PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002068echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002069
2070exit $FAILS