blob: f1ff9172011c449a53a74b7d111cee443877eb82 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
21O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
23G_CLI="$GNUTLS_CLI"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010037 printf " -h|--help\tPrint this help.\n"
38 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
39 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
40 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
78 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020083# skip next test if OpenSSL doesn't support FALLBACK_SCSV
84requires_openssl_with_fallback_scsv() {
85 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
86 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
87 then
88 OPENSSL_HAS_FBSCSV="YES"
89 else
90 OPENSSL_HAS_FBSCSV="NO"
91 fi
92 fi
93 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
94 SKIP_NEXT="YES"
95 fi
96}
97
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020098# skip next test if GnuTLS isn't available
99requires_gnutls() {
100 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
101 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
102 GNUTLS_AVAILABLE="YES"
103 else
104 GNUTLS_AVAILABLE="NO"
105 fi
106 fi
107 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
108 SKIP_NEXT="YES"
109 fi
110}
111
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100112# print_name <name>
113print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100114 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200115 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100116 for i in `seq 1 $LEN`; do printf '.'; done
117 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100118
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200119 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100120}
121
122# fail <message>
123fail() {
124 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100125 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100126
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200127 mv $SRV_OUT o-srv-${TESTS}.log
128 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100129 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100130
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200131 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
132 echo " ! server output:"
133 cat o-srv-${TESTS}.log
134 echo " ! ============================================================"
135 echo " ! client output:"
136 cat o-cli-${TESTS}.log
137 fi
138
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200139 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100140}
141
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100142# is_polar <cmd_line>
143is_polar() {
144 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
145}
146
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100147# has_mem_err <log_file_name>
148has_mem_err() {
149 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
150 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
151 then
152 return 1 # false: does not have errors
153 else
154 return 0 # true: has errors
155 fi
156}
157
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200158# wait for server to start: two versions depending on lsof availability
159wait_server_start() {
160 if which lsof >/dev/null; then
161 # make sure we don't loop forever
162 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
163 WATCHDOG_PID=$!
164
165 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100166 until lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null;
167 do :; done
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200168
169 kill $WATCHDOG_PID
170 wait $WATCHDOG_PID
171 else
172 sleep "$START_DELAY"
173 fi
174}
175
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200176# wait for client to terminate and set CLI_EXIT
177# must be called right after starting the client
178wait_client_done() {
179 CLI_PID=$!
180
181 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
182 WATCHDOG_PID=$!
183
184 wait $CLI_PID
185 CLI_EXIT=$?
186
187 kill $WATCHDOG_PID
188 wait $WATCHDOG_PID
189
190 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
191}
192
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100193# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100194# Options: -s pattern pattern that must be present in server output
195# -c pattern pattern that must be present in client output
196# -S pattern pattern that must be absent in server output
197# -C pattern pattern that must be absent in client output
198run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100199 NAME="$1"
200 SRV_CMD="$2"
201 CLI_CMD="$3"
202 CLI_EXPECT="$4"
203 shift 4
204
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100205 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
206 else
207 return
208 fi
209
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100210 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100211
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200212 # should we skip?
213 if [ "X$SKIP_NEXT" = "XYES" ]; then
214 SKIP_NEXT="NO"
215 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200216 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200217 return
218 fi
219
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100220 # prepend valgrind to our commands if active
221 if [ "$MEMCHECK" -gt 0 ]; then
222 if is_polar "$SRV_CMD"; then
223 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
224 fi
225 if is_polar "$CLI_CMD"; then
226 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
227 fi
228 fi
229
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100230 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200231 echo "$SRV_CMD" > $SRV_OUT
232 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100233 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200234 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200235
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200236 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200237 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
238 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100239
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200240 # kill the server
241 kill $SRV_PID
242 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100243
244 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200245 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100246 # expected client exit to incorrectly succeed in case of catastrophic
247 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100248 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200249 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100250 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100251 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100252 return
253 fi
254 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100255 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200256 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100257 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100258 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100259 return
260 fi
261 fi
262
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100263 # check server exit code
264 if [ $? != 0 ]; then
265 fail "server fail"
266 return
267 fi
268
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100269 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100270 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
271 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100272 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100273 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100274 return
275 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100276
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100277 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200278 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100279 while [ $# -gt 0 ]
280 do
281 case $1 in
282 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200283 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100284 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100285 return
286 fi
287 ;;
288
289 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200290 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100291 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100292 return
293 fi
294 ;;
295
296 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200297 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100298 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299 return
300 fi
301 ;;
302
303 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200304 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100305 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100306 return
307 fi
308 ;;
309
310 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200311 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100312 exit 1
313 esac
314 shift 2
315 done
316
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100317 # check valgrind's results
318 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200319 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100320 fail "Server has memory errors"
321 return
322 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200323 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100324 fail "Client has memory errors"
325 return
326 fi
327 fi
328
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100329 # if we're here, everything is ok
330 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200331 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100332}
333
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100334cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200335 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200336 kill $SRV_PID >/dev/null 2>&1
337 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100338 exit 1
339}
340
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100341#
342# MAIN
343#
344
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100345get_options "$@"
346
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100347# sanity checks, avoid an avalanche of errors
348if [ ! -x "$P_SRV" ]; then
349 echo "Command '$P_SRV' is not an executable file"
350 exit 1
351fi
352if [ ! -x "$P_CLI" ]; then
353 echo "Command '$P_CLI' is not an executable file"
354 exit 1
355fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100356if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
357 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100358 exit 1
359fi
360
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200361# used by watchdog
362MAIN_PID="$$"
363
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200364# be more patient with valgrind
365if [ "$MEMCHECK" -gt 0 ]; then
366 START_DELAY=3
367 DOG_DELAY=30
368else
369 START_DELAY=1
370 DOG_DELAY=10
371fi
372
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200373# Pick a "unique" port in the range 10000-19999.
374PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200375PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200376
377# fix commands to use this port
378P_SRV="$P_SRV server_port=$PORT"
379P_CLI="$P_CLI server_port=$PORT"
380O_SRV="$O_SRV -accept $PORT"
381O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200382G_SRV="$G_SRV -p $PORT"
383G_CLI="$G_CLI -p $PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200384
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200385# Also pick a unique name for intermediate files
386SRV_OUT="srv_out.$$"
387CLI_OUT="cli_out.$$"
388SESSION="session.$$"
389
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200390SKIP_NEXT="NO"
391
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100392trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100393
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200394# Basic test
395
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200396# Checks that:
397# - things work with all ciphersuites active (used with config-full in all.sh)
398# - the expected (highest security) parameters are selected
399# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200400run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200401 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200402 "$P_CLI" \
403 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200404 -s "Protocol is TLSv1.2" \
405 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
406 -s "client hello v3, signature_algorithm ext: 6" \
407 -s "ECDHE curve: secp521r1" \
408 -S "error" \
409 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200410
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100411# Test for SSLv2 ClientHello
412
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200413requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200414run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100415 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100416 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100417 0 \
418 -S "parse client hello v2" \
419 -S "ssl_handshake returned"
420
421# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200422requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200423run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200424 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100425 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100426 0 \
427 -s "parse client hello v2" \
428 -S "ssl_handshake returned"
429
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100430# Tests for Truncated HMAC extension
431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200432run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200433 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100434 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100435 0 \
436 -s "dumping 'computed mac' (20 bytes)"
437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200438run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200439 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100440 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100441 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100442 -s "dumping 'computed mac' (10 bytes)"
443
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100444# Tests for Encrypt-then-MAC extension
445
446run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100447 "$P_SRV debug_level=3 \
448 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100449 "$P_CLI debug_level=3" \
450 0 \
451 -c "client hello, adding encrypt_then_mac extension" \
452 -s "found encrypt then mac extension" \
453 -s "server hello, adding encrypt then mac extension" \
454 -c "found encrypt_then_mac extension" \
455 -c "using encrypt then mac" \
456 -s "using encrypt then mac"
457
458run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100459 "$P_SRV debug_level=3 etm=0 \
460 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100461 "$P_CLI debug_level=3 etm=1" \
462 0 \
463 -c "client hello, adding encrypt_then_mac extension" \
464 -s "found encrypt then mac extension" \
465 -S "server hello, adding encrypt then mac extension" \
466 -C "found encrypt_then_mac extension" \
467 -C "using encrypt then mac" \
468 -S "using encrypt then mac"
469
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100470run_test "Encrypt then MAC: client enabled, aead cipher" \
471 "$P_SRV debug_level=3 etm=1 \
472 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
473 "$P_CLI debug_level=3 etm=1" \
474 0 \
475 -c "client hello, adding encrypt_then_mac extension" \
476 -s "found encrypt then mac extension" \
477 -S "server hello, adding encrypt then mac extension" \
478 -C "found encrypt_then_mac extension" \
479 -C "using encrypt then mac" \
480 -S "using encrypt then mac"
481
482run_test "Encrypt then MAC: client enabled, stream cipher" \
483 "$P_SRV debug_level=3 etm=1 \
484 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
485 "$P_CLI debug_level=3 etm=1" \
486 0 \
487 -c "client hello, adding encrypt_then_mac extension" \
488 -s "found encrypt then mac extension" \
489 -S "server hello, adding encrypt then mac extension" \
490 -C "found encrypt_then_mac extension" \
491 -C "using encrypt then mac" \
492 -S "using encrypt then mac"
493
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100494run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100495 "$P_SRV debug_level=3 etm=1 \
496 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100497 "$P_CLI debug_level=3 etm=0" \
498 0 \
499 -C "client hello, adding encrypt_then_mac extension" \
500 -S "found encrypt then mac extension" \
501 -S "server hello, adding encrypt then mac extension" \
502 -C "found encrypt_then_mac extension" \
503 -C "using encrypt then mac" \
504 -S "using encrypt then mac"
505
506run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100507 "$P_SRV debug_level=3 \
508 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100509 "$P_CLI debug_level=3 force_version=ssl3" \
510 0 \
511 -C "client hello, adding encrypt_then_mac extension" \
512 -S "found encrypt then mac extension" \
513 -S "server hello, adding encrypt then mac extension" \
514 -C "found encrypt_then_mac extension" \
515 -C "using encrypt then mac" \
516 -S "using encrypt then mac"
517
518run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100519 "$P_SRV debug_level=3 force_version=ssl3 \
520 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100521 "$P_CLI debug_level=3" \
522 0 \
523 -c "client hello, adding encrypt_then_mac extension" \
524 -s "found encrypt then mac extension" \
525 -S "server hello, adding encrypt then mac extension" \
526 -C "found encrypt_then_mac extension" \
527 -C "using encrypt then mac" \
528 -S "using encrypt then mac"
529
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200530# Tests for Extended Master Secret extension
531
532run_test "Extended Master Secret: default" \
533 "$P_SRV debug_level=3" \
534 "$P_CLI debug_level=3" \
535 0 \
536 -c "client hello, adding extended_master_secret extension" \
537 -s "found extended master secret extension" \
538 -s "server hello, adding extended master secret extension" \
539 -c "found extended_master_secret extension" \
540 -c "using extended master secret" \
541 -s "using extended master secret"
542
543run_test "Extended Master Secret: client enabled, server disabled" \
544 "$P_SRV debug_level=3 extended_ms=0" \
545 "$P_CLI debug_level=3 extended_ms=1" \
546 0 \
547 -c "client hello, adding extended_master_secret extension" \
548 -s "found extended master secret extension" \
549 -S "server hello, adding extended master secret extension" \
550 -C "found extended_master_secret extension" \
551 -C "using extended master secret" \
552 -S "using extended master secret"
553
554run_test "Extended Master Secret: client disabled, server enabled" \
555 "$P_SRV debug_level=3 extended_ms=1" \
556 "$P_CLI debug_level=3 extended_ms=0" \
557 0 \
558 -C "client hello, adding extended_master_secret extension" \
559 -S "found extended master secret extension" \
560 -S "server hello, adding extended master secret extension" \
561 -C "found extended_master_secret extension" \
562 -C "using extended master secret" \
563 -S "using extended master secret"
564
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200565run_test "Extended Master Secret: client SSLv3, server enabled" \
566 "$P_SRV debug_level=3" \
567 "$P_CLI debug_level=3 force_version=ssl3" \
568 0 \
569 -C "client hello, adding extended_master_secret extension" \
570 -S "found extended master secret extension" \
571 -S "server hello, adding extended master secret extension" \
572 -C "found extended_master_secret extension" \
573 -C "using extended master secret" \
574 -S "using extended master secret"
575
576run_test "Extended Master Secret: client enabled, server SSLv3" \
577 "$P_SRV debug_level=3 force_version=ssl3" \
578 "$P_CLI debug_level=3" \
579 0 \
580 -c "client hello, adding extended_master_secret extension" \
581 -s "found extended master secret extension" \
582 -S "server hello, adding extended master secret extension" \
583 -C "found extended_master_secret extension" \
584 -C "using extended master secret" \
585 -S "using extended master secret"
586
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200587# Tests for FALLBACK_SCSV
588
589run_test "Fallback SCSV: default" \
590 "$P_SRV" \
591 "$P_CLI debug_level=3 force_version=tls1_1" \
592 0 \
593 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200594 -S "received FALLBACK_SCSV" \
595 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200596 -C "is a fatal alert message (msg 86)"
597
598run_test "Fallback SCSV: explicitly disabled" \
599 "$P_SRV" \
600 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
601 0 \
602 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200603 -S "received FALLBACK_SCSV" \
604 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200605 -C "is a fatal alert message (msg 86)"
606
607run_test "Fallback SCSV: enabled" \
608 "$P_SRV" \
609 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200610 1 \
611 -c "adding FALLBACK_SCSV" \
612 -s "received FALLBACK_SCSV" \
613 -s "inapropriate fallback" \
614 -c "is a fatal alert message (msg 86)"
615
616run_test "Fallback SCSV: enabled, max version" \
617 "$P_SRV" \
618 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200619 0 \
620 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200621 -s "received FALLBACK_SCSV" \
622 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200623 -C "is a fatal alert message (msg 86)"
624
625requires_openssl_with_fallback_scsv
626run_test "Fallback SCSV: default, openssl server" \
627 "$O_SRV" \
628 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
629 0 \
630 -C "adding FALLBACK_SCSV" \
631 -C "is a fatal alert message (msg 86)"
632
633requires_openssl_with_fallback_scsv
634run_test "Fallback SCSV: enabled, openssl server" \
635 "$O_SRV" \
636 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
637 1 \
638 -c "adding FALLBACK_SCSV" \
639 -c "is a fatal alert message (msg 86)"
640
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200641requires_openssl_with_fallback_scsv
642run_test "Fallback SCSV: disabled, openssl client" \
643 "$P_SRV" \
644 "$O_CLI -tls1_1" \
645 0 \
646 -S "received FALLBACK_SCSV" \
647 -S "inapropriate fallback"
648
649requires_openssl_with_fallback_scsv
650run_test "Fallback SCSV: enabled, openssl client" \
651 "$P_SRV" \
652 "$O_CLI -tls1_1 -fallback_scsv" \
653 1 \
654 -s "received FALLBACK_SCSV" \
655 -s "inapropriate fallback"
656
657requires_openssl_with_fallback_scsv
658run_test "Fallback SCSV: enabled, max version, openssl client" \
659 "$P_SRV" \
660 "$O_CLI -fallback_scsv" \
661 0 \
662 -s "received FALLBACK_SCSV" \
663 -S "inapropriate fallback"
664
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100665# Tests for Session Tickets
666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200667run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200668 "$P_SRV debug_level=3 tickets=1" \
669 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100670 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100671 -c "client hello, adding session ticket extension" \
672 -s "found session ticket extension" \
673 -s "server hello, adding session ticket extension" \
674 -c "found session_ticket extension" \
675 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100676 -S "session successfully restored from cache" \
677 -s "session successfully restored from ticket" \
678 -s "a session has been resumed" \
679 -c "a session has been resumed"
680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200681run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200682 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
683 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100684 0 \
685 -c "client hello, adding session ticket extension" \
686 -s "found session ticket extension" \
687 -s "server hello, adding session ticket extension" \
688 -c "found session_ticket extension" \
689 -c "parse new session ticket" \
690 -S "session successfully restored from cache" \
691 -s "session successfully restored from ticket" \
692 -s "a session has been resumed" \
693 -c "a session has been resumed"
694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200695run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200696 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
697 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100698 0 \
699 -c "client hello, adding session ticket extension" \
700 -s "found session ticket extension" \
701 -s "server hello, adding session ticket extension" \
702 -c "found session_ticket extension" \
703 -c "parse new session ticket" \
704 -S "session successfully restored from cache" \
705 -S "session successfully restored from ticket" \
706 -S "a session has been resumed" \
707 -C "a session has been resumed"
708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200709run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100710 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200711 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100712 0 \
713 -c "client hello, adding session ticket extension" \
714 -c "found session_ticket extension" \
715 -c "parse new session ticket" \
716 -c "a session has been resumed"
717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200718run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200719 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200720 "( $O_CLI -sess_out $SESSION; \
721 $O_CLI -sess_in $SESSION; \
722 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100723 0 \
724 -s "found session ticket extension" \
725 -s "server hello, adding session ticket extension" \
726 -S "session successfully restored from cache" \
727 -s "session successfully restored from ticket" \
728 -s "a session has been resumed"
729
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100730# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200732run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200733 "$P_SRV debug_level=3 tickets=0" \
734 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100735 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100736 -c "client hello, adding session ticket extension" \
737 -s "found session ticket extension" \
738 -S "server hello, adding session ticket extension" \
739 -C "found session_ticket extension" \
740 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100741 -s "session successfully restored from cache" \
742 -S "session successfully restored from ticket" \
743 -s "a session has been resumed" \
744 -c "a session has been resumed"
745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200746run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200747 "$P_SRV debug_level=3 tickets=1" \
748 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100749 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100750 -C "client hello, adding session ticket extension" \
751 -S "found session ticket extension" \
752 -S "server hello, adding session ticket extension" \
753 -C "found session_ticket extension" \
754 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100755 -s "session successfully restored from cache" \
756 -S "session successfully restored from ticket" \
757 -s "a session has been resumed" \
758 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200760run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200761 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
762 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100763 0 \
764 -S "session successfully restored from cache" \
765 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100766 -S "a session has been resumed" \
767 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200769run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200770 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
771 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100772 0 \
773 -s "session successfully restored from cache" \
774 -S "session successfully restored from ticket" \
775 -s "a session has been resumed" \
776 -c "a session has been resumed"
777
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200778run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200779 "$P_SRV debug_level=3 tickets=0" \
780 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100781 0 \
782 -s "session successfully restored from cache" \
783 -S "session successfully restored from ticket" \
784 -s "a session has been resumed" \
785 -c "a session has been resumed"
786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200787run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200788 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
789 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100790 0 \
791 -S "session successfully restored from cache" \
792 -S "session successfully restored from ticket" \
793 -S "a session has been resumed" \
794 -C "a session has been resumed"
795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200796run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200797 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
798 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100799 0 \
800 -s "session successfully restored from cache" \
801 -S "session successfully restored from ticket" \
802 -s "a session has been resumed" \
803 -c "a session has been resumed"
804
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200805run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200806 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200807 "( $O_CLI -sess_out $SESSION; \
808 $O_CLI -sess_in $SESSION; \
809 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100810 0 \
811 -s "found session ticket extension" \
812 -S "server hello, adding session ticket extension" \
813 -s "session successfully restored from cache" \
814 -S "session successfully restored from ticket" \
815 -s "a session has been resumed"
816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200817run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100818 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200819 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100820 0 \
821 -C "found session_ticket extension" \
822 -C "parse new session ticket" \
823 -c "a session has been resumed"
824
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100825# Tests for Max Fragment Length extension
826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200827run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200828 "$P_SRV debug_level=3" \
829 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100830 0 \
831 -C "client hello, adding max_fragment_length extension" \
832 -S "found max fragment length extension" \
833 -S "server hello, max_fragment_length extension" \
834 -C "found max_fragment_length extension"
835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200836run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200837 "$P_SRV debug_level=3" \
838 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100839 0 \
840 -c "client hello, adding max_fragment_length extension" \
841 -s "found max fragment length extension" \
842 -s "server hello, max_fragment_length extension" \
843 -c "found max_fragment_length extension"
844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200845run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200846 "$P_SRV debug_level=3 max_frag_len=4096" \
847 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100848 0 \
849 -C "client hello, adding max_fragment_length extension" \
850 -S "found max fragment length extension" \
851 -S "server hello, max_fragment_length extension" \
852 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200854requires_gnutls
855run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200856 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200857 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200858 0 \
859 -c "client hello, adding max_fragment_length extension" \
860 -c "found max_fragment_length extension"
861
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100862# Tests for renegotiation
863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200864run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200865 "$P_SRV debug_level=3 exchanges=2" \
866 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100867 0 \
868 -C "client hello, adding renegotiation extension" \
869 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
870 -S "found renegotiation extension" \
871 -s "server hello, secure renegotiation extension" \
872 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100873 -C "=> renegotiate" \
874 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100875 -S "write hello request"
876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200877run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200878 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
879 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100880 0 \
881 -c "client hello, adding renegotiation extension" \
882 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
883 -s "found renegotiation extension" \
884 -s "server hello, secure renegotiation extension" \
885 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100886 -c "=> renegotiate" \
887 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100888 -S "write hello request"
889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200890run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200891 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
892 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100893 0 \
894 -c "client hello, adding renegotiation extension" \
895 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
896 -s "found renegotiation extension" \
897 -s "server hello, secure renegotiation extension" \
898 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100899 -c "=> renegotiate" \
900 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100901 -s "write hello request"
902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200903run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200904 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
905 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100906 0 \
907 -c "client hello, adding renegotiation extension" \
908 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
909 -s "found renegotiation extension" \
910 -s "server hello, secure renegotiation extension" \
911 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100912 -c "=> renegotiate" \
913 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100914 -s "write hello request"
915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200916run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200917 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
918 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100919 1 \
920 -c "client hello, adding renegotiation extension" \
921 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
922 -S "found renegotiation extension" \
923 -s "server hello, secure renegotiation extension" \
924 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100925 -c "=> renegotiate" \
926 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200927 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200928 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200929 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200931run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200932 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
933 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100934 0 \
935 -C "client hello, adding renegotiation extension" \
936 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
937 -S "found renegotiation extension" \
938 -s "server hello, secure renegotiation extension" \
939 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100940 -C "=> renegotiate" \
941 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100942 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200943 -S "SSL - An unexpected message was received from our peer" \
944 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200946run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200947 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200948 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200949 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200950 0 \
951 -C "client hello, adding renegotiation extension" \
952 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
953 -S "found renegotiation extension" \
954 -s "server hello, secure renegotiation extension" \
955 -c "found renegotiation extension" \
956 -C "=> renegotiate" \
957 -S "=> renegotiate" \
958 -s "write hello request" \
959 -S "SSL - An unexpected message was received from our peer" \
960 -S "failed"
961
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200962# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200963run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200964 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200965 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200966 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200967 0 \
968 -C "client hello, adding renegotiation extension" \
969 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
970 -S "found renegotiation extension" \
971 -s "server hello, secure renegotiation extension" \
972 -c "found renegotiation extension" \
973 -C "=> renegotiate" \
974 -S "=> renegotiate" \
975 -s "write hello request" \
976 -S "SSL - An unexpected message was received from our peer" \
977 -S "failed"
978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200979run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200980 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200981 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200982 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200983 0 \
984 -C "client hello, adding renegotiation extension" \
985 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
986 -S "found renegotiation extension" \
987 -s "server hello, secure renegotiation extension" \
988 -c "found renegotiation extension" \
989 -C "=> renegotiate" \
990 -S "=> renegotiate" \
991 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200992 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200994run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200995 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200996 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200997 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200998 0 \
999 -c "client hello, adding renegotiation extension" \
1000 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1001 -s "found renegotiation extension" \
1002 -s "server hello, secure renegotiation extension" \
1003 -c "found renegotiation extension" \
1004 -c "=> renegotiate" \
1005 -s "=> renegotiate" \
1006 -s "write hello request" \
1007 -S "SSL - An unexpected message was received from our peer" \
1008 -S "failed"
1009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001010run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001011 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1012 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001013 0 \
1014 -c "client hello, adding renegotiation extension" \
1015 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1016 -s "found renegotiation extension" \
1017 -s "server hello, secure renegotiation extension" \
1018 -c "found renegotiation extension" \
1019 -c "=> renegotiate" \
1020 -s "=> renegotiate" \
1021 -S "write hello request"
1022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001023run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001024 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1025 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001026 0 \
1027 -c "client hello, adding renegotiation extension" \
1028 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1029 -s "found renegotiation extension" \
1030 -s "server hello, secure renegotiation extension" \
1031 -c "found renegotiation extension" \
1032 -c "=> renegotiate" \
1033 -s "=> renegotiate" \
1034 -s "write hello request"
1035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001036run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001037 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001038 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001039 0 \
1040 -c "client hello, adding renegotiation extension" \
1041 -c "found renegotiation extension" \
1042 -c "=> renegotiate" \
1043 -C "ssl_handshake returned" \
1044 -C "error" \
1045 -c "HTTP/1.0 200 [Oo][Kk]"
1046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001047run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001048 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001049 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001050 0 \
1051 -c "client hello, adding renegotiation extension" \
1052 -c "found renegotiation extension" \
1053 -c "=> renegotiate" \
1054 -C "ssl_handshake returned" \
1055 -C "error" \
1056 -c "HTTP/1.0 200 [Oo][Kk]"
1057
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001058# Tests for auth_mode
1059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001060run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001061 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001062 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001063 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001064 1 \
1065 -c "x509_verify_cert() returned" \
1066 -c "! self-signed or not signed by a trusted CA" \
1067 -c "! ssl_handshake returned" \
1068 -c "X509 - Certificate verification failed"
1069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001070run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001071 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001072 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001073 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001074 0 \
1075 -c "x509_verify_cert() returned" \
1076 -c "! self-signed or not signed by a trusted CA" \
1077 -C "! ssl_handshake returned" \
1078 -C "X509 - Certificate verification failed"
1079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001080run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001081 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001082 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001083 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001084 0 \
1085 -C "x509_verify_cert() returned" \
1086 -C "! self-signed or not signed by a trusted CA" \
1087 -C "! ssl_handshake returned" \
1088 -C "X509 - Certificate verification failed"
1089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001090run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001091 "$P_SRV debug_level=3 auth_mode=required" \
1092 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001093 key_file=data_files/server5.key" \
1094 1 \
1095 -S "skip write certificate request" \
1096 -C "skip parse certificate request" \
1097 -c "got a certificate request" \
1098 -C "skip write certificate" \
1099 -C "skip write certificate verify" \
1100 -S "skip parse certificate verify" \
1101 -s "x509_verify_cert() returned" \
1102 -S "! self-signed or not signed by a trusted CA" \
1103 -s "! ssl_handshake returned" \
1104 -c "! ssl_handshake returned" \
1105 -s "X509 - Certificate verification failed"
1106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001107run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001108 "$P_SRV debug_level=3 auth_mode=optional" \
1109 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001110 key_file=data_files/server5.key" \
1111 0 \
1112 -S "skip write certificate request" \
1113 -C "skip parse certificate request" \
1114 -c "got a certificate request" \
1115 -C "skip write certificate" \
1116 -C "skip write certificate verify" \
1117 -S "skip parse certificate verify" \
1118 -s "x509_verify_cert() returned" \
1119 -s "! self-signed or not signed by a trusted CA" \
1120 -S "! ssl_handshake returned" \
1121 -C "! ssl_handshake returned" \
1122 -S "X509 - Certificate verification failed"
1123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001124run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001125 "$P_SRV debug_level=3 auth_mode=none" \
1126 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001127 key_file=data_files/server5.key" \
1128 0 \
1129 -s "skip write certificate request" \
1130 -C "skip parse certificate request" \
1131 -c "got no certificate request" \
1132 -c "skip write certificate" \
1133 -c "skip write certificate verify" \
1134 -s "skip parse certificate verify" \
1135 -S "x509_verify_cert() returned" \
1136 -S "! self-signed or not signed by a trusted CA" \
1137 -S "! ssl_handshake returned" \
1138 -C "! ssl_handshake returned" \
1139 -S "X509 - Certificate verification failed"
1140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001141run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001142 "$P_SRV debug_level=3 auth_mode=optional" \
1143 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001144 0 \
1145 -S "skip write certificate request" \
1146 -C "skip parse certificate request" \
1147 -c "got a certificate request" \
1148 -C "skip write certificate$" \
1149 -C "got no certificate to send" \
1150 -S "SSLv3 client has no certificate" \
1151 -c "skip write certificate verify" \
1152 -s "skip parse certificate verify" \
1153 -s "! no client certificate sent" \
1154 -S "! ssl_handshake returned" \
1155 -C "! ssl_handshake returned" \
1156 -S "X509 - Certificate verification failed"
1157
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001158run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001159 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001160 "$O_CLI" \
1161 0 \
1162 -S "skip write certificate request" \
1163 -s "skip parse certificate verify" \
1164 -s "! no client certificate sent" \
1165 -S "! ssl_handshake returned" \
1166 -S "X509 - Certificate verification failed"
1167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001168run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001169 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001170 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001171 0 \
1172 -C "skip parse certificate request" \
1173 -c "got a certificate request" \
1174 -C "skip write certificate$" \
1175 -c "skip write certificate verify" \
1176 -C "! ssl_handshake returned"
1177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001178run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001179 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1180 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001181 0 \
1182 -S "skip write certificate request" \
1183 -C "skip parse certificate request" \
1184 -c "got a certificate request" \
1185 -C "skip write certificate$" \
1186 -c "skip write certificate verify" \
1187 -c "got no certificate to send" \
1188 -s "SSLv3 client has no certificate" \
1189 -s "skip parse certificate verify" \
1190 -s "! no client certificate sent" \
1191 -S "! ssl_handshake returned" \
1192 -C "! ssl_handshake returned" \
1193 -S "X509 - Certificate verification failed"
1194
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001195# tests for SNI
1196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001197run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001198 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001199 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001200 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001201 server_name=localhost" \
1202 0 \
1203 -S "parse ServerName extension" \
1204 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1205 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001207run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001208 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001209 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001210 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 +01001211 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001212 server_name=localhost" \
1213 0 \
1214 -s "parse ServerName extension" \
1215 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1216 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001218run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001219 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001220 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001221 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 +01001222 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001223 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001224 0 \
1225 -s "parse ServerName extension" \
1226 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001227 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001230 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001231 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001232 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 +01001233 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001234 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001235 1 \
1236 -s "parse ServerName extension" \
1237 -s "ssl_sni_wrapper() returned" \
1238 -s "ssl_handshake returned" \
1239 -c "ssl_handshake returned" \
1240 -c "SSL - A fatal alert message was received from our peer"
1241
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001242# Tests for non-blocking I/O: exercise a variety of handshake flows
1243
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001244run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001245 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1246 "$P_CLI nbio=2 tickets=0" \
1247 0 \
1248 -S "ssl_handshake returned" \
1249 -C "ssl_handshake returned" \
1250 -c "Read from server: .* bytes read"
1251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001252run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001253 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1254 "$P_CLI nbio=2 tickets=0" \
1255 0 \
1256 -S "ssl_handshake returned" \
1257 -C "ssl_handshake returned" \
1258 -c "Read from server: .* bytes read"
1259
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001260run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001261 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1262 "$P_CLI nbio=2 tickets=1" \
1263 0 \
1264 -S "ssl_handshake returned" \
1265 -C "ssl_handshake returned" \
1266 -c "Read from server: .* bytes read"
1267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001268run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001269 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1270 "$P_CLI nbio=2 tickets=1" \
1271 0 \
1272 -S "ssl_handshake returned" \
1273 -C "ssl_handshake returned" \
1274 -c "Read from server: .* bytes read"
1275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001276run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001277 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1278 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1279 0 \
1280 -S "ssl_handshake returned" \
1281 -C "ssl_handshake returned" \
1282 -c "Read from server: .* bytes read"
1283
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001284run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001285 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1286 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1287 0 \
1288 -S "ssl_handshake returned" \
1289 -C "ssl_handshake returned" \
1290 -c "Read from server: .* bytes read"
1291
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001292run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001293 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1294 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1295 0 \
1296 -S "ssl_handshake returned" \
1297 -C "ssl_handshake returned" \
1298 -c "Read from server: .* bytes read"
1299
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001300# Tests for version negotiation
1301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001302run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001303 "$P_SRV" \
1304 "$P_CLI" \
1305 0 \
1306 -S "ssl_handshake returned" \
1307 -C "ssl_handshake returned" \
1308 -s "Protocol is TLSv1.2" \
1309 -c "Protocol is TLSv1.2"
1310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001311run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001312 "$P_SRV" \
1313 "$P_CLI max_version=tls1_1" \
1314 0 \
1315 -S "ssl_handshake returned" \
1316 -C "ssl_handshake returned" \
1317 -s "Protocol is TLSv1.1" \
1318 -c "Protocol is TLSv1.1"
1319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001320run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001321 "$P_SRV max_version=tls1_1" \
1322 "$P_CLI" \
1323 0 \
1324 -S "ssl_handshake returned" \
1325 -C "ssl_handshake returned" \
1326 -s "Protocol is TLSv1.1" \
1327 -c "Protocol is TLSv1.1"
1328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001329run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001330 "$P_SRV max_version=tls1_1" \
1331 "$P_CLI max_version=tls1_1" \
1332 0 \
1333 -S "ssl_handshake returned" \
1334 -C "ssl_handshake returned" \
1335 -s "Protocol is TLSv1.1" \
1336 -c "Protocol is TLSv1.1"
1337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001338run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001339 "$P_SRV min_version=tls1_1" \
1340 "$P_CLI max_version=tls1_1" \
1341 0 \
1342 -S "ssl_handshake returned" \
1343 -C "ssl_handshake returned" \
1344 -s "Protocol is TLSv1.1" \
1345 -c "Protocol is TLSv1.1"
1346
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001347run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001348 "$P_SRV max_version=tls1_1" \
1349 "$P_CLI min_version=tls1_1" \
1350 0 \
1351 -S "ssl_handshake returned" \
1352 -C "ssl_handshake returned" \
1353 -s "Protocol is TLSv1.1" \
1354 -c "Protocol is TLSv1.1"
1355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001356run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001357 "$P_SRV max_version=tls1_1" \
1358 "$P_CLI min_version=tls1_2" \
1359 1 \
1360 -s "ssl_handshake returned" \
1361 -c "ssl_handshake returned" \
1362 -c "SSL - Handshake protocol not within min/max boundaries"
1363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001364run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001365 "$P_SRV min_version=tls1_2" \
1366 "$P_CLI max_version=tls1_1" \
1367 1 \
1368 -s "ssl_handshake returned" \
1369 -c "ssl_handshake returned" \
1370 -s "SSL - Handshake protocol not within min/max boundaries"
1371
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001372# Tests for ALPN extension
1373
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001374if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1375
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001376run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001377 "$P_SRV debug_level=3" \
1378 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001379 0 \
1380 -C "client hello, adding alpn extension" \
1381 -S "found alpn extension" \
1382 -C "got an alert message, type: \\[2:120]" \
1383 -S "server hello, adding alpn extension" \
1384 -C "found alpn extension " \
1385 -C "Application Layer Protocol is" \
1386 -S "Application Layer Protocol is"
1387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001388run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001389 "$P_SRV debug_level=3" \
1390 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001391 0 \
1392 -c "client hello, adding alpn extension" \
1393 -s "found alpn extension" \
1394 -C "got an alert message, type: \\[2:120]" \
1395 -S "server hello, adding alpn extension" \
1396 -C "found alpn extension " \
1397 -c "Application Layer Protocol is (none)" \
1398 -S "Application Layer Protocol is"
1399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001400run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001401 "$P_SRV debug_level=3 alpn=abc,1234" \
1402 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001403 0 \
1404 -C "client hello, adding alpn extension" \
1405 -S "found alpn extension" \
1406 -C "got an alert message, type: \\[2:120]" \
1407 -S "server hello, adding alpn extension" \
1408 -C "found alpn extension " \
1409 -C "Application Layer Protocol is" \
1410 -s "Application Layer Protocol is (none)"
1411
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001412run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001413 "$P_SRV debug_level=3 alpn=abc,1234" \
1414 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001415 0 \
1416 -c "client hello, adding alpn extension" \
1417 -s "found alpn extension" \
1418 -C "got an alert message, type: \\[2:120]" \
1419 -s "server hello, adding alpn extension" \
1420 -c "found alpn extension" \
1421 -c "Application Layer Protocol is abc" \
1422 -s "Application Layer Protocol is abc"
1423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001424run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001425 "$P_SRV debug_level=3 alpn=abc,1234" \
1426 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001427 0 \
1428 -c "client hello, adding alpn extension" \
1429 -s "found alpn extension" \
1430 -C "got an alert message, type: \\[2:120]" \
1431 -s "server hello, adding alpn extension" \
1432 -c "found alpn extension" \
1433 -c "Application Layer Protocol is abc" \
1434 -s "Application Layer Protocol is abc"
1435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001436run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001437 "$P_SRV debug_level=3 alpn=abc,1234" \
1438 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001439 0 \
1440 -c "client hello, adding alpn extension" \
1441 -s "found alpn extension" \
1442 -C "got an alert message, type: \\[2:120]" \
1443 -s "server hello, adding alpn extension" \
1444 -c "found alpn extension" \
1445 -c "Application Layer Protocol is 1234" \
1446 -s "Application Layer Protocol is 1234"
1447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001448run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001449 "$P_SRV debug_level=3 alpn=abc,123" \
1450 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001451 1 \
1452 -c "client hello, adding alpn extension" \
1453 -s "found alpn extension" \
1454 -c "got an alert message, type: \\[2:120]" \
1455 -S "server hello, adding alpn extension" \
1456 -C "found alpn extension" \
1457 -C "Application Layer Protocol is 1234" \
1458 -S "Application Layer Protocol is 1234"
1459
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001460fi
1461
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001462# Tests for keyUsage in leaf certificates, part 1:
1463# server-side certificate/suite selection
1464
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001465run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001466 "$P_SRV key_file=data_files/server2.key \
1467 crt_file=data_files/server2.ku-ds.crt" \
1468 "$P_CLI" \
1469 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001470 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001471
1472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001473run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001474 "$P_SRV key_file=data_files/server2.key \
1475 crt_file=data_files/server2.ku-ke.crt" \
1476 "$P_CLI" \
1477 0 \
1478 -c "Ciphersuite is TLS-RSA-WITH-"
1479
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001480run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001481 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001482 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001483 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001484 1 \
1485 -C "Ciphersuite is "
1486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001487run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001488 "$P_SRV key_file=data_files/server5.key \
1489 crt_file=data_files/server5.ku-ds.crt" \
1490 "$P_CLI" \
1491 0 \
1492 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1493
1494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001495run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001496 "$P_SRV key_file=data_files/server5.key \
1497 crt_file=data_files/server5.ku-ka.crt" \
1498 "$P_CLI" \
1499 0 \
1500 -c "Ciphersuite is TLS-ECDH-"
1501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001502run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001503 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001504 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001505 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001506 1 \
1507 -C "Ciphersuite is "
1508
1509# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001510# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001512run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001513 "$O_SRV -key data_files/server2.key \
1514 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001515 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001516 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1517 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001518 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001519 -C "Processing of the Certificate handshake message failed" \
1520 -c "Ciphersuite is TLS-"
1521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001522run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001523 "$O_SRV -key data_files/server2.key \
1524 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001526 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1527 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001528 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001529 -C "Processing of the Certificate handshake message failed" \
1530 -c "Ciphersuite is TLS-"
1531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001532run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001533 "$O_SRV -key data_files/server2.key \
1534 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001535 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001536 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1537 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001538 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001539 -C "Processing of the Certificate handshake message failed" \
1540 -c "Ciphersuite is TLS-"
1541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001542run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001543 "$O_SRV -key data_files/server2.key \
1544 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001545 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001546 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1547 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001548 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001549 -c "Processing of the Certificate handshake message failed" \
1550 -C "Ciphersuite is TLS-"
1551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001552run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001553 "$O_SRV -key data_files/server2.key \
1554 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001555 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001556 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1557 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001558 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001559 -C "Processing of the Certificate handshake message failed" \
1560 -c "Ciphersuite is TLS-"
1561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001562run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001563 "$O_SRV -key data_files/server2.key \
1564 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001565 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001566 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1567 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001568 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001569 -c "Processing of the Certificate handshake message failed" \
1570 -C "Ciphersuite is TLS-"
1571
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001572# Tests for keyUsage in leaf certificates, part 3:
1573# server-side checking of client cert
1574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001575run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001576 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001577 "$O_CLI -key data_files/server2.key \
1578 -cert data_files/server2.ku-ds.crt" \
1579 0 \
1580 -S "bad certificate (usage extensions)" \
1581 -S "Processing of the Certificate handshake message failed"
1582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001583run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001584 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001585 "$O_CLI -key data_files/server2.key \
1586 -cert data_files/server2.ku-ke.crt" \
1587 0 \
1588 -s "bad certificate (usage extensions)" \
1589 -S "Processing of the Certificate handshake message failed"
1590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001591run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001592 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001593 "$O_CLI -key data_files/server2.key \
1594 -cert data_files/server2.ku-ke.crt" \
1595 1 \
1596 -s "bad certificate (usage extensions)" \
1597 -s "Processing of the Certificate handshake message failed"
1598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001599run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001600 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001601 "$O_CLI -key data_files/server5.key \
1602 -cert data_files/server5.ku-ds.crt" \
1603 0 \
1604 -S "bad certificate (usage extensions)" \
1605 -S "Processing of the Certificate handshake message failed"
1606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001607run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001608 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001609 "$O_CLI -key data_files/server5.key \
1610 -cert data_files/server5.ku-ka.crt" \
1611 0 \
1612 -s "bad certificate (usage extensions)" \
1613 -S "Processing of the Certificate handshake message failed"
1614
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001615# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001617run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001618 "$P_SRV key_file=data_files/server5.key \
1619 crt_file=data_files/server5.eku-srv.crt" \
1620 "$P_CLI" \
1621 0
1622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001623run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001624 "$P_SRV key_file=data_files/server5.key \
1625 crt_file=data_files/server5.eku-srv.crt" \
1626 "$P_CLI" \
1627 0
1628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001629run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001630 "$P_SRV key_file=data_files/server5.key \
1631 crt_file=data_files/server5.eku-cs_any.crt" \
1632 "$P_CLI" \
1633 0
1634
1635# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001636run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001637 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1638 crt_file=data_files/server5.eku-cli.crt" \
1639 "$P_CLI psk=badbad" \
1640 1
1641
1642# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1643
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001644run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001645 "$O_SRV -key data_files/server5.key \
1646 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001647 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001648 0 \
1649 -C "bad certificate (usage extensions)" \
1650 -C "Processing of the Certificate handshake message failed" \
1651 -c "Ciphersuite is TLS-"
1652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001653run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001654 "$O_SRV -key data_files/server5.key \
1655 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001656 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001657 0 \
1658 -C "bad certificate (usage extensions)" \
1659 -C "Processing of the Certificate handshake message failed" \
1660 -c "Ciphersuite is TLS-"
1661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001662run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001663 "$O_SRV -key data_files/server5.key \
1664 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001665 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001666 0 \
1667 -C "bad certificate (usage extensions)" \
1668 -C "Processing of the Certificate handshake message failed" \
1669 -c "Ciphersuite is TLS-"
1670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001671run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001672 "$O_SRV -key data_files/server5.key \
1673 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001674 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001675 1 \
1676 -c "bad certificate (usage extensions)" \
1677 -c "Processing of the Certificate handshake message failed" \
1678 -C "Ciphersuite is TLS-"
1679
1680# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001682run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001683 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001684 "$O_CLI -key data_files/server5.key \
1685 -cert data_files/server5.eku-cli.crt" \
1686 0 \
1687 -S "bad certificate (usage extensions)" \
1688 -S "Processing of the Certificate handshake message failed"
1689
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001690run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001691 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001692 "$O_CLI -key data_files/server5.key \
1693 -cert data_files/server5.eku-srv_cli.crt" \
1694 0 \
1695 -S "bad certificate (usage extensions)" \
1696 -S "Processing of the Certificate handshake message failed"
1697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001698run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001699 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001700 "$O_CLI -key data_files/server5.key \
1701 -cert data_files/server5.eku-cs_any.crt" \
1702 0 \
1703 -S "bad certificate (usage extensions)" \
1704 -S "Processing of the Certificate handshake message failed"
1705
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001706run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001707 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001708 "$O_CLI -key data_files/server5.key \
1709 -cert data_files/server5.eku-cs.crt" \
1710 0 \
1711 -s "bad certificate (usage extensions)" \
1712 -S "Processing of the Certificate handshake message failed"
1713
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001714run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001715 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001716 "$O_CLI -key data_files/server5.key \
1717 -cert data_files/server5.eku-cs.crt" \
1718 1 \
1719 -s "bad certificate (usage extensions)" \
1720 -s "Processing of the Certificate handshake message failed"
1721
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001722# Tests for DHM parameters loading
1723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001724run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001725 "$P_SRV" \
1726 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1727 debug_level=3" \
1728 0 \
1729 -c "value of 'DHM: P ' (2048 bits)" \
1730 -c "value of 'DHM: G ' (2048 bits)"
1731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001732run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001733 "$P_SRV dhm_file=data_files/dhparams.pem" \
1734 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1735 debug_level=3" \
1736 0 \
1737 -c "value of 'DHM: P ' (1024 bits)" \
1738 -c "value of 'DHM: G ' (2 bits)"
1739
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001740# Tests for PSK callback
1741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001742run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001743 "$P_SRV psk=abc123 psk_identity=foo" \
1744 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1745 psk_identity=foo psk=abc123" \
1746 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001747 -S "SSL - The server has no ciphersuites in common" \
1748 -S "SSL - Unknown identity received" \
1749 -S "SSL - Verification of the message MAC failed"
1750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001751run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001752 "$P_SRV" \
1753 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1754 psk_identity=foo psk=abc123" \
1755 1 \
1756 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001757 -S "SSL - Unknown identity received" \
1758 -S "SSL - Verification of the message MAC failed"
1759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001760run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001761 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1762 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1763 psk_identity=foo psk=abc123" \
1764 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001765 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001766 -s "SSL - Unknown identity received" \
1767 -S "SSL - Verification of the message MAC failed"
1768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001769run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001770 "$P_SRV psk_list=abc,dead,def,beef" \
1771 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1772 psk_identity=abc psk=dead" \
1773 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001774 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001775 -S "SSL - Unknown identity received" \
1776 -S "SSL - Verification of the message MAC failed"
1777
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001778run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001779 "$P_SRV psk_list=abc,dead,def,beef" \
1780 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1781 psk_identity=def psk=beef" \
1782 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001783 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001784 -S "SSL - Unknown identity received" \
1785 -S "SSL - Verification of the message MAC failed"
1786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001787run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001788 "$P_SRV psk_list=abc,dead,def,beef" \
1789 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1790 psk_identity=ghi psk=beef" \
1791 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001792 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001793 -s "SSL - Unknown identity received" \
1794 -S "SSL - Verification of the message MAC failed"
1795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001796run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001797 "$P_SRV psk_list=abc,dead,def,beef" \
1798 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1799 psk_identity=abc psk=beef" \
1800 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001801 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001802 -S "SSL - Unknown identity received" \
1803 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001804
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001805# Tests for ciphersuites per version
1806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001807run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001808 "$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" \
1809 "$P_CLI force_version=ssl3" \
1810 0 \
1811 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1812
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001813run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001814 "$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" \
1815 "$P_CLI force_version=tls1" \
1816 0 \
1817 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001819run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001820 "$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" \
1821 "$P_CLI force_version=tls1_1" \
1822 0 \
1823 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001825run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001826 "$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" \
1827 "$P_CLI force_version=tls1_2" \
1828 0 \
1829 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1830
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001831# Tests for ssl_get_bytes_avail()
1832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001833run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001834 "$P_SRV" \
1835 "$P_CLI request_size=100" \
1836 0 \
1837 -s "Read from client: 100 bytes read$"
1838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001839run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001840 "$P_SRV" \
1841 "$P_CLI request_size=500" \
1842 0 \
1843 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001844
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001845# Tests for small packets
1846
1847run_test "Small packet SSLv3 BlockCipher" \
1848 "$P_SRV" \
1849 "$P_CLI request_size=1 force_version=ssl3 \
1850 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1851 0 \
1852 -s "Read from client: 1 bytes read"
1853
1854run_test "Small packet SSLv3 StreamCipher" \
1855 "$P_SRV" \
1856 "$P_CLI request_size=1 force_version=ssl3 \
1857 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1858 0 \
1859 -s "Read from client: 1 bytes read"
1860
1861run_test "Small packet TLS 1.0 BlockCipher" \
1862 "$P_SRV" \
1863 "$P_CLI request_size=1 force_version=tls1 \
1864 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1865 0 \
1866 -s "Read from client: 1 bytes read"
1867
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01001868run_test "Small packet TLS 1.0 BlockCipher without EtM" \
1869 "$P_SRV" \
1870 "$P_CLI request_size=1 force_version=tls1 etm=0 \
1871 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1872 0 \
1873 -s "Read from client: 1 bytes read"
1874
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001875run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1876 "$P_SRV" \
1877 "$P_CLI request_size=1 force_version=tls1 \
1878 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1879 trunc_hmac=1" \
1880 0 \
1881 -s "Read from client: 1 bytes read"
1882
1883run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1884 "$P_SRV" \
1885 "$P_CLI request_size=1 force_version=tls1 \
1886 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1887 trunc_hmac=1" \
1888 0 \
1889 -s "Read from client: 1 bytes read"
1890
1891run_test "Small packet TLS 1.1 BlockCipher" \
1892 "$P_SRV" \
1893 "$P_CLI request_size=1 force_version=tls1_1 \
1894 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1895 0 \
1896 -s "Read from client: 1 bytes read"
1897
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01001898run_test "Small packet TLS 1.1 BlockCipher without EtM" \
1899 "$P_SRV" \
1900 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
1901 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1902 0 \
1903 -s "Read from client: 1 bytes read"
1904
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001905run_test "Small packet TLS 1.1 StreamCipher" \
1906 "$P_SRV" \
1907 "$P_CLI request_size=1 force_version=tls1_1 \
1908 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1909 0 \
1910 -s "Read from client: 1 bytes read"
1911
1912run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1913 "$P_SRV" \
1914 "$P_CLI request_size=1 force_version=tls1_1 \
1915 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1916 trunc_hmac=1" \
1917 0 \
1918 -s "Read from client: 1 bytes read"
1919
1920run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1921 "$P_SRV" \
1922 "$P_CLI request_size=1 force_version=tls1_1 \
1923 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1924 trunc_hmac=1" \
1925 0 \
1926 -s "Read from client: 1 bytes read"
1927
1928run_test "Small packet TLS 1.2 BlockCipher" \
1929 "$P_SRV" \
1930 "$P_CLI request_size=1 force_version=tls1_2 \
1931 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1932 0 \
1933 -s "Read from client: 1 bytes read"
1934
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01001935run_test "Small packet TLS 1.2 BlockCipher without EtM" \
1936 "$P_SRV" \
1937 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
1938 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1939 0 \
1940 -s "Read from client: 1 bytes read"
1941
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001942run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1943 "$P_SRV" \
1944 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1945 0 \
1946 -s "Read from client: 1 bytes read"
1947
1948run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1949 "$P_SRV" \
1950 "$P_CLI request_size=1 force_version=tls1_2 \
1951 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1952 trunc_hmac=1" \
1953 0 \
1954 -s "Read from client: 1 bytes read"
1955
1956run_test "Small packet TLS 1.2 StreamCipher" \
1957 "$P_SRV" \
1958 "$P_CLI request_size=1 force_version=tls1_2 \
1959 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1960 0 \
1961 -s "Read from client: 1 bytes read"
1962
1963run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1964 "$P_SRV" \
1965 "$P_CLI request_size=1 force_version=tls1_2 \
1966 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1967 trunc_hmac=1" \
1968 0 \
1969 -s "Read from client: 1 bytes read"
1970
1971run_test "Small packet TLS 1.2 AEAD" \
1972 "$P_SRV" \
1973 "$P_CLI request_size=1 force_version=tls1_2 \
1974 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1975 0 \
1976 -s "Read from client: 1 bytes read"
1977
1978run_test "Small packet TLS 1.2 AEAD shorter tag" \
1979 "$P_SRV" \
1980 "$P_CLI request_size=1 force_version=tls1_2 \
1981 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1982 0 \
1983 -s "Read from client: 1 bytes read"
1984
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001985# Test for large packets
1986
1987run_test "Large packet SSLv3 BlockCipher" \
1988 "$P_SRV" \
1989 "$P_CLI request_size=16384 force_version=ssl3 \
1990 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1991 0 \
1992 -s "Read from client: 16384 bytes read"
1993
1994run_test "Large packet SSLv3 StreamCipher" \
1995 "$P_SRV" \
1996 "$P_CLI request_size=16384 force_version=ssl3 \
1997 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1998 0 \
1999 -s "Read from client: 16384 bytes read"
2000
2001run_test "Large packet TLS 1.0 BlockCipher" \
2002 "$P_SRV" \
2003 "$P_CLI request_size=16384 force_version=tls1 \
2004 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2005 0 \
2006 -s "Read from client: 16384 bytes read"
2007
2008run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2009 "$P_SRV" \
2010 "$P_CLI request_size=16384 force_version=tls1 \
2011 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2012 trunc_hmac=1" \
2013 0 \
2014 -s "Read from client: 16384 bytes read"
2015
2016run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
2017 "$P_SRV" \
2018 "$P_CLI request_size=16384 force_version=tls1 \
2019 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2020 trunc_hmac=1" \
2021 0 \
2022 -s "Read from client: 16384 bytes read"
2023
2024run_test "Large packet TLS 1.1 BlockCipher" \
2025 "$P_SRV" \
2026 "$P_CLI request_size=16384 force_version=tls1_1 \
2027 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2028 0 \
2029 -s "Read from client: 16384 bytes read"
2030
2031run_test "Large packet TLS 1.1 StreamCipher" \
2032 "$P_SRV" \
2033 "$P_CLI request_size=16384 force_version=tls1_1 \
2034 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2035 0 \
2036 -s "Read from client: 16384 bytes read"
2037
2038run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2039 "$P_SRV" \
2040 "$P_CLI request_size=16384 force_version=tls1_1 \
2041 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2042 trunc_hmac=1" \
2043 0 \
2044 -s "Read from client: 16384 bytes read"
2045
2046run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
2047 "$P_SRV" \
2048 "$P_CLI request_size=16384 force_version=tls1_1 \
2049 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2050 trunc_hmac=1" \
2051 0 \
2052 -s "Read from client: 16384 bytes read"
2053
2054run_test "Large packet TLS 1.2 BlockCipher" \
2055 "$P_SRV" \
2056 "$P_CLI request_size=16384 force_version=tls1_2 \
2057 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2058 0 \
2059 -s "Read from client: 16384 bytes read"
2060
2061run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2062 "$P_SRV" \
2063 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
2064 0 \
2065 -s "Read from client: 16384 bytes read"
2066
2067run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2068 "$P_SRV" \
2069 "$P_CLI request_size=16384 force_version=tls1_2 \
2070 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2071 trunc_hmac=1" \
2072 0 \
2073 -s "Read from client: 16384 bytes read"
2074
2075run_test "Large packet TLS 1.2 StreamCipher" \
2076 "$P_SRV" \
2077 "$P_CLI request_size=16384 force_version=tls1_2 \
2078 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2079 0 \
2080 -s "Read from client: 16384 bytes read"
2081
2082run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
2083 "$P_SRV" \
2084 "$P_CLI request_size=16384 force_version=tls1_2 \
2085 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2086 trunc_hmac=1" \
2087 0 \
2088 -s "Read from client: 16384 bytes read"
2089
2090run_test "Large packet TLS 1.2 AEAD" \
2091 "$P_SRV" \
2092 "$P_CLI request_size=16384 force_version=tls1_2 \
2093 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2094 0 \
2095 -s "Read from client: 16384 bytes read"
2096
2097run_test "Large packet TLS 1.2 AEAD shorter tag" \
2098 "$P_SRV" \
2099 "$P_CLI request_size=16384 force_version=tls1_2 \
2100 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2101 0 \
2102 -s "Read from client: 16384 bytes read"
2103
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002104# Final report
2105
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002106echo "------------------------------------------------------------------------"
2107
2108if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002109 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002110else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002111 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002112fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002113PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002114echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002115
2116exit $FAILS