blob: e2efae91c7b709317897124dfc8f10f8d29ac7d3 [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é-Gonnard6461f362015-06-29 16:20:13 +020020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010021O_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() {
Manuel Pégourié-Gonnard84690c32015-08-04 20:34:39 +0200160 if which lsof >/dev/null 2>&1; then
161 START_TIME=$( date +%s )
162 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200163
164 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard84690c32015-08-04 20:34:39 +0200165 while [ $DONE -eq 0 ]; do
166 if lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null
167 then
168 DONE=1
169 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
170 echo "SERVERSTART TIMEOUT"
171 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
172 DONE=1
173 fi
174 done
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200175 else
176 sleep "$START_DELAY"
177 fi
178}
179
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200180# wait for client to terminate and set CLI_EXIT
181# must be called right after starting the client
182wait_client_done() {
183 CLI_PID=$!
184
185 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
186 WATCHDOG_PID=$!
187
188 wait $CLI_PID
189 CLI_EXIT=$?
190
191 kill $WATCHDOG_PID
192 wait $WATCHDOG_PID
193
194 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
195}
196
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100197# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100198# Options: -s pattern pattern that must be present in server output
199# -c pattern pattern that must be present in client output
200# -S pattern pattern that must be absent in server output
201# -C pattern pattern that must be absent in client output
202run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100203 NAME="$1"
204 SRV_CMD="$2"
205 CLI_CMD="$3"
206 CLI_EXPECT="$4"
207 shift 4
208
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100209 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
210 else
211 return
212 fi
213
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100214 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100215
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200216 # should we skip?
217 if [ "X$SKIP_NEXT" = "XYES" ]; then
218 SKIP_NEXT="NO"
219 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200220 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200221 return
222 fi
223
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100224 # prepend valgrind to our commands if active
225 if [ "$MEMCHECK" -gt 0 ]; then
226 if is_polar "$SRV_CMD"; then
227 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
228 fi
229 if is_polar "$CLI_CMD"; then
230 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
231 fi
232 fi
233
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100234 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200235 echo "$SRV_CMD" > $SRV_OUT
236 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100237 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200238 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200239
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200240 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200241 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
242 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100243
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200244 # kill the server
245 kill $SRV_PID
246 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100247
248 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200249 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100250 # expected client exit to incorrectly succeed in case of catastrophic
251 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100252 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200253 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100254 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100255 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100256 return
257 fi
258 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100259 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200260 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100261 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100262 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100263 return
264 fi
265 fi
266
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100267 # check server exit code
268 if [ $? != 0 ]; then
269 fail "server fail"
270 return
271 fi
272
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100273 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100274 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
275 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100276 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100277 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100278 return
279 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100280
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100281 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200282 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100283 while [ $# -gt 0 ]
284 do
285 case $1 in
286 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200287 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100288 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100289 return
290 fi
291 ;;
292
293 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200294 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100295 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100296 return
297 fi
298 ;;
299
300 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200301 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100302 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100303 return
304 fi
305 ;;
306
307 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200308 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100309 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100310 return
311 fi
312 ;;
313
314 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200315 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100316 exit 1
317 esac
318 shift 2
319 done
320
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100321 # check valgrind's results
322 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200323 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100324 fail "Server has memory errors"
325 return
326 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200327 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100328 fail "Client has memory errors"
329 return
330 fi
331 fi
332
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100333 # if we're here, everything is ok
334 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200335 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100336}
337
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100338cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200339 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200340 kill $SRV_PID >/dev/null 2>&1
341 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100342 exit 1
343}
344
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100345#
346# MAIN
347#
348
Manuel Pégourié-Gonnard751286b2015-03-10 13:41:04 +0000349if cd $( dirname $0 ); then :; else
350 echo "cd $( dirname $0 ) failed" >&2
351 exit 1
352fi
353
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100354get_options "$@"
355
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100356# sanity checks, avoid an avalanche of errors
357if [ ! -x "$P_SRV" ]; then
358 echo "Command '$P_SRV' is not an executable file"
359 exit 1
360fi
361if [ ! -x "$P_CLI" ]; then
362 echo "Command '$P_CLI' is not an executable file"
363 exit 1
364fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100365if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
366 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100367 exit 1
368fi
369
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200370# used by watchdog
371MAIN_PID="$$"
372
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200373# be more patient with valgrind
374if [ "$MEMCHECK" -gt 0 ]; then
375 START_DELAY=3
376 DOG_DELAY=30
377else
378 START_DELAY=1
379 DOG_DELAY=10
380fi
381
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200382# Pick a "unique" port in the range 10000-19999.
383PORT="0000$$"
Manuel Pégourié-Gonnarddc370e42015-01-22 10:24:59 +0000384PORT="1$( printf $PORT | tail -c 4 )"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200385
386# fix commands to use this port
387P_SRV="$P_SRV server_port=$PORT"
388P_CLI="$P_CLI server_port=$PORT"
389O_SRV="$O_SRV -accept $PORT"
390O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200391G_SRV="$G_SRV -p $PORT"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100392G_CLI="$G_CLI -p $PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200393
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200394# Also pick a unique name for intermediate files
395SRV_OUT="srv_out.$$"
396CLI_OUT="cli_out.$$"
397SESSION="session.$$"
398
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200399SKIP_NEXT="NO"
400
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100401trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100402
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200403# Basic test
404
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200405# Checks that:
406# - things work with all ciphersuites active (used with config-full in all.sh)
407# - the expected (highest security) parameters are selected
408# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200409run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200410 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200411 "$P_CLI" \
412 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200413 -s "Protocol is TLSv1.2" \
414 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
415 -s "client hello v3, signature_algorithm ext: 6" \
416 -s "ECDHE curve: secp521r1" \
417 -S "error" \
418 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200419
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100420# Tests for rc4 option
421
422run_test "RC4: server disabled, client enabled" \
423 "$P_SRV" \
424 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
425 1 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100426 -s "SSL - None of the common ciphersuites is usable"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100427
428run_test "RC4: server enabled, client disabled" \
429 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
430 "$P_CLI" \
431 1 \
432 -s "SSL - The server has no ciphersuites in common"
433
434run_test "RC4: both enabled" \
435 "$P_SRV arc4=1" \
436 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
437 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100438 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100439 -S "SSL - The server has no ciphersuites in common"
440
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100441# Test for SSLv2 ClientHello
442
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200443requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200444run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100445 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100446 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100447 0 \
448 -S "parse client hello v2" \
449 -S "ssl_handshake returned"
450
451# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200452requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200453run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200454 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100455 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100456 0 \
457 -s "parse client hello v2" \
458 -S "ssl_handshake returned"
459
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100460# Tests for Truncated HMAC extension
461
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100462run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200463 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100464 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100465 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100466 -s "dumping 'computed mac' (20 bytes)" \
467 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100468
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100469run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200470 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100471 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
472 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100473 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100474 -s "dumping 'computed mac' (20 bytes)" \
475 -S "dumping 'computed mac' (10 bytes)"
476
477run_test "Truncated HMAC: client enabled, server default" \
478 "$P_SRV debug_level=4" \
479 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
480 trunc_hmac=1" \
481 0 \
482 -S "dumping 'computed mac' (20 bytes)" \
483 -s "dumping 'computed mac' (10 bytes)"
484
485run_test "Truncated HMAC: client enabled, server disabled" \
486 "$P_SRV debug_level=4 trunc_hmac=0" \
487 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
488 trunc_hmac=1" \
489 0 \
490 -s "dumping 'computed mac' (20 bytes)" \
491 -S "dumping 'computed mac' (10 bytes)"
492
493run_test "Truncated HMAC: client enabled, server enabled" \
494 "$P_SRV debug_level=4 trunc_hmac=1" \
495 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
496 trunc_hmac=1" \
497 0 \
498 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100499 -s "dumping 'computed mac' (10 bytes)"
500
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100501# Tests for Encrypt-then-MAC extension
502
503run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100504 "$P_SRV debug_level=3 \
505 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100506 "$P_CLI debug_level=3" \
507 0 \
508 -c "client hello, adding encrypt_then_mac extension" \
509 -s "found encrypt then mac extension" \
510 -s "server hello, adding encrypt then mac extension" \
511 -c "found encrypt_then_mac extension" \
512 -c "using encrypt then mac" \
513 -s "using encrypt then mac"
514
515run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100516 "$P_SRV debug_level=3 etm=0 \
517 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100518 "$P_CLI debug_level=3 etm=1" \
519 0 \
520 -c "client hello, adding encrypt_then_mac extension" \
521 -s "found encrypt then mac extension" \
522 -S "server hello, adding encrypt then mac extension" \
523 -C "found encrypt_then_mac extension" \
524 -C "using encrypt then mac" \
525 -S "using encrypt then mac"
526
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100527run_test "Encrypt then MAC: client enabled, aead cipher" \
528 "$P_SRV debug_level=3 etm=1 \
529 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
530 "$P_CLI debug_level=3 etm=1" \
531 0 \
532 -c "client hello, adding encrypt_then_mac extension" \
533 -s "found encrypt then mac extension" \
534 -S "server hello, adding encrypt then mac extension" \
535 -C "found encrypt_then_mac extension" \
536 -C "using encrypt then mac" \
537 -S "using encrypt then mac"
538
539run_test "Encrypt then MAC: client enabled, stream cipher" \
540 "$P_SRV debug_level=3 etm=1 \
541 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100542 "$P_CLI debug_level=3 etm=1 arc4=1" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100543 0 \
544 -c "client hello, adding encrypt_then_mac extension" \
545 -s "found encrypt then mac extension" \
546 -S "server hello, adding encrypt then mac extension" \
547 -C "found encrypt_then_mac extension" \
548 -C "using encrypt then mac" \
549 -S "using encrypt then mac"
550
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100551run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100552 "$P_SRV debug_level=3 etm=1 \
553 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100554 "$P_CLI debug_level=3 etm=0" \
555 0 \
556 -C "client hello, adding encrypt_then_mac extension" \
557 -S "found encrypt then mac extension" \
558 -S "server hello, adding encrypt then mac extension" \
559 -C "found encrypt_then_mac extension" \
560 -C "using encrypt then mac" \
561 -S "using encrypt then mac"
562
563run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100564 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100565 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100566 "$P_CLI debug_level=3 force_version=ssl3" \
567 0 \
568 -C "client hello, adding encrypt_then_mac extension" \
569 -S "found encrypt then mac extension" \
570 -S "server hello, adding encrypt then mac extension" \
571 -C "found encrypt_then_mac extension" \
572 -C "using encrypt then mac" \
573 -S "using encrypt then mac"
574
575run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100576 "$P_SRV debug_level=3 force_version=ssl3 \
577 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100578 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100579 0 \
580 -c "client hello, adding encrypt_then_mac extension" \
581 -s "found encrypt then mac extension" \
582 -S "server hello, adding encrypt then mac extension" \
583 -C "found encrypt_then_mac extension" \
584 -C "using encrypt then mac" \
585 -S "using encrypt then mac"
586
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200587# Tests for Extended Master Secret extension
588
589run_test "Extended Master Secret: default" \
590 "$P_SRV debug_level=3" \
591 "$P_CLI debug_level=3" \
592 0 \
593 -c "client hello, adding extended_master_secret extension" \
594 -s "found extended master secret extension" \
595 -s "server hello, adding extended master secret extension" \
596 -c "found extended_master_secret extension" \
597 -c "using extended master secret" \
598 -s "using extended master secret"
599
600run_test "Extended Master Secret: client enabled, server disabled" \
601 "$P_SRV debug_level=3 extended_ms=0" \
602 "$P_CLI debug_level=3 extended_ms=1" \
603 0 \
604 -c "client hello, adding extended_master_secret extension" \
605 -s "found extended master secret extension" \
606 -S "server hello, adding extended master secret extension" \
607 -C "found extended_master_secret extension" \
608 -C "using extended master secret" \
609 -S "using extended master secret"
610
611run_test "Extended Master Secret: client disabled, server enabled" \
612 "$P_SRV debug_level=3 extended_ms=1" \
613 "$P_CLI debug_level=3 extended_ms=0" \
614 0 \
615 -C "client hello, adding extended_master_secret extension" \
616 -S "found extended master secret extension" \
617 -S "server hello, adding extended master secret extension" \
618 -C "found extended_master_secret extension" \
619 -C "using extended master secret" \
620 -S "using extended master secret"
621
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200622run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100623 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200624 "$P_CLI debug_level=3 force_version=ssl3" \
625 0 \
626 -C "client hello, adding extended_master_secret extension" \
627 -S "found extended master secret extension" \
628 -S "server hello, adding extended master secret extension" \
629 -C "found extended_master_secret extension" \
630 -C "using extended master secret" \
631 -S "using extended master secret"
632
633run_test "Extended Master Secret: client enabled, server SSLv3" \
634 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100635 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200636 0 \
637 -c "client hello, adding extended_master_secret extension" \
638 -s "found extended master secret extension" \
639 -S "server hello, adding extended master secret extension" \
640 -C "found extended_master_secret extension" \
641 -C "using extended master secret" \
642 -S "using extended master secret"
643
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200644# Tests for FALLBACK_SCSV
645
646run_test "Fallback SCSV: default" \
647 "$P_SRV" \
648 "$P_CLI debug_level=3 force_version=tls1_1" \
649 0 \
650 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200651 -S "received FALLBACK_SCSV" \
652 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200653 -C "is a fatal alert message (msg 86)"
654
655run_test "Fallback SCSV: explicitly disabled" \
656 "$P_SRV" \
657 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
658 0 \
659 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200660 -S "received FALLBACK_SCSV" \
661 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200662 -C "is a fatal alert message (msg 86)"
663
664run_test "Fallback SCSV: enabled" \
665 "$P_SRV" \
666 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200667 1 \
668 -c "adding FALLBACK_SCSV" \
669 -s "received FALLBACK_SCSV" \
670 -s "inapropriate fallback" \
671 -c "is a fatal alert message (msg 86)"
672
673run_test "Fallback SCSV: enabled, max version" \
674 "$P_SRV" \
675 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200676 0 \
677 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200678 -s "received FALLBACK_SCSV" \
679 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200680 -C "is a fatal alert message (msg 86)"
681
682requires_openssl_with_fallback_scsv
683run_test "Fallback SCSV: default, openssl server" \
684 "$O_SRV" \
685 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
686 0 \
687 -C "adding FALLBACK_SCSV" \
688 -C "is a fatal alert message (msg 86)"
689
690requires_openssl_with_fallback_scsv
691run_test "Fallback SCSV: enabled, openssl server" \
692 "$O_SRV" \
693 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
694 1 \
695 -c "adding FALLBACK_SCSV" \
696 -c "is a fatal alert message (msg 86)"
697
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200698requires_openssl_with_fallback_scsv
699run_test "Fallback SCSV: disabled, openssl client" \
700 "$P_SRV" \
701 "$O_CLI -tls1_1" \
702 0 \
703 -S "received FALLBACK_SCSV" \
704 -S "inapropriate fallback"
705
706requires_openssl_with_fallback_scsv
707run_test "Fallback SCSV: enabled, openssl client" \
708 "$P_SRV" \
709 "$O_CLI -tls1_1 -fallback_scsv" \
710 1 \
711 -s "received FALLBACK_SCSV" \
712 -s "inapropriate fallback"
713
714requires_openssl_with_fallback_scsv
715run_test "Fallback SCSV: enabled, max version, openssl client" \
716 "$P_SRV" \
717 "$O_CLI -fallback_scsv" \
718 0 \
719 -s "received FALLBACK_SCSV" \
720 -S "inapropriate fallback"
721
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100722# Tests for CBC 1/n-1 record splitting
723
724run_test "CBC Record splitting: TLS 1.2, no splitting" \
725 "$P_SRV" \
726 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
727 request_size=123 force_version=tls1_2" \
728 0 \
729 -s "Read from client: 123 bytes read" \
730 -S "Read from client: 1 bytes read" \
731 -S "122 bytes read"
732
733run_test "CBC Record splitting: TLS 1.1, no splitting" \
734 "$P_SRV" \
735 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
736 request_size=123 force_version=tls1_1" \
737 0 \
738 -s "Read from client: 123 bytes read" \
739 -S "Read from client: 1 bytes read" \
740 -S "122 bytes read"
741
742run_test "CBC Record splitting: TLS 1.0, splitting" \
743 "$P_SRV" \
744 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
745 request_size=123 force_version=tls1" \
746 0 \
747 -S "Read from client: 123 bytes read" \
748 -s "Read from client: 1 bytes read" \
749 -s "122 bytes read"
750
751run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100752 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100753 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
754 request_size=123 force_version=ssl3" \
755 0 \
756 -S "Read from client: 123 bytes read" \
757 -s "Read from client: 1 bytes read" \
758 -s "122 bytes read"
759
760run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100761 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100762 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
763 request_size=123 force_version=tls1" \
764 0 \
765 -s "Read from client: 123 bytes read" \
766 -S "Read from client: 1 bytes read" \
767 -S "122 bytes read"
768
769run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
770 "$P_SRV" \
771 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
772 request_size=123 force_version=tls1 recsplit=0" \
773 0 \
774 -s "Read from client: 123 bytes read" \
775 -S "Read from client: 1 bytes read" \
776 -S "122 bytes read"
777
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100778run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
779 "$P_SRV nbio=2" \
780 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
781 request_size=123 force_version=tls1" \
782 0 \
783 -S "Read from client: 123 bytes read" \
784 -s "Read from client: 1 bytes read" \
785 -s "122 bytes read"
786
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100787# Tests for Session Tickets
788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200789run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200790 "$P_SRV debug_level=3 tickets=1" \
791 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100792 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100793 -c "client hello, adding session ticket extension" \
794 -s "found session ticket extension" \
795 -s "server hello, adding session ticket extension" \
796 -c "found session_ticket extension" \
797 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100798 -S "session successfully restored from cache" \
799 -s "session successfully restored from ticket" \
800 -s "a session has been resumed" \
801 -c "a session has been resumed"
802
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200803run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200804 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
805 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100806 0 \
807 -c "client hello, adding session ticket extension" \
808 -s "found session ticket extension" \
809 -s "server hello, adding session ticket extension" \
810 -c "found session_ticket extension" \
811 -c "parse new session ticket" \
812 -S "session successfully restored from cache" \
813 -s "session successfully restored from ticket" \
814 -s "a session has been resumed" \
815 -c "a session has been resumed"
816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200817run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200818 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
819 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100820 0 \
821 -c "client hello, adding session ticket extension" \
822 -s "found session ticket extension" \
823 -s "server hello, adding session ticket extension" \
824 -c "found session_ticket extension" \
825 -c "parse new session ticket" \
826 -S "session successfully restored from cache" \
827 -S "session successfully restored from ticket" \
828 -S "a session has been resumed" \
829 -C "a session has been resumed"
830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200831run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100832 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200833 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100834 0 \
835 -c "client hello, adding session ticket extension" \
836 -c "found session_ticket extension" \
837 -c "parse new session ticket" \
838 -c "a session has been resumed"
839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200840run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200841 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200842 "( $O_CLI -sess_out $SESSION; \
843 $O_CLI -sess_in $SESSION; \
844 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100845 0 \
846 -s "found session ticket extension" \
847 -s "server hello, adding session ticket extension" \
848 -S "session successfully restored from cache" \
849 -s "session successfully restored from ticket" \
850 -s "a session has been resumed"
851
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100852# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200854run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200855 "$P_SRV debug_level=3 tickets=0" \
856 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100857 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100858 -c "client hello, adding session ticket extension" \
859 -s "found session ticket extension" \
860 -S "server hello, adding session ticket extension" \
861 -C "found session_ticket extension" \
862 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100863 -s "session successfully restored from cache" \
864 -S "session successfully restored from ticket" \
865 -s "a session has been resumed" \
866 -c "a session has been resumed"
867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200868run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200869 "$P_SRV debug_level=3 tickets=1" \
870 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100871 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100872 -C "client hello, adding session ticket extension" \
873 -S "found session ticket extension" \
874 -S "server hello, adding session ticket extension" \
875 -C "found session_ticket extension" \
876 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100877 -s "session successfully restored from cache" \
878 -S "session successfully restored from ticket" \
879 -s "a session has been resumed" \
880 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200882run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200883 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
884 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100885 0 \
886 -S "session successfully restored from cache" \
887 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100888 -S "a session has been resumed" \
889 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100890
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200891run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200892 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
893 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100894 0 \
895 -s "session successfully restored from cache" \
896 -S "session successfully restored from ticket" \
897 -s "a session has been resumed" \
898 -c "a session has been resumed"
899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200900run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200901 "$P_SRV debug_level=3 tickets=0" \
902 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100903 0 \
904 -s "session successfully restored from cache" \
905 -S "session successfully restored from ticket" \
906 -s "a session has been resumed" \
907 -c "a session has been resumed"
908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200909run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200910 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
911 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100912 0 \
913 -S "session successfully restored from cache" \
914 -S "session successfully restored from ticket" \
915 -S "a session has been resumed" \
916 -C "a session has been resumed"
917
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200918run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200919 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
920 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100921 0 \
922 -s "session successfully restored from cache" \
923 -S "session successfully restored from ticket" \
924 -s "a session has been resumed" \
925 -c "a session has been resumed"
926
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200927run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200928 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200929 "( $O_CLI -sess_out $SESSION; \
930 $O_CLI -sess_in $SESSION; \
931 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100932 0 \
933 -s "found session ticket extension" \
934 -S "server hello, adding session ticket extension" \
935 -s "session successfully restored from cache" \
936 -S "session successfully restored from ticket" \
937 -s "a session has been resumed"
938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200939run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100940 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200941 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100942 0 \
943 -C "found session_ticket extension" \
944 -C "parse new session ticket" \
945 -c "a session has been resumed"
946
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100947# Tests for Max Fragment Length extension
948
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200949run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200950 "$P_SRV debug_level=3" \
951 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100952 0 \
953 -C "client hello, adding max_fragment_length extension" \
954 -S "found max fragment length extension" \
955 -S "server hello, max_fragment_length extension" \
956 -C "found max_fragment_length extension"
957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200958run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200959 "$P_SRV debug_level=3" \
960 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100961 0 \
962 -c "client hello, adding max_fragment_length extension" \
963 -s "found max fragment length extension" \
964 -s "server hello, max_fragment_length extension" \
965 -c "found max_fragment_length extension"
966
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200967run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200968 "$P_SRV debug_level=3 max_frag_len=4096" \
969 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100970 0 \
971 -C "client hello, adding max_fragment_length extension" \
972 -S "found max fragment length extension" \
973 -S "server hello, max_fragment_length extension" \
974 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100975
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200976requires_gnutls
977run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200978 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200979 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200980 0 \
981 -c "client hello, adding max_fragment_length extension" \
982 -c "found max_fragment_length extension"
983
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100984# Tests for renegotiation
985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200986run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200987 "$P_SRV debug_level=3 exchanges=2" \
988 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100989 0 \
990 -C "client hello, adding renegotiation extension" \
991 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
992 -S "found renegotiation extension" \
993 -s "server hello, secure renegotiation extension" \
994 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100995 -C "=> renegotiate" \
996 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100997 -S "write hello request"
998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200999run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001000 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
1001 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001002 0 \
1003 -c "client hello, adding renegotiation extension" \
1004 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1005 -s "found renegotiation extension" \
1006 -s "server hello, secure renegotiation extension" \
1007 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001008 -c "=> renegotiate" \
1009 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001010 -S "write hello request"
1011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001012run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001013 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1014 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001015 0 \
1016 -c "client hello, adding renegotiation extension" \
1017 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1018 -s "found renegotiation extension" \
1019 -s "server hello, secure renegotiation extension" \
1020 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001021 -c "=> renegotiate" \
1022 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001023 -s "write hello request"
1024
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001025run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001026 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1027 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001028 0 \
1029 -c "client hello, adding renegotiation extension" \
1030 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1031 -s "found renegotiation extension" \
1032 -s "server hello, secure renegotiation extension" \
1033 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001034 -c "=> renegotiate" \
1035 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001036 -s "write hello request"
1037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001038run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001039 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1040 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001041 1 \
1042 -c "client hello, adding renegotiation extension" \
1043 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1044 -S "found renegotiation extension" \
1045 -s "server hello, secure renegotiation extension" \
1046 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001047 -c "=> renegotiate" \
1048 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001049 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001050 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001051 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001053run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001054 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1055 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001056 0 \
1057 -C "client hello, adding renegotiation extension" \
1058 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1059 -S "found renegotiation extension" \
1060 -s "server hello, secure renegotiation extension" \
1061 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001062 -C "=> renegotiate" \
1063 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001064 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001065 -S "SSL - An unexpected message was received from our peer" \
1066 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001068run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001069 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001070 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001071 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001072 0 \
1073 -C "client hello, adding renegotiation extension" \
1074 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1075 -S "found renegotiation extension" \
1076 -s "server hello, secure renegotiation extension" \
1077 -c "found renegotiation extension" \
1078 -C "=> renegotiate" \
1079 -S "=> renegotiate" \
1080 -s "write hello request" \
1081 -S "SSL - An unexpected message was received from our peer" \
1082 -S "failed"
1083
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001084# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001085run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001086 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001087 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001088 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001089 0 \
1090 -C "client hello, adding renegotiation extension" \
1091 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1092 -S "found renegotiation extension" \
1093 -s "server hello, secure renegotiation extension" \
1094 -c "found renegotiation extension" \
1095 -C "=> renegotiate" \
1096 -S "=> renegotiate" \
1097 -s "write hello request" \
1098 -S "SSL - An unexpected message was received from our peer" \
1099 -S "failed"
1100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001101run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001102 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001103 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001104 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001105 0 \
1106 -C "client hello, adding renegotiation extension" \
1107 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1108 -S "found renegotiation extension" \
1109 -s "server hello, secure renegotiation extension" \
1110 -c "found renegotiation extension" \
1111 -C "=> renegotiate" \
1112 -S "=> renegotiate" \
1113 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001114 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001116run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001117 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001118 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001119 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001120 0 \
1121 -c "client hello, adding renegotiation extension" \
1122 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1123 -s "found renegotiation extension" \
1124 -s "server hello, secure renegotiation extension" \
1125 -c "found renegotiation extension" \
1126 -c "=> renegotiate" \
1127 -s "=> renegotiate" \
1128 -s "write hello request" \
1129 -S "SSL - An unexpected message was received from our peer" \
1130 -S "failed"
1131
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001132run_test "Renegotiation: periodic, just below period" \
1133 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1134 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1135 0 \
1136 -C "client hello, adding renegotiation extension" \
1137 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1138 -S "found renegotiation extension" \
1139 -s "server hello, secure renegotiation extension" \
1140 -c "found renegotiation extension" \
1141 -S "record counter limit reached: renegotiate" \
1142 -C "=> renegotiate" \
1143 -S "=> renegotiate" \
1144 -S "write hello request" \
1145 -S "SSL - An unexpected message was received from our peer" \
1146 -S "failed"
1147
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001148# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001149run_test "Renegotiation: periodic, just above period" \
1150 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001151 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001152 0 \
1153 -c "client hello, adding renegotiation extension" \
1154 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1155 -s "found renegotiation extension" \
1156 -s "server hello, secure renegotiation extension" \
1157 -c "found renegotiation extension" \
1158 -s "record counter limit reached: renegotiate" \
1159 -c "=> renegotiate" \
1160 -s "=> renegotiate" \
1161 -s "write hello request" \
1162 -S "SSL - An unexpected message was received from our peer" \
1163 -S "failed"
1164
1165run_test "Renegotiation: periodic, two times period" \
1166 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001167 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001168 0 \
1169 -c "client hello, adding renegotiation extension" \
1170 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1171 -s "found renegotiation extension" \
1172 -s "server hello, secure renegotiation extension" \
1173 -c "found renegotiation extension" \
1174 -s "record counter limit reached: renegotiate" \
1175 -c "=> renegotiate" \
1176 -s "=> renegotiate" \
1177 -s "write hello request" \
1178 -S "SSL - An unexpected message was received from our peer" \
1179 -S "failed"
1180
1181run_test "Renegotiation: periodic, above period, disabled" \
1182 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1183 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1184 0 \
1185 -C "client hello, adding renegotiation extension" \
1186 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1187 -S "found renegotiation extension" \
1188 -s "server hello, secure renegotiation extension" \
1189 -c "found renegotiation extension" \
1190 -S "record counter limit reached: renegotiate" \
1191 -C "=> renegotiate" \
1192 -S "=> renegotiate" \
1193 -S "write hello request" \
1194 -S "SSL - An unexpected message was received from our peer" \
1195 -S "failed"
1196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001197run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001198 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1199 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001200 0 \
1201 -c "client hello, adding renegotiation extension" \
1202 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1203 -s "found renegotiation extension" \
1204 -s "server hello, secure renegotiation extension" \
1205 -c "found renegotiation extension" \
1206 -c "=> renegotiate" \
1207 -s "=> renegotiate" \
1208 -S "write hello request"
1209
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001210run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001211 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1212 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001213 0 \
1214 -c "client hello, adding renegotiation extension" \
1215 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1216 -s "found renegotiation extension" \
1217 -s "server hello, secure renegotiation extension" \
1218 -c "found renegotiation extension" \
1219 -c "=> renegotiate" \
1220 -s "=> renegotiate" \
1221 -s "write hello request"
1222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001223run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001224 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001225 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001226 0 \
1227 -c "client hello, adding renegotiation extension" \
1228 -c "found renegotiation extension" \
1229 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001230 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001231 -C "error" \
1232 -c "HTTP/1.0 200 [Oo][Kk]"
1233
Paul Bakker539d9722015-02-08 16:18:35 +01001234requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001235run_test "Renegotiation: gnutls server strict, client-initiated" \
1236 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001237 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001238 0 \
1239 -c "client hello, adding renegotiation extension" \
1240 -c "found renegotiation extension" \
1241 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001242 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001243 -C "error" \
1244 -c "HTTP/1.0 200 [Oo][Kk]"
1245
Paul Bakker539d9722015-02-08 16:18:35 +01001246requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001247run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1248 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1249 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1250 1 \
1251 -c "client hello, adding renegotiation extension" \
1252 -C "found renegotiation extension" \
1253 -c "=> renegotiate" \
1254 -c "ssl_handshake() returned" \
1255 -c "error" \
1256 -C "HTTP/1.0 200 [Oo][Kk]"
1257
Paul Bakker539d9722015-02-08 16:18:35 +01001258requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001259run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1260 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1261 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1262 allow_legacy=0" \
1263 1 \
1264 -c "client hello, adding renegotiation extension" \
1265 -C "found renegotiation extension" \
1266 -c "=> renegotiate" \
1267 -c "ssl_handshake() returned" \
1268 -c "error" \
1269 -C "HTTP/1.0 200 [Oo][Kk]"
1270
Paul Bakker539d9722015-02-08 16:18:35 +01001271requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001272run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1273 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1274 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1275 allow_legacy=1" \
1276 0 \
1277 -c "client hello, adding renegotiation extension" \
1278 -C "found renegotiation extension" \
1279 -c "=> renegotiate" \
1280 -C "ssl_hanshake() returned" \
1281 -C "error" \
1282 -c "HTTP/1.0 200 [Oo][Kk]"
1283
1284# Test for the "secure renegotation" extension only (no actual renegotiation)
1285
Paul Bakker539d9722015-02-08 16:18:35 +01001286requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001287run_test "Renego ext: gnutls server strict, client default" \
1288 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1289 "$P_CLI debug_level=3" \
1290 0 \
1291 -c "found renegotiation extension" \
1292 -C "error" \
1293 -c "HTTP/1.0 200 [Oo][Kk]"
1294
Paul Bakker539d9722015-02-08 16:18:35 +01001295requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001296run_test "Renego ext: gnutls server unsafe, client default" \
1297 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1298 "$P_CLI debug_level=3" \
1299 0 \
1300 -C "found renegotiation extension" \
1301 -C "error" \
1302 -c "HTTP/1.0 200 [Oo][Kk]"
1303
Paul Bakker539d9722015-02-08 16:18:35 +01001304requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001305run_test "Renego ext: gnutls server unsafe, client break legacy" \
1306 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1307 "$P_CLI debug_level=3 allow_legacy=-1" \
1308 1 \
1309 -C "found renegotiation extension" \
1310 -c "error" \
1311 -C "HTTP/1.0 200 [Oo][Kk]"
1312
Paul Bakker539d9722015-02-08 16:18:35 +01001313requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001314run_test "Renego ext: gnutls client strict, server default" \
1315 "$P_SRV debug_level=3" \
1316 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1317 0 \
1318 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1319 -s "server hello, secure renegotiation extension"
1320
Paul Bakker539d9722015-02-08 16:18:35 +01001321requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001322run_test "Renego ext: gnutls client unsafe, server default" \
1323 "$P_SRV debug_level=3" \
1324 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1325 0 \
1326 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1327 -S "server hello, secure renegotiation extension"
1328
Paul Bakker539d9722015-02-08 16:18:35 +01001329requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001330run_test "Renego ext: gnutls client unsafe, server break legacy" \
1331 "$P_SRV debug_level=3 allow_legacy=-1" \
1332 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1333 1 \
1334 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1335 -S "server hello, secure renegotiation extension"
1336
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001337# Tests for auth_mode
1338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001339run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001340 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001341 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001342 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001343 1 \
1344 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001345 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001346 -c "! ssl_handshake returned" \
1347 -c "X509 - Certificate verification failed"
1348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001349run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001350 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001351 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001352 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001353 0 \
1354 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001355 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001356 -C "! ssl_handshake returned" \
1357 -C "X509 - Certificate verification failed"
1358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001359run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001360 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001361 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001362 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001363 0 \
1364 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001365 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001366 -C "! ssl_handshake returned" \
1367 -C "X509 - Certificate verification failed"
1368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001369run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001370 "$P_SRV debug_level=3 auth_mode=required" \
1371 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001372 key_file=data_files/server5.key" \
1373 1 \
1374 -S "skip write certificate request" \
1375 -C "skip parse certificate request" \
1376 -c "got a certificate request" \
1377 -C "skip write certificate" \
1378 -C "skip write certificate verify" \
1379 -S "skip parse certificate verify" \
1380 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001381 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001382 -s "! ssl_handshake returned" \
1383 -c "! ssl_handshake returned" \
1384 -s "X509 - Certificate verification failed"
1385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001386run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001387 "$P_SRV debug_level=3 auth_mode=optional" \
1388 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001389 key_file=data_files/server5.key" \
1390 0 \
1391 -S "skip write certificate request" \
1392 -C "skip parse certificate request" \
1393 -c "got a certificate request" \
1394 -C "skip write certificate" \
1395 -C "skip write certificate verify" \
1396 -S "skip parse certificate verify" \
1397 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001398 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001399 -S "! ssl_handshake returned" \
1400 -C "! ssl_handshake returned" \
1401 -S "X509 - Certificate verification failed"
1402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001403run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001404 "$P_SRV debug_level=3 auth_mode=none" \
1405 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001406 key_file=data_files/server5.key" \
1407 0 \
1408 -s "skip write certificate request" \
1409 -C "skip parse certificate request" \
1410 -c "got no certificate request" \
1411 -c "skip write certificate" \
1412 -c "skip write certificate verify" \
1413 -s "skip parse certificate verify" \
1414 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001415 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001416 -S "! ssl_handshake returned" \
1417 -C "! ssl_handshake returned" \
1418 -S "X509 - Certificate verification failed"
1419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001420run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001421 "$P_SRV debug_level=3 auth_mode=optional" \
1422 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001423 0 \
1424 -S "skip write certificate request" \
1425 -C "skip parse certificate request" \
1426 -c "got a certificate request" \
1427 -C "skip write certificate$" \
1428 -C "got no certificate to send" \
1429 -S "SSLv3 client has no certificate" \
1430 -c "skip write certificate verify" \
1431 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001432 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001433 -S "! ssl_handshake returned" \
1434 -C "! ssl_handshake returned" \
1435 -S "X509 - Certificate verification failed"
1436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001437run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001438 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001439 "$O_CLI" \
1440 0 \
1441 -S "skip write certificate request" \
1442 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001443 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001444 -S "! ssl_handshake returned" \
1445 -S "X509 - Certificate verification failed"
1446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001447run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001448 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001449 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001450 0 \
1451 -C "skip parse certificate request" \
1452 -c "got a certificate request" \
1453 -C "skip write certificate$" \
1454 -c "skip write certificate verify" \
1455 -C "! ssl_handshake returned"
1456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001457run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001458 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001459 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001460 0 \
1461 -S "skip write certificate request" \
1462 -C "skip parse certificate request" \
1463 -c "got a certificate request" \
1464 -C "skip write certificate$" \
1465 -c "skip write certificate verify" \
1466 -c "got no certificate to send" \
1467 -s "SSLv3 client has no certificate" \
1468 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001469 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001470 -S "! ssl_handshake returned" \
1471 -C "! ssl_handshake returned" \
1472 -S "X509 - Certificate verification failed"
1473
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001474# Tests for certificate selection based on SHA verson
1475
1476run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1477 "$P_SRV crt_file=data_files/server5.crt \
1478 key_file=data_files/server5.key \
1479 crt_file2=data_files/server5-sha1.crt \
1480 key_file2=data_files/server5.key" \
1481 "$P_CLI force_version=tls1_2" \
1482 0 \
1483 -c "signed using.*ECDSA with SHA256" \
1484 -C "signed using.*ECDSA with SHA1"
1485
1486run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1487 "$P_SRV crt_file=data_files/server5.crt \
1488 key_file=data_files/server5.key \
1489 crt_file2=data_files/server5-sha1.crt \
1490 key_file2=data_files/server5.key" \
1491 "$P_CLI force_version=tls1_1" \
1492 0 \
1493 -C "signed using.*ECDSA with SHA256" \
1494 -c "signed using.*ECDSA with SHA1"
1495
1496run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1497 "$P_SRV crt_file=data_files/server5.crt \
1498 key_file=data_files/server5.key \
1499 crt_file2=data_files/server5-sha1.crt \
1500 key_file2=data_files/server5.key" \
1501 "$P_CLI force_version=tls1" \
1502 0 \
1503 -C "signed using.*ECDSA with SHA256" \
1504 -c "signed using.*ECDSA with SHA1"
1505
1506run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1507 "$P_SRV crt_file=data_files/server5.crt \
1508 key_file=data_files/server5.key \
1509 crt_file2=data_files/server6.crt \
1510 key_file2=data_files/server6.key" \
1511 "$P_CLI force_version=tls1_1" \
1512 0 \
1513 -c "serial number.*09" \
1514 -c "signed using.*ECDSA with SHA256" \
1515 -C "signed using.*ECDSA with SHA1"
1516
1517run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1518 "$P_SRV crt_file=data_files/server6.crt \
1519 key_file=data_files/server6.key \
1520 crt_file2=data_files/server5.crt \
1521 key_file2=data_files/server5.key" \
1522 "$P_CLI force_version=tls1_1" \
1523 0 \
1524 -c "serial number.*0A" \
1525 -c "signed using.*ECDSA with SHA256" \
1526 -C "signed using.*ECDSA with SHA1"
1527
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001528# tests for SNI
1529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001530run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001531 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001532 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001533 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001534 server_name=localhost" \
1535 0 \
1536 -S "parse ServerName extension" \
1537 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1538 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001540run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001541 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001542 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001543 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 +01001544 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001545 server_name=localhost" \
1546 0 \
1547 -s "parse ServerName extension" \
1548 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1549 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001551run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001552 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001553 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001554 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 +01001555 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001556 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001557 0 \
1558 -s "parse ServerName extension" \
1559 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001560 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001562run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001563 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001564 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001565 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 +01001566 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001567 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001568 1 \
1569 -s "parse ServerName extension" \
1570 -s "ssl_sni_wrapper() returned" \
1571 -s "ssl_handshake returned" \
1572 -c "ssl_handshake returned" \
1573 -c "SSL - A fatal alert message was received from our peer"
1574
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001575# Tests for non-blocking I/O: exercise a variety of handshake flows
1576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001577run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001578 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1579 "$P_CLI nbio=2 tickets=0" \
1580 0 \
1581 -S "ssl_handshake returned" \
1582 -C "ssl_handshake returned" \
1583 -c "Read from server: .* bytes read"
1584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001585run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001586 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1587 "$P_CLI nbio=2 tickets=0" \
1588 0 \
1589 -S "ssl_handshake returned" \
1590 -C "ssl_handshake returned" \
1591 -c "Read from server: .* bytes read"
1592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001593run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001594 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1595 "$P_CLI nbio=2 tickets=1" \
1596 0 \
1597 -S "ssl_handshake returned" \
1598 -C "ssl_handshake returned" \
1599 -c "Read from server: .* bytes read"
1600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001601run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001602 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1603 "$P_CLI nbio=2 tickets=1" \
1604 0 \
1605 -S "ssl_handshake returned" \
1606 -C "ssl_handshake returned" \
1607 -c "Read from server: .* bytes read"
1608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001609run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001610 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1611 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1612 0 \
1613 -S "ssl_handshake returned" \
1614 -C "ssl_handshake returned" \
1615 -c "Read from server: .* bytes read"
1616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001617run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001618 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1619 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1620 0 \
1621 -S "ssl_handshake returned" \
1622 -C "ssl_handshake returned" \
1623 -c "Read from server: .* bytes read"
1624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001625run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001626 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1627 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1628 0 \
1629 -S "ssl_handshake returned" \
1630 -C "ssl_handshake returned" \
1631 -c "Read from server: .* bytes read"
1632
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001633# Tests for version negotiation
1634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001635run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001636 "$P_SRV" \
1637 "$P_CLI" \
1638 0 \
1639 -S "ssl_handshake returned" \
1640 -C "ssl_handshake returned" \
1641 -s "Protocol is TLSv1.2" \
1642 -c "Protocol is TLSv1.2"
1643
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001644run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001645 "$P_SRV" \
1646 "$P_CLI max_version=tls1_1" \
1647 0 \
1648 -S "ssl_handshake returned" \
1649 -C "ssl_handshake returned" \
1650 -s "Protocol is TLSv1.1" \
1651 -c "Protocol is TLSv1.1"
1652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001653run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001654 "$P_SRV max_version=tls1_1" \
1655 "$P_CLI" \
1656 0 \
1657 -S "ssl_handshake returned" \
1658 -C "ssl_handshake returned" \
1659 -s "Protocol is TLSv1.1" \
1660 -c "Protocol is TLSv1.1"
1661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001662run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001663 "$P_SRV max_version=tls1_1" \
1664 "$P_CLI max_version=tls1_1" \
1665 0 \
1666 -S "ssl_handshake returned" \
1667 -C "ssl_handshake returned" \
1668 -s "Protocol is TLSv1.1" \
1669 -c "Protocol is TLSv1.1"
1670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001671run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001672 "$P_SRV min_version=tls1_1" \
1673 "$P_CLI max_version=tls1_1" \
1674 0 \
1675 -S "ssl_handshake returned" \
1676 -C "ssl_handshake returned" \
1677 -s "Protocol is TLSv1.1" \
1678 -c "Protocol is TLSv1.1"
1679
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001680run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001681 "$P_SRV max_version=tls1_1" \
1682 "$P_CLI min_version=tls1_1" \
1683 0 \
1684 -S "ssl_handshake returned" \
1685 -C "ssl_handshake returned" \
1686 -s "Protocol is TLSv1.1" \
1687 -c "Protocol is TLSv1.1"
1688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001689run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001690 "$P_SRV max_version=tls1_1" \
1691 "$P_CLI min_version=tls1_2" \
1692 1 \
1693 -s "ssl_handshake returned" \
1694 -c "ssl_handshake returned" \
1695 -c "SSL - Handshake protocol not within min/max boundaries"
1696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001697run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001698 "$P_SRV min_version=tls1_2" \
1699 "$P_CLI max_version=tls1_1" \
1700 1 \
1701 -s "ssl_handshake returned" \
1702 -c "ssl_handshake returned" \
1703 -s "SSL - Handshake protocol not within min/max boundaries"
1704
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001705# Tests for ALPN extension
1706
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001707if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001709run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001710 "$P_SRV debug_level=3" \
1711 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001712 0 \
1713 -C "client hello, adding alpn extension" \
1714 -S "found alpn extension" \
1715 -C "got an alert message, type: \\[2:120]" \
1716 -S "server hello, adding alpn extension" \
1717 -C "found alpn extension " \
1718 -C "Application Layer Protocol is" \
1719 -S "Application Layer Protocol is"
1720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001721run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001722 "$P_SRV debug_level=3" \
1723 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001724 0 \
1725 -c "client hello, adding alpn extension" \
1726 -s "found alpn extension" \
1727 -C "got an alert message, type: \\[2:120]" \
1728 -S "server hello, adding alpn extension" \
1729 -C "found alpn extension " \
1730 -c "Application Layer Protocol is (none)" \
1731 -S "Application Layer Protocol is"
1732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001733run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001734 "$P_SRV debug_level=3 alpn=abc,1234" \
1735 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001736 0 \
1737 -C "client hello, adding alpn extension" \
1738 -S "found alpn extension" \
1739 -C "got an alert message, type: \\[2:120]" \
1740 -S "server hello, adding alpn extension" \
1741 -C "found alpn extension " \
1742 -C "Application Layer Protocol is" \
1743 -s "Application Layer Protocol is (none)"
1744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001745run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001746 "$P_SRV debug_level=3 alpn=abc,1234" \
1747 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001748 0 \
1749 -c "client hello, adding alpn extension" \
1750 -s "found alpn extension" \
1751 -C "got an alert message, type: \\[2:120]" \
1752 -s "server hello, adding alpn extension" \
1753 -c "found alpn extension" \
1754 -c "Application Layer Protocol is abc" \
1755 -s "Application Layer Protocol is abc"
1756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001757run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001758 "$P_SRV debug_level=3 alpn=abc,1234" \
1759 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001760 0 \
1761 -c "client hello, adding alpn extension" \
1762 -s "found alpn extension" \
1763 -C "got an alert message, type: \\[2:120]" \
1764 -s "server hello, adding alpn extension" \
1765 -c "found alpn extension" \
1766 -c "Application Layer Protocol is abc" \
1767 -s "Application Layer Protocol is abc"
1768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001769run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001770 "$P_SRV debug_level=3 alpn=abc,1234" \
1771 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001772 0 \
1773 -c "client hello, adding alpn extension" \
1774 -s "found alpn extension" \
1775 -C "got an alert message, type: \\[2:120]" \
1776 -s "server hello, adding alpn extension" \
1777 -c "found alpn extension" \
1778 -c "Application Layer Protocol is 1234" \
1779 -s "Application Layer Protocol is 1234"
1780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001781run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001782 "$P_SRV debug_level=3 alpn=abc,123" \
1783 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001784 1 \
1785 -c "client hello, adding alpn extension" \
1786 -s "found alpn extension" \
1787 -c "got an alert message, type: \\[2:120]" \
1788 -S "server hello, adding alpn extension" \
1789 -C "found alpn extension" \
1790 -C "Application Layer Protocol is 1234" \
1791 -S "Application Layer Protocol is 1234"
1792
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001793fi
1794
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001795# Tests for keyUsage in leaf certificates, part 1:
1796# server-side certificate/suite selection
1797
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001798run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001799 "$P_SRV key_file=data_files/server2.key \
1800 crt_file=data_files/server2.ku-ds.crt" \
1801 "$P_CLI" \
1802 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001803 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001804
1805
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001806run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001807 "$P_SRV key_file=data_files/server2.key \
1808 crt_file=data_files/server2.ku-ke.crt" \
1809 "$P_CLI" \
1810 0 \
1811 -c "Ciphersuite is TLS-RSA-WITH-"
1812
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001813run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001814 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001815 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001816 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001817 1 \
1818 -C "Ciphersuite is "
1819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001820run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001821 "$P_SRV key_file=data_files/server5.key \
1822 crt_file=data_files/server5.ku-ds.crt" \
1823 "$P_CLI" \
1824 0 \
1825 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1826
1827
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001828run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001829 "$P_SRV key_file=data_files/server5.key \
1830 crt_file=data_files/server5.ku-ka.crt" \
1831 "$P_CLI" \
1832 0 \
1833 -c "Ciphersuite is TLS-ECDH-"
1834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001835run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001836 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001837 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001838 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001839 1 \
1840 -C "Ciphersuite is "
1841
1842# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001843# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001845run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001846 "$O_SRV -key data_files/server2.key \
1847 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001848 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001849 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1850 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001851 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001852 -C "Processing of the Certificate handshake message failed" \
1853 -c "Ciphersuite is TLS-"
1854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001855run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001856 "$O_SRV -key data_files/server2.key \
1857 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001858 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001859 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1860 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001861 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001862 -C "Processing of the Certificate handshake message failed" \
1863 -c "Ciphersuite is TLS-"
1864
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001865run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001866 "$O_SRV -key data_files/server2.key \
1867 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001868 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001869 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1870 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001871 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001872 -C "Processing of the Certificate handshake message failed" \
1873 -c "Ciphersuite is TLS-"
1874
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001875run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001876 "$O_SRV -key data_files/server2.key \
1877 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001878 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001879 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1880 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001881 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001882 -c "Processing of the Certificate handshake message failed" \
1883 -C "Ciphersuite is TLS-"
1884
Manuel Pégourié-Gonnarde16b62c2015-04-17 16:55:53 +02001885run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
1886 "$O_SRV -key data_files/server2.key \
1887 -cert data_files/server2.ku-ke.crt" \
1888 "$P_CLI debug_level=1 auth_mode=optional \
1889 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1890 0 \
1891 -c "bad certificate (usage extensions)" \
1892 -C "Processing of the Certificate handshake message failed" \
1893 -c "Ciphersuite is TLS-" \
1894 -c "! Usage does not match the keyUsage extension"
1895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001896run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001897 "$O_SRV -key data_files/server2.key \
1898 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001899 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001900 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1901 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001902 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001903 -C "Processing of the Certificate handshake message failed" \
1904 -c "Ciphersuite is TLS-"
1905
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001906run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001907 "$O_SRV -key data_files/server2.key \
1908 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001909 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001910 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1911 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001912 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001913 -c "Processing of the Certificate handshake message failed" \
1914 -C "Ciphersuite is TLS-"
1915
Manuel Pégourié-Gonnarde16b62c2015-04-17 16:55:53 +02001916run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
1917 "$O_SRV -key data_files/server2.key \
1918 -cert data_files/server2.ku-ds.crt" \
1919 "$P_CLI debug_level=1 auth_mode=optional \
1920 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1921 0 \
1922 -c "bad certificate (usage extensions)" \
1923 -C "Processing of the Certificate handshake message failed" \
1924 -c "Ciphersuite is TLS-" \
1925 -c "! Usage does not match the keyUsage extension"
1926
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001927# Tests for keyUsage in leaf certificates, part 3:
1928# server-side checking of client cert
1929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001930run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001931 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001932 "$O_CLI -key data_files/server2.key \
1933 -cert data_files/server2.ku-ds.crt" \
1934 0 \
1935 -S "bad certificate (usage extensions)" \
1936 -S "Processing of the Certificate handshake message failed"
1937
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001938run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001939 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001940 "$O_CLI -key data_files/server2.key \
1941 -cert data_files/server2.ku-ke.crt" \
1942 0 \
1943 -s "bad certificate (usage extensions)" \
1944 -S "Processing of the Certificate handshake message failed"
1945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001946run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001947 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001948 "$O_CLI -key data_files/server2.key \
1949 -cert data_files/server2.ku-ke.crt" \
1950 1 \
1951 -s "bad certificate (usage extensions)" \
1952 -s "Processing of the Certificate handshake message failed"
1953
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001954run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001955 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001956 "$O_CLI -key data_files/server5.key \
1957 -cert data_files/server5.ku-ds.crt" \
1958 0 \
1959 -S "bad certificate (usage extensions)" \
1960 -S "Processing of the Certificate handshake message failed"
1961
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001962run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001963 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001964 "$O_CLI -key data_files/server5.key \
1965 -cert data_files/server5.ku-ka.crt" \
1966 0 \
1967 -s "bad certificate (usage extensions)" \
1968 -S "Processing of the Certificate handshake message failed"
1969
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001970# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1971
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001972run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001973 "$P_SRV key_file=data_files/server5.key \
1974 crt_file=data_files/server5.eku-srv.crt" \
1975 "$P_CLI" \
1976 0
1977
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001978run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001979 "$P_SRV key_file=data_files/server5.key \
1980 crt_file=data_files/server5.eku-srv.crt" \
1981 "$P_CLI" \
1982 0
1983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001984run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001985 "$P_SRV key_file=data_files/server5.key \
1986 crt_file=data_files/server5.eku-cs_any.crt" \
1987 "$P_CLI" \
1988 0
1989
1990# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001991run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001992 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1993 crt_file=data_files/server5.eku-cli.crt" \
1994 "$P_CLI psk=badbad" \
1995 1
1996
1997# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001999run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002000 "$O_SRV -key data_files/server5.key \
2001 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002002 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002003 0 \
2004 -C "bad certificate (usage extensions)" \
2005 -C "Processing of the Certificate handshake message failed" \
2006 -c "Ciphersuite is TLS-"
2007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002008run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002009 "$O_SRV -key data_files/server5.key \
2010 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002011 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002012 0 \
2013 -C "bad certificate (usage extensions)" \
2014 -C "Processing of the Certificate handshake message failed" \
2015 -c "Ciphersuite is TLS-"
2016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002017run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002018 "$O_SRV -key data_files/server5.key \
2019 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002020 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002021 0 \
2022 -C "bad certificate (usage extensions)" \
2023 -C "Processing of the Certificate handshake message failed" \
2024 -c "Ciphersuite is TLS-"
2025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002026run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002027 "$O_SRV -key data_files/server5.key \
2028 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002029 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002030 1 \
2031 -c "bad certificate (usage extensions)" \
2032 -c "Processing of the Certificate handshake message failed" \
2033 -C "Ciphersuite is TLS-"
2034
2035# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002037run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002038 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002039 "$O_CLI -key data_files/server5.key \
2040 -cert data_files/server5.eku-cli.crt" \
2041 0 \
2042 -S "bad certificate (usage extensions)" \
2043 -S "Processing of the Certificate handshake message failed"
2044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002045run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002046 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002047 "$O_CLI -key data_files/server5.key \
2048 -cert data_files/server5.eku-srv_cli.crt" \
2049 0 \
2050 -S "bad certificate (usage extensions)" \
2051 -S "Processing of the Certificate handshake message failed"
2052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002053run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002054 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002055 "$O_CLI -key data_files/server5.key \
2056 -cert data_files/server5.eku-cs_any.crt" \
2057 0 \
2058 -S "bad certificate (usage extensions)" \
2059 -S "Processing of the Certificate handshake message failed"
2060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002061run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002062 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002063 "$O_CLI -key data_files/server5.key \
2064 -cert data_files/server5.eku-cs.crt" \
2065 0 \
2066 -s "bad certificate (usage extensions)" \
2067 -S "Processing of the Certificate handshake message failed"
2068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002069run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002070 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002071 "$O_CLI -key data_files/server5.key \
2072 -cert data_files/server5.eku-cs.crt" \
2073 1 \
2074 -s "bad certificate (usage extensions)" \
2075 -s "Processing of the Certificate handshake message failed"
2076
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002077# Tests for DHM parameters loading
2078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002079run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002080 "$P_SRV" \
2081 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2082 debug_level=3" \
2083 0 \
2084 -c "value of 'DHM: P ' (2048 bits)" \
2085 -c "value of 'DHM: G ' (2048 bits)"
2086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002087run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002088 "$P_SRV dhm_file=data_files/dhparams.pem" \
2089 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2090 debug_level=3" \
2091 0 \
2092 -c "value of 'DHM: P ' (1024 bits)" \
2093 -c "value of 'DHM: G ' (2 bits)"
2094
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002095# Tests for PSK callback
2096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002097run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002098 "$P_SRV psk=abc123 psk_identity=foo" \
2099 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2100 psk_identity=foo psk=abc123" \
2101 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002102 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002103 -S "SSL - Unknown identity received" \
2104 -S "SSL - Verification of the message MAC failed"
2105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002106run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002107 "$P_SRV" \
2108 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2109 psk_identity=foo psk=abc123" \
2110 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002111 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002112 -S "SSL - Unknown identity received" \
2113 -S "SSL - Verification of the message MAC failed"
2114
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002115run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002116 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2117 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2118 psk_identity=foo psk=abc123" \
2119 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002120 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002121 -s "SSL - Unknown identity received" \
2122 -S "SSL - Verification of the message MAC failed"
2123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002124run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002125 "$P_SRV psk_list=abc,dead,def,beef" \
2126 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2127 psk_identity=abc psk=dead" \
2128 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002129 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002130 -S "SSL - Unknown identity received" \
2131 -S "SSL - Verification of the message MAC failed"
2132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002133run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002134 "$P_SRV psk_list=abc,dead,def,beef" \
2135 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2136 psk_identity=def psk=beef" \
2137 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002138 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002139 -S "SSL - Unknown identity received" \
2140 -S "SSL - Verification of the message MAC failed"
2141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002142run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002143 "$P_SRV psk_list=abc,dead,def,beef" \
2144 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2145 psk_identity=ghi psk=beef" \
2146 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002147 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002148 -s "SSL - Unknown identity received" \
2149 -S "SSL - Verification of the message MAC failed"
2150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002151run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002152 "$P_SRV psk_list=abc,dead,def,beef" \
2153 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2154 psk_identity=abc psk=beef" \
2155 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002156 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002157 -S "SSL - Unknown identity received" \
2158 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002159
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002160# Tests for ciphersuites per version
2161
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002162run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002163 "$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 +02002164 "$P_CLI force_version=ssl3" \
2165 0 \
2166 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002168run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002169 "$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" \
2170 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002171 0 \
2172 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002174run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002175 "$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" \
2176 "$P_CLI force_version=tls1_1" \
2177 0 \
2178 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2179
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002180run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002181 "$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" \
2182 "$P_CLI force_version=tls1_2" \
2183 0 \
2184 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2185
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002186# Tests for ssl_get_bytes_avail()
2187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002188run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002189 "$P_SRV" \
2190 "$P_CLI request_size=100" \
2191 0 \
2192 -s "Read from client: 100 bytes read$"
2193
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002194run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002195 "$P_SRV" \
2196 "$P_CLI request_size=500" \
2197 0 \
2198 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002199
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002200# Tests for small packets
2201
2202run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002203 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002204 "$P_CLI request_size=1 force_version=ssl3 \
2205 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2206 0 \
2207 -s "Read from client: 1 bytes read"
2208
2209run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002210 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002211 "$P_CLI request_size=1 force_version=ssl3 \
2212 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2213 0 \
2214 -s "Read from client: 1 bytes read"
2215
2216run_test "Small packet TLS 1.0 BlockCipher" \
2217 "$P_SRV" \
2218 "$P_CLI request_size=1 force_version=tls1 \
2219 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2220 0 \
2221 -s "Read from client: 1 bytes read"
2222
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002223run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2224 "$P_SRV" \
2225 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2226 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2227 0 \
2228 -s "Read from client: 1 bytes read"
2229
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002230run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2231 "$P_SRV" \
2232 "$P_CLI request_size=1 force_version=tls1 \
2233 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2234 trunc_hmac=1" \
2235 0 \
2236 -s "Read from client: 1 bytes read"
2237
2238run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002239 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002240 "$P_CLI request_size=1 force_version=tls1 \
2241 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2242 trunc_hmac=1" \
2243 0 \
2244 -s "Read from client: 1 bytes read"
2245
2246run_test "Small packet TLS 1.1 BlockCipher" \
2247 "$P_SRV" \
2248 "$P_CLI request_size=1 force_version=tls1_1 \
2249 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2250 0 \
2251 -s "Read from client: 1 bytes read"
2252
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002253run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2254 "$P_SRV" \
2255 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2256 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2257 0 \
2258 -s "Read from client: 1 bytes read"
2259
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002260run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002261 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002262 "$P_CLI request_size=1 force_version=tls1_1 \
2263 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2264 0 \
2265 -s "Read from client: 1 bytes read"
2266
2267run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2268 "$P_SRV" \
2269 "$P_CLI request_size=1 force_version=tls1_1 \
2270 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2271 trunc_hmac=1" \
2272 0 \
2273 -s "Read from client: 1 bytes read"
2274
2275run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002276 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002277 "$P_CLI request_size=1 force_version=tls1_1 \
2278 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2279 trunc_hmac=1" \
2280 0 \
2281 -s "Read from client: 1 bytes read"
2282
2283run_test "Small packet TLS 1.2 BlockCipher" \
2284 "$P_SRV" \
2285 "$P_CLI request_size=1 force_version=tls1_2 \
2286 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2287 0 \
2288 -s "Read from client: 1 bytes read"
2289
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002290run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2291 "$P_SRV" \
2292 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2293 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2294 0 \
2295 -s "Read from client: 1 bytes read"
2296
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002297run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2298 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002299 "$P_CLI request_size=1 force_version=tls1_2 \
2300 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002301 0 \
2302 -s "Read from client: 1 bytes read"
2303
2304run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2305 "$P_SRV" \
2306 "$P_CLI request_size=1 force_version=tls1_2 \
2307 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2308 trunc_hmac=1" \
2309 0 \
2310 -s "Read from client: 1 bytes read"
2311
2312run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002313 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002314 "$P_CLI request_size=1 force_version=tls1_2 \
2315 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2316 0 \
2317 -s "Read from client: 1 bytes read"
2318
2319run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002320 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002321 "$P_CLI request_size=1 force_version=tls1_2 \
2322 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2323 trunc_hmac=1" \
2324 0 \
2325 -s "Read from client: 1 bytes read"
2326
2327run_test "Small packet TLS 1.2 AEAD" \
2328 "$P_SRV" \
2329 "$P_CLI request_size=1 force_version=tls1_2 \
2330 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2331 0 \
2332 -s "Read from client: 1 bytes read"
2333
2334run_test "Small packet TLS 1.2 AEAD shorter tag" \
2335 "$P_SRV" \
2336 "$P_CLI request_size=1 force_version=tls1_2 \
2337 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2338 0 \
2339 -s "Read from client: 1 bytes read"
2340
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002341# Test for large packets
2342
2343run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002344 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002345 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002346 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2347 0 \
2348 -s "Read from client: 16384 bytes read"
2349
2350run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002351 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002352 "$P_CLI request_size=16384 force_version=ssl3 \
2353 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2354 0 \
2355 -s "Read from client: 16384 bytes read"
2356
2357run_test "Large packet TLS 1.0 BlockCipher" \
2358 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002359 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002360 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2361 0 \
2362 -s "Read from client: 16384 bytes read"
2363
2364run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2365 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002366 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002367 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2368 trunc_hmac=1" \
2369 0 \
2370 -s "Read from client: 16384 bytes read"
2371
2372run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002373 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002374 "$P_CLI request_size=16384 force_version=tls1 \
2375 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2376 trunc_hmac=1" \
2377 0 \
2378 -s "Read from client: 16384 bytes read"
2379
2380run_test "Large packet TLS 1.1 BlockCipher" \
2381 "$P_SRV" \
2382 "$P_CLI request_size=16384 force_version=tls1_1 \
2383 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2384 0 \
2385 -s "Read from client: 16384 bytes read"
2386
2387run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002388 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002389 "$P_CLI request_size=16384 force_version=tls1_1 \
2390 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2391 0 \
2392 -s "Read from client: 16384 bytes read"
2393
2394run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2395 "$P_SRV" \
2396 "$P_CLI request_size=16384 force_version=tls1_1 \
2397 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2398 trunc_hmac=1" \
2399 0 \
2400 -s "Read from client: 16384 bytes read"
2401
2402run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002403 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002404 "$P_CLI request_size=16384 force_version=tls1_1 \
2405 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2406 trunc_hmac=1" \
2407 0 \
2408 -s "Read from client: 16384 bytes read"
2409
2410run_test "Large packet TLS 1.2 BlockCipher" \
2411 "$P_SRV" \
2412 "$P_CLI request_size=16384 force_version=tls1_2 \
2413 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2414 0 \
2415 -s "Read from client: 16384 bytes read"
2416
2417run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2418 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002419 "$P_CLI request_size=16384 force_version=tls1_2 \
2420 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002421 0 \
2422 -s "Read from client: 16384 bytes read"
2423
2424run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2425 "$P_SRV" \
2426 "$P_CLI request_size=16384 force_version=tls1_2 \
2427 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2428 trunc_hmac=1" \
2429 0 \
2430 -s "Read from client: 16384 bytes read"
2431
2432run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002433 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002434 "$P_CLI request_size=16384 force_version=tls1_2 \
2435 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2436 0 \
2437 -s "Read from client: 16384 bytes read"
2438
2439run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002440 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002441 "$P_CLI request_size=16384 force_version=tls1_2 \
2442 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2443 trunc_hmac=1" \
2444 0 \
2445 -s "Read from client: 16384 bytes read"
2446
2447run_test "Large packet TLS 1.2 AEAD" \
2448 "$P_SRV" \
2449 "$P_CLI request_size=16384 force_version=tls1_2 \
2450 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2451 0 \
2452 -s "Read from client: 16384 bytes read"
2453
2454run_test "Large packet TLS 1.2 AEAD shorter tag" \
2455 "$P_SRV" \
2456 "$P_CLI request_size=16384 force_version=tls1_2 \
2457 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2458 0 \
2459 -s "Read from client: 16384 bytes read"
2460
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002461# Final report
2462
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002463echo "------------------------------------------------------------------------"
2464
2465if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002466 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002467else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002468 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002469fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002470PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002471echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002472
2473exit $FAILS