blob: 75c59423a1bc810bf7d873712586abcf290cac20 [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"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010023G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
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é-Gonnardf46f1282014-12-11 11:51:28 +010037 printf " -h|--help\tPrint this help.\n"
38 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
39 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
40 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
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() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100114 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200115 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100116 for i in `seq 1 $LEN`; do printf '.'; done
117 printf ' '
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
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100166 until lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null;
167 do :; done
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200168
169 kill $WATCHDOG_PID
170 wait $WATCHDOG_PID
171 else
172 sleep "$START_DELAY"
173 fi
174}
175
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200176# wait for client to terminate and set CLI_EXIT
177# must be called right after starting the client
178wait_client_done() {
179 CLI_PID=$!
180
181 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
182 WATCHDOG_PID=$!
183
184 wait $CLI_PID
185 CLI_EXIT=$?
186
187 kill $WATCHDOG_PID
188 wait $WATCHDOG_PID
189
190 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
191}
192
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100193# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100194# Options: -s pattern pattern that must be present in server output
195# -c pattern pattern that must be present in client output
196# -S pattern pattern that must be absent in server output
197# -C pattern pattern that must be absent in client output
198run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100199 NAME="$1"
200 SRV_CMD="$2"
201 CLI_CMD="$3"
202 CLI_EXPECT="$4"
203 shift 4
204
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100205 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
206 else
207 return
208 fi
209
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100210 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100211
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200212 # should we skip?
213 if [ "X$SKIP_NEXT" = "XYES" ]; then
214 SKIP_NEXT="NO"
215 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200216 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200217 return
218 fi
219
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100220 # prepend valgrind to our commands if active
221 if [ "$MEMCHECK" -gt 0 ]; then
222 if is_polar "$SRV_CMD"; then
223 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
224 fi
225 if is_polar "$CLI_CMD"; then
226 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
227 fi
228 fi
229
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100230 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200231 echo "$SRV_CMD" > $SRV_OUT
232 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100233 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200234 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200235
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200236 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200237 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
238 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100239
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200240 # kill the server
241 kill $SRV_PID
242 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100243
244 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200245 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100246 # expected client exit to incorrectly succeed in case of catastrophic
247 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100248 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200249 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100250 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100251 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100252 return
253 fi
254 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100255 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200256 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100257 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100258 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100259 return
260 fi
261 fi
262
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100263 # check server exit code
264 if [ $? != 0 ]; then
265 fail "server fail"
266 return
267 fi
268
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100269 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100270 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
271 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100272 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100273 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100274 return
275 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100276
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100277 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200278 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100279 while [ $# -gt 0 ]
280 do
281 case $1 in
282 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200283 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100284 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100285 return
286 fi
287 ;;
288
289 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200290 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100291 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100292 return
293 fi
294 ;;
295
296 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200297 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100298 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299 return
300 fi
301 ;;
302
303 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200304 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100305 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100306 return
307 fi
308 ;;
309
310 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200311 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100312 exit 1
313 esac
314 shift 2
315 done
316
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100317 # check valgrind's results
318 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200319 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100320 fail "Server has memory errors"
321 return
322 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200323 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100324 fail "Client has memory errors"
325 return
326 fi
327 fi
328
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100329 # if we're here, everything is ok
330 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200331 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100332}
333
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100334cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200335 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200336 kill $SRV_PID >/dev/null 2>&1
337 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100338 exit 1
339}
340
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100341#
342# MAIN
343#
344
Manuel Pégourié-Gonnard751286b2015-03-10 13:41:04 +0000345if cd $( dirname $0 ); then :; else
346 echo "cd $( dirname $0 ) failed" >&2
347 exit 1
348fi
349
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100350get_options "$@"
351
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100352# sanity checks, avoid an avalanche of errors
353if [ ! -x "$P_SRV" ]; then
354 echo "Command '$P_SRV' is not an executable file"
355 exit 1
356fi
357if [ ! -x "$P_CLI" ]; then
358 echo "Command '$P_CLI' is not an executable file"
359 exit 1
360fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100361if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
362 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100363 exit 1
364fi
365
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200366# used by watchdog
367MAIN_PID="$$"
368
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200369# be more patient with valgrind
370if [ "$MEMCHECK" -gt 0 ]; then
371 START_DELAY=3
372 DOG_DELAY=30
373else
374 START_DELAY=1
375 DOG_DELAY=10
376fi
377
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200378# Pick a "unique" port in the range 10000-19999.
379PORT="0000$$"
Manuel Pégourié-Gonnarddc370e42015-01-22 10:24:59 +0000380PORT="1$( printf $PORT | tail -c 4 )"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200381
382# fix commands to use this port
383P_SRV="$P_SRV server_port=$PORT"
384P_CLI="$P_CLI server_port=$PORT"
385O_SRV="$O_SRV -accept $PORT"
386O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200387G_SRV="$G_SRV -p $PORT"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100388G_CLI="$G_CLI -p $PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200389
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200390# Also pick a unique name for intermediate files
391SRV_OUT="srv_out.$$"
392CLI_OUT="cli_out.$$"
393SESSION="session.$$"
394
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200395SKIP_NEXT="NO"
396
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100397trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100398
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200399# Basic test
400
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200401# Checks that:
402# - things work with all ciphersuites active (used with config-full in all.sh)
403# - the expected (highest security) parameters are selected
404# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200405run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200406 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200407 "$P_CLI" \
408 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200409 -s "Protocol is TLSv1.2" \
410 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
411 -s "client hello v3, signature_algorithm ext: 6" \
412 -s "ECDHE curve: secp521r1" \
413 -S "error" \
414 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200415
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100416# Tests for rc4 option
417
418run_test "RC4: server disabled, client enabled" \
419 "$P_SRV" \
420 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
421 1 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100422 -s "SSL - None of the common ciphersuites is usable"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100423
424run_test "RC4: server enabled, client disabled" \
425 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
426 "$P_CLI" \
427 1 \
428 -s "SSL - The server has no ciphersuites in common"
429
430run_test "RC4: both enabled" \
431 "$P_SRV arc4=1" \
432 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
433 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100434 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100435 -S "SSL - The server has no ciphersuites in common"
436
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100437# Test for SSLv2 ClientHello
438
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200439requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200440run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100441 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100442 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100443 0 \
444 -S "parse client hello v2" \
445 -S "ssl_handshake returned"
446
447# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200448requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200449run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200450 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100451 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100452 0 \
453 -s "parse client hello v2" \
454 -S "ssl_handshake returned"
455
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100456# Tests for Truncated HMAC extension
457
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100458run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200459 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100460 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100461 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100462 -s "dumping 'computed mac' (20 bytes)" \
463 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100464
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100465run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200466 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100467 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
468 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100469 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100470 -s "dumping 'computed mac' (20 bytes)" \
471 -S "dumping 'computed mac' (10 bytes)"
472
473run_test "Truncated HMAC: client enabled, server default" \
474 "$P_SRV debug_level=4" \
475 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
476 trunc_hmac=1" \
477 0 \
478 -S "dumping 'computed mac' (20 bytes)" \
479 -s "dumping 'computed mac' (10 bytes)"
480
481run_test "Truncated HMAC: client enabled, server disabled" \
482 "$P_SRV debug_level=4 trunc_hmac=0" \
483 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
484 trunc_hmac=1" \
485 0 \
486 -s "dumping 'computed mac' (20 bytes)" \
487 -S "dumping 'computed mac' (10 bytes)"
488
489run_test "Truncated HMAC: client enabled, server enabled" \
490 "$P_SRV debug_level=4 trunc_hmac=1" \
491 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
492 trunc_hmac=1" \
493 0 \
494 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100495 -s "dumping 'computed mac' (10 bytes)"
496
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100497# Tests for Encrypt-then-MAC extension
498
499run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100500 "$P_SRV debug_level=3 \
501 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100502 "$P_CLI debug_level=3" \
503 0 \
504 -c "client hello, adding encrypt_then_mac extension" \
505 -s "found encrypt then mac extension" \
506 -s "server hello, adding encrypt then mac extension" \
507 -c "found encrypt_then_mac extension" \
508 -c "using encrypt then mac" \
509 -s "using encrypt then mac"
510
511run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100512 "$P_SRV debug_level=3 etm=0 \
513 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100514 "$P_CLI debug_level=3 etm=1" \
515 0 \
516 -c "client hello, adding encrypt_then_mac extension" \
517 -s "found encrypt then mac extension" \
518 -S "server hello, adding encrypt then mac extension" \
519 -C "found encrypt_then_mac extension" \
520 -C "using encrypt then mac" \
521 -S "using encrypt then mac"
522
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100523run_test "Encrypt then MAC: client enabled, aead cipher" \
524 "$P_SRV debug_level=3 etm=1 \
525 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
526 "$P_CLI debug_level=3 etm=1" \
527 0 \
528 -c "client hello, adding encrypt_then_mac extension" \
529 -s "found encrypt then mac extension" \
530 -S "server hello, adding encrypt then mac extension" \
531 -C "found encrypt_then_mac extension" \
532 -C "using encrypt then mac" \
533 -S "using encrypt then mac"
534
535run_test "Encrypt then MAC: client enabled, stream cipher" \
536 "$P_SRV debug_level=3 etm=1 \
537 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100538 "$P_CLI debug_level=3 etm=1 arc4=1" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100539 0 \
540 -c "client hello, adding encrypt_then_mac extension" \
541 -s "found encrypt then mac extension" \
542 -S "server hello, adding encrypt then mac extension" \
543 -C "found encrypt_then_mac extension" \
544 -C "using encrypt then mac" \
545 -S "using encrypt then mac"
546
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100547run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100548 "$P_SRV debug_level=3 etm=1 \
549 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100550 "$P_CLI debug_level=3 etm=0" \
551 0 \
552 -C "client hello, adding encrypt_then_mac extension" \
553 -S "found encrypt then mac extension" \
554 -S "server hello, adding encrypt then mac extension" \
555 -C "found encrypt_then_mac extension" \
556 -C "using encrypt then mac" \
557 -S "using encrypt then mac"
558
559run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100560 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100561 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100562 "$P_CLI debug_level=3 force_version=ssl3" \
563 0 \
564 -C "client hello, adding encrypt_then_mac extension" \
565 -S "found encrypt then mac extension" \
566 -S "server hello, adding encrypt then mac extension" \
567 -C "found encrypt_then_mac extension" \
568 -C "using encrypt then mac" \
569 -S "using encrypt then mac"
570
571run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100572 "$P_SRV debug_level=3 force_version=ssl3 \
573 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100574 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100575 0 \
576 -c "client hello, adding encrypt_then_mac extension" \
577 -s "found encrypt then mac extension" \
578 -S "server hello, adding encrypt then mac extension" \
579 -C "found encrypt_then_mac extension" \
580 -C "using encrypt then mac" \
581 -S "using encrypt then mac"
582
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200583# Tests for Extended Master Secret extension
584
585run_test "Extended Master Secret: default" \
586 "$P_SRV debug_level=3" \
587 "$P_CLI debug_level=3" \
588 0 \
589 -c "client hello, adding extended_master_secret extension" \
590 -s "found extended master secret extension" \
591 -s "server hello, adding extended master secret extension" \
592 -c "found extended_master_secret extension" \
593 -c "using extended master secret" \
594 -s "using extended master secret"
595
596run_test "Extended Master Secret: client enabled, server disabled" \
597 "$P_SRV debug_level=3 extended_ms=0" \
598 "$P_CLI debug_level=3 extended_ms=1" \
599 0 \
600 -c "client hello, adding extended_master_secret extension" \
601 -s "found extended master secret extension" \
602 -S "server hello, adding extended master secret extension" \
603 -C "found extended_master_secret extension" \
604 -C "using extended master secret" \
605 -S "using extended master secret"
606
607run_test "Extended Master Secret: client disabled, server enabled" \
608 "$P_SRV debug_level=3 extended_ms=1" \
609 "$P_CLI debug_level=3 extended_ms=0" \
610 0 \
611 -C "client hello, adding extended_master_secret extension" \
612 -S "found extended master secret extension" \
613 -S "server hello, adding extended master secret extension" \
614 -C "found extended_master_secret extension" \
615 -C "using extended master secret" \
616 -S "using extended master secret"
617
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200618run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100619 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200620 "$P_CLI debug_level=3 force_version=ssl3" \
621 0 \
622 -C "client hello, adding extended_master_secret extension" \
623 -S "found extended master secret extension" \
624 -S "server hello, adding extended master secret extension" \
625 -C "found extended_master_secret extension" \
626 -C "using extended master secret" \
627 -S "using extended master secret"
628
629run_test "Extended Master Secret: client enabled, server SSLv3" \
630 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100631 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200632 0 \
633 -c "client hello, adding extended_master_secret extension" \
634 -s "found extended master secret extension" \
635 -S "server hello, adding extended master secret extension" \
636 -C "found extended_master_secret extension" \
637 -C "using extended master secret" \
638 -S "using extended master secret"
639
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200640# Tests for FALLBACK_SCSV
641
642run_test "Fallback SCSV: default" \
643 "$P_SRV" \
644 "$P_CLI debug_level=3 force_version=tls1_1" \
645 0 \
646 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200647 -S "received FALLBACK_SCSV" \
648 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200649 -C "is a fatal alert message (msg 86)"
650
651run_test "Fallback SCSV: explicitly disabled" \
652 "$P_SRV" \
653 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
654 0 \
655 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200656 -S "received FALLBACK_SCSV" \
657 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200658 -C "is a fatal alert message (msg 86)"
659
660run_test "Fallback SCSV: enabled" \
661 "$P_SRV" \
662 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200663 1 \
664 -c "adding FALLBACK_SCSV" \
665 -s "received FALLBACK_SCSV" \
666 -s "inapropriate fallback" \
667 -c "is a fatal alert message (msg 86)"
668
669run_test "Fallback SCSV: enabled, max version" \
670 "$P_SRV" \
671 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200672 0 \
673 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200674 -s "received FALLBACK_SCSV" \
675 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200676 -C "is a fatal alert message (msg 86)"
677
678requires_openssl_with_fallback_scsv
679run_test "Fallback SCSV: default, openssl server" \
680 "$O_SRV" \
681 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
682 0 \
683 -C "adding FALLBACK_SCSV" \
684 -C "is a fatal alert message (msg 86)"
685
686requires_openssl_with_fallback_scsv
687run_test "Fallback SCSV: enabled, openssl server" \
688 "$O_SRV" \
689 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
690 1 \
691 -c "adding FALLBACK_SCSV" \
692 -c "is a fatal alert message (msg 86)"
693
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200694requires_openssl_with_fallback_scsv
695run_test "Fallback SCSV: disabled, openssl client" \
696 "$P_SRV" \
697 "$O_CLI -tls1_1" \
698 0 \
699 -S "received FALLBACK_SCSV" \
700 -S "inapropriate fallback"
701
702requires_openssl_with_fallback_scsv
703run_test "Fallback SCSV: enabled, openssl client" \
704 "$P_SRV" \
705 "$O_CLI -tls1_1 -fallback_scsv" \
706 1 \
707 -s "received FALLBACK_SCSV" \
708 -s "inapropriate fallback"
709
710requires_openssl_with_fallback_scsv
711run_test "Fallback SCSV: enabled, max version, openssl client" \
712 "$P_SRV" \
713 "$O_CLI -fallback_scsv" \
714 0 \
715 -s "received FALLBACK_SCSV" \
716 -S "inapropriate fallback"
717
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100718# Tests for CBC 1/n-1 record splitting
719
720run_test "CBC Record splitting: TLS 1.2, no splitting" \
721 "$P_SRV" \
722 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
723 request_size=123 force_version=tls1_2" \
724 0 \
725 -s "Read from client: 123 bytes read" \
726 -S "Read from client: 1 bytes read" \
727 -S "122 bytes read"
728
729run_test "CBC Record splitting: TLS 1.1, no splitting" \
730 "$P_SRV" \
731 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
732 request_size=123 force_version=tls1_1" \
733 0 \
734 -s "Read from client: 123 bytes read" \
735 -S "Read from client: 1 bytes read" \
736 -S "122 bytes read"
737
738run_test "CBC Record splitting: TLS 1.0, splitting" \
739 "$P_SRV" \
740 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
741 request_size=123 force_version=tls1" \
742 0 \
743 -S "Read from client: 123 bytes read" \
744 -s "Read from client: 1 bytes read" \
745 -s "122 bytes read"
746
747run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100748 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100749 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
750 request_size=123 force_version=ssl3" \
751 0 \
752 -S "Read from client: 123 bytes read" \
753 -s "Read from client: 1 bytes read" \
754 -s "122 bytes read"
755
756run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100757 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100758 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
759 request_size=123 force_version=tls1" \
760 0 \
761 -s "Read from client: 123 bytes read" \
762 -S "Read from client: 1 bytes read" \
763 -S "122 bytes read"
764
765run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
766 "$P_SRV" \
767 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
768 request_size=123 force_version=tls1 recsplit=0" \
769 0 \
770 -s "Read from client: 123 bytes read" \
771 -S "Read from client: 1 bytes read" \
772 -S "122 bytes read"
773
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100774run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
775 "$P_SRV nbio=2" \
776 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
777 request_size=123 force_version=tls1" \
778 0 \
779 -S "Read from client: 123 bytes read" \
780 -s "Read from client: 1 bytes read" \
781 -s "122 bytes read"
782
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100783# Tests for Session Tickets
784
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200785run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200786 "$P_SRV debug_level=3 tickets=1" \
787 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100788 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100789 -c "client hello, adding session ticket extension" \
790 -s "found session ticket extension" \
791 -s "server hello, adding session ticket extension" \
792 -c "found session_ticket extension" \
793 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100794 -S "session successfully restored from cache" \
795 -s "session successfully restored from ticket" \
796 -s "a session has been resumed" \
797 -c "a session has been resumed"
798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200799run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200800 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
801 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100802 0 \
803 -c "client hello, adding session ticket extension" \
804 -s "found session ticket extension" \
805 -s "server hello, adding session ticket extension" \
806 -c "found session_ticket extension" \
807 -c "parse new session ticket" \
808 -S "session successfully restored from cache" \
809 -s "session successfully restored from ticket" \
810 -s "a session has been resumed" \
811 -c "a session has been resumed"
812
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200813run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200814 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
815 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100816 0 \
817 -c "client hello, adding session ticket extension" \
818 -s "found session ticket extension" \
819 -s "server hello, adding session ticket extension" \
820 -c "found session_ticket extension" \
821 -c "parse new session ticket" \
822 -S "session successfully restored from cache" \
823 -S "session successfully restored from ticket" \
824 -S "a session has been resumed" \
825 -C "a session has been resumed"
826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200827run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100828 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200829 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100830 0 \
831 -c "client hello, adding session ticket extension" \
832 -c "found session_ticket extension" \
833 -c "parse new session ticket" \
834 -c "a session has been resumed"
835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200836run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200837 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200838 "( $O_CLI -sess_out $SESSION; \
839 $O_CLI -sess_in $SESSION; \
840 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100841 0 \
842 -s "found session ticket extension" \
843 -s "server hello, adding session ticket extension" \
844 -S "session successfully restored from cache" \
845 -s "session successfully restored from ticket" \
846 -s "a session has been resumed"
847
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100848# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200850run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200851 "$P_SRV debug_level=3 tickets=0" \
852 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100853 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100854 -c "client hello, adding session ticket extension" \
855 -s "found session ticket extension" \
856 -S "server hello, adding session ticket extension" \
857 -C "found session_ticket extension" \
858 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100859 -s "session successfully restored from cache" \
860 -S "session successfully restored from ticket" \
861 -s "a session has been resumed" \
862 -c "a session has been resumed"
863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200864run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200865 "$P_SRV debug_level=3 tickets=1" \
866 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100867 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100868 -C "client hello, adding session ticket extension" \
869 -S "found session ticket extension" \
870 -S "server hello, adding session ticket extension" \
871 -C "found session_ticket extension" \
872 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100873 -s "session successfully restored from cache" \
874 -S "session successfully restored from ticket" \
875 -s "a session has been resumed" \
876 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100877
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200878run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200879 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
880 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100881 0 \
882 -S "session successfully restored from cache" \
883 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100884 -S "a session has been resumed" \
885 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100886
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200887run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200888 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
889 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100890 0 \
891 -s "session successfully restored from cache" \
892 -S "session successfully restored from ticket" \
893 -s "a session has been resumed" \
894 -c "a session has been resumed"
895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200896run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200897 "$P_SRV debug_level=3 tickets=0" \
898 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100899 0 \
900 -s "session successfully restored from cache" \
901 -S "session successfully restored from ticket" \
902 -s "a session has been resumed" \
903 -c "a session has been resumed"
904
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200905run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200906 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
907 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100908 0 \
909 -S "session successfully restored from cache" \
910 -S "session successfully restored from ticket" \
911 -S "a session has been resumed" \
912 -C "a session has been resumed"
913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200914run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200915 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
916 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100917 0 \
918 -s "session successfully restored from cache" \
919 -S "session successfully restored from ticket" \
920 -s "a session has been resumed" \
921 -c "a session has been resumed"
922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200923run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200924 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200925 "( $O_CLI -sess_out $SESSION; \
926 $O_CLI -sess_in $SESSION; \
927 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100928 0 \
929 -s "found session ticket extension" \
930 -S "server hello, adding session ticket extension" \
931 -s "session successfully restored from cache" \
932 -S "session successfully restored from ticket" \
933 -s "a session has been resumed"
934
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200935run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100936 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200937 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100938 0 \
939 -C "found session_ticket extension" \
940 -C "parse new session ticket" \
941 -c "a session has been resumed"
942
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100943# Tests for Max Fragment Length extension
944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200945run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200946 "$P_SRV debug_level=3" \
947 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100948 0 \
949 -C "client hello, adding max_fragment_length extension" \
950 -S "found max fragment length extension" \
951 -S "server hello, max_fragment_length extension" \
952 -C "found max_fragment_length extension"
953
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200954run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200955 "$P_SRV debug_level=3" \
956 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100957 0 \
958 -c "client hello, adding max_fragment_length extension" \
959 -s "found max fragment length extension" \
960 -s "server hello, max_fragment_length extension" \
961 -c "found max_fragment_length extension"
962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200963run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200964 "$P_SRV debug_level=3 max_frag_len=4096" \
965 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100966 0 \
967 -C "client hello, adding max_fragment_length extension" \
968 -S "found max fragment length extension" \
969 -S "server hello, max_fragment_length extension" \
970 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100971
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200972requires_gnutls
973run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200974 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200975 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200976 0 \
977 -c "client hello, adding max_fragment_length extension" \
978 -c "found max_fragment_length extension"
979
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100980# Tests for renegotiation
981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200982run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200983 "$P_SRV debug_level=3 exchanges=2" \
984 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100985 0 \
986 -C "client hello, adding renegotiation extension" \
987 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
988 -S "found renegotiation extension" \
989 -s "server hello, secure renegotiation extension" \
990 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100991 -C "=> renegotiate" \
992 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100993 -S "write hello request"
994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200995run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200996 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
997 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100998 0 \
999 -c "client hello, adding renegotiation extension" \
1000 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1001 -s "found renegotiation extension" \
1002 -s "server hello, secure renegotiation extension" \
1003 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001004 -c "=> renegotiate" \
1005 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001006 -S "write hello request"
1007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001008run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001009 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1010 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001011 0 \
1012 -c "client hello, adding renegotiation extension" \
1013 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1014 -s "found renegotiation extension" \
1015 -s "server hello, secure renegotiation extension" \
1016 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001017 -c "=> renegotiate" \
1018 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001019 -s "write hello request"
1020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001021run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001022 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1023 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001024 0 \
1025 -c "client hello, adding renegotiation extension" \
1026 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1027 -s "found renegotiation extension" \
1028 -s "server hello, secure renegotiation extension" \
1029 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001030 -c "=> renegotiate" \
1031 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001032 -s "write hello request"
1033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001034run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001035 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1036 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001037 1 \
1038 -c "client hello, adding renegotiation extension" \
1039 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1040 -S "found renegotiation extension" \
1041 -s "server hello, secure renegotiation extension" \
1042 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001043 -c "=> renegotiate" \
1044 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001045 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001046 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001047 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001048
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001049run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001050 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1051 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001052 0 \
1053 -C "client hello, adding renegotiation extension" \
1054 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1055 -S "found renegotiation extension" \
1056 -s "server hello, secure renegotiation extension" \
1057 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001058 -C "=> renegotiate" \
1059 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001060 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001061 -S "SSL - An unexpected message was received from our peer" \
1062 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001063
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001064run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001065 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001066 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001067 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001068 0 \
1069 -C "client hello, adding renegotiation extension" \
1070 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1071 -S "found renegotiation extension" \
1072 -s "server hello, secure renegotiation extension" \
1073 -c "found renegotiation extension" \
1074 -C "=> renegotiate" \
1075 -S "=> renegotiate" \
1076 -s "write hello request" \
1077 -S "SSL - An unexpected message was received from our peer" \
1078 -S "failed"
1079
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001080# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001081run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001082 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001083 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001084 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001085 0 \
1086 -C "client hello, adding renegotiation extension" \
1087 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1088 -S "found renegotiation extension" \
1089 -s "server hello, secure renegotiation extension" \
1090 -c "found renegotiation extension" \
1091 -C "=> renegotiate" \
1092 -S "=> renegotiate" \
1093 -s "write hello request" \
1094 -S "SSL - An unexpected message was received from our peer" \
1095 -S "failed"
1096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001097run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001098 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001099 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001100 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001101 0 \
1102 -C "client hello, adding renegotiation extension" \
1103 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1104 -S "found renegotiation extension" \
1105 -s "server hello, secure renegotiation extension" \
1106 -c "found renegotiation extension" \
1107 -C "=> renegotiate" \
1108 -S "=> renegotiate" \
1109 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001110 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001111
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001112run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001113 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001114 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001115 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001116 0 \
1117 -c "client hello, adding renegotiation extension" \
1118 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1119 -s "found renegotiation extension" \
1120 -s "server hello, secure renegotiation extension" \
1121 -c "found renegotiation extension" \
1122 -c "=> renegotiate" \
1123 -s "=> renegotiate" \
1124 -s "write hello request" \
1125 -S "SSL - An unexpected message was received from our peer" \
1126 -S "failed"
1127
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001128run_test "Renegotiation: periodic, just below period" \
1129 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1130 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1131 0 \
1132 -C "client hello, adding renegotiation extension" \
1133 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1134 -S "found renegotiation extension" \
1135 -s "server hello, secure renegotiation extension" \
1136 -c "found renegotiation extension" \
1137 -S "record counter limit reached: renegotiate" \
1138 -C "=> renegotiate" \
1139 -S "=> renegotiate" \
1140 -S "write hello request" \
1141 -S "SSL - An unexpected message was received from our peer" \
1142 -S "failed"
1143
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001144# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001145run_test "Renegotiation: periodic, just above period" \
1146 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001147 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001148 0 \
1149 -c "client hello, adding renegotiation extension" \
1150 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1151 -s "found renegotiation extension" \
1152 -s "server hello, secure renegotiation extension" \
1153 -c "found renegotiation extension" \
1154 -s "record counter limit reached: renegotiate" \
1155 -c "=> renegotiate" \
1156 -s "=> renegotiate" \
1157 -s "write hello request" \
1158 -S "SSL - An unexpected message was received from our peer" \
1159 -S "failed"
1160
1161run_test "Renegotiation: periodic, two times period" \
1162 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001163 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001164 0 \
1165 -c "client hello, adding renegotiation extension" \
1166 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1167 -s "found renegotiation extension" \
1168 -s "server hello, secure renegotiation extension" \
1169 -c "found renegotiation extension" \
1170 -s "record counter limit reached: renegotiate" \
1171 -c "=> renegotiate" \
1172 -s "=> renegotiate" \
1173 -s "write hello request" \
1174 -S "SSL - An unexpected message was received from our peer" \
1175 -S "failed"
1176
1177run_test "Renegotiation: periodic, above period, disabled" \
1178 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1179 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1180 0 \
1181 -C "client hello, adding renegotiation extension" \
1182 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1183 -S "found renegotiation extension" \
1184 -s "server hello, secure renegotiation extension" \
1185 -c "found renegotiation extension" \
1186 -S "record counter limit reached: renegotiate" \
1187 -C "=> renegotiate" \
1188 -S "=> renegotiate" \
1189 -S "write hello request" \
1190 -S "SSL - An unexpected message was received from our peer" \
1191 -S "failed"
1192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001193run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001194 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1195 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001196 0 \
1197 -c "client hello, adding renegotiation extension" \
1198 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1199 -s "found renegotiation extension" \
1200 -s "server hello, secure renegotiation extension" \
1201 -c "found renegotiation extension" \
1202 -c "=> renegotiate" \
1203 -s "=> renegotiate" \
1204 -S "write hello request"
1205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001206run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001207 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1208 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001209 0 \
1210 -c "client hello, adding renegotiation extension" \
1211 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1212 -s "found renegotiation extension" \
1213 -s "server hello, secure renegotiation extension" \
1214 -c "found renegotiation extension" \
1215 -c "=> renegotiate" \
1216 -s "=> renegotiate" \
1217 -s "write hello request"
1218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001219run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001220 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001221 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001222 0 \
1223 -c "client hello, adding renegotiation extension" \
1224 -c "found renegotiation extension" \
1225 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001226 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001227 -C "error" \
1228 -c "HTTP/1.0 200 [Oo][Kk]"
1229
Paul Bakker539d9722015-02-08 16:18:35 +01001230requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001231run_test "Renegotiation: gnutls server strict, client-initiated" \
1232 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001233 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001234 0 \
1235 -c "client hello, adding renegotiation extension" \
1236 -c "found renegotiation extension" \
1237 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001238 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001239 -C "error" \
1240 -c "HTTP/1.0 200 [Oo][Kk]"
1241
Paul Bakker539d9722015-02-08 16:18:35 +01001242requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001243run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1244 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1245 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1246 1 \
1247 -c "client hello, adding renegotiation extension" \
1248 -C "found renegotiation extension" \
1249 -c "=> renegotiate" \
1250 -c "ssl_handshake() returned" \
1251 -c "error" \
1252 -C "HTTP/1.0 200 [Oo][Kk]"
1253
Paul Bakker539d9722015-02-08 16:18:35 +01001254requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001255run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1256 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1257 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1258 allow_legacy=0" \
1259 1 \
1260 -c "client hello, adding renegotiation extension" \
1261 -C "found renegotiation extension" \
1262 -c "=> renegotiate" \
1263 -c "ssl_handshake() returned" \
1264 -c "error" \
1265 -C "HTTP/1.0 200 [Oo][Kk]"
1266
Paul Bakker539d9722015-02-08 16:18:35 +01001267requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001268run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1269 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1270 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1271 allow_legacy=1" \
1272 0 \
1273 -c "client hello, adding renegotiation extension" \
1274 -C "found renegotiation extension" \
1275 -c "=> renegotiate" \
1276 -C "ssl_hanshake() returned" \
1277 -C "error" \
1278 -c "HTTP/1.0 200 [Oo][Kk]"
1279
1280# Test for the "secure renegotation" extension only (no actual renegotiation)
1281
Paul Bakker539d9722015-02-08 16:18:35 +01001282requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001283run_test "Renego ext: gnutls server strict, client default" \
1284 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1285 "$P_CLI debug_level=3" \
1286 0 \
1287 -c "found renegotiation extension" \
1288 -C "error" \
1289 -c "HTTP/1.0 200 [Oo][Kk]"
1290
Paul Bakker539d9722015-02-08 16:18:35 +01001291requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001292run_test "Renego ext: gnutls server unsafe, client default" \
1293 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1294 "$P_CLI debug_level=3" \
1295 0 \
1296 -C "found renegotiation extension" \
1297 -C "error" \
1298 -c "HTTP/1.0 200 [Oo][Kk]"
1299
Paul Bakker539d9722015-02-08 16:18:35 +01001300requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001301run_test "Renego ext: gnutls server unsafe, client break legacy" \
1302 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1303 "$P_CLI debug_level=3 allow_legacy=-1" \
1304 1 \
1305 -C "found renegotiation extension" \
1306 -c "error" \
1307 -C "HTTP/1.0 200 [Oo][Kk]"
1308
Paul Bakker539d9722015-02-08 16:18:35 +01001309requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001310run_test "Renego ext: gnutls client strict, server default" \
1311 "$P_SRV debug_level=3" \
1312 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1313 0 \
1314 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1315 -s "server hello, secure renegotiation extension"
1316
Paul Bakker539d9722015-02-08 16:18:35 +01001317requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001318run_test "Renego ext: gnutls client unsafe, server default" \
1319 "$P_SRV debug_level=3" \
1320 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1321 0 \
1322 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1323 -S "server hello, secure renegotiation extension"
1324
Paul Bakker539d9722015-02-08 16:18:35 +01001325requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001326run_test "Renego ext: gnutls client unsafe, server break legacy" \
1327 "$P_SRV debug_level=3 allow_legacy=-1" \
1328 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1329 1 \
1330 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1331 -S "server hello, secure renegotiation extension"
1332
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001333# Tests for auth_mode
1334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001335run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001336 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001337 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001338 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001339 1 \
1340 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001341 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001342 -c "! ssl_handshake returned" \
1343 -c "X509 - Certificate verification failed"
1344
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001345run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001346 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001347 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001348 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001349 0 \
1350 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001351 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001352 -C "! ssl_handshake returned" \
1353 -C "X509 - Certificate verification failed"
1354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001355run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001356 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001357 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001358 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001359 0 \
1360 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001361 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001362 -C "! ssl_handshake returned" \
1363 -C "X509 - Certificate verification failed"
1364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001365run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001366 "$P_SRV debug_level=3 auth_mode=required" \
1367 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001368 key_file=data_files/server5.key" \
1369 1 \
1370 -S "skip write certificate request" \
1371 -C "skip parse certificate request" \
1372 -c "got a certificate request" \
1373 -C "skip write certificate" \
1374 -C "skip write certificate verify" \
1375 -S "skip parse certificate verify" \
1376 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001377 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001378 -s "! ssl_handshake returned" \
1379 -c "! ssl_handshake returned" \
1380 -s "X509 - Certificate verification failed"
1381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001382run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001383 "$P_SRV debug_level=3 auth_mode=optional" \
1384 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001385 key_file=data_files/server5.key" \
1386 0 \
1387 -S "skip write certificate request" \
1388 -C "skip parse certificate request" \
1389 -c "got a certificate request" \
1390 -C "skip write certificate" \
1391 -C "skip write certificate verify" \
1392 -S "skip parse certificate verify" \
1393 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001394 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001395 -S "! ssl_handshake returned" \
1396 -C "! ssl_handshake returned" \
1397 -S "X509 - Certificate verification failed"
1398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001399run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001400 "$P_SRV debug_level=3 auth_mode=none" \
1401 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001402 key_file=data_files/server5.key" \
1403 0 \
1404 -s "skip write certificate request" \
1405 -C "skip parse certificate request" \
1406 -c "got no certificate request" \
1407 -c "skip write certificate" \
1408 -c "skip write certificate verify" \
1409 -s "skip parse certificate verify" \
1410 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001411 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001412 -S "! ssl_handshake returned" \
1413 -C "! ssl_handshake returned" \
1414 -S "X509 - Certificate verification failed"
1415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001416run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001417 "$P_SRV debug_level=3 auth_mode=optional" \
1418 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001419 0 \
1420 -S "skip write certificate request" \
1421 -C "skip parse certificate request" \
1422 -c "got a certificate request" \
1423 -C "skip write certificate$" \
1424 -C "got no certificate to send" \
1425 -S "SSLv3 client has no certificate" \
1426 -c "skip write certificate verify" \
1427 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001428 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001429 -S "! ssl_handshake returned" \
1430 -C "! ssl_handshake returned" \
1431 -S "X509 - Certificate verification failed"
1432
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001433run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001434 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001435 "$O_CLI" \
1436 0 \
1437 -S "skip write certificate request" \
1438 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001439 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001440 -S "! ssl_handshake returned" \
1441 -S "X509 - Certificate verification failed"
1442
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001443run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001444 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001445 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001446 0 \
1447 -C "skip parse certificate request" \
1448 -c "got a certificate request" \
1449 -C "skip write certificate$" \
1450 -c "skip write certificate verify" \
1451 -C "! ssl_handshake returned"
1452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001453run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001454 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001455 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001456 0 \
1457 -S "skip write certificate request" \
1458 -C "skip parse certificate request" \
1459 -c "got a certificate request" \
1460 -C "skip write certificate$" \
1461 -c "skip write certificate verify" \
1462 -c "got no certificate to send" \
1463 -s "SSLv3 client has no certificate" \
1464 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001465 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001466 -S "! ssl_handshake returned" \
1467 -C "! ssl_handshake returned" \
1468 -S "X509 - Certificate verification failed"
1469
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001470# Tests for certificate selection based on SHA verson
1471
1472run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1473 "$P_SRV crt_file=data_files/server5.crt \
1474 key_file=data_files/server5.key \
1475 crt_file2=data_files/server5-sha1.crt \
1476 key_file2=data_files/server5.key" \
1477 "$P_CLI force_version=tls1_2" \
1478 0 \
1479 -c "signed using.*ECDSA with SHA256" \
1480 -C "signed using.*ECDSA with SHA1"
1481
1482run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1483 "$P_SRV crt_file=data_files/server5.crt \
1484 key_file=data_files/server5.key \
1485 crt_file2=data_files/server5-sha1.crt \
1486 key_file2=data_files/server5.key" \
1487 "$P_CLI force_version=tls1_1" \
1488 0 \
1489 -C "signed using.*ECDSA with SHA256" \
1490 -c "signed using.*ECDSA with SHA1"
1491
1492run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1493 "$P_SRV crt_file=data_files/server5.crt \
1494 key_file=data_files/server5.key \
1495 crt_file2=data_files/server5-sha1.crt \
1496 key_file2=data_files/server5.key" \
1497 "$P_CLI force_version=tls1" \
1498 0 \
1499 -C "signed using.*ECDSA with SHA256" \
1500 -c "signed using.*ECDSA with SHA1"
1501
1502run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1503 "$P_SRV crt_file=data_files/server5.crt \
1504 key_file=data_files/server5.key \
1505 crt_file2=data_files/server6.crt \
1506 key_file2=data_files/server6.key" \
1507 "$P_CLI force_version=tls1_1" \
1508 0 \
1509 -c "serial number.*09" \
1510 -c "signed using.*ECDSA with SHA256" \
1511 -C "signed using.*ECDSA with SHA1"
1512
1513run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1514 "$P_SRV crt_file=data_files/server6.crt \
1515 key_file=data_files/server6.key \
1516 crt_file2=data_files/server5.crt \
1517 key_file2=data_files/server5.key" \
1518 "$P_CLI force_version=tls1_1" \
1519 0 \
1520 -c "serial number.*0A" \
1521 -c "signed using.*ECDSA with SHA256" \
1522 -C "signed using.*ECDSA with SHA1"
1523
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001524# tests for SNI
1525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001526run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001527 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001528 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001529 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001530 server_name=localhost" \
1531 0 \
1532 -S "parse ServerName extension" \
1533 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1534 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1535
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001536run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001537 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001538 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001539 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 +01001540 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001541 server_name=localhost" \
1542 0 \
1543 -s "parse ServerName extension" \
1544 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1545 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001547run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001548 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001549 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001550 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 +01001551 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001552 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001553 0 \
1554 -s "parse ServerName extension" \
1555 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001556 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001558run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001559 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001560 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001561 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 +01001562 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001563 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001564 1 \
1565 -s "parse ServerName extension" \
1566 -s "ssl_sni_wrapper() returned" \
1567 -s "ssl_handshake returned" \
1568 -c "ssl_handshake returned" \
1569 -c "SSL - A fatal alert message was received from our peer"
1570
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001571# Tests for non-blocking I/O: exercise a variety of handshake flows
1572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001573run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001574 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1575 "$P_CLI nbio=2 tickets=0" \
1576 0 \
1577 -S "ssl_handshake returned" \
1578 -C "ssl_handshake returned" \
1579 -c "Read from server: .* bytes read"
1580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001581run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001582 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1583 "$P_CLI nbio=2 tickets=0" \
1584 0 \
1585 -S "ssl_handshake returned" \
1586 -C "ssl_handshake returned" \
1587 -c "Read from server: .* bytes read"
1588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001589run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001590 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1591 "$P_CLI nbio=2 tickets=1" \
1592 0 \
1593 -S "ssl_handshake returned" \
1594 -C "ssl_handshake returned" \
1595 -c "Read from server: .* bytes read"
1596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001597run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001598 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1599 "$P_CLI nbio=2 tickets=1" \
1600 0 \
1601 -S "ssl_handshake returned" \
1602 -C "ssl_handshake returned" \
1603 -c "Read from server: .* bytes read"
1604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001605run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001606 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1607 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1608 0 \
1609 -S "ssl_handshake returned" \
1610 -C "ssl_handshake returned" \
1611 -c "Read from server: .* bytes read"
1612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001613run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001614 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1615 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1616 0 \
1617 -S "ssl_handshake returned" \
1618 -C "ssl_handshake returned" \
1619 -c "Read from server: .* bytes read"
1620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001621run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001622 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1623 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1624 0 \
1625 -S "ssl_handshake returned" \
1626 -C "ssl_handshake returned" \
1627 -c "Read from server: .* bytes read"
1628
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001629# Tests for version negotiation
1630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001631run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001632 "$P_SRV" \
1633 "$P_CLI" \
1634 0 \
1635 -S "ssl_handshake returned" \
1636 -C "ssl_handshake returned" \
1637 -s "Protocol is TLSv1.2" \
1638 -c "Protocol is TLSv1.2"
1639
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001640run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001641 "$P_SRV" \
1642 "$P_CLI max_version=tls1_1" \
1643 0 \
1644 -S "ssl_handshake returned" \
1645 -C "ssl_handshake returned" \
1646 -s "Protocol is TLSv1.1" \
1647 -c "Protocol is TLSv1.1"
1648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001649run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001650 "$P_SRV max_version=tls1_1" \
1651 "$P_CLI" \
1652 0 \
1653 -S "ssl_handshake returned" \
1654 -C "ssl_handshake returned" \
1655 -s "Protocol is TLSv1.1" \
1656 -c "Protocol is TLSv1.1"
1657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001658run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001659 "$P_SRV max_version=tls1_1" \
1660 "$P_CLI max_version=tls1_1" \
1661 0 \
1662 -S "ssl_handshake returned" \
1663 -C "ssl_handshake returned" \
1664 -s "Protocol is TLSv1.1" \
1665 -c "Protocol is TLSv1.1"
1666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001667run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001668 "$P_SRV min_version=tls1_1" \
1669 "$P_CLI max_version=tls1_1" \
1670 0 \
1671 -S "ssl_handshake returned" \
1672 -C "ssl_handshake returned" \
1673 -s "Protocol is TLSv1.1" \
1674 -c "Protocol is TLSv1.1"
1675
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001676run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001677 "$P_SRV max_version=tls1_1" \
1678 "$P_CLI min_version=tls1_1" \
1679 0 \
1680 -S "ssl_handshake returned" \
1681 -C "ssl_handshake returned" \
1682 -s "Protocol is TLSv1.1" \
1683 -c "Protocol is TLSv1.1"
1684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001685run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001686 "$P_SRV max_version=tls1_1" \
1687 "$P_CLI min_version=tls1_2" \
1688 1 \
1689 -s "ssl_handshake returned" \
1690 -c "ssl_handshake returned" \
1691 -c "SSL - Handshake protocol not within min/max boundaries"
1692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001693run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001694 "$P_SRV min_version=tls1_2" \
1695 "$P_CLI max_version=tls1_1" \
1696 1 \
1697 -s "ssl_handshake returned" \
1698 -c "ssl_handshake returned" \
1699 -s "SSL - Handshake protocol not within min/max boundaries"
1700
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001701# Tests for ALPN extension
1702
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001703if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001705run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001706 "$P_SRV debug_level=3" \
1707 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001708 0 \
1709 -C "client hello, adding alpn extension" \
1710 -S "found alpn extension" \
1711 -C "got an alert message, type: \\[2:120]" \
1712 -S "server hello, adding alpn extension" \
1713 -C "found alpn extension " \
1714 -C "Application Layer Protocol is" \
1715 -S "Application Layer Protocol is"
1716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001717run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001718 "$P_SRV debug_level=3" \
1719 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001720 0 \
1721 -c "client hello, adding alpn extension" \
1722 -s "found alpn extension" \
1723 -C "got an alert message, type: \\[2:120]" \
1724 -S "server hello, adding alpn extension" \
1725 -C "found alpn extension " \
1726 -c "Application Layer Protocol is (none)" \
1727 -S "Application Layer Protocol is"
1728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001729run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001730 "$P_SRV debug_level=3 alpn=abc,1234" \
1731 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001732 0 \
1733 -C "client hello, adding alpn extension" \
1734 -S "found alpn extension" \
1735 -C "got an alert message, type: \\[2:120]" \
1736 -S "server hello, adding alpn extension" \
1737 -C "found alpn extension " \
1738 -C "Application Layer Protocol is" \
1739 -s "Application Layer Protocol is (none)"
1740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001741run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001742 "$P_SRV debug_level=3 alpn=abc,1234" \
1743 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001744 0 \
1745 -c "client hello, adding alpn extension" \
1746 -s "found alpn extension" \
1747 -C "got an alert message, type: \\[2:120]" \
1748 -s "server hello, adding alpn extension" \
1749 -c "found alpn extension" \
1750 -c "Application Layer Protocol is abc" \
1751 -s "Application Layer Protocol is abc"
1752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001753run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001754 "$P_SRV debug_level=3 alpn=abc,1234" \
1755 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001756 0 \
1757 -c "client hello, adding alpn extension" \
1758 -s "found alpn extension" \
1759 -C "got an alert message, type: \\[2:120]" \
1760 -s "server hello, adding alpn extension" \
1761 -c "found alpn extension" \
1762 -c "Application Layer Protocol is abc" \
1763 -s "Application Layer Protocol is abc"
1764
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001765run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001766 "$P_SRV debug_level=3 alpn=abc,1234" \
1767 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001768 0 \
1769 -c "client hello, adding alpn extension" \
1770 -s "found alpn extension" \
1771 -C "got an alert message, type: \\[2:120]" \
1772 -s "server hello, adding alpn extension" \
1773 -c "found alpn extension" \
1774 -c "Application Layer Protocol is 1234" \
1775 -s "Application Layer Protocol is 1234"
1776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001778 "$P_SRV debug_level=3 alpn=abc,123" \
1779 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001780 1 \
1781 -c "client hello, adding alpn extension" \
1782 -s "found alpn extension" \
1783 -c "got an alert message, type: \\[2:120]" \
1784 -S "server hello, adding alpn extension" \
1785 -C "found alpn extension" \
1786 -C "Application Layer Protocol is 1234" \
1787 -S "Application Layer Protocol is 1234"
1788
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001789fi
1790
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001791# Tests for keyUsage in leaf certificates, part 1:
1792# server-side certificate/suite selection
1793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001794run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001795 "$P_SRV key_file=data_files/server2.key \
1796 crt_file=data_files/server2.ku-ds.crt" \
1797 "$P_CLI" \
1798 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001799 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001800
1801
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001802run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001803 "$P_SRV key_file=data_files/server2.key \
1804 crt_file=data_files/server2.ku-ke.crt" \
1805 "$P_CLI" \
1806 0 \
1807 -c "Ciphersuite is TLS-RSA-WITH-"
1808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001809run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001810 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001811 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001812 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001813 1 \
1814 -C "Ciphersuite is "
1815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001816run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001817 "$P_SRV key_file=data_files/server5.key \
1818 crt_file=data_files/server5.ku-ds.crt" \
1819 "$P_CLI" \
1820 0 \
1821 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1822
1823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001824run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001825 "$P_SRV key_file=data_files/server5.key \
1826 crt_file=data_files/server5.ku-ka.crt" \
1827 "$P_CLI" \
1828 0 \
1829 -c "Ciphersuite is TLS-ECDH-"
1830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001831run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001832 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001833 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001834 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001835 1 \
1836 -C "Ciphersuite is "
1837
1838# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001839# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001841run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001842 "$O_SRV -key data_files/server2.key \
1843 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001844 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001845 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1846 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001847 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001848 -C "Processing of the Certificate handshake message failed" \
1849 -c "Ciphersuite is TLS-"
1850
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001851run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001852 "$O_SRV -key data_files/server2.key \
1853 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001854 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001855 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1856 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001857 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001858 -C "Processing of the Certificate handshake message failed" \
1859 -c "Ciphersuite is TLS-"
1860
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001861run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001862 "$O_SRV -key data_files/server2.key \
1863 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001864 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001865 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1866 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001867 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001868 -C "Processing of the Certificate handshake message failed" \
1869 -c "Ciphersuite is TLS-"
1870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001871run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001872 "$O_SRV -key data_files/server2.key \
1873 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001874 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001875 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1876 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001877 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001878 -c "Processing of the Certificate handshake message failed" \
1879 -C "Ciphersuite is TLS-"
1880
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001881run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001882 "$O_SRV -key data_files/server2.key \
1883 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001884 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001885 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1886 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001887 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001888 -C "Processing of the Certificate handshake message failed" \
1889 -c "Ciphersuite is TLS-"
1890
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001891run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001892 "$O_SRV -key data_files/server2.key \
1893 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001894 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001895 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1896 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001897 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001898 -c "Processing of the Certificate handshake message failed" \
1899 -C "Ciphersuite is TLS-"
1900
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001901# Tests for keyUsage in leaf certificates, part 3:
1902# server-side checking of client cert
1903
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001904run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001905 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001906 "$O_CLI -key data_files/server2.key \
1907 -cert data_files/server2.ku-ds.crt" \
1908 0 \
1909 -S "bad certificate (usage extensions)" \
1910 -S "Processing of the Certificate handshake message failed"
1911
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001912run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001913 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001914 "$O_CLI -key data_files/server2.key \
1915 -cert data_files/server2.ku-ke.crt" \
1916 0 \
1917 -s "bad certificate (usage extensions)" \
1918 -S "Processing of the Certificate handshake message failed"
1919
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001920run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001921 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001922 "$O_CLI -key data_files/server2.key \
1923 -cert data_files/server2.ku-ke.crt" \
1924 1 \
1925 -s "bad certificate (usage extensions)" \
1926 -s "Processing of the Certificate handshake message failed"
1927
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001928run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001929 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001930 "$O_CLI -key data_files/server5.key \
1931 -cert data_files/server5.ku-ds.crt" \
1932 0 \
1933 -S "bad certificate (usage extensions)" \
1934 -S "Processing of the Certificate handshake message failed"
1935
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001936run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001937 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001938 "$O_CLI -key data_files/server5.key \
1939 -cert data_files/server5.ku-ka.crt" \
1940 0 \
1941 -s "bad certificate (usage extensions)" \
1942 -S "Processing of the Certificate handshake message failed"
1943
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001944# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001946run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001947 "$P_SRV key_file=data_files/server5.key \
1948 crt_file=data_files/server5.eku-srv.crt" \
1949 "$P_CLI" \
1950 0
1951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001952run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001953 "$P_SRV key_file=data_files/server5.key \
1954 crt_file=data_files/server5.eku-srv.crt" \
1955 "$P_CLI" \
1956 0
1957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001958run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001959 "$P_SRV key_file=data_files/server5.key \
1960 crt_file=data_files/server5.eku-cs_any.crt" \
1961 "$P_CLI" \
1962 0
1963
1964# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001965run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001966 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1967 crt_file=data_files/server5.eku-cli.crt" \
1968 "$P_CLI psk=badbad" \
1969 1
1970
1971# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001973run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001974 "$O_SRV -key data_files/server5.key \
1975 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001976 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001977 0 \
1978 -C "bad certificate (usage extensions)" \
1979 -C "Processing of the Certificate handshake message failed" \
1980 -c "Ciphersuite is TLS-"
1981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001982run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001983 "$O_SRV -key data_files/server5.key \
1984 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001985 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001986 0 \
1987 -C "bad certificate (usage extensions)" \
1988 -C "Processing of the Certificate handshake message failed" \
1989 -c "Ciphersuite is TLS-"
1990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001991run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001992 "$O_SRV -key data_files/server5.key \
1993 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001994 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001995 0 \
1996 -C "bad certificate (usage extensions)" \
1997 -C "Processing of the Certificate handshake message failed" \
1998 -c "Ciphersuite is TLS-"
1999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002000run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002001 "$O_SRV -key data_files/server5.key \
2002 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002003 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002004 1 \
2005 -c "bad certificate (usage extensions)" \
2006 -c "Processing of the Certificate handshake message failed" \
2007 -C "Ciphersuite is TLS-"
2008
2009# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002011run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002012 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002013 "$O_CLI -key data_files/server5.key \
2014 -cert data_files/server5.eku-cli.crt" \
2015 0 \
2016 -S "bad certificate (usage extensions)" \
2017 -S "Processing of the Certificate handshake message failed"
2018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002019run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002020 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002021 "$O_CLI -key data_files/server5.key \
2022 -cert data_files/server5.eku-srv_cli.crt" \
2023 0 \
2024 -S "bad certificate (usage extensions)" \
2025 -S "Processing of the Certificate handshake message failed"
2026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002027run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002028 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002029 "$O_CLI -key data_files/server5.key \
2030 -cert data_files/server5.eku-cs_any.crt" \
2031 0 \
2032 -S "bad certificate (usage extensions)" \
2033 -S "Processing of the Certificate handshake message failed"
2034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002035run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002036 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002037 "$O_CLI -key data_files/server5.key \
2038 -cert data_files/server5.eku-cs.crt" \
2039 0 \
2040 -s "bad certificate (usage extensions)" \
2041 -S "Processing of the Certificate handshake message failed"
2042
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002043run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002044 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002045 "$O_CLI -key data_files/server5.key \
2046 -cert data_files/server5.eku-cs.crt" \
2047 1 \
2048 -s "bad certificate (usage extensions)" \
2049 -s "Processing of the Certificate handshake message failed"
2050
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002051# Tests for DHM parameters loading
2052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002053run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002054 "$P_SRV" \
2055 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2056 debug_level=3" \
2057 0 \
2058 -c "value of 'DHM: P ' (2048 bits)" \
2059 -c "value of 'DHM: G ' (2048 bits)"
2060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002061run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002062 "$P_SRV dhm_file=data_files/dhparams.pem" \
2063 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2064 debug_level=3" \
2065 0 \
2066 -c "value of 'DHM: P ' (1024 bits)" \
2067 -c "value of 'DHM: G ' (2 bits)"
2068
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002069# Tests for PSK callback
2070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002071run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002072 "$P_SRV psk=abc123 psk_identity=foo" \
2073 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2074 psk_identity=foo psk=abc123" \
2075 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002076 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002077 -S "SSL - Unknown identity received" \
2078 -S "SSL - Verification of the message MAC failed"
2079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002080run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002081 "$P_SRV" \
2082 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2083 psk_identity=foo psk=abc123" \
2084 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002085 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002086 -S "SSL - Unknown identity received" \
2087 -S "SSL - Verification of the message MAC failed"
2088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002089run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002090 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2091 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2092 psk_identity=foo psk=abc123" \
2093 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002094 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002095 -s "SSL - Unknown identity received" \
2096 -S "SSL - Verification of the message MAC failed"
2097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002098run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002099 "$P_SRV psk_list=abc,dead,def,beef" \
2100 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2101 psk_identity=abc psk=dead" \
2102 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002103 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002104 -S "SSL - Unknown identity received" \
2105 -S "SSL - Verification of the message MAC failed"
2106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002107run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002108 "$P_SRV psk_list=abc,dead,def,beef" \
2109 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2110 psk_identity=def psk=beef" \
2111 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002112 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002113 -S "SSL - Unknown identity received" \
2114 -S "SSL - Verification of the message MAC failed"
2115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002116run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002117 "$P_SRV psk_list=abc,dead,def,beef" \
2118 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2119 psk_identity=ghi psk=beef" \
2120 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002121 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002122 -s "SSL - Unknown identity received" \
2123 -S "SSL - Verification of the message MAC failed"
2124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002125run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002126 "$P_SRV psk_list=abc,dead,def,beef" \
2127 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2128 psk_identity=abc psk=beef" \
2129 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002130 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002131 -S "SSL - Unknown identity received" \
2132 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002133
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002134# Tests for ciphersuites per version
2135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002136run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002137 "$P_SRV min_version=ssl3 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" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002138 "$P_CLI force_version=ssl3" \
2139 0 \
2140 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002142run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002143 "$P_SRV arc4=1 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" \
2144 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002145 0 \
2146 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2147
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002148run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002149 "$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" \
2150 "$P_CLI force_version=tls1_1" \
2151 0 \
2152 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002154run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002155 "$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" \
2156 "$P_CLI force_version=tls1_2" \
2157 0 \
2158 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2159
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002160# Tests for ssl_get_bytes_avail()
2161
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002162run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002163 "$P_SRV" \
2164 "$P_CLI request_size=100" \
2165 0 \
2166 -s "Read from client: 100 bytes read$"
2167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002168run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002169 "$P_SRV" \
2170 "$P_CLI request_size=500" \
2171 0 \
2172 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002173
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002174# Tests for small packets
2175
2176run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002177 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002178 "$P_CLI request_size=1 force_version=ssl3 \
2179 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2180 0 \
2181 -s "Read from client: 1 bytes read"
2182
2183run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002184 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002185 "$P_CLI request_size=1 force_version=ssl3 \
2186 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2187 0 \
2188 -s "Read from client: 1 bytes read"
2189
2190run_test "Small packet TLS 1.0 BlockCipher" \
2191 "$P_SRV" \
2192 "$P_CLI request_size=1 force_version=tls1 \
2193 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2194 0 \
2195 -s "Read from client: 1 bytes read"
2196
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002197run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2198 "$P_SRV" \
2199 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2200 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2201 0 \
2202 -s "Read from client: 1 bytes read"
2203
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002204run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2205 "$P_SRV" \
2206 "$P_CLI request_size=1 force_version=tls1 \
2207 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2208 trunc_hmac=1" \
2209 0 \
2210 -s "Read from client: 1 bytes read"
2211
2212run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002213 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002214 "$P_CLI request_size=1 force_version=tls1 \
2215 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2216 trunc_hmac=1" \
2217 0 \
2218 -s "Read from client: 1 bytes read"
2219
2220run_test "Small packet TLS 1.1 BlockCipher" \
2221 "$P_SRV" \
2222 "$P_CLI request_size=1 force_version=tls1_1 \
2223 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2224 0 \
2225 -s "Read from client: 1 bytes read"
2226
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002227run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2228 "$P_SRV" \
2229 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2230 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2231 0 \
2232 -s "Read from client: 1 bytes read"
2233
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002234run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002235 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002236 "$P_CLI request_size=1 force_version=tls1_1 \
2237 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2238 0 \
2239 -s "Read from client: 1 bytes read"
2240
2241run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2242 "$P_SRV" \
2243 "$P_CLI request_size=1 force_version=tls1_1 \
2244 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2245 trunc_hmac=1" \
2246 0 \
2247 -s "Read from client: 1 bytes read"
2248
2249run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002250 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002251 "$P_CLI request_size=1 force_version=tls1_1 \
2252 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2253 trunc_hmac=1" \
2254 0 \
2255 -s "Read from client: 1 bytes read"
2256
2257run_test "Small packet TLS 1.2 BlockCipher" \
2258 "$P_SRV" \
2259 "$P_CLI request_size=1 force_version=tls1_2 \
2260 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2261 0 \
2262 -s "Read from client: 1 bytes read"
2263
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002264run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2265 "$P_SRV" \
2266 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2267 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2268 0 \
2269 -s "Read from client: 1 bytes read"
2270
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002271run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2272 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002273 "$P_CLI request_size=1 force_version=tls1_2 \
2274 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002275 0 \
2276 -s "Read from client: 1 bytes read"
2277
2278run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2279 "$P_SRV" \
2280 "$P_CLI request_size=1 force_version=tls1_2 \
2281 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2282 trunc_hmac=1" \
2283 0 \
2284 -s "Read from client: 1 bytes read"
2285
2286run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002287 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002288 "$P_CLI request_size=1 force_version=tls1_2 \
2289 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2290 0 \
2291 -s "Read from client: 1 bytes read"
2292
2293run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002294 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002295 "$P_CLI request_size=1 force_version=tls1_2 \
2296 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2297 trunc_hmac=1" \
2298 0 \
2299 -s "Read from client: 1 bytes read"
2300
2301run_test "Small packet TLS 1.2 AEAD" \
2302 "$P_SRV" \
2303 "$P_CLI request_size=1 force_version=tls1_2 \
2304 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2305 0 \
2306 -s "Read from client: 1 bytes read"
2307
2308run_test "Small packet TLS 1.2 AEAD shorter tag" \
2309 "$P_SRV" \
2310 "$P_CLI request_size=1 force_version=tls1_2 \
2311 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2312 0 \
2313 -s "Read from client: 1 bytes read"
2314
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002315# Test for large packets
2316
2317run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002318 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002319 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002320 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2321 0 \
2322 -s "Read from client: 16384 bytes read"
2323
2324run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002325 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002326 "$P_CLI request_size=16384 force_version=ssl3 \
2327 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2328 0 \
2329 -s "Read from client: 16384 bytes read"
2330
2331run_test "Large packet TLS 1.0 BlockCipher" \
2332 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002333 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002334 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2335 0 \
2336 -s "Read from client: 16384 bytes read"
2337
2338run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2339 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002340 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002341 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2342 trunc_hmac=1" \
2343 0 \
2344 -s "Read from client: 16384 bytes read"
2345
2346run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002347 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002348 "$P_CLI request_size=16384 force_version=tls1 \
2349 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2350 trunc_hmac=1" \
2351 0 \
2352 -s "Read from client: 16384 bytes read"
2353
2354run_test "Large packet TLS 1.1 BlockCipher" \
2355 "$P_SRV" \
2356 "$P_CLI request_size=16384 force_version=tls1_1 \
2357 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2358 0 \
2359 -s "Read from client: 16384 bytes read"
2360
2361run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002362 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002363 "$P_CLI request_size=16384 force_version=tls1_1 \
2364 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2365 0 \
2366 -s "Read from client: 16384 bytes read"
2367
2368run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2369 "$P_SRV" \
2370 "$P_CLI request_size=16384 force_version=tls1_1 \
2371 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2372 trunc_hmac=1" \
2373 0 \
2374 -s "Read from client: 16384 bytes read"
2375
2376run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002377 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002378 "$P_CLI request_size=16384 force_version=tls1_1 \
2379 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2380 trunc_hmac=1" \
2381 0 \
2382 -s "Read from client: 16384 bytes read"
2383
2384run_test "Large packet TLS 1.2 BlockCipher" \
2385 "$P_SRV" \
2386 "$P_CLI request_size=16384 force_version=tls1_2 \
2387 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2388 0 \
2389 -s "Read from client: 16384 bytes read"
2390
2391run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2392 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002393 "$P_CLI request_size=16384 force_version=tls1_2 \
2394 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002395 0 \
2396 -s "Read from client: 16384 bytes read"
2397
2398run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2399 "$P_SRV" \
2400 "$P_CLI request_size=16384 force_version=tls1_2 \
2401 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2402 trunc_hmac=1" \
2403 0 \
2404 -s "Read from client: 16384 bytes read"
2405
2406run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002407 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002408 "$P_CLI request_size=16384 force_version=tls1_2 \
2409 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2410 0 \
2411 -s "Read from client: 16384 bytes read"
2412
2413run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002414 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002415 "$P_CLI request_size=16384 force_version=tls1_2 \
2416 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2417 trunc_hmac=1" \
2418 0 \
2419 -s "Read from client: 16384 bytes read"
2420
2421run_test "Large packet TLS 1.2 AEAD" \
2422 "$P_SRV" \
2423 "$P_CLI request_size=16384 force_version=tls1_2 \
2424 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2425 0 \
2426 -s "Read from client: 16384 bytes read"
2427
2428run_test "Large packet TLS 1.2 AEAD shorter tag" \
2429 "$P_SRV" \
2430 "$P_CLI request_size=16384 force_version=tls1_2 \
2431 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2432 0 \
2433 -s "Read from client: 16384 bytes read"
2434
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002435# Final report
2436
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002437echo "------------------------------------------------------------------------"
2438
2439if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002440 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002441else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002442 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002443fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002444PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002445echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002446
2447exit $FAILS