blob: 79de1b7be6d82d00b280418a8d86f3497443cfd8 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
21O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
23G_CLI="$GNUTLS_CLI"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010037 echo -e " -h|--help\tPrint this help."
38 echo -e " -m|--memcheck\tCheck memory leaks and errors."
39 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
40 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
78 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020083# skip next test if GnuTLS isn't available
84requires_gnutls() {
85 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
86 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
87 GNUTLS_AVAILABLE="YES"
88 else
89 GNUTLS_AVAILABLE="NO"
90 fi
91 fi
92 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
93 SKIP_NEXT="YES"
94 fi
95}
96
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010097# print_name <name>
98print_name() {
99 echo -n "$1 "
100 LEN=`echo "$1" | wc -c`
101 LEN=`echo 72 - $LEN | bc`
102 for i in `seq 1 $LEN`; do echo -n '.'; done
103 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100104
105 TESTS=`echo $TESTS + 1 | bc`
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100106}
107
108# fail <message>
109fail() {
110 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100111 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100112
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200113 cp $SRV_OUT o-srv-${TESTS}.log
114 cp $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100115 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100116
117 FAILS=`echo $FAILS + 1 | bc`
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100118}
119
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100120# is_polar <cmd_line>
121is_polar() {
122 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
123}
124
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100125# has_mem_err <log_file_name>
126has_mem_err() {
127 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
128 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
129 then
130 return 1 # false: does not have errors
131 else
132 return 0 # true: has errors
133 fi
134}
135
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200136# wait for server to start: two versions depending on lsof availability
137wait_server_start() {
138 if which lsof >/dev/null; then
139 # make sure we don't loop forever
140 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
141 WATCHDOG_PID=$!
142
143 # make a tight loop, server usually takes less than 1 sec to start
144 until lsof -nbi TCP:"$PORT" | grep LISTEN >/dev/null; do :; done
145
146 kill $WATCHDOG_PID
147 wait $WATCHDOG_PID
148 else
149 sleep "$START_DELAY"
150 fi
151}
152
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100153# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100154# Options: -s pattern pattern that must be present in server output
155# -c pattern pattern that must be present in client output
156# -S pattern pattern that must be absent in server output
157# -C pattern pattern that must be absent in client output
158run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100159 NAME="$1"
160 SRV_CMD="$2"
161 CLI_CMD="$3"
162 CLI_EXPECT="$4"
163 shift 4
164
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100165 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
166 else
167 return
168 fi
169
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100170 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100171
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200172 # should we skip?
173 if [ "X$SKIP_NEXT" = "XYES" ]; then
174 SKIP_NEXT="NO"
175 echo "SKIP"
176 SKIPS=`echo $SKIPS + 1 | bc`
177 return
178 fi
179
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100180 # prepend valgrind to our commands if active
181 if [ "$MEMCHECK" -gt 0 ]; then
182 if is_polar "$SRV_CMD"; then
183 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
184 fi
185 if is_polar "$CLI_CMD"; then
186 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
187 fi
188 fi
189
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100190 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200191 echo "$SRV_CMD" > $SRV_OUT
192 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100193 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200194 wait_server_start
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200195 echo "$CLI_CMD" > $CLI_OUT
196 eval "$CLI_CMD" >> $CLI_OUT 2>&1
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100197 CLI_EXIT=$?
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200198 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100199
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200200 # kill the server
201 kill $SRV_PID
202 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100203
204 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200205 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100206 # expected client exit to incorrectly succeed in case of catastrophic
207 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100208 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200209 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100210 else
211 fail "server failed to start"
212 return
213 fi
214 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100215 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200216 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100217 else
218 fail "client failed to start"
219 return
220 fi
221 fi
222
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100223 # check server exit code
224 if [ $? != 0 ]; then
225 fail "server fail"
226 return
227 fi
228
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100229 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100230 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
231 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100232 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100233 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100234 return
235 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100236
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100237 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200238 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100239 while [ $# -gt 0 ]
240 do
241 case $1 in
242 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200243 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100244 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100245 return
246 fi
247 ;;
248
249 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200250 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100251 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100252 return
253 fi
254 ;;
255
256 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200257 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100258 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100259 return
260 fi
261 ;;
262
263 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200264 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100265 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100266 return
267 fi
268 ;;
269
270 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200271 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100272 exit 1
273 esac
274 shift 2
275 done
276
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100277 # check valgrind's results
278 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200279 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100280 fail "Server has memory errors"
281 return
282 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200283 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100284 fail "Client has memory errors"
285 return
286 fi
287 fi
288
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100289 # if we're here, everything is ok
290 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200291 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100292}
293
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100294cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200295 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200296 kill $SRV_PID >/dev/null 2>&1
297 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100298 exit 1
299}
300
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100301#
302# MAIN
303#
304
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100305get_options "$@"
306
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100307# sanity checks, avoid an avalanche of errors
308if [ ! -x "$P_SRV" ]; then
309 echo "Command '$P_SRV' is not an executable file"
310 exit 1
311fi
312if [ ! -x "$P_CLI" ]; then
313 echo "Command '$P_CLI' is not an executable file"
314 exit 1
315fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100316if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
317 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100318 exit 1
319fi
320
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200321# used by watchdog
322MAIN_PID="$$"
323
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200324# be more patient with valgrind
325if [ "$MEMCHECK" -gt 0 ]; then
326 START_DELAY=3
327 DOG_DELAY=30
328else
329 START_DELAY=1
330 DOG_DELAY=10
331fi
332
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200333# Pick a "unique" port in the range 10000-19999.
334PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200335PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200336
337# fix commands to use this port
338P_SRV="$P_SRV server_port=$PORT"
339P_CLI="$P_CLI server_port=$PORT"
340O_SRV="$O_SRV -accept $PORT"
341O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200342G_SRV="$G_SRV -p $PORT"
343G_CLI="$G_CLI -p $PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200344
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200345# Also pick a unique name for intermediate files
346SRV_OUT="srv_out.$$"
347CLI_OUT="cli_out.$$"
348SESSION="session.$$"
349
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200350SKIP_NEXT="NO"
351
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100352trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100353
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200354# Basic test
355
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200356# Checks that:
357# - things work with all ciphersuites active (used with config-full in all.sh)
358# - the expected (highest security) parameters are selected
359# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200360run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200361 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200362 "$P_CLI" \
363 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200364 -s "Protocol is TLSv1.2" \
365 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
366 -s "client hello v3, signature_algorithm ext: 6" \
367 -s "ECDHE curve: secp521r1" \
368 -S "error" \
369 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200370
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100371# Test for SSLv2 ClientHello
372
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200373requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200374run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100375 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100376 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100377 0 \
378 -S "parse client hello v2" \
379 -S "ssl_handshake returned"
380
381# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200382requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200383run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200384 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100385 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100386 0 \
387 -s "parse client hello v2" \
388 -S "ssl_handshake returned"
389
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100390# Tests for Truncated HMAC extension
391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200392run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200393 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100394 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100395 0 \
396 -s "dumping 'computed mac' (20 bytes)"
397
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200398run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200399 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100400 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100401 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100402 -s "dumping 'computed mac' (10 bytes)"
403
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100404# Tests for Session Tickets
405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200406run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200407 "$P_SRV debug_level=3 tickets=1" \
408 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100409 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100410 -c "client hello, adding session ticket extension" \
411 -s "found session ticket extension" \
412 -s "server hello, adding session ticket extension" \
413 -c "found session_ticket extension" \
414 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100415 -S "session successfully restored from cache" \
416 -s "session successfully restored from ticket" \
417 -s "a session has been resumed" \
418 -c "a session has been resumed"
419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200420run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200421 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
422 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100423 0 \
424 -c "client hello, adding session ticket extension" \
425 -s "found session ticket extension" \
426 -s "server hello, adding session ticket extension" \
427 -c "found session_ticket extension" \
428 -c "parse new session ticket" \
429 -S "session successfully restored from cache" \
430 -s "session successfully restored from ticket" \
431 -s "a session has been resumed" \
432 -c "a session has been resumed"
433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200434run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200435 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
436 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100437 0 \
438 -c "client hello, adding session ticket extension" \
439 -s "found session ticket extension" \
440 -s "server hello, adding session ticket extension" \
441 -c "found session_ticket extension" \
442 -c "parse new session ticket" \
443 -S "session successfully restored from cache" \
444 -S "session successfully restored from ticket" \
445 -S "a session has been resumed" \
446 -C "a session has been resumed"
447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200448run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100449 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200450 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100451 0 \
452 -c "client hello, adding session ticket extension" \
453 -c "found session_ticket extension" \
454 -c "parse new session ticket" \
455 -c "a session has been resumed"
456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200457run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200458 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200459 "( $O_CLI -sess_out $SESSION; \
460 $O_CLI -sess_in $SESSION; \
461 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100462 0 \
463 -s "found session ticket extension" \
464 -s "server hello, adding session ticket extension" \
465 -S "session successfully restored from cache" \
466 -s "session successfully restored from ticket" \
467 -s "a session has been resumed"
468
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100469# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200471run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200472 "$P_SRV debug_level=3 tickets=0" \
473 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100474 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100475 -c "client hello, adding session ticket extension" \
476 -s "found session ticket extension" \
477 -S "server hello, adding session ticket extension" \
478 -C "found session_ticket extension" \
479 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100480 -s "session successfully restored from cache" \
481 -S "session successfully restored from ticket" \
482 -s "a session has been resumed" \
483 -c "a session has been resumed"
484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200485run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200486 "$P_SRV debug_level=3 tickets=1" \
487 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100488 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100489 -C "client hello, adding session ticket extension" \
490 -S "found session ticket extension" \
491 -S "server hello, adding session ticket extension" \
492 -C "found session_ticket extension" \
493 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100494 -s "session successfully restored from cache" \
495 -S "session successfully restored from ticket" \
496 -s "a session has been resumed" \
497 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100498
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200499run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200500 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
501 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100502 0 \
503 -S "session successfully restored from cache" \
504 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100505 -S "a session has been resumed" \
506 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200508run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200509 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
510 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100511 0 \
512 -s "session successfully restored from cache" \
513 -S "session successfully restored from ticket" \
514 -s "a session has been resumed" \
515 -c "a session has been resumed"
516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200517run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200518 "$P_SRV debug_level=3 tickets=0" \
519 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100520 0 \
521 -s "session successfully restored from cache" \
522 -S "session successfully restored from ticket" \
523 -s "a session has been resumed" \
524 -c "a session has been resumed"
525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200526run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200527 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
528 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100529 0 \
530 -S "session successfully restored from cache" \
531 -S "session successfully restored from ticket" \
532 -S "a session has been resumed" \
533 -C "a session has been resumed"
534
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200535run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200536 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
537 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100538 0 \
539 -s "session successfully restored from cache" \
540 -S "session successfully restored from ticket" \
541 -s "a session has been resumed" \
542 -c "a session has been resumed"
543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200544run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200545 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200546 "( $O_CLI -sess_out $SESSION; \
547 $O_CLI -sess_in $SESSION; \
548 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100549 0 \
550 -s "found session ticket extension" \
551 -S "server hello, adding session ticket extension" \
552 -s "session successfully restored from cache" \
553 -S "session successfully restored from ticket" \
554 -s "a session has been resumed"
555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200556run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100557 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200558 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100559 0 \
560 -C "found session_ticket extension" \
561 -C "parse new session ticket" \
562 -c "a session has been resumed"
563
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100564# Tests for Max Fragment Length extension
565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200566run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200567 "$P_SRV debug_level=3" \
568 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100569 0 \
570 -C "client hello, adding max_fragment_length extension" \
571 -S "found max fragment length extension" \
572 -S "server hello, max_fragment_length extension" \
573 -C "found max_fragment_length extension"
574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200575run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200576 "$P_SRV debug_level=3" \
577 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100578 0 \
579 -c "client hello, adding max_fragment_length extension" \
580 -s "found max fragment length extension" \
581 -s "server hello, max_fragment_length extension" \
582 -c "found max_fragment_length extension"
583
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200584run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200585 "$P_SRV debug_level=3 max_frag_len=4096" \
586 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100587 0 \
588 -C "client hello, adding max_fragment_length extension" \
589 -S "found max fragment length extension" \
590 -S "server hello, max_fragment_length extension" \
591 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200593requires_gnutls
594run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200595 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200596 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200597 0 \
598 -c "client hello, adding max_fragment_length extension" \
599 -c "found max_fragment_length extension"
600
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100601# Tests for renegotiation
602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200603run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200604 "$P_SRV debug_level=3 exchanges=2" \
605 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100606 0 \
607 -C "client hello, adding renegotiation extension" \
608 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
609 -S "found renegotiation extension" \
610 -s "server hello, secure renegotiation extension" \
611 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100612 -C "=> renegotiate" \
613 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100614 -S "write hello request"
615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200616run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200617 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
618 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100619 0 \
620 -c "client hello, adding renegotiation extension" \
621 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
622 -s "found renegotiation extension" \
623 -s "server hello, secure renegotiation extension" \
624 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100625 -c "=> renegotiate" \
626 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100627 -S "write hello request"
628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200629run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200630 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
631 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100632 0 \
633 -c "client hello, adding renegotiation extension" \
634 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
635 -s "found renegotiation extension" \
636 -s "server hello, secure renegotiation extension" \
637 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100638 -c "=> renegotiate" \
639 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100640 -s "write hello request"
641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200642run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200643 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
644 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100645 0 \
646 -c "client hello, adding renegotiation extension" \
647 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
648 -s "found renegotiation extension" \
649 -s "server hello, secure renegotiation extension" \
650 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100651 -c "=> renegotiate" \
652 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100653 -s "write hello request"
654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200655run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200656 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
657 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100658 1 \
659 -c "client hello, adding renegotiation extension" \
660 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
661 -S "found renegotiation extension" \
662 -s "server hello, secure renegotiation extension" \
663 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100664 -c "=> renegotiate" \
665 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200666 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200667 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200668 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100669
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200670run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200671 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
672 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100673 0 \
674 -C "client hello, adding renegotiation extension" \
675 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
676 -S "found renegotiation extension" \
677 -s "server hello, secure renegotiation extension" \
678 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100679 -C "=> renegotiate" \
680 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100681 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200682 -S "SSL - An unexpected message was received from our peer" \
683 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200685run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200686 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200687 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200688 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200689 0 \
690 -C "client hello, adding renegotiation extension" \
691 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
692 -S "found renegotiation extension" \
693 -s "server hello, secure renegotiation extension" \
694 -c "found renegotiation extension" \
695 -C "=> renegotiate" \
696 -S "=> renegotiate" \
697 -s "write hello request" \
698 -S "SSL - An unexpected message was received from our peer" \
699 -S "failed"
700
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200701# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200702run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200703 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200704 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200705 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200706 0 \
707 -C "client hello, adding renegotiation extension" \
708 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
709 -S "found renegotiation extension" \
710 -s "server hello, secure renegotiation extension" \
711 -c "found renegotiation extension" \
712 -C "=> renegotiate" \
713 -S "=> renegotiate" \
714 -s "write hello request" \
715 -S "SSL - An unexpected message was received from our peer" \
716 -S "failed"
717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200718run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200719 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200720 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200721 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200722 0 \
723 -C "client hello, adding renegotiation extension" \
724 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
725 -S "found renegotiation extension" \
726 -s "server hello, secure renegotiation extension" \
727 -c "found renegotiation extension" \
728 -C "=> renegotiate" \
729 -S "=> renegotiate" \
730 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200731 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200733run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200734 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200735 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200736 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200737 0 \
738 -c "client hello, adding renegotiation extension" \
739 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
740 -s "found renegotiation extension" \
741 -s "server hello, secure renegotiation extension" \
742 -c "found renegotiation extension" \
743 -c "=> renegotiate" \
744 -s "=> renegotiate" \
745 -s "write hello request" \
746 -S "SSL - An unexpected message was received from our peer" \
747 -S "failed"
748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200749run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200750 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
751 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200752 0 \
753 -c "client hello, adding renegotiation extension" \
754 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
755 -s "found renegotiation extension" \
756 -s "server hello, secure renegotiation extension" \
757 -c "found renegotiation extension" \
758 -c "=> renegotiate" \
759 -s "=> renegotiate" \
760 -S "write hello request"
761
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200762run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200763 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
764 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200765 0 \
766 -c "client hello, adding renegotiation extension" \
767 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
768 -s "found renegotiation extension" \
769 -s "server hello, secure renegotiation extension" \
770 -c "found renegotiation extension" \
771 -c "=> renegotiate" \
772 -s "=> renegotiate" \
773 -s "write hello request"
774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200775run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200776 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200777 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200778 0 \
779 -c "client hello, adding renegotiation extension" \
780 -c "found renegotiation extension" \
781 -c "=> renegotiate" \
782 -C "ssl_handshake returned" \
783 -C "error" \
784 -c "HTTP/1.0 200 [Oo][Kk]"
785
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200786run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200787 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200788 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200789 0 \
790 -c "client hello, adding renegotiation extension" \
791 -c "found renegotiation extension" \
792 -c "=> renegotiate" \
793 -C "ssl_handshake returned" \
794 -C "error" \
795 -c "HTTP/1.0 200 [Oo][Kk]"
796
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100797# Tests for auth_mode
798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200799run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100800 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100801 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200802 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100803 1 \
804 -c "x509_verify_cert() returned" \
805 -c "! self-signed or not signed by a trusted CA" \
806 -c "! ssl_handshake returned" \
807 -c "X509 - Certificate verification failed"
808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200809run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100810 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100811 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200812 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100813 0 \
814 -c "x509_verify_cert() returned" \
815 -c "! self-signed or not signed by a trusted CA" \
816 -C "! ssl_handshake returned" \
817 -C "X509 - Certificate verification failed"
818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200819run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100820 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100821 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200822 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100823 0 \
824 -C "x509_verify_cert() returned" \
825 -C "! self-signed or not signed by a trusted CA" \
826 -C "! ssl_handshake returned" \
827 -C "X509 - Certificate verification failed"
828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200829run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200830 "$P_SRV debug_level=3 auth_mode=required" \
831 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100832 key_file=data_files/server5.key" \
833 1 \
834 -S "skip write certificate request" \
835 -C "skip parse certificate request" \
836 -c "got a certificate request" \
837 -C "skip write certificate" \
838 -C "skip write certificate verify" \
839 -S "skip parse certificate verify" \
840 -s "x509_verify_cert() returned" \
841 -S "! self-signed or not signed by a trusted CA" \
842 -s "! ssl_handshake returned" \
843 -c "! ssl_handshake returned" \
844 -s "X509 - Certificate verification failed"
845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200846run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200847 "$P_SRV debug_level=3 auth_mode=optional" \
848 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100849 key_file=data_files/server5.key" \
850 0 \
851 -S "skip write certificate request" \
852 -C "skip parse certificate request" \
853 -c "got a certificate request" \
854 -C "skip write certificate" \
855 -C "skip write certificate verify" \
856 -S "skip parse certificate verify" \
857 -s "x509_verify_cert() returned" \
858 -s "! self-signed or not signed by a trusted CA" \
859 -S "! ssl_handshake returned" \
860 -C "! ssl_handshake returned" \
861 -S "X509 - Certificate verification failed"
862
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200863run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200864 "$P_SRV debug_level=3 auth_mode=none" \
865 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100866 key_file=data_files/server5.key" \
867 0 \
868 -s "skip write certificate request" \
869 -C "skip parse certificate request" \
870 -c "got no certificate request" \
871 -c "skip write certificate" \
872 -c "skip write certificate verify" \
873 -s "skip parse certificate verify" \
874 -S "x509_verify_cert() returned" \
875 -S "! self-signed or not signed by a trusted CA" \
876 -S "! ssl_handshake returned" \
877 -C "! ssl_handshake returned" \
878 -S "X509 - Certificate verification failed"
879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200880run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200881 "$P_SRV debug_level=3 auth_mode=optional" \
882 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100883 0 \
884 -S "skip write certificate request" \
885 -C "skip parse certificate request" \
886 -c "got a certificate request" \
887 -C "skip write certificate$" \
888 -C "got no certificate to send" \
889 -S "SSLv3 client has no certificate" \
890 -c "skip write certificate verify" \
891 -s "skip parse certificate verify" \
892 -s "! no client certificate sent" \
893 -S "! ssl_handshake returned" \
894 -C "! ssl_handshake returned" \
895 -S "X509 - Certificate verification failed"
896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200897run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200898 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100899 "$O_CLI" \
900 0 \
901 -S "skip write certificate request" \
902 -s "skip parse certificate verify" \
903 -s "! no client certificate sent" \
904 -S "! ssl_handshake returned" \
905 -S "X509 - Certificate verification failed"
906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200907run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100908 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200909 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100910 0 \
911 -C "skip parse certificate request" \
912 -c "got a certificate request" \
913 -C "skip write certificate$" \
914 -c "skip write certificate verify" \
915 -C "! ssl_handshake returned"
916
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200917run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200918 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
919 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100920 0 \
921 -S "skip write certificate request" \
922 -C "skip parse certificate request" \
923 -c "got a certificate request" \
924 -C "skip write certificate$" \
925 -c "skip write certificate verify" \
926 -c "got no certificate to send" \
927 -s "SSLv3 client has no certificate" \
928 -s "skip parse certificate verify" \
929 -s "! no client certificate sent" \
930 -S "! ssl_handshake returned" \
931 -C "! ssl_handshake returned" \
932 -S "X509 - Certificate verification failed"
933
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100934# tests for SNI
935
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200936run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200937 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100938 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100939 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100940 server_name=localhost" \
941 0 \
942 -S "parse ServerName extension" \
943 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
944 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200946run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200947 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100948 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100949 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 +0100950 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100951 server_name=localhost" \
952 0 \
953 -s "parse ServerName extension" \
954 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
955 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200957run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200958 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100959 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100960 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 +0100961 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100962 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100963 0 \
964 -s "parse ServerName extension" \
965 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100966 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200968run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200969 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100970 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100971 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 +0100972 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100973 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100974 1 \
975 -s "parse ServerName extension" \
976 -s "ssl_sni_wrapper() returned" \
977 -s "ssl_handshake returned" \
978 -c "ssl_handshake returned" \
979 -c "SSL - A fatal alert message was received from our peer"
980
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +0100981# Tests for non-blocking I/O: exercise a variety of handshake flows
982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200983run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +0100984 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
985 "$P_CLI nbio=2 tickets=0" \
986 0 \
987 -S "ssl_handshake returned" \
988 -C "ssl_handshake returned" \
989 -c "Read from server: .* bytes read"
990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200991run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +0100992 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
993 "$P_CLI nbio=2 tickets=0" \
994 0 \
995 -S "ssl_handshake returned" \
996 -C "ssl_handshake returned" \
997 -c "Read from server: .* bytes read"
998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200999run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001000 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1001 "$P_CLI nbio=2 tickets=1" \
1002 0 \
1003 -S "ssl_handshake returned" \
1004 -C "ssl_handshake returned" \
1005 -c "Read from server: .* bytes read"
1006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001007run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001008 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1009 "$P_CLI nbio=2 tickets=1" \
1010 0 \
1011 -S "ssl_handshake returned" \
1012 -C "ssl_handshake returned" \
1013 -c "Read from server: .* bytes read"
1014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001015run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001016 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1017 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1018 0 \
1019 -S "ssl_handshake returned" \
1020 -C "ssl_handshake returned" \
1021 -c "Read from server: .* bytes read"
1022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001023run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001024 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1025 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1026 0 \
1027 -S "ssl_handshake returned" \
1028 -C "ssl_handshake returned" \
1029 -c "Read from server: .* bytes read"
1030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001031run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001032 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1033 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1034 0 \
1035 -S "ssl_handshake returned" \
1036 -C "ssl_handshake returned" \
1037 -c "Read from server: .* bytes read"
1038
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001039# Tests for version negotiation
1040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001041run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001042 "$P_SRV" \
1043 "$P_CLI" \
1044 0 \
1045 -S "ssl_handshake returned" \
1046 -C "ssl_handshake returned" \
1047 -s "Protocol is TLSv1.2" \
1048 -c "Protocol is TLSv1.2"
1049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001050run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001051 "$P_SRV" \
1052 "$P_CLI max_version=tls1_1" \
1053 0 \
1054 -S "ssl_handshake returned" \
1055 -C "ssl_handshake returned" \
1056 -s "Protocol is TLSv1.1" \
1057 -c "Protocol is TLSv1.1"
1058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001059run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001060 "$P_SRV max_version=tls1_1" \
1061 "$P_CLI" \
1062 0 \
1063 -S "ssl_handshake returned" \
1064 -C "ssl_handshake returned" \
1065 -s "Protocol is TLSv1.1" \
1066 -c "Protocol is TLSv1.1"
1067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001068run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001069 "$P_SRV max_version=tls1_1" \
1070 "$P_CLI max_version=tls1_1" \
1071 0 \
1072 -S "ssl_handshake returned" \
1073 -C "ssl_handshake returned" \
1074 -s "Protocol is TLSv1.1" \
1075 -c "Protocol is TLSv1.1"
1076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001077run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001078 "$P_SRV min_version=tls1_1" \
1079 "$P_CLI max_version=tls1_1" \
1080 0 \
1081 -S "ssl_handshake returned" \
1082 -C "ssl_handshake returned" \
1083 -s "Protocol is TLSv1.1" \
1084 -c "Protocol is TLSv1.1"
1085
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001086run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001087 "$P_SRV max_version=tls1_1" \
1088 "$P_CLI min_version=tls1_1" \
1089 0 \
1090 -S "ssl_handshake returned" \
1091 -C "ssl_handshake returned" \
1092 -s "Protocol is TLSv1.1" \
1093 -c "Protocol is TLSv1.1"
1094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001095run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001096 "$P_SRV max_version=tls1_1" \
1097 "$P_CLI min_version=tls1_2" \
1098 1 \
1099 -s "ssl_handshake returned" \
1100 -c "ssl_handshake returned" \
1101 -c "SSL - Handshake protocol not within min/max boundaries"
1102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001103run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001104 "$P_SRV min_version=tls1_2" \
1105 "$P_CLI max_version=tls1_1" \
1106 1 \
1107 -s "ssl_handshake returned" \
1108 -c "ssl_handshake returned" \
1109 -s "SSL - Handshake protocol not within min/max boundaries"
1110
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001111# Tests for ALPN extension
1112
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001113if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1114
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001115run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001116 "$P_SRV debug_level=3" \
1117 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001118 0 \
1119 -C "client hello, adding alpn extension" \
1120 -S "found alpn extension" \
1121 -C "got an alert message, type: \\[2:120]" \
1122 -S "server hello, adding alpn extension" \
1123 -C "found alpn extension " \
1124 -C "Application Layer Protocol is" \
1125 -S "Application Layer Protocol is"
1126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001127run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001128 "$P_SRV debug_level=3" \
1129 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001130 0 \
1131 -c "client hello, adding alpn extension" \
1132 -s "found alpn extension" \
1133 -C "got an alert message, type: \\[2:120]" \
1134 -S "server hello, adding alpn extension" \
1135 -C "found alpn extension " \
1136 -c "Application Layer Protocol is (none)" \
1137 -S "Application Layer Protocol is"
1138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001139run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001140 "$P_SRV debug_level=3 alpn=abc,1234" \
1141 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001142 0 \
1143 -C "client hello, adding alpn extension" \
1144 -S "found alpn extension" \
1145 -C "got an alert message, type: \\[2:120]" \
1146 -S "server hello, adding alpn extension" \
1147 -C "found alpn extension " \
1148 -C "Application Layer Protocol is" \
1149 -s "Application Layer Protocol is (none)"
1150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001151run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001152 "$P_SRV debug_level=3 alpn=abc,1234" \
1153 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001154 0 \
1155 -c "client hello, adding alpn extension" \
1156 -s "found alpn extension" \
1157 -C "got an alert message, type: \\[2:120]" \
1158 -s "server hello, adding alpn extension" \
1159 -c "found alpn extension" \
1160 -c "Application Layer Protocol is abc" \
1161 -s "Application Layer Protocol is abc"
1162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001163run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001164 "$P_SRV debug_level=3 alpn=abc,1234" \
1165 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001166 0 \
1167 -c "client hello, adding alpn extension" \
1168 -s "found alpn extension" \
1169 -C "got an alert message, type: \\[2:120]" \
1170 -s "server hello, adding alpn extension" \
1171 -c "found alpn extension" \
1172 -c "Application Layer Protocol is abc" \
1173 -s "Application Layer Protocol is abc"
1174
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001175run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001176 "$P_SRV debug_level=3 alpn=abc,1234" \
1177 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001178 0 \
1179 -c "client hello, adding alpn extension" \
1180 -s "found alpn extension" \
1181 -C "got an alert message, type: \\[2:120]" \
1182 -s "server hello, adding alpn extension" \
1183 -c "found alpn extension" \
1184 -c "Application Layer Protocol is 1234" \
1185 -s "Application Layer Protocol is 1234"
1186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001187run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001188 "$P_SRV debug_level=3 alpn=abc,123" \
1189 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001190 1 \
1191 -c "client hello, adding alpn extension" \
1192 -s "found alpn extension" \
1193 -c "got an alert message, type: \\[2:120]" \
1194 -S "server hello, adding alpn extension" \
1195 -C "found alpn extension" \
1196 -C "Application Layer Protocol is 1234" \
1197 -S "Application Layer Protocol is 1234"
1198
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001199fi
1200
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001201# Tests for keyUsage in leaf certificates, part 1:
1202# server-side certificate/suite selection
1203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001204run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001205 "$P_SRV key_file=data_files/server2.key \
1206 crt_file=data_files/server2.ku-ds.crt" \
1207 "$P_CLI" \
1208 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001209 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001210
1211
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001212run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001213 "$P_SRV key_file=data_files/server2.key \
1214 crt_file=data_files/server2.ku-ke.crt" \
1215 "$P_CLI" \
1216 0 \
1217 -c "Ciphersuite is TLS-RSA-WITH-"
1218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001219run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001220 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001221 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001222 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001223 1 \
1224 -C "Ciphersuite is "
1225
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001226run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001227 "$P_SRV key_file=data_files/server5.key \
1228 crt_file=data_files/server5.ku-ds.crt" \
1229 "$P_CLI" \
1230 0 \
1231 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1232
1233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001234run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001235 "$P_SRV key_file=data_files/server5.key \
1236 crt_file=data_files/server5.ku-ka.crt" \
1237 "$P_CLI" \
1238 0 \
1239 -c "Ciphersuite is TLS-ECDH-"
1240
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001241run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001242 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001243 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001244 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001245 1 \
1246 -C "Ciphersuite is "
1247
1248# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001249# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001251run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001252 "$O_SRV -key data_files/server2.key \
1253 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001254 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001255 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1256 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001257 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001258 -C "Processing of the Certificate handshake message failed" \
1259 -c "Ciphersuite is TLS-"
1260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001261run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001262 "$O_SRV -key data_files/server2.key \
1263 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001264 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001265 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1266 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001267 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001268 -C "Processing of the Certificate handshake message failed" \
1269 -c "Ciphersuite is TLS-"
1270
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001271run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001272 "$O_SRV -key data_files/server2.key \
1273 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001274 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001275 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1276 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001277 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001278 -C "Processing of the Certificate handshake message failed" \
1279 -c "Ciphersuite is TLS-"
1280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001281run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001282 "$O_SRV -key data_files/server2.key \
1283 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001284 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001285 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1286 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001287 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001288 -c "Processing of the Certificate handshake message failed" \
1289 -C "Ciphersuite is TLS-"
1290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001291run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001292 "$O_SRV -key data_files/server2.key \
1293 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001294 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001295 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1296 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001297 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001298 -C "Processing of the Certificate handshake message failed" \
1299 -c "Ciphersuite is TLS-"
1300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001301run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001302 "$O_SRV -key data_files/server2.key \
1303 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001304 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001305 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1306 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001307 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001308 -c "Processing of the Certificate handshake message failed" \
1309 -C "Ciphersuite is TLS-"
1310
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001311# Tests for keyUsage in leaf certificates, part 3:
1312# server-side checking of client cert
1313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001314run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001315 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001316 "$O_CLI -key data_files/server2.key \
1317 -cert data_files/server2.ku-ds.crt" \
1318 0 \
1319 -S "bad certificate (usage extensions)" \
1320 -S "Processing of the Certificate handshake message failed"
1321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001322run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001323 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001324 "$O_CLI -key data_files/server2.key \
1325 -cert data_files/server2.ku-ke.crt" \
1326 0 \
1327 -s "bad certificate (usage extensions)" \
1328 -S "Processing of the Certificate handshake message failed"
1329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001330run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001331 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001332 "$O_CLI -key data_files/server2.key \
1333 -cert data_files/server2.ku-ke.crt" \
1334 1 \
1335 -s "bad certificate (usage extensions)" \
1336 -s "Processing of the Certificate handshake message failed"
1337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001338run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001339 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001340 "$O_CLI -key data_files/server5.key \
1341 -cert data_files/server5.ku-ds.crt" \
1342 0 \
1343 -S "bad certificate (usage extensions)" \
1344 -S "Processing of the Certificate handshake message failed"
1345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001348 "$O_CLI -key data_files/server5.key \
1349 -cert data_files/server5.ku-ka.crt" \
1350 0 \
1351 -s "bad certificate (usage extensions)" \
1352 -S "Processing of the Certificate handshake message failed"
1353
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001354# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001356run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001357 "$P_SRV key_file=data_files/server5.key \
1358 crt_file=data_files/server5.eku-srv.crt" \
1359 "$P_CLI" \
1360 0
1361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001362run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001363 "$P_SRV key_file=data_files/server5.key \
1364 crt_file=data_files/server5.eku-srv.crt" \
1365 "$P_CLI" \
1366 0
1367
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001368run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001369 "$P_SRV key_file=data_files/server5.key \
1370 crt_file=data_files/server5.eku-cs_any.crt" \
1371 "$P_CLI" \
1372 0
1373
1374# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001375run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001376 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1377 crt_file=data_files/server5.eku-cli.crt" \
1378 "$P_CLI psk=badbad" \
1379 1
1380
1381# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001383run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001384 "$O_SRV -key data_files/server5.key \
1385 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001386 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001387 0 \
1388 -C "bad certificate (usage extensions)" \
1389 -C "Processing of the Certificate handshake message failed" \
1390 -c "Ciphersuite is TLS-"
1391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001392run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001393 "$O_SRV -key data_files/server5.key \
1394 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001395 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001396 0 \
1397 -C "bad certificate (usage extensions)" \
1398 -C "Processing of the Certificate handshake message failed" \
1399 -c "Ciphersuite is TLS-"
1400
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001401run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001402 "$O_SRV -key data_files/server5.key \
1403 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001404 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001405 0 \
1406 -C "bad certificate (usage extensions)" \
1407 -C "Processing of the Certificate handshake message failed" \
1408 -c "Ciphersuite is TLS-"
1409
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001410run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001411 "$O_SRV -key data_files/server5.key \
1412 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001413 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001414 1 \
1415 -c "bad certificate (usage extensions)" \
1416 -c "Processing of the Certificate handshake message failed" \
1417 -C "Ciphersuite is TLS-"
1418
1419# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001421run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001422 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001423 "$O_CLI -key data_files/server5.key \
1424 -cert data_files/server5.eku-cli.crt" \
1425 0 \
1426 -S "bad certificate (usage extensions)" \
1427 -S "Processing of the Certificate handshake message failed"
1428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001429run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001430 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001431 "$O_CLI -key data_files/server5.key \
1432 -cert data_files/server5.eku-srv_cli.crt" \
1433 0 \
1434 -S "bad certificate (usage extensions)" \
1435 -S "Processing of the Certificate handshake message failed"
1436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001437run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001438 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001439 "$O_CLI -key data_files/server5.key \
1440 -cert data_files/server5.eku-cs_any.crt" \
1441 0 \
1442 -S "bad certificate (usage extensions)" \
1443 -S "Processing of the Certificate handshake message failed"
1444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001445run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001446 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001447 "$O_CLI -key data_files/server5.key \
1448 -cert data_files/server5.eku-cs.crt" \
1449 0 \
1450 -s "bad certificate (usage extensions)" \
1451 -S "Processing of the Certificate handshake message failed"
1452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001453run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001454 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001455 "$O_CLI -key data_files/server5.key \
1456 -cert data_files/server5.eku-cs.crt" \
1457 1 \
1458 -s "bad certificate (usage extensions)" \
1459 -s "Processing of the Certificate handshake message failed"
1460
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001461# Tests for DHM parameters loading
1462
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001463run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001464 "$P_SRV" \
1465 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1466 debug_level=3" \
1467 0 \
1468 -c "value of 'DHM: P ' (2048 bits)" \
1469 -c "value of 'DHM: G ' (2048 bits)"
1470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001471run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001472 "$P_SRV dhm_file=data_files/dhparams.pem" \
1473 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1474 debug_level=3" \
1475 0 \
1476 -c "value of 'DHM: P ' (1024 bits)" \
1477 -c "value of 'DHM: G ' (2 bits)"
1478
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001479# Tests for PSK callback
1480
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001481run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001482 "$P_SRV psk=abc123 psk_identity=foo" \
1483 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1484 psk_identity=foo psk=abc123" \
1485 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001486 -S "SSL - The server has no ciphersuites in common" \
1487 -S "SSL - Unknown identity received" \
1488 -S "SSL - Verification of the message MAC failed"
1489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001490run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001491 "$P_SRV" \
1492 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1493 psk_identity=foo psk=abc123" \
1494 1 \
1495 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001496 -S "SSL - Unknown identity received" \
1497 -S "SSL - Verification of the message MAC failed"
1498
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001499run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001500 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1501 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1502 psk_identity=foo psk=abc123" \
1503 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001504 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001505 -s "SSL - Unknown identity received" \
1506 -S "SSL - Verification of the message MAC failed"
1507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001508run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001509 "$P_SRV psk_list=abc,dead,def,beef" \
1510 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1511 psk_identity=abc psk=dead" \
1512 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001513 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001514 -S "SSL - Unknown identity received" \
1515 -S "SSL - Verification of the message MAC failed"
1516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001517run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001518 "$P_SRV psk_list=abc,dead,def,beef" \
1519 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1520 psk_identity=def psk=beef" \
1521 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001522 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001523 -S "SSL - Unknown identity received" \
1524 -S "SSL - Verification of the message MAC failed"
1525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001526run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001527 "$P_SRV psk_list=abc,dead,def,beef" \
1528 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1529 psk_identity=ghi psk=beef" \
1530 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001531 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001532 -s "SSL - Unknown identity received" \
1533 -S "SSL - Verification of the message MAC failed"
1534
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001535run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001536 "$P_SRV psk_list=abc,dead,def,beef" \
1537 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1538 psk_identity=abc psk=beef" \
1539 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001540 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001541 -S "SSL - Unknown identity received" \
1542 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001543
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001544# Tests for ciphersuites per version
1545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001546run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001547 "$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" \
1548 "$P_CLI force_version=ssl3" \
1549 0 \
1550 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001552run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001553 "$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" \
1554 "$P_CLI force_version=tls1" \
1555 0 \
1556 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001558run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001559 "$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" \
1560 "$P_CLI force_version=tls1_1" \
1561 0 \
1562 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001564run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001565 "$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" \
1566 "$P_CLI force_version=tls1_2" \
1567 0 \
1568 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1569
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001570# Tests for ssl_get_bytes_avail()
1571
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001572run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001573 "$P_SRV" \
1574 "$P_CLI request_size=100" \
1575 0 \
1576 -s "Read from client: 100 bytes read$"
1577
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001578run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001579 "$P_SRV" \
1580 "$P_CLI request_size=500" \
1581 0 \
1582 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001583
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001584# Tests for small packets
1585
1586run_test "Small packet SSLv3 BlockCipher" \
1587 "$P_SRV" \
1588 "$P_CLI request_size=1 force_version=ssl3 \
1589 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1590 0 \
1591 -s "Read from client: 1 bytes read"
1592
1593run_test "Small packet SSLv3 StreamCipher" \
1594 "$P_SRV" \
1595 "$P_CLI request_size=1 force_version=ssl3 \
1596 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1597 0 \
1598 -s "Read from client: 1 bytes read"
1599
1600run_test "Small packet TLS 1.0 BlockCipher" \
1601 "$P_SRV" \
1602 "$P_CLI request_size=1 force_version=tls1 \
1603 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1604 0 \
1605 -s "Read from client: 1 bytes read"
1606
1607run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1608 "$P_SRV" \
1609 "$P_CLI request_size=1 force_version=tls1 \
1610 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1611 trunc_hmac=1" \
1612 0 \
1613 -s "Read from client: 1 bytes read"
1614
1615run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1616 "$P_SRV" \
1617 "$P_CLI request_size=1 force_version=tls1 \
1618 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1619 trunc_hmac=1" \
1620 0 \
1621 -s "Read from client: 1 bytes read"
1622
1623run_test "Small packet TLS 1.1 BlockCipher" \
1624 "$P_SRV" \
1625 "$P_CLI request_size=1 force_version=tls1_1 \
1626 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1627 0 \
1628 -s "Read from client: 1 bytes read"
1629
1630run_test "Small packet TLS 1.1 StreamCipher" \
1631 "$P_SRV" \
1632 "$P_CLI request_size=1 force_version=tls1_1 \
1633 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1634 0 \
1635 -s "Read from client: 1 bytes read"
1636
1637run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1638 "$P_SRV" \
1639 "$P_CLI request_size=1 force_version=tls1_1 \
1640 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1641 trunc_hmac=1" \
1642 0 \
1643 -s "Read from client: 1 bytes read"
1644
1645run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1646 "$P_SRV" \
1647 "$P_CLI request_size=1 force_version=tls1_1 \
1648 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1649 trunc_hmac=1" \
1650 0 \
1651 -s "Read from client: 1 bytes read"
1652
1653run_test "Small packet TLS 1.2 BlockCipher" \
1654 "$P_SRV" \
1655 "$P_CLI request_size=1 force_version=tls1_2 \
1656 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1657 0 \
1658 -s "Read from client: 1 bytes read"
1659
1660run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1661 "$P_SRV" \
1662 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1663 0 \
1664 -s "Read from client: 1 bytes read"
1665
1666run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1667 "$P_SRV" \
1668 "$P_CLI request_size=1 force_version=tls1_2 \
1669 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1670 trunc_hmac=1" \
1671 0 \
1672 -s "Read from client: 1 bytes read"
1673
1674run_test "Small packet TLS 1.2 StreamCipher" \
1675 "$P_SRV" \
1676 "$P_CLI request_size=1 force_version=tls1_2 \
1677 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1678 0 \
1679 -s "Read from client: 1 bytes read"
1680
1681run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1682 "$P_SRV" \
1683 "$P_CLI request_size=1 force_version=tls1_2 \
1684 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1685 trunc_hmac=1" \
1686 0 \
1687 -s "Read from client: 1 bytes read"
1688
1689run_test "Small packet TLS 1.2 AEAD" \
1690 "$P_SRV" \
1691 "$P_CLI request_size=1 force_version=tls1_2 \
1692 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1693 0 \
1694 -s "Read from client: 1 bytes read"
1695
1696run_test "Small packet TLS 1.2 AEAD shorter tag" \
1697 "$P_SRV" \
1698 "$P_CLI request_size=1 force_version=tls1_2 \
1699 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1700 0 \
1701 -s "Read from client: 1 bytes read"
1702
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001703# Test for large packets
1704
1705run_test "Large packet SSLv3 BlockCipher" \
1706 "$P_SRV" \
1707 "$P_CLI request_size=16384 force_version=ssl3 \
1708 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1709 0 \
1710 -s "Read from client: 16384 bytes read"
1711
1712run_test "Large packet SSLv3 StreamCipher" \
1713 "$P_SRV" \
1714 "$P_CLI request_size=16384 force_version=ssl3 \
1715 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1716 0 \
1717 -s "Read from client: 16384 bytes read"
1718
1719run_test "Large packet TLS 1.0 BlockCipher" \
1720 "$P_SRV" \
1721 "$P_CLI request_size=16384 force_version=tls1 \
1722 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1723 0 \
1724 -s "Read from client: 16384 bytes read"
1725
1726run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1727 "$P_SRV" \
1728 "$P_CLI request_size=16384 force_version=tls1 \
1729 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1730 trunc_hmac=1" \
1731 0 \
1732 -s "Read from client: 16384 bytes read"
1733
1734run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1735 "$P_SRV" \
1736 "$P_CLI request_size=16384 force_version=tls1 \
1737 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1738 trunc_hmac=1" \
1739 0 \
1740 -s "Read from client: 16384 bytes read"
1741
1742run_test "Large packet TLS 1.1 BlockCipher" \
1743 "$P_SRV" \
1744 "$P_CLI request_size=16384 force_version=tls1_1 \
1745 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1746 0 \
1747 -s "Read from client: 16384 bytes read"
1748
1749run_test "Large packet TLS 1.1 StreamCipher" \
1750 "$P_SRV" \
1751 "$P_CLI request_size=16384 force_version=tls1_1 \
1752 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1753 0 \
1754 -s "Read from client: 16384 bytes read"
1755
1756run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1757 "$P_SRV" \
1758 "$P_CLI request_size=16384 force_version=tls1_1 \
1759 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1760 trunc_hmac=1" \
1761 0 \
1762 -s "Read from client: 16384 bytes read"
1763
1764run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1765 "$P_SRV" \
1766 "$P_CLI request_size=16384 force_version=tls1_1 \
1767 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1768 trunc_hmac=1" \
1769 0 \
1770 -s "Read from client: 16384 bytes read"
1771
1772run_test "Large packet TLS 1.2 BlockCipher" \
1773 "$P_SRV" \
1774 "$P_CLI request_size=16384 force_version=tls1_2 \
1775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1776 0 \
1777 -s "Read from client: 16384 bytes read"
1778
1779run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1780 "$P_SRV" \
1781 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1782 0 \
1783 -s "Read from client: 16384 bytes read"
1784
1785run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1786 "$P_SRV" \
1787 "$P_CLI request_size=16384 force_version=tls1_2 \
1788 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1789 trunc_hmac=1" \
1790 0 \
1791 -s "Read from client: 16384 bytes read"
1792
1793run_test "Large packet TLS 1.2 StreamCipher" \
1794 "$P_SRV" \
1795 "$P_CLI request_size=16384 force_version=tls1_2 \
1796 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1797 0 \
1798 -s "Read from client: 16384 bytes read"
1799
1800run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1801 "$P_SRV" \
1802 "$P_CLI request_size=16384 force_version=tls1_2 \
1803 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1804 trunc_hmac=1" \
1805 0 \
1806 -s "Read from client: 16384 bytes read"
1807
1808run_test "Large packet TLS 1.2 AEAD" \
1809 "$P_SRV" \
1810 "$P_CLI request_size=16384 force_version=tls1_2 \
1811 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1812 0 \
1813 -s "Read from client: 16384 bytes read"
1814
1815run_test "Large packet TLS 1.2 AEAD shorter tag" \
1816 "$P_SRV" \
1817 "$P_CLI request_size=16384 force_version=tls1_2 \
1818 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1819 0 \
1820 -s "Read from client: 16384 bytes read"
1821
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001822# Final report
1823
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001824echo "------------------------------------------------------------------------"
1825
1826if [ $FAILS = 0 ]; then
1827 echo -n "PASSED"
1828else
1829 echo -n "FAILED"
1830fi
1831PASSES=`echo $TESTS - $FAILS | bc`
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001832echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001833
1834exit $FAILS