blob: 1349737f909bca3e4037b8dfdaff1fa198e7a575 [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
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100469run_test "Encrypt then MAC: client enabled, aead cipher" \
470 "$P_SRV debug_level=3 etm=1 \
471 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
472 "$P_CLI debug_level=3 etm=1" \
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 enabled, stream cipher" \
482 "$P_SRV debug_level=3 etm=1 \
483 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
484 "$P_CLI debug_level=3 etm=1" \
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
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100493run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100494 "$P_SRV debug_level=3 etm=1 \
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 etm=0" \
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
505run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100506 "$P_SRV debug_level=3 \
507 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100508 "$P_CLI debug_level=3 force_version=ssl3" \
509 0 \
510 -C "client hello, adding encrypt_then_mac extension" \
511 -S "found encrypt then mac extension" \
512 -S "server hello, adding encrypt then mac extension" \
513 -C "found encrypt_then_mac extension" \
514 -C "using encrypt then mac" \
515 -S "using encrypt then mac"
516
517run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100518 "$P_SRV debug_level=3 force_version=ssl3 \
519 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100520 "$P_CLI debug_level=3" \
521 0 \
522 -c "client hello, adding encrypt_then_mac extension" \
523 -s "found encrypt then mac extension" \
524 -S "server hello, adding encrypt then mac extension" \
525 -C "found encrypt_then_mac extension" \
526 -C "using encrypt then mac" \
527 -S "using encrypt then mac"
528
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200529# Tests for Extended Master Secret extension
530
531run_test "Extended Master Secret: default" \
532 "$P_SRV debug_level=3" \
533 "$P_CLI debug_level=3" \
534 0 \
535 -c "client hello, adding extended_master_secret extension" \
536 -s "found extended master secret extension" \
537 -s "server hello, adding extended master secret extension" \
538 -c "found extended_master_secret extension" \
539 -c "using extended master secret" \
540 -s "using extended master secret"
541
542run_test "Extended Master Secret: client enabled, server disabled" \
543 "$P_SRV debug_level=3 extended_ms=0" \
544 "$P_CLI debug_level=3 extended_ms=1" \
545 0 \
546 -c "client hello, adding extended_master_secret extension" \
547 -s "found extended master secret extension" \
548 -S "server hello, adding extended master secret extension" \
549 -C "found extended_master_secret extension" \
550 -C "using extended master secret" \
551 -S "using extended master secret"
552
553run_test "Extended Master Secret: client disabled, server enabled" \
554 "$P_SRV debug_level=3 extended_ms=1" \
555 "$P_CLI debug_level=3 extended_ms=0" \
556 0 \
557 -C "client hello, adding extended_master_secret extension" \
558 -S "found extended master secret extension" \
559 -S "server hello, adding extended master secret extension" \
560 -C "found extended_master_secret extension" \
561 -C "using extended master secret" \
562 -S "using extended master secret"
563
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200564run_test "Extended Master Secret: client SSLv3, server enabled" \
565 "$P_SRV debug_level=3" \
566 "$P_CLI debug_level=3 force_version=ssl3" \
567 0 \
568 -C "client hello, adding extended_master_secret extension" \
569 -S "found extended master secret extension" \
570 -S "server hello, adding extended master secret extension" \
571 -C "found extended_master_secret extension" \
572 -C "using extended master secret" \
573 -S "using extended master secret"
574
575run_test "Extended Master Secret: client enabled, server SSLv3" \
576 "$P_SRV debug_level=3 force_version=ssl3" \
577 "$P_CLI debug_level=3" \
578 0 \
579 -c "client hello, adding extended_master_secret extension" \
580 -s "found extended master secret extension" \
581 -S "server hello, adding extended master secret extension" \
582 -C "found extended_master_secret extension" \
583 -C "using extended master secret" \
584 -S "using extended master secret"
585
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200586# Tests for FALLBACK_SCSV
587
588run_test "Fallback SCSV: default" \
589 "$P_SRV" \
590 "$P_CLI debug_level=3 force_version=tls1_1" \
591 0 \
592 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200593 -S "received FALLBACK_SCSV" \
594 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200595 -C "is a fatal alert message (msg 86)"
596
597run_test "Fallback SCSV: explicitly disabled" \
598 "$P_SRV" \
599 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
600 0 \
601 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200602 -S "received FALLBACK_SCSV" \
603 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200604 -C "is a fatal alert message (msg 86)"
605
606run_test "Fallback SCSV: enabled" \
607 "$P_SRV" \
608 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200609 1 \
610 -c "adding FALLBACK_SCSV" \
611 -s "received FALLBACK_SCSV" \
612 -s "inapropriate fallback" \
613 -c "is a fatal alert message (msg 86)"
614
615run_test "Fallback SCSV: enabled, max version" \
616 "$P_SRV" \
617 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200618 0 \
619 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200620 -s "received FALLBACK_SCSV" \
621 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200622 -C "is a fatal alert message (msg 86)"
623
624requires_openssl_with_fallback_scsv
625run_test "Fallback SCSV: default, openssl server" \
626 "$O_SRV" \
627 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
628 0 \
629 -C "adding FALLBACK_SCSV" \
630 -C "is a fatal alert message (msg 86)"
631
632requires_openssl_with_fallback_scsv
633run_test "Fallback SCSV: enabled, openssl server" \
634 "$O_SRV" \
635 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
636 1 \
637 -c "adding FALLBACK_SCSV" \
638 -c "is a fatal alert message (msg 86)"
639
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200640requires_openssl_with_fallback_scsv
641run_test "Fallback SCSV: disabled, openssl client" \
642 "$P_SRV" \
643 "$O_CLI -tls1_1" \
644 0 \
645 -S "received FALLBACK_SCSV" \
646 -S "inapropriate fallback"
647
648requires_openssl_with_fallback_scsv
649run_test "Fallback SCSV: enabled, openssl client" \
650 "$P_SRV" \
651 "$O_CLI -tls1_1 -fallback_scsv" \
652 1 \
653 -s "received FALLBACK_SCSV" \
654 -s "inapropriate fallback"
655
656requires_openssl_with_fallback_scsv
657run_test "Fallback SCSV: enabled, max version, openssl client" \
658 "$P_SRV" \
659 "$O_CLI -fallback_scsv" \
660 0 \
661 -s "received FALLBACK_SCSV" \
662 -S "inapropriate fallback"
663
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100664# Tests for Session Tickets
665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200666run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200667 "$P_SRV debug_level=3 tickets=1" \
668 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100669 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100670 -c "client hello, adding session ticket extension" \
671 -s "found session ticket extension" \
672 -s "server hello, adding session ticket extension" \
673 -c "found session_ticket extension" \
674 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100675 -S "session successfully restored from cache" \
676 -s "session successfully restored from ticket" \
677 -s "a session has been resumed" \
678 -c "a session has been resumed"
679
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200680run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200681 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
682 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100683 0 \
684 -c "client hello, adding session ticket extension" \
685 -s "found session ticket extension" \
686 -s "server hello, adding session ticket extension" \
687 -c "found session_ticket extension" \
688 -c "parse new session ticket" \
689 -S "session successfully restored from cache" \
690 -s "session successfully restored from ticket" \
691 -s "a session has been resumed" \
692 -c "a session has been resumed"
693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200694run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200695 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
696 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100697 0 \
698 -c "client hello, adding session ticket extension" \
699 -s "found session ticket extension" \
700 -s "server hello, adding session ticket extension" \
701 -c "found session_ticket extension" \
702 -c "parse new session ticket" \
703 -S "session successfully restored from cache" \
704 -S "session successfully restored from ticket" \
705 -S "a session has been resumed" \
706 -C "a session has been resumed"
707
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200708run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100709 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200710 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100711 0 \
712 -c "client hello, adding session ticket extension" \
713 -c "found session_ticket extension" \
714 -c "parse new session ticket" \
715 -c "a session has been resumed"
716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200717run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200718 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200719 "( $O_CLI -sess_out $SESSION; \
720 $O_CLI -sess_in $SESSION; \
721 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100722 0 \
723 -s "found session ticket extension" \
724 -s "server hello, adding session ticket extension" \
725 -S "session successfully restored from cache" \
726 -s "session successfully restored from ticket" \
727 -s "a session has been resumed"
728
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100729# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100730
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200731run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200732 "$P_SRV debug_level=3 tickets=0" \
733 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100734 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100735 -c "client hello, adding session ticket extension" \
736 -s "found session ticket extension" \
737 -S "server hello, adding session ticket extension" \
738 -C "found session_ticket extension" \
739 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100740 -s "session successfully restored from cache" \
741 -S "session successfully restored from ticket" \
742 -s "a session has been resumed" \
743 -c "a session has been resumed"
744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200745run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200746 "$P_SRV debug_level=3 tickets=1" \
747 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100748 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100749 -C "client hello, adding session ticket extension" \
750 -S "found session ticket extension" \
751 -S "server hello, adding session ticket extension" \
752 -C "found session_ticket extension" \
753 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100754 -s "session successfully restored from cache" \
755 -S "session successfully restored from ticket" \
756 -s "a session has been resumed" \
757 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200759run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200760 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
761 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100762 0 \
763 -S "session successfully restored from cache" \
764 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100765 -S "a session has been resumed" \
766 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100767
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200768run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200769 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
770 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100771 0 \
772 -s "session successfully restored from cache" \
773 -S "session successfully restored from ticket" \
774 -s "a session has been resumed" \
775 -c "a session has been resumed"
776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200777run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200778 "$P_SRV debug_level=3 tickets=0" \
779 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100780 0 \
781 -s "session successfully restored from cache" \
782 -S "session successfully restored from ticket" \
783 -s "a session has been resumed" \
784 -c "a session has been resumed"
785
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200786run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200787 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
788 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100789 0 \
790 -S "session successfully restored from cache" \
791 -S "session successfully restored from ticket" \
792 -S "a session has been resumed" \
793 -C "a session has been resumed"
794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200795run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200796 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
797 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100798 0 \
799 -s "session successfully restored from cache" \
800 -S "session successfully restored from ticket" \
801 -s "a session has been resumed" \
802 -c "a session has been resumed"
803
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200804run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200805 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200806 "( $O_CLI -sess_out $SESSION; \
807 $O_CLI -sess_in $SESSION; \
808 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100809 0 \
810 -s "found session ticket extension" \
811 -S "server hello, adding session ticket extension" \
812 -s "session successfully restored from cache" \
813 -S "session successfully restored from ticket" \
814 -s "a session has been resumed"
815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200816run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100817 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200818 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100819 0 \
820 -C "found session_ticket extension" \
821 -C "parse new session ticket" \
822 -c "a session has been resumed"
823
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100824# Tests for Max Fragment Length extension
825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200826run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200827 "$P_SRV debug_level=3" \
828 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100829 0 \
830 -C "client hello, adding max_fragment_length extension" \
831 -S "found max fragment length extension" \
832 -S "server hello, max_fragment_length extension" \
833 -C "found max_fragment_length extension"
834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200835run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200836 "$P_SRV debug_level=3" \
837 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100838 0 \
839 -c "client hello, adding max_fragment_length extension" \
840 -s "found max fragment length extension" \
841 -s "server hello, max_fragment_length extension" \
842 -c "found max_fragment_length extension"
843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200844run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200845 "$P_SRV debug_level=3 max_frag_len=4096" \
846 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100847 0 \
848 -C "client hello, adding max_fragment_length extension" \
849 -S "found max fragment length extension" \
850 -S "server hello, max_fragment_length extension" \
851 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100852
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200853requires_gnutls
854run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200855 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200856 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200857 0 \
858 -c "client hello, adding max_fragment_length extension" \
859 -c "found max_fragment_length extension"
860
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100861# Tests for renegotiation
862
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200863run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200864 "$P_SRV debug_level=3 exchanges=2" \
865 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100866 0 \
867 -C "client hello, adding renegotiation extension" \
868 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
869 -S "found renegotiation extension" \
870 -s "server hello, secure renegotiation extension" \
871 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100872 -C "=> renegotiate" \
873 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100874 -S "write hello request"
875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200876run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200877 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
878 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100879 0 \
880 -c "client hello, adding renegotiation extension" \
881 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
882 -s "found renegotiation extension" \
883 -s "server hello, secure renegotiation extension" \
884 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100885 -c "=> renegotiate" \
886 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100887 -S "write hello request"
888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200889run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200890 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
891 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100892 0 \
893 -c "client hello, adding renegotiation extension" \
894 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
895 -s "found renegotiation extension" \
896 -s "server hello, secure renegotiation extension" \
897 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100898 -c "=> renegotiate" \
899 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100900 -s "write hello request"
901
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200902run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200903 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
904 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100905 0 \
906 -c "client hello, adding renegotiation extension" \
907 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
908 -s "found renegotiation extension" \
909 -s "server hello, secure renegotiation extension" \
910 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100911 -c "=> renegotiate" \
912 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100913 -s "write hello request"
914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200915run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200916 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
917 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100918 1 \
919 -c "client hello, adding renegotiation extension" \
920 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
921 -S "found renegotiation extension" \
922 -s "server hello, secure renegotiation extension" \
923 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100924 -c "=> renegotiate" \
925 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200926 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200927 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200928 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200930run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200931 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
932 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100933 0 \
934 -C "client hello, adding renegotiation extension" \
935 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
936 -S "found renegotiation extension" \
937 -s "server hello, secure renegotiation extension" \
938 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100939 -C "=> renegotiate" \
940 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100941 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200942 -S "SSL - An unexpected message was received from our peer" \
943 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200945run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200946 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200947 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200948 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200949 0 \
950 -C "client hello, adding renegotiation extension" \
951 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
952 -S "found renegotiation extension" \
953 -s "server hello, secure renegotiation extension" \
954 -c "found renegotiation extension" \
955 -C "=> renegotiate" \
956 -S "=> renegotiate" \
957 -s "write hello request" \
958 -S "SSL - An unexpected message was received from our peer" \
959 -S "failed"
960
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200961# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200962run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200963 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200964 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200965 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200966 0 \
967 -C "client hello, adding renegotiation extension" \
968 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
969 -S "found renegotiation extension" \
970 -s "server hello, secure renegotiation extension" \
971 -c "found renegotiation extension" \
972 -C "=> renegotiate" \
973 -S "=> renegotiate" \
974 -s "write hello request" \
975 -S "SSL - An unexpected message was received from our peer" \
976 -S "failed"
977
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200978run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200979 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200980 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200981 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200982 0 \
983 -C "client hello, adding renegotiation extension" \
984 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
985 -S "found renegotiation extension" \
986 -s "server hello, secure renegotiation extension" \
987 -c "found renegotiation extension" \
988 -C "=> renegotiate" \
989 -S "=> renegotiate" \
990 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200991 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200993run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200994 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200995 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200996 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200997 0 \
998 -c "client hello, adding renegotiation extension" \
999 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1000 -s "found renegotiation extension" \
1001 -s "server hello, secure renegotiation extension" \
1002 -c "found renegotiation extension" \
1003 -c "=> renegotiate" \
1004 -s "=> renegotiate" \
1005 -s "write hello request" \
1006 -S "SSL - An unexpected message was received from our peer" \
1007 -S "failed"
1008
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001009run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001010 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1011 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001012 0 \
1013 -c "client hello, adding renegotiation extension" \
1014 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1015 -s "found renegotiation extension" \
1016 -s "server hello, secure renegotiation extension" \
1017 -c "found renegotiation extension" \
1018 -c "=> renegotiate" \
1019 -s "=> renegotiate" \
1020 -S "write hello request"
1021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001022run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001023 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1024 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001025 0 \
1026 -c "client hello, adding renegotiation extension" \
1027 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1028 -s "found renegotiation extension" \
1029 -s "server hello, secure renegotiation extension" \
1030 -c "found renegotiation extension" \
1031 -c "=> renegotiate" \
1032 -s "=> renegotiate" \
1033 -s "write hello request"
1034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001035run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001036 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001037 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001038 0 \
1039 -c "client hello, adding renegotiation extension" \
1040 -c "found renegotiation extension" \
1041 -c "=> renegotiate" \
1042 -C "ssl_handshake returned" \
1043 -C "error" \
1044 -c "HTTP/1.0 200 [Oo][Kk]"
1045
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001046run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001047 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001048 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001049 0 \
1050 -c "client hello, adding renegotiation extension" \
1051 -c "found renegotiation extension" \
1052 -c "=> renegotiate" \
1053 -C "ssl_handshake returned" \
1054 -C "error" \
1055 -c "HTTP/1.0 200 [Oo][Kk]"
1056
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001057# Tests for auth_mode
1058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001059run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001060 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001061 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001062 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001063 1 \
1064 -c "x509_verify_cert() returned" \
1065 -c "! self-signed or not signed by a trusted CA" \
1066 -c "! ssl_handshake returned" \
1067 -c "X509 - Certificate verification failed"
1068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001069run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001070 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001071 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001072 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001073 0 \
1074 -c "x509_verify_cert() returned" \
1075 -c "! self-signed or not signed by a trusted CA" \
1076 -C "! ssl_handshake returned" \
1077 -C "X509 - Certificate verification failed"
1078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001079run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001080 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001081 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001082 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001083 0 \
1084 -C "x509_verify_cert() returned" \
1085 -C "! self-signed or not signed by a trusted CA" \
1086 -C "! ssl_handshake returned" \
1087 -C "X509 - Certificate verification failed"
1088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001089run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001090 "$P_SRV debug_level=3 auth_mode=required" \
1091 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001092 key_file=data_files/server5.key" \
1093 1 \
1094 -S "skip write certificate request" \
1095 -C "skip parse certificate request" \
1096 -c "got a certificate request" \
1097 -C "skip write certificate" \
1098 -C "skip write certificate verify" \
1099 -S "skip parse certificate verify" \
1100 -s "x509_verify_cert() returned" \
1101 -S "! self-signed or not signed by a trusted CA" \
1102 -s "! ssl_handshake returned" \
1103 -c "! ssl_handshake returned" \
1104 -s "X509 - Certificate verification failed"
1105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001106run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001107 "$P_SRV debug_level=3 auth_mode=optional" \
1108 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001109 key_file=data_files/server5.key" \
1110 0 \
1111 -S "skip write certificate request" \
1112 -C "skip parse certificate request" \
1113 -c "got a certificate request" \
1114 -C "skip write certificate" \
1115 -C "skip write certificate verify" \
1116 -S "skip parse certificate verify" \
1117 -s "x509_verify_cert() returned" \
1118 -s "! self-signed or not signed by a trusted CA" \
1119 -S "! ssl_handshake returned" \
1120 -C "! ssl_handshake returned" \
1121 -S "X509 - Certificate verification failed"
1122
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001123run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001124 "$P_SRV debug_level=3 auth_mode=none" \
1125 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001126 key_file=data_files/server5.key" \
1127 0 \
1128 -s "skip write certificate request" \
1129 -C "skip parse certificate request" \
1130 -c "got no certificate request" \
1131 -c "skip write certificate" \
1132 -c "skip write certificate verify" \
1133 -s "skip parse certificate verify" \
1134 -S "x509_verify_cert() returned" \
1135 -S "! self-signed or not signed by a trusted CA" \
1136 -S "! ssl_handshake returned" \
1137 -C "! ssl_handshake returned" \
1138 -S "X509 - Certificate verification failed"
1139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001140run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001141 "$P_SRV debug_level=3 auth_mode=optional" \
1142 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001143 0 \
1144 -S "skip write certificate request" \
1145 -C "skip parse certificate request" \
1146 -c "got a certificate request" \
1147 -C "skip write certificate$" \
1148 -C "got no certificate to send" \
1149 -S "SSLv3 client has no certificate" \
1150 -c "skip write certificate verify" \
1151 -s "skip parse certificate verify" \
1152 -s "! no client certificate sent" \
1153 -S "! ssl_handshake returned" \
1154 -C "! ssl_handshake returned" \
1155 -S "X509 - Certificate verification failed"
1156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001157run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001158 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001159 "$O_CLI" \
1160 0 \
1161 -S "skip write certificate request" \
1162 -s "skip parse certificate verify" \
1163 -s "! no client certificate sent" \
1164 -S "! ssl_handshake returned" \
1165 -S "X509 - Certificate verification failed"
1166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001167run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001168 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001169 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001170 0 \
1171 -C "skip parse certificate request" \
1172 -c "got a certificate request" \
1173 -C "skip write certificate$" \
1174 -c "skip write certificate verify" \
1175 -C "! ssl_handshake returned"
1176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001177run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001178 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1179 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001180 0 \
1181 -S "skip write certificate request" \
1182 -C "skip parse certificate request" \
1183 -c "got a certificate request" \
1184 -C "skip write certificate$" \
1185 -c "skip write certificate verify" \
1186 -c "got no certificate to send" \
1187 -s "SSLv3 client has no certificate" \
1188 -s "skip parse certificate verify" \
1189 -s "! no client certificate sent" \
1190 -S "! ssl_handshake returned" \
1191 -C "! ssl_handshake returned" \
1192 -S "X509 - Certificate verification failed"
1193
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001194# tests for SNI
1195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001196run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001197 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001198 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001199 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001200 server_name=localhost" \
1201 0 \
1202 -S "parse ServerName extension" \
1203 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1204 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001206run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001207 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001208 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001209 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 +01001210 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001211 server_name=localhost" \
1212 0 \
1213 -s "parse ServerName extension" \
1214 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1215 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1216
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001217run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001218 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001219 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001220 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 +01001221 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001222 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001223 0 \
1224 -s "parse ServerName extension" \
1225 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001226 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001228run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001229 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001230 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001231 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 +01001232 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001233 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001234 1 \
1235 -s "parse ServerName extension" \
1236 -s "ssl_sni_wrapper() returned" \
1237 -s "ssl_handshake returned" \
1238 -c "ssl_handshake returned" \
1239 -c "SSL - A fatal alert message was received from our peer"
1240
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001241# Tests for non-blocking I/O: exercise a variety of handshake flows
1242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001243run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001244 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1245 "$P_CLI nbio=2 tickets=0" \
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: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001252 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1253 "$P_CLI nbio=2 tickets=0" \
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" \
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" \
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: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001268 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1269 "$P_CLI nbio=2 tickets=1" \
1270 0 \
1271 -S "ssl_handshake returned" \
1272 -C "ssl_handshake returned" \
1273 -c "Read from server: .* bytes read"
1274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001275run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001276 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1277 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1278 0 \
1279 -S "ssl_handshake returned" \
1280 -C "ssl_handshake returned" \
1281 -c "Read from server: .* bytes read"
1282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001283run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001284 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1285 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1286 0 \
1287 -S "ssl_handshake returned" \
1288 -C "ssl_handshake returned" \
1289 -c "Read from server: .* bytes read"
1290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001291run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001292 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1293 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1294 0 \
1295 -S "ssl_handshake returned" \
1296 -C "ssl_handshake returned" \
1297 -c "Read from server: .* bytes read"
1298
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001299# Tests for version negotiation
1300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001301run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001302 "$P_SRV" \
1303 "$P_CLI" \
1304 0 \
1305 -S "ssl_handshake returned" \
1306 -C "ssl_handshake returned" \
1307 -s "Protocol is TLSv1.2" \
1308 -c "Protocol is TLSv1.2"
1309
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001310run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001311 "$P_SRV" \
1312 "$P_CLI max_version=tls1_1" \
1313 0 \
1314 -S "ssl_handshake returned" \
1315 -C "ssl_handshake returned" \
1316 -s "Protocol is TLSv1.1" \
1317 -c "Protocol is TLSv1.1"
1318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001319run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001320 "$P_SRV max_version=tls1_1" \
1321 "$P_CLI" \
1322 0 \
1323 -S "ssl_handshake returned" \
1324 -C "ssl_handshake returned" \
1325 -s "Protocol is TLSv1.1" \
1326 -c "Protocol is TLSv1.1"
1327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001328run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001329 "$P_SRV max_version=tls1_1" \
1330 "$P_CLI max_version=tls1_1" \
1331 0 \
1332 -S "ssl_handshake returned" \
1333 -C "ssl_handshake returned" \
1334 -s "Protocol is TLSv1.1" \
1335 -c "Protocol is TLSv1.1"
1336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001337run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001338 "$P_SRV min_version=tls1_1" \
1339 "$P_CLI max_version=tls1_1" \
1340 0 \
1341 -S "ssl_handshake returned" \
1342 -C "ssl_handshake returned" \
1343 -s "Protocol is TLSv1.1" \
1344 -c "Protocol is TLSv1.1"
1345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001347 "$P_SRV max_version=tls1_1" \
1348 "$P_CLI min_version=tls1_1" \
1349 0 \
1350 -S "ssl_handshake returned" \
1351 -C "ssl_handshake returned" \
1352 -s "Protocol is TLSv1.1" \
1353 -c "Protocol is TLSv1.1"
1354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001355run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001356 "$P_SRV max_version=tls1_1" \
1357 "$P_CLI min_version=tls1_2" \
1358 1 \
1359 -s "ssl_handshake returned" \
1360 -c "ssl_handshake returned" \
1361 -c "SSL - Handshake protocol not within min/max boundaries"
1362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001363run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001364 "$P_SRV min_version=tls1_2" \
1365 "$P_CLI max_version=tls1_1" \
1366 1 \
1367 -s "ssl_handshake returned" \
1368 -c "ssl_handshake returned" \
1369 -s "SSL - Handshake protocol not within min/max boundaries"
1370
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001371# Tests for ALPN extension
1372
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001373if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001375run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001376 "$P_SRV debug_level=3" \
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"
1386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001387run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001388 "$P_SRV debug_level=3" \
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 (none)" \
1397 -S "Application Layer Protocol is"
1398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001399run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001400 "$P_SRV debug_level=3 alpn=abc,1234" \
1401 "$P_CLI debug_level=3" \
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" \
1409 -s "Application Layer Protocol is (none)"
1410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001411run_test "ALPN: both, common cli1-srv1" \
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=abc,1234" \
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 abc" \
1421 -s "Application Layer Protocol is abc"
1422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001423run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001424 "$P_SRV debug_level=3 alpn=abc,1234" \
1425 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001426 0 \
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 abc" \
1433 -s "Application Layer Protocol is abc"
1434
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001435run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001436 "$P_SRV debug_level=3 alpn=abc,1234" \
1437 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001438 0 \
1439 -c "client hello, adding alpn extension" \
1440 -s "found alpn extension" \
1441 -C "got an alert message, type: \\[2:120]" \
1442 -s "server hello, adding alpn extension" \
1443 -c "found alpn extension" \
1444 -c "Application Layer Protocol is 1234" \
1445 -s "Application Layer Protocol is 1234"
1446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001447run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001448 "$P_SRV debug_level=3 alpn=abc,123" \
1449 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001450 1 \
1451 -c "client hello, adding alpn extension" \
1452 -s "found alpn extension" \
1453 -c "got an alert message, type: \\[2:120]" \
1454 -S "server hello, adding alpn extension" \
1455 -C "found alpn extension" \
1456 -C "Application Layer Protocol is 1234" \
1457 -S "Application Layer Protocol is 1234"
1458
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001459fi
1460
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001461# Tests for keyUsage in leaf certificates, part 1:
1462# server-side certificate/suite selection
1463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001464run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001465 "$P_SRV key_file=data_files/server2.key \
1466 crt_file=data_files/server2.ku-ds.crt" \
1467 "$P_CLI" \
1468 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001469 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001470
1471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001472run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001473 "$P_SRV key_file=data_files/server2.key \
1474 crt_file=data_files/server2.ku-ke.crt" \
1475 "$P_CLI" \
1476 0 \
1477 -c "Ciphersuite is TLS-RSA-WITH-"
1478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001479run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001480 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001481 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001482 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001483 1 \
1484 -C "Ciphersuite is "
1485
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001486run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001487 "$P_SRV key_file=data_files/server5.key \
1488 crt_file=data_files/server5.ku-ds.crt" \
1489 "$P_CLI" \
1490 0 \
1491 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1492
1493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001494run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001495 "$P_SRV key_file=data_files/server5.key \
1496 crt_file=data_files/server5.ku-ka.crt" \
1497 "$P_CLI" \
1498 0 \
1499 -c "Ciphersuite is TLS-ECDH-"
1500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001501run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001502 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001503 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001504 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001505 1 \
1506 -C "Ciphersuite is "
1507
1508# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001509# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001511run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001512 "$O_SRV -key data_files/server2.key \
1513 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001514 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001515 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1516 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001517 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001518 -C "Processing of the Certificate handshake message failed" \
1519 -c "Ciphersuite is TLS-"
1520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001521run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001522 "$O_SRV -key data_files/server2.key \
1523 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001524 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001525 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1526 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001527 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001528 -C "Processing of the Certificate handshake message failed" \
1529 -c "Ciphersuite is TLS-"
1530
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001531run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001532 "$O_SRV -key data_files/server2.key \
1533 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001534 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001535 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1536 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001537 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001538 -C "Processing of the Certificate handshake message failed" \
1539 -c "Ciphersuite is TLS-"
1540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001541run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001542 "$O_SRV -key data_files/server2.key \
1543 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001544 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001545 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1546 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001547 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001548 -c "Processing of the Certificate handshake message failed" \
1549 -C "Ciphersuite is TLS-"
1550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001551run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001552 "$O_SRV -key data_files/server2.key \
1553 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001554 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001555 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1556 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001557 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001558 -C "Processing of the Certificate handshake message failed" \
1559 -c "Ciphersuite is TLS-"
1560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001561run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001562 "$O_SRV -key data_files/server2.key \
1563 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001564 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001565 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1566 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001567 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001568 -c "Processing of the Certificate handshake message failed" \
1569 -C "Ciphersuite is TLS-"
1570
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001571# Tests for keyUsage in leaf certificates, part 3:
1572# server-side checking of client cert
1573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001574run_test "keyUsage cli-auth: RSA, 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/server2.key \
1577 -cert data_files/server2.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: RSA, KeyEncipherment: 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/server2.key \
1585 -cert data_files/server2.ku-ke.crt" \
1586 0 \
1587 -s "bad certificate (usage extensions)" \
1588 -S "Processing of the Certificate handshake message failed"
1589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001590run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001591 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001592 "$O_CLI -key data_files/server2.key \
1593 -cert data_files/server2.ku-ke.crt" \
1594 1 \
1595 -s "bad certificate (usage extensions)" \
1596 -s "Processing of the Certificate handshake message failed"
1597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001598run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001599 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001600 "$O_CLI -key data_files/server5.key \
1601 -cert data_files/server5.ku-ds.crt" \
1602 0 \
1603 -S "bad certificate (usage extensions)" \
1604 -S "Processing of the Certificate handshake message failed"
1605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001606run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001607 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001608 "$O_CLI -key data_files/server5.key \
1609 -cert data_files/server5.ku-ka.crt" \
1610 0 \
1611 -s "bad certificate (usage extensions)" \
1612 -S "Processing of the Certificate handshake message failed"
1613
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001614# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001616run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001617 "$P_SRV key_file=data_files/server5.key \
1618 crt_file=data_files/server5.eku-srv.crt" \
1619 "$P_CLI" \
1620 0
1621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001622run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001623 "$P_SRV key_file=data_files/server5.key \
1624 crt_file=data_files/server5.eku-srv.crt" \
1625 "$P_CLI" \
1626 0
1627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001628run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001629 "$P_SRV key_file=data_files/server5.key \
1630 crt_file=data_files/server5.eku-cs_any.crt" \
1631 "$P_CLI" \
1632 0
1633
1634# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001635run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001636 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1637 crt_file=data_files/server5.eku-cli.crt" \
1638 "$P_CLI psk=badbad" \
1639 1
1640
1641# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001643run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001644 "$O_SRV -key data_files/server5.key \
1645 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001646 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001647 0 \
1648 -C "bad certificate (usage extensions)" \
1649 -C "Processing of the Certificate handshake message failed" \
1650 -c "Ciphersuite is TLS-"
1651
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001652run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001653 "$O_SRV -key data_files/server5.key \
1654 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001655 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001656 0 \
1657 -C "bad certificate (usage extensions)" \
1658 -C "Processing of the Certificate handshake message failed" \
1659 -c "Ciphersuite is TLS-"
1660
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001661run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001662 "$O_SRV -key data_files/server5.key \
1663 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001664 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001665 0 \
1666 -C "bad certificate (usage extensions)" \
1667 -C "Processing of the Certificate handshake message failed" \
1668 -c "Ciphersuite is TLS-"
1669
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001670run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001671 "$O_SRV -key data_files/server5.key \
1672 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001673 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001674 1 \
1675 -c "bad certificate (usage extensions)" \
1676 -c "Processing of the Certificate handshake message failed" \
1677 -C "Ciphersuite is TLS-"
1678
1679# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001681run_test "extKeyUsage cli-auth: clientAuth -> OK" \
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-cli.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: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001690 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001691 "$O_CLI -key data_files/server5.key \
1692 -cert data_files/server5.eku-srv_cli.crt" \
1693 0 \
1694 -S "bad certificate (usage extensions)" \
1695 -S "Processing of the Certificate handshake message failed"
1696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001697run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001698 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001699 "$O_CLI -key data_files/server5.key \
1700 -cert data_files/server5.eku-cs_any.crt" \
1701 0 \
1702 -S "bad certificate (usage extensions)" \
1703 -S "Processing of the Certificate handshake message failed"
1704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001705run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001706 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001707 "$O_CLI -key data_files/server5.key \
1708 -cert data_files/server5.eku-cs.crt" \
1709 0 \
1710 -s "bad certificate (usage extensions)" \
1711 -S "Processing of the Certificate handshake message failed"
1712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001713run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001714 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001715 "$O_CLI -key data_files/server5.key \
1716 -cert data_files/server5.eku-cs.crt" \
1717 1 \
1718 -s "bad certificate (usage extensions)" \
1719 -s "Processing of the Certificate handshake message failed"
1720
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001721# Tests for DHM parameters loading
1722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001723run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001724 "$P_SRV" \
1725 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1726 debug_level=3" \
1727 0 \
1728 -c "value of 'DHM: P ' (2048 bits)" \
1729 -c "value of 'DHM: G ' (2048 bits)"
1730
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001731run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001732 "$P_SRV dhm_file=data_files/dhparams.pem" \
1733 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1734 debug_level=3" \
1735 0 \
1736 -c "value of 'DHM: P ' (1024 bits)" \
1737 -c "value of 'DHM: G ' (2 bits)"
1738
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001739# Tests for PSK callback
1740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001741run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001742 "$P_SRV psk=abc123 psk_identity=foo" \
1743 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1744 psk_identity=foo psk=abc123" \
1745 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001746 -S "SSL - The server has no ciphersuites in common" \
1747 -S "SSL - Unknown identity received" \
1748 -S "SSL - Verification of the message MAC failed"
1749
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001750run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001751 "$P_SRV" \
1752 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1753 psk_identity=foo psk=abc123" \
1754 1 \
1755 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001756 -S "SSL - Unknown identity received" \
1757 -S "SSL - Verification of the message MAC failed"
1758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001759run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001760 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1761 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1762 psk_identity=foo psk=abc123" \
1763 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001764 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001765 -s "SSL - Unknown identity received" \
1766 -S "SSL - Verification of the message MAC failed"
1767
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001768run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001769 "$P_SRV psk_list=abc,dead,def,beef" \
1770 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1771 psk_identity=abc psk=dead" \
1772 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001773 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001774 -S "SSL - Unknown identity received" \
1775 -S "SSL - Verification of the message MAC failed"
1776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001778 "$P_SRV psk_list=abc,dead,def,beef" \
1779 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1780 psk_identity=def psk=beef" \
1781 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001782 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001783 -S "SSL - Unknown identity received" \
1784 -S "SSL - Verification of the message MAC failed"
1785
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001786run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001787 "$P_SRV psk_list=abc,dead,def,beef" \
1788 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1789 psk_identity=ghi psk=beef" \
1790 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001791 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001792 -s "SSL - Unknown identity received" \
1793 -S "SSL - Verification of the message MAC failed"
1794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001795run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001796 "$P_SRV psk_list=abc,dead,def,beef" \
1797 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1798 psk_identity=abc psk=beef" \
1799 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001800 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001801 -S "SSL - Unknown identity received" \
1802 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001803
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001804# Tests for ciphersuites per version
1805
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001806run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001807 "$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" \
1808 "$P_CLI force_version=ssl3" \
1809 0 \
1810 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001812run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001813 "$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" \
1814 "$P_CLI force_version=tls1" \
1815 0 \
1816 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1817
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001818run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001819 "$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" \
1820 "$P_CLI force_version=tls1_1" \
1821 0 \
1822 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001824run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001825 "$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" \
1826 "$P_CLI force_version=tls1_2" \
1827 0 \
1828 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1829
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001830# Tests for ssl_get_bytes_avail()
1831
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001832run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001833 "$P_SRV" \
1834 "$P_CLI request_size=100" \
1835 0 \
1836 -s "Read from client: 100 bytes read$"
1837
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001838run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001839 "$P_SRV" \
1840 "$P_CLI request_size=500" \
1841 0 \
1842 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001843
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001844# Tests for small packets
1845
1846run_test "Small packet SSLv3 BlockCipher" \
1847 "$P_SRV" \
1848 "$P_CLI request_size=1 force_version=ssl3 \
1849 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1850 0 \
1851 -s "Read from client: 1 bytes read"
1852
1853run_test "Small packet SSLv3 StreamCipher" \
1854 "$P_SRV" \
1855 "$P_CLI request_size=1 force_version=ssl3 \
1856 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1857 0 \
1858 -s "Read from client: 1 bytes read"
1859
1860run_test "Small packet TLS 1.0 BlockCipher" \
1861 "$P_SRV" \
1862 "$P_CLI request_size=1 force_version=tls1 \
1863 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1864 0 \
1865 -s "Read from client: 1 bytes read"
1866
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01001867run_test "Small packet TLS 1.0 BlockCipher without EtM" \
1868 "$P_SRV" \
1869 "$P_CLI request_size=1 force_version=tls1 etm=0 \
1870 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1871 0 \
1872 -s "Read from client: 1 bytes read"
1873
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001874run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1875 "$P_SRV" \
1876 "$P_CLI request_size=1 force_version=tls1 \
1877 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1878 trunc_hmac=1" \
1879 0 \
1880 -s "Read from client: 1 bytes read"
1881
1882run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1883 "$P_SRV" \
1884 "$P_CLI request_size=1 force_version=tls1 \
1885 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1886 trunc_hmac=1" \
1887 0 \
1888 -s "Read from client: 1 bytes read"
1889
1890run_test "Small packet TLS 1.1 BlockCipher" \
1891 "$P_SRV" \
1892 "$P_CLI request_size=1 force_version=tls1_1 \
1893 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1894 0 \
1895 -s "Read from client: 1 bytes read"
1896
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01001897run_test "Small packet TLS 1.1 BlockCipher without EtM" \
1898 "$P_SRV" \
1899 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
1900 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1901 0 \
1902 -s "Read from client: 1 bytes read"
1903
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001904run_test "Small packet TLS 1.1 StreamCipher" \
1905 "$P_SRV" \
1906 "$P_CLI request_size=1 force_version=tls1_1 \
1907 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1908 0 \
1909 -s "Read from client: 1 bytes read"
1910
1911run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1912 "$P_SRV" \
1913 "$P_CLI request_size=1 force_version=tls1_1 \
1914 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1915 trunc_hmac=1" \
1916 0 \
1917 -s "Read from client: 1 bytes read"
1918
1919run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1920 "$P_SRV" \
1921 "$P_CLI request_size=1 force_version=tls1_1 \
1922 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1923 trunc_hmac=1" \
1924 0 \
1925 -s "Read from client: 1 bytes read"
1926
1927run_test "Small packet TLS 1.2 BlockCipher" \
1928 "$P_SRV" \
1929 "$P_CLI request_size=1 force_version=tls1_2 \
1930 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1931 0 \
1932 -s "Read from client: 1 bytes read"
1933
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01001934run_test "Small packet TLS 1.2 BlockCipher without EtM" \
1935 "$P_SRV" \
1936 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
1937 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1938 0 \
1939 -s "Read from client: 1 bytes read"
1940
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001941run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1942 "$P_SRV" \
1943 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1944 0 \
1945 -s "Read from client: 1 bytes read"
1946
1947run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1948 "$P_SRV" \
1949 "$P_CLI request_size=1 force_version=tls1_2 \
1950 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1951 trunc_hmac=1" \
1952 0 \
1953 -s "Read from client: 1 bytes read"
1954
1955run_test "Small packet TLS 1.2 StreamCipher" \
1956 "$P_SRV" \
1957 "$P_CLI request_size=1 force_version=tls1_2 \
1958 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1959 0 \
1960 -s "Read from client: 1 bytes read"
1961
1962run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1963 "$P_SRV" \
1964 "$P_CLI request_size=1 force_version=tls1_2 \
1965 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1966 trunc_hmac=1" \
1967 0 \
1968 -s "Read from client: 1 bytes read"
1969
1970run_test "Small packet TLS 1.2 AEAD" \
1971 "$P_SRV" \
1972 "$P_CLI request_size=1 force_version=tls1_2 \
1973 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1974 0 \
1975 -s "Read from client: 1 bytes read"
1976
1977run_test "Small packet TLS 1.2 AEAD shorter tag" \
1978 "$P_SRV" \
1979 "$P_CLI request_size=1 force_version=tls1_2 \
1980 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1981 0 \
1982 -s "Read from client: 1 bytes read"
1983
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001984# Test for large packets
1985
1986run_test "Large packet SSLv3 BlockCipher" \
1987 "$P_SRV" \
1988 "$P_CLI request_size=16384 force_version=ssl3 \
1989 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1990 0 \
1991 -s "Read from client: 16384 bytes read"
1992
1993run_test "Large packet SSLv3 StreamCipher" \
1994 "$P_SRV" \
1995 "$P_CLI request_size=16384 force_version=ssl3 \
1996 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1997 0 \
1998 -s "Read from client: 16384 bytes read"
1999
2000run_test "Large packet TLS 1.0 BlockCipher" \
2001 "$P_SRV" \
2002 "$P_CLI request_size=16384 force_version=tls1 \
2003 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2004 0 \
2005 -s "Read from client: 16384 bytes read"
2006
2007run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2008 "$P_SRV" \
2009 "$P_CLI request_size=16384 force_version=tls1 \
2010 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2011 trunc_hmac=1" \
2012 0 \
2013 -s "Read from client: 16384 bytes read"
2014
2015run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
2016 "$P_SRV" \
2017 "$P_CLI request_size=16384 force_version=tls1 \
2018 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2019 trunc_hmac=1" \
2020 0 \
2021 -s "Read from client: 16384 bytes read"
2022
2023run_test "Large packet TLS 1.1 BlockCipher" \
2024 "$P_SRV" \
2025 "$P_CLI request_size=16384 force_version=tls1_1 \
2026 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2027 0 \
2028 -s "Read from client: 16384 bytes read"
2029
2030run_test "Large packet TLS 1.1 StreamCipher" \
2031 "$P_SRV" \
2032 "$P_CLI request_size=16384 force_version=tls1_1 \
2033 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2034 0 \
2035 -s "Read from client: 16384 bytes read"
2036
2037run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2038 "$P_SRV" \
2039 "$P_CLI request_size=16384 force_version=tls1_1 \
2040 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2041 trunc_hmac=1" \
2042 0 \
2043 -s "Read from client: 16384 bytes read"
2044
2045run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
2046 "$P_SRV" \
2047 "$P_CLI request_size=16384 force_version=tls1_1 \
2048 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2049 trunc_hmac=1" \
2050 0 \
2051 -s "Read from client: 16384 bytes read"
2052
2053run_test "Large packet TLS 1.2 BlockCipher" \
2054 "$P_SRV" \
2055 "$P_CLI request_size=16384 force_version=tls1_2 \
2056 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2057 0 \
2058 -s "Read from client: 16384 bytes read"
2059
2060run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2061 "$P_SRV" \
2062 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
2063 0 \
2064 -s "Read from client: 16384 bytes read"
2065
2066run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2067 "$P_SRV" \
2068 "$P_CLI request_size=16384 force_version=tls1_2 \
2069 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2070 trunc_hmac=1" \
2071 0 \
2072 -s "Read from client: 16384 bytes read"
2073
2074run_test "Large packet TLS 1.2 StreamCipher" \
2075 "$P_SRV" \
2076 "$P_CLI request_size=16384 force_version=tls1_2 \
2077 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2078 0 \
2079 -s "Read from client: 16384 bytes read"
2080
2081run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
2082 "$P_SRV" \
2083 "$P_CLI request_size=16384 force_version=tls1_2 \
2084 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2085 trunc_hmac=1" \
2086 0 \
2087 -s "Read from client: 16384 bytes read"
2088
2089run_test "Large packet TLS 1.2 AEAD" \
2090 "$P_SRV" \
2091 "$P_CLI request_size=16384 force_version=tls1_2 \
2092 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2093 0 \
2094 -s "Read from client: 16384 bytes read"
2095
2096run_test "Large packet TLS 1.2 AEAD shorter tag" \
2097 "$P_SRV" \
2098 "$P_CLI request_size=16384 force_version=tls1_2 \
2099 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2100 0 \
2101 -s "Read from client: 16384 bytes read"
2102
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002103# Final report
2104
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002105echo "------------------------------------------------------------------------"
2106
2107if [ $FAILS = 0 ]; then
2108 echo -n "PASSED"
2109else
2110 echo -n "FAILED"
2111fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002112PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002113echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002114
2115exit $FAILS