blob: 225df96feb9f4ee82f53684dac166f938494c90e [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é-Gonnardc0f6a692014-08-30 22:41:47 +0200153# wait for client to terminate and set CLI_EXIT
154# must be called right after starting the client
155wait_client_done() {
156 CLI_PID=$!
157
158 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
159 WATCHDOG_PID=$!
160
161 wait $CLI_PID
162 CLI_EXIT=$?
163
164 kill $WATCHDOG_PID
165 wait $WATCHDOG_PID
166
167 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
168}
169
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100170# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100171# Options: -s pattern pattern that must be present in server output
172# -c pattern pattern that must be present in client output
173# -S pattern pattern that must be absent in server output
174# -C pattern pattern that must be absent in client output
175run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100176 NAME="$1"
177 SRV_CMD="$2"
178 CLI_CMD="$3"
179 CLI_EXPECT="$4"
180 shift 4
181
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100182 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
183 else
184 return
185 fi
186
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100187 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100188
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200189 # should we skip?
190 if [ "X$SKIP_NEXT" = "XYES" ]; then
191 SKIP_NEXT="NO"
192 echo "SKIP"
193 SKIPS=`echo $SKIPS + 1 | bc`
194 return
195 fi
196
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100197 # prepend valgrind to our commands if active
198 if [ "$MEMCHECK" -gt 0 ]; then
199 if is_polar "$SRV_CMD"; then
200 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
201 fi
202 if is_polar "$CLI_CMD"; then
203 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
204 fi
205 fi
206
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100207 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200208 echo "$SRV_CMD" > $SRV_OUT
209 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100210 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200211 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200212
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200213 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200214 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
215 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100216
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200217 # kill the server
218 kill $SRV_PID
219 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100220
221 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200222 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100223 # expected client exit to incorrectly succeed in case of catastrophic
224 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100225 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200226 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100227 else
228 fail "server failed to start"
229 return
230 fi
231 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100232 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200233 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100234 else
235 fail "client failed to start"
236 return
237 fi
238 fi
239
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100240 # check server exit code
241 if [ $? != 0 ]; then
242 fail "server fail"
243 return
244 fi
245
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100246 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100247 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
248 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100249 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100250 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100251 return
252 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100253
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100254 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200255 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100256 while [ $# -gt 0 ]
257 do
258 case $1 in
259 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200260 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100261 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100262 return
263 fi
264 ;;
265
266 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200267 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100268 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100269 return
270 fi
271 ;;
272
273 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200274 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100275 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100276 return
277 fi
278 ;;
279
280 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200281 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100282 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100283 return
284 fi
285 ;;
286
287 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200288 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100289 exit 1
290 esac
291 shift 2
292 done
293
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100294 # check valgrind's results
295 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200296 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100297 fail "Server has memory errors"
298 return
299 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200300 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100301 fail "Client has memory errors"
302 return
303 fi
304 fi
305
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100306 # if we're here, everything is ok
307 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200308 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100309}
310
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100311cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200312 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200313 kill $SRV_PID >/dev/null 2>&1
314 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100315 exit 1
316}
317
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100318#
319# MAIN
320#
321
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100322get_options "$@"
323
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100324# sanity checks, avoid an avalanche of errors
325if [ ! -x "$P_SRV" ]; then
326 echo "Command '$P_SRV' is not an executable file"
327 exit 1
328fi
329if [ ! -x "$P_CLI" ]; then
330 echo "Command '$P_CLI' is not an executable file"
331 exit 1
332fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100333if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
334 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100335 exit 1
336fi
337
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200338# used by watchdog
339MAIN_PID="$$"
340
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200341# be more patient with valgrind
342if [ "$MEMCHECK" -gt 0 ]; then
343 START_DELAY=3
344 DOG_DELAY=30
345else
346 START_DELAY=1
347 DOG_DELAY=10
348fi
349
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200350# Pick a "unique" port in the range 10000-19999.
351PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200352PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200353
354# fix commands to use this port
355P_SRV="$P_SRV server_port=$PORT"
356P_CLI="$P_CLI server_port=$PORT"
357O_SRV="$O_SRV -accept $PORT"
358O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200359G_SRV="$G_SRV -p $PORT"
360G_CLI="$G_CLI -p $PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200361
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200362# Also pick a unique name for intermediate files
363SRV_OUT="srv_out.$$"
364CLI_OUT="cli_out.$$"
365SESSION="session.$$"
366
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200367SKIP_NEXT="NO"
368
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100369trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100370
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200371# Basic test
372
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200373# Checks that:
374# - things work with all ciphersuites active (used with config-full in all.sh)
375# - the expected (highest security) parameters are selected
376# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200377run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200378 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200379 "$P_CLI" \
380 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200381 -s "Protocol is TLSv1.2" \
382 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
383 -s "client hello v3, signature_algorithm ext: 6" \
384 -s "ECDHE curve: secp521r1" \
385 -S "error" \
386 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200387
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100388# Test for SSLv2 ClientHello
389
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200390requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200391run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100392 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100393 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100394 0 \
395 -S "parse client hello v2" \
396 -S "ssl_handshake returned"
397
398# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200399requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200400run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200401 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100402 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100403 0 \
404 -s "parse client hello v2" \
405 -S "ssl_handshake returned"
406
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100407# Tests for Truncated HMAC extension
408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200409run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200410 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100411 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100412 0 \
413 -s "dumping 'computed mac' (20 bytes)"
414
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200415run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200416 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100417 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100418 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100419 -s "dumping 'computed mac' (10 bytes)"
420
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100421# Tests for Session Tickets
422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200423run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200424 "$P_SRV debug_level=3 tickets=1" \
425 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100426 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100427 -c "client hello, adding session ticket extension" \
428 -s "found session ticket extension" \
429 -s "server hello, adding session ticket extension" \
430 -c "found session_ticket extension" \
431 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100432 -S "session successfully restored from cache" \
433 -s "session successfully restored from ticket" \
434 -s "a session has been resumed" \
435 -c "a session has been resumed"
436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200437run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200438 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
439 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100440 0 \
441 -c "client hello, adding session ticket extension" \
442 -s "found session ticket extension" \
443 -s "server hello, adding session ticket extension" \
444 -c "found session_ticket extension" \
445 -c "parse new session ticket" \
446 -S "session successfully restored from cache" \
447 -s "session successfully restored from ticket" \
448 -s "a session has been resumed" \
449 -c "a session has been resumed"
450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200451run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200452 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
453 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100454 0 \
455 -c "client hello, adding session ticket extension" \
456 -s "found session ticket extension" \
457 -s "server hello, adding session ticket extension" \
458 -c "found session_ticket extension" \
459 -c "parse new session ticket" \
460 -S "session successfully restored from cache" \
461 -S "session successfully restored from ticket" \
462 -S "a session has been resumed" \
463 -C "a session has been resumed"
464
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200465run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100466 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200467 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100468 0 \
469 -c "client hello, adding session ticket extension" \
470 -c "found session_ticket extension" \
471 -c "parse new session ticket" \
472 -c "a session has been resumed"
473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200474run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200475 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200476 "( $O_CLI -sess_out $SESSION; \
477 $O_CLI -sess_in $SESSION; \
478 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100479 0 \
480 -s "found session ticket extension" \
481 -s "server hello, adding session ticket extension" \
482 -S "session successfully restored from cache" \
483 -s "session successfully restored from ticket" \
484 -s "a session has been resumed"
485
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100486# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200488run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200489 "$P_SRV debug_level=3 tickets=0" \
490 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100491 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100492 -c "client hello, adding session ticket extension" \
493 -s "found session ticket extension" \
494 -S "server hello, adding session ticket extension" \
495 -C "found session_ticket extension" \
496 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100497 -s "session successfully restored from cache" \
498 -S "session successfully restored from ticket" \
499 -s "a session has been resumed" \
500 -c "a session has been resumed"
501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200502run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200503 "$P_SRV debug_level=3 tickets=1" \
504 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100505 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100506 -C "client hello, adding session ticket extension" \
507 -S "found session ticket extension" \
508 -S "server hello, adding session ticket extension" \
509 -C "found session_ticket extension" \
510 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100511 -s "session successfully restored from cache" \
512 -S "session successfully restored from ticket" \
513 -s "a session has been resumed" \
514 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200516run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200517 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
518 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100519 0 \
520 -S "session successfully restored from cache" \
521 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100522 -S "a session has been resumed" \
523 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100524
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200525run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200526 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
527 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100528 0 \
529 -s "session successfully restored from cache" \
530 -S "session successfully restored from ticket" \
531 -s "a session has been resumed" \
532 -c "a session has been resumed"
533
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200534run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200535 "$P_SRV debug_level=3 tickets=0" \
536 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100537 0 \
538 -s "session successfully restored from cache" \
539 -S "session successfully restored from ticket" \
540 -s "a session has been resumed" \
541 -c "a session has been resumed"
542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200543run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200544 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
545 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100546 0 \
547 -S "session successfully restored from cache" \
548 -S "session successfully restored from ticket" \
549 -S "a session has been resumed" \
550 -C "a session has been resumed"
551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200552run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200553 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
554 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100555 0 \
556 -s "session successfully restored from cache" \
557 -S "session successfully restored from ticket" \
558 -s "a session has been resumed" \
559 -c "a session has been resumed"
560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200561run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200562 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200563 "( $O_CLI -sess_out $SESSION; \
564 $O_CLI -sess_in $SESSION; \
565 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100566 0 \
567 -s "found session ticket extension" \
568 -S "server hello, adding session ticket extension" \
569 -s "session successfully restored from cache" \
570 -S "session successfully restored from ticket" \
571 -s "a session has been resumed"
572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200573run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100574 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200575 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100576 0 \
577 -C "found session_ticket extension" \
578 -C "parse new session ticket" \
579 -c "a session has been resumed"
580
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100581# Tests for Max Fragment Length extension
582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200583run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200584 "$P_SRV debug_level=3" \
585 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100586 0 \
587 -C "client hello, adding max_fragment_length extension" \
588 -S "found max fragment length extension" \
589 -S "server hello, max_fragment_length extension" \
590 -C "found max_fragment_length extension"
591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200592run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200593 "$P_SRV debug_level=3" \
594 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100595 0 \
596 -c "client hello, adding max_fragment_length extension" \
597 -s "found max fragment length extension" \
598 -s "server hello, max_fragment_length extension" \
599 -c "found max_fragment_length extension"
600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200601run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200602 "$P_SRV debug_level=3 max_frag_len=4096" \
603 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100604 0 \
605 -C "client hello, adding max_fragment_length extension" \
606 -S "found max fragment length extension" \
607 -S "server hello, max_fragment_length extension" \
608 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100609
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200610requires_gnutls
611run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200612 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200613 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200614 0 \
615 -c "client hello, adding max_fragment_length extension" \
616 -c "found max_fragment_length extension"
617
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100618# Tests for renegotiation
619
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200620run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200621 "$P_SRV debug_level=3 exchanges=2" \
622 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100623 0 \
624 -C "client hello, adding renegotiation extension" \
625 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
626 -S "found renegotiation extension" \
627 -s "server hello, secure renegotiation extension" \
628 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100629 -C "=> renegotiate" \
630 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100631 -S "write hello request"
632
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200633run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200634 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
635 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100636 0 \
637 -c "client hello, adding renegotiation extension" \
638 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
639 -s "found renegotiation extension" \
640 -s "server hello, secure renegotiation extension" \
641 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100642 -c "=> renegotiate" \
643 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100644 -S "write hello request"
645
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200646run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200647 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
648 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100649 0 \
650 -c "client hello, adding renegotiation extension" \
651 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
652 -s "found renegotiation extension" \
653 -s "server hello, secure renegotiation extension" \
654 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100655 -c "=> renegotiate" \
656 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100657 -s "write hello request"
658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200659run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200660 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
661 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100662 0 \
663 -c "client hello, adding renegotiation extension" \
664 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
665 -s "found renegotiation extension" \
666 -s "server hello, secure renegotiation extension" \
667 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100668 -c "=> renegotiate" \
669 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100670 -s "write hello request"
671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200672run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200673 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
674 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100675 1 \
676 -c "client hello, adding renegotiation extension" \
677 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
678 -S "found renegotiation extension" \
679 -s "server hello, secure renegotiation extension" \
680 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100681 -c "=> renegotiate" \
682 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200683 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200684 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200685 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200687run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200688 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
689 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100690 0 \
691 -C "client hello, adding renegotiation extension" \
692 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
693 -S "found renegotiation extension" \
694 -s "server hello, secure renegotiation extension" \
695 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100696 -C "=> renegotiate" \
697 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100698 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200699 -S "SSL - An unexpected message was received from our peer" \
700 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100701
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200702run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200703 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200704 renego_delay=-1" \
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é-Gonnarda8c0a0d2014-08-15 12:07:38 +0200718# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200719run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200720 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200721 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200722 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200723 0 \
724 -C "client hello, adding renegotiation extension" \
725 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
726 -S "found renegotiation extension" \
727 -s "server hello, secure renegotiation extension" \
728 -c "found renegotiation extension" \
729 -C "=> renegotiate" \
730 -S "=> renegotiate" \
731 -s "write hello request" \
732 -S "SSL - An unexpected message was received from our peer" \
733 -S "failed"
734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200735run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200736 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200737 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200738 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200739 0 \
740 -C "client hello, adding renegotiation extension" \
741 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
742 -S "found renegotiation extension" \
743 -s "server hello, secure renegotiation extension" \
744 -c "found renegotiation extension" \
745 -C "=> renegotiate" \
746 -S "=> renegotiate" \
747 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200748 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200749
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200750run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200751 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200752 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200753 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200754 0 \
755 -c "client hello, adding renegotiation extension" \
756 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
757 -s "found renegotiation extension" \
758 -s "server hello, secure renegotiation extension" \
759 -c "found renegotiation extension" \
760 -c "=> renegotiate" \
761 -s "=> renegotiate" \
762 -s "write hello request" \
763 -S "SSL - An unexpected message was received from our peer" \
764 -S "failed"
765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200766run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200767 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
768 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200769 0 \
770 -c "client hello, adding renegotiation extension" \
771 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
772 -s "found renegotiation extension" \
773 -s "server hello, secure renegotiation extension" \
774 -c "found renegotiation extension" \
775 -c "=> renegotiate" \
776 -s "=> renegotiate" \
777 -S "write hello request"
778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200779run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200780 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
781 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200782 0 \
783 -c "client hello, adding renegotiation extension" \
784 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
785 -s "found renegotiation extension" \
786 -s "server hello, secure renegotiation extension" \
787 -c "found renegotiation extension" \
788 -c "=> renegotiate" \
789 -s "=> renegotiate" \
790 -s "write hello request"
791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200792run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200793 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200794 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200795 0 \
796 -c "client hello, adding renegotiation extension" \
797 -c "found renegotiation extension" \
798 -c "=> renegotiate" \
799 -C "ssl_handshake returned" \
800 -C "error" \
801 -c "HTTP/1.0 200 [Oo][Kk]"
802
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200803run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200804 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200805 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200806 0 \
807 -c "client hello, adding renegotiation extension" \
808 -c "found renegotiation extension" \
809 -c "=> renegotiate" \
810 -C "ssl_handshake returned" \
811 -C "error" \
812 -c "HTTP/1.0 200 [Oo][Kk]"
813
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100814# Tests for auth_mode
815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200816run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100817 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100818 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200819 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100820 1 \
821 -c "x509_verify_cert() returned" \
822 -c "! self-signed or not signed by a trusted CA" \
823 -c "! ssl_handshake returned" \
824 -c "X509 - Certificate verification failed"
825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200826run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100827 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100828 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200829 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100830 0 \
831 -c "x509_verify_cert() returned" \
832 -c "! self-signed or not signed by a trusted CA" \
833 -C "! ssl_handshake returned" \
834 -C "X509 - Certificate verification failed"
835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200836run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100837 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100838 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200839 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100840 0 \
841 -C "x509_verify_cert() returned" \
842 -C "! self-signed or not signed by a trusted CA" \
843 -C "! ssl_handshake returned" \
844 -C "X509 - Certificate verification failed"
845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200846run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200847 "$P_SRV debug_level=3 auth_mode=required" \
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 1 \
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 optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200864 "$P_SRV debug_level=3 auth_mode=optional" \
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 a 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 badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200881 "$P_SRV debug_level=3 auth_mode=none" \
882 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100883 key_file=data_files/server5.key" \
884 0 \
885 -s "skip write certificate request" \
886 -C "skip parse certificate request" \
887 -c "got no certificate request" \
888 -c "skip write certificate" \
889 -c "skip write certificate verify" \
890 -s "skip parse certificate verify" \
891 -S "x509_verify_cert() returned" \
892 -S "! self-signed or not signed by a trusted CA" \
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: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200898 "$P_SRV debug_level=3 auth_mode=optional" \
899 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100900 0 \
901 -S "skip write certificate request" \
902 -C "skip parse certificate request" \
903 -c "got a certificate request" \
904 -C "skip write certificate$" \
905 -C "got no certificate to send" \
906 -S "SSLv3 client has no certificate" \
907 -c "skip write certificate verify" \
908 -s "skip parse certificate verify" \
909 -s "! no client certificate sent" \
910 -S "! ssl_handshake returned" \
911 -C "! ssl_handshake returned" \
912 -S "X509 - Certificate verification failed"
913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200914run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200915 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100916 "$O_CLI" \
917 0 \
918 -S "skip write certificate request" \
919 -s "skip parse certificate verify" \
920 -s "! no client certificate sent" \
921 -S "! ssl_handshake returned" \
922 -S "X509 - Certificate verification failed"
923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200924run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100925 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200926 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100927 0 \
928 -C "skip parse certificate request" \
929 -c "got a certificate request" \
930 -C "skip write certificate$" \
931 -c "skip write certificate verify" \
932 -C "! ssl_handshake returned"
933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200934run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200935 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
936 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100937 0 \
938 -S "skip write certificate request" \
939 -C "skip parse certificate request" \
940 -c "got a certificate request" \
941 -C "skip write certificate$" \
942 -c "skip write certificate verify" \
943 -c "got no certificate to send" \
944 -s "SSLv3 client has no certificate" \
945 -s "skip parse certificate verify" \
946 -s "! no client certificate sent" \
947 -S "! ssl_handshake returned" \
948 -C "! ssl_handshake returned" \
949 -S "X509 - Certificate verification failed"
950
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100951# tests for SNI
952
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200953run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200954 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100955 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100956 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100957 server_name=localhost" \
958 0 \
959 -S "parse ServerName extension" \
960 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
961 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200963run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200964 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100965 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100966 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 +0100967 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100968 server_name=localhost" \
969 0 \
970 -s "parse ServerName extension" \
971 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
972 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
973
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200974run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200975 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100976 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100977 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 +0100978 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100979 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100980 0 \
981 -s "parse ServerName extension" \
982 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100983 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200985run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200986 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100987 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100988 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 +0100989 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100990 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100991 1 \
992 -s "parse ServerName extension" \
993 -s "ssl_sni_wrapper() returned" \
994 -s "ssl_handshake returned" \
995 -c "ssl_handshake returned" \
996 -c "SSL - A fatal alert message was received from our peer"
997
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +0100998# Tests for non-blocking I/O: exercise a variety of handshake flows
999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001000run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001001 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1002 "$P_CLI nbio=2 tickets=0" \
1003 0 \
1004 -S "ssl_handshake returned" \
1005 -C "ssl_handshake returned" \
1006 -c "Read from server: .* bytes read"
1007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001008run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001009 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1010 "$P_CLI nbio=2 tickets=0" \
1011 0 \
1012 -S "ssl_handshake returned" \
1013 -C "ssl_handshake returned" \
1014 -c "Read from server: .* bytes read"
1015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001016run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001017 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1018 "$P_CLI nbio=2 tickets=1" \
1019 0 \
1020 -S "ssl_handshake returned" \
1021 -C "ssl_handshake returned" \
1022 -c "Read from server: .* bytes read"
1023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001024run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001025 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1026 "$P_CLI nbio=2 tickets=1" \
1027 0 \
1028 -S "ssl_handshake returned" \
1029 -C "ssl_handshake returned" \
1030 -c "Read from server: .* bytes read"
1031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001032run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001033 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1034 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1035 0 \
1036 -S "ssl_handshake returned" \
1037 -C "ssl_handshake returned" \
1038 -c "Read from server: .* bytes read"
1039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001040run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001041 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1042 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1043 0 \
1044 -S "ssl_handshake returned" \
1045 -C "ssl_handshake returned" \
1046 -c "Read from server: .* bytes read"
1047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001048run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001049 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1050 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1051 0 \
1052 -S "ssl_handshake returned" \
1053 -C "ssl_handshake returned" \
1054 -c "Read from server: .* bytes read"
1055
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001056# Tests for version negotiation
1057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001058run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001059 "$P_SRV" \
1060 "$P_CLI" \
1061 0 \
1062 -S "ssl_handshake returned" \
1063 -C "ssl_handshake returned" \
1064 -s "Protocol is TLSv1.2" \
1065 -c "Protocol is TLSv1.2"
1066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001067run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001068 "$P_SRV" \
1069 "$P_CLI max_version=tls1_1" \
1070 0 \
1071 -S "ssl_handshake returned" \
1072 -C "ssl_handshake returned" \
1073 -s "Protocol is TLSv1.1" \
1074 -c "Protocol is TLSv1.1"
1075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001076run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001077 "$P_SRV max_version=tls1_1" \
1078 "$P_CLI" \
1079 0 \
1080 -S "ssl_handshake returned" \
1081 -C "ssl_handshake returned" \
1082 -s "Protocol is TLSv1.1" \
1083 -c "Protocol is TLSv1.1"
1084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001085run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001086 "$P_SRV max_version=tls1_1" \
1087 "$P_CLI max_version=tls1_1" \
1088 0 \
1089 -S "ssl_handshake returned" \
1090 -C "ssl_handshake returned" \
1091 -s "Protocol is TLSv1.1" \
1092 -c "Protocol is TLSv1.1"
1093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001094run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001095 "$P_SRV min_version=tls1_1" \
1096 "$P_CLI max_version=tls1_1" \
1097 0 \
1098 -S "ssl_handshake returned" \
1099 -C "ssl_handshake returned" \
1100 -s "Protocol is TLSv1.1" \
1101 -c "Protocol is TLSv1.1"
1102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001103run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001104 "$P_SRV max_version=tls1_1" \
1105 "$P_CLI min_version=tls1_1" \
1106 0 \
1107 -S "ssl_handshake returned" \
1108 -C "ssl_handshake returned" \
1109 -s "Protocol is TLSv1.1" \
1110 -c "Protocol is TLSv1.1"
1111
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001112run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001113 "$P_SRV max_version=tls1_1" \
1114 "$P_CLI min_version=tls1_2" \
1115 1 \
1116 -s "ssl_handshake returned" \
1117 -c "ssl_handshake returned" \
1118 -c "SSL - Handshake protocol not within min/max boundaries"
1119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001120run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001121 "$P_SRV min_version=tls1_2" \
1122 "$P_CLI max_version=tls1_1" \
1123 1 \
1124 -s "ssl_handshake returned" \
1125 -c "ssl_handshake returned" \
1126 -s "SSL - Handshake protocol not within min/max boundaries"
1127
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001128# Tests for ALPN extension
1129
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001130if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001132run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001133 "$P_SRV debug_level=3" \
1134 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001135 0 \
1136 -C "client hello, adding alpn extension" \
1137 -S "found alpn extension" \
1138 -C "got an alert message, type: \\[2:120]" \
1139 -S "server hello, adding alpn extension" \
1140 -C "found alpn extension " \
1141 -C "Application Layer Protocol is" \
1142 -S "Application Layer Protocol is"
1143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001144run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001145 "$P_SRV debug_level=3" \
1146 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001147 0 \
1148 -c "client hello, adding alpn extension" \
1149 -s "found alpn extension" \
1150 -C "got an alert message, type: \\[2:120]" \
1151 -S "server hello, adding alpn extension" \
1152 -C "found alpn extension " \
1153 -c "Application Layer Protocol is (none)" \
1154 -S "Application Layer Protocol is"
1155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001156run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001157 "$P_SRV debug_level=3 alpn=abc,1234" \
1158 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001159 0 \
1160 -C "client hello, adding alpn extension" \
1161 -S "found alpn extension" \
1162 -C "got an alert message, type: \\[2:120]" \
1163 -S "server hello, adding alpn extension" \
1164 -C "found alpn extension " \
1165 -C "Application Layer Protocol is" \
1166 -s "Application Layer Protocol is (none)"
1167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001168run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001169 "$P_SRV debug_level=3 alpn=abc,1234" \
1170 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001171 0 \
1172 -c "client hello, adding alpn extension" \
1173 -s "found alpn extension" \
1174 -C "got an alert message, type: \\[2:120]" \
1175 -s "server hello, adding alpn extension" \
1176 -c "found alpn extension" \
1177 -c "Application Layer Protocol is abc" \
1178 -s "Application Layer Protocol is abc"
1179
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001180run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001181 "$P_SRV debug_level=3 alpn=abc,1234" \
1182 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001183 0 \
1184 -c "client hello, adding alpn extension" \
1185 -s "found alpn extension" \
1186 -C "got an alert message, type: \\[2:120]" \
1187 -s "server hello, adding alpn extension" \
1188 -c "found alpn extension" \
1189 -c "Application Layer Protocol is abc" \
1190 -s "Application Layer Protocol is abc"
1191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001192run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001193 "$P_SRV debug_level=3 alpn=abc,1234" \
1194 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001195 0 \
1196 -c "client hello, adding alpn extension" \
1197 -s "found alpn extension" \
1198 -C "got an alert message, type: \\[2:120]" \
1199 -s "server hello, adding alpn extension" \
1200 -c "found alpn extension" \
1201 -c "Application Layer Protocol is 1234" \
1202 -s "Application Layer Protocol is 1234"
1203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001204run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001205 "$P_SRV debug_level=3 alpn=abc,123" \
1206 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001207 1 \
1208 -c "client hello, adding alpn extension" \
1209 -s "found alpn extension" \
1210 -c "got an alert message, type: \\[2:120]" \
1211 -S "server hello, adding alpn extension" \
1212 -C "found alpn extension" \
1213 -C "Application Layer Protocol is 1234" \
1214 -S "Application Layer Protocol is 1234"
1215
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001216fi
1217
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001218# Tests for keyUsage in leaf certificates, part 1:
1219# server-side certificate/suite selection
1220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001221run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001222 "$P_SRV key_file=data_files/server2.key \
1223 crt_file=data_files/server2.ku-ds.crt" \
1224 "$P_CLI" \
1225 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001226 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001227
1228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001230 "$P_SRV key_file=data_files/server2.key \
1231 crt_file=data_files/server2.ku-ke.crt" \
1232 "$P_CLI" \
1233 0 \
1234 -c "Ciphersuite is TLS-RSA-WITH-"
1235
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001236run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001237 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001238 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001239 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001240 1 \
1241 -C "Ciphersuite is "
1242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001243run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001244 "$P_SRV key_file=data_files/server5.key \
1245 crt_file=data_files/server5.ku-ds.crt" \
1246 "$P_CLI" \
1247 0 \
1248 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1249
1250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001251run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001252 "$P_SRV key_file=data_files/server5.key \
1253 crt_file=data_files/server5.ku-ka.crt" \
1254 "$P_CLI" \
1255 0 \
1256 -c "Ciphersuite is TLS-ECDH-"
1257
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001258run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001259 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001260 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001261 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001262 1 \
1263 -C "Ciphersuite is "
1264
1265# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001266# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001268run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001269 "$O_SRV -key data_files/server2.key \
1270 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001271 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001272 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1273 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001274 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001275 -C "Processing of the Certificate handshake message failed" \
1276 -c "Ciphersuite is TLS-"
1277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001278run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001279 "$O_SRV -key data_files/server2.key \
1280 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001281 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001282 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1283 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001284 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001285 -C "Processing of the Certificate handshake message failed" \
1286 -c "Ciphersuite is TLS-"
1287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001288run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001289 "$O_SRV -key data_files/server2.key \
1290 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001291 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001292 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1293 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001294 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001295 -C "Processing of the Certificate handshake message failed" \
1296 -c "Ciphersuite is TLS-"
1297
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001298run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001299 "$O_SRV -key data_files/server2.key \
1300 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001301 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001302 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1303 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001304 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001305 -c "Processing of the Certificate handshake message failed" \
1306 -C "Ciphersuite is TLS-"
1307
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001308run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001309 "$O_SRV -key data_files/server2.key \
1310 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001311 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001312 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1313 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001314 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001315 -C "Processing of the Certificate handshake message failed" \
1316 -c "Ciphersuite is TLS-"
1317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001318run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001319 "$O_SRV -key data_files/server2.key \
1320 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001321 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001322 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1323 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001324 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001325 -c "Processing of the Certificate handshake message failed" \
1326 -C "Ciphersuite is TLS-"
1327
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001328# Tests for keyUsage in leaf certificates, part 3:
1329# server-side checking of client cert
1330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001331run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001332 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001333 "$O_CLI -key data_files/server2.key \
1334 -cert data_files/server2.ku-ds.crt" \
1335 0 \
1336 -S "bad certificate (usage extensions)" \
1337 -S "Processing of the Certificate handshake message failed"
1338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001339run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001340 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001341 "$O_CLI -key data_files/server2.key \
1342 -cert data_files/server2.ku-ke.crt" \
1343 0 \
1344 -s "bad certificate (usage extensions)" \
1345 -S "Processing of the Certificate handshake message failed"
1346
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001347run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001348 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001349 "$O_CLI -key data_files/server2.key \
1350 -cert data_files/server2.ku-ke.crt" \
1351 1 \
1352 -s "bad certificate (usage extensions)" \
1353 -s "Processing of the Certificate handshake message failed"
1354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001355run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001356 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001357 "$O_CLI -key data_files/server5.key \
1358 -cert data_files/server5.ku-ds.crt" \
1359 0 \
1360 -S "bad certificate (usage extensions)" \
1361 -S "Processing of the Certificate handshake message failed"
1362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001363run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001365 "$O_CLI -key data_files/server5.key \
1366 -cert data_files/server5.ku-ka.crt" \
1367 0 \
1368 -s "bad certificate (usage extensions)" \
1369 -S "Processing of the Certificate handshake message failed"
1370
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001371# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001373run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001374 "$P_SRV key_file=data_files/server5.key \
1375 crt_file=data_files/server5.eku-srv.crt" \
1376 "$P_CLI" \
1377 0
1378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001379run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001380 "$P_SRV key_file=data_files/server5.key \
1381 crt_file=data_files/server5.eku-srv.crt" \
1382 "$P_CLI" \
1383 0
1384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001385run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001386 "$P_SRV key_file=data_files/server5.key \
1387 crt_file=data_files/server5.eku-cs_any.crt" \
1388 "$P_CLI" \
1389 0
1390
1391# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001392run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001393 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1394 crt_file=data_files/server5.eku-cli.crt" \
1395 "$P_CLI psk=badbad" \
1396 1
1397
1398# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001400run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001401 "$O_SRV -key data_files/server5.key \
1402 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001403 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001404 0 \
1405 -C "bad certificate (usage extensions)" \
1406 -C "Processing of the Certificate handshake message failed" \
1407 -c "Ciphersuite is TLS-"
1408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001409run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001410 "$O_SRV -key data_files/server5.key \
1411 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001412 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001413 0 \
1414 -C "bad certificate (usage extensions)" \
1415 -C "Processing of the Certificate handshake message failed" \
1416 -c "Ciphersuite is TLS-"
1417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001418run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001419 "$O_SRV -key data_files/server5.key \
1420 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001421 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001422 0 \
1423 -C "bad certificate (usage extensions)" \
1424 -C "Processing of the Certificate handshake message failed" \
1425 -c "Ciphersuite is TLS-"
1426
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001427run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001428 "$O_SRV -key data_files/server5.key \
1429 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001430 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001431 1 \
1432 -c "bad certificate (usage extensions)" \
1433 -c "Processing of the Certificate handshake message failed" \
1434 -C "Ciphersuite is TLS-"
1435
1436# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001438run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001439 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001440 "$O_CLI -key data_files/server5.key \
1441 -cert data_files/server5.eku-cli.crt" \
1442 0 \
1443 -S "bad certificate (usage extensions)" \
1444 -S "Processing of the Certificate handshake message failed"
1445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001446run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001447 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001448 "$O_CLI -key data_files/server5.key \
1449 -cert data_files/server5.eku-srv_cli.crt" \
1450 0 \
1451 -S "bad certificate (usage extensions)" \
1452 -S "Processing of the Certificate handshake message failed"
1453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001454run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001455 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001456 "$O_CLI -key data_files/server5.key \
1457 -cert data_files/server5.eku-cs_any.crt" \
1458 0 \
1459 -S "bad certificate (usage extensions)" \
1460 -S "Processing of the Certificate handshake message failed"
1461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001462run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001463 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001464 "$O_CLI -key data_files/server5.key \
1465 -cert data_files/server5.eku-cs.crt" \
1466 0 \
1467 -s "bad certificate (usage extensions)" \
1468 -S "Processing of the Certificate handshake message failed"
1469
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001470run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001471 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001472 "$O_CLI -key data_files/server5.key \
1473 -cert data_files/server5.eku-cs.crt" \
1474 1 \
1475 -s "bad certificate (usage extensions)" \
1476 -s "Processing of the Certificate handshake message failed"
1477
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001478# Tests for DHM parameters loading
1479
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001480run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001481 "$P_SRV" \
1482 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1483 debug_level=3" \
1484 0 \
1485 -c "value of 'DHM: P ' (2048 bits)" \
1486 -c "value of 'DHM: G ' (2048 bits)"
1487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001488run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001489 "$P_SRV dhm_file=data_files/dhparams.pem" \
1490 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1491 debug_level=3" \
1492 0 \
1493 -c "value of 'DHM: P ' (1024 bits)" \
1494 -c "value of 'DHM: G ' (2 bits)"
1495
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001496# Tests for PSK callback
1497
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001498run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001499 "$P_SRV psk=abc123 psk_identity=foo" \
1500 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1501 psk_identity=foo psk=abc123" \
1502 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001503 -S "SSL - The server has no ciphersuites in common" \
1504 -S "SSL - Unknown identity received" \
1505 -S "SSL - Verification of the message MAC failed"
1506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001508 "$P_SRV" \
1509 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1510 psk_identity=foo psk=abc123" \
1511 1 \
1512 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001513 -S "SSL - Unknown identity received" \
1514 -S "SSL - Verification of the message MAC failed"
1515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001516run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001517 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1518 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1519 psk_identity=foo psk=abc123" \
1520 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001521 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001522 -s "SSL - Unknown identity received" \
1523 -S "SSL - Verification of the message MAC failed"
1524
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001525run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001526 "$P_SRV psk_list=abc,dead,def,beef" \
1527 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1528 psk_identity=abc psk=dead" \
1529 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001530 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001531 -S "SSL - Unknown identity received" \
1532 -S "SSL - Verification of the message MAC failed"
1533
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001534run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001535 "$P_SRV psk_list=abc,dead,def,beef" \
1536 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1537 psk_identity=def psk=beef" \
1538 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001539 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001540 -S "SSL - Unknown identity received" \
1541 -S "SSL - Verification of the message MAC failed"
1542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001543run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001544 "$P_SRV psk_list=abc,dead,def,beef" \
1545 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1546 psk_identity=ghi psk=beef" \
1547 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001548 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001549 -s "SSL - Unknown identity received" \
1550 -S "SSL - Verification of the message MAC failed"
1551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001552run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001553 "$P_SRV psk_list=abc,dead,def,beef" \
1554 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1555 psk_identity=abc psk=beef" \
1556 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001557 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001558 -S "SSL - Unknown identity received" \
1559 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001560
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001561# Tests for ciphersuites per version
1562
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001563run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001564 "$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" \
1565 "$P_CLI force_version=ssl3" \
1566 0 \
1567 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001569run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001570 "$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" \
1571 "$P_CLI force_version=tls1" \
1572 0 \
1573 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001575run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001576 "$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" \
1577 "$P_CLI force_version=tls1_1" \
1578 0 \
1579 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001581run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001582 "$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" \
1583 "$P_CLI force_version=tls1_2" \
1584 0 \
1585 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1586
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001587# Tests for ssl_get_bytes_avail()
1588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001589run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001590 "$P_SRV" \
1591 "$P_CLI request_size=100" \
1592 0 \
1593 -s "Read from client: 100 bytes read$"
1594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001595run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001596 "$P_SRV" \
1597 "$P_CLI request_size=500" \
1598 0 \
1599 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001600
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001601# Tests for small packets
1602
1603run_test "Small packet SSLv3 BlockCipher" \
1604 "$P_SRV" \
1605 "$P_CLI request_size=1 force_version=ssl3 \
1606 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1607 0 \
1608 -s "Read from client: 1 bytes read"
1609
1610run_test "Small packet SSLv3 StreamCipher" \
1611 "$P_SRV" \
1612 "$P_CLI request_size=1 force_version=ssl3 \
1613 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1614 0 \
1615 -s "Read from client: 1 bytes read"
1616
1617run_test "Small packet TLS 1.0 BlockCipher" \
1618 "$P_SRV" \
1619 "$P_CLI request_size=1 force_version=tls1 \
1620 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1621 0 \
1622 -s "Read from client: 1 bytes read"
1623
1624run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1625 "$P_SRV" \
1626 "$P_CLI request_size=1 force_version=tls1 \
1627 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1628 trunc_hmac=1" \
1629 0 \
1630 -s "Read from client: 1 bytes read"
1631
1632run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1633 "$P_SRV" \
1634 "$P_CLI request_size=1 force_version=tls1 \
1635 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1636 trunc_hmac=1" \
1637 0 \
1638 -s "Read from client: 1 bytes read"
1639
1640run_test "Small packet TLS 1.1 BlockCipher" \
1641 "$P_SRV" \
1642 "$P_CLI request_size=1 force_version=tls1_1 \
1643 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1644 0 \
1645 -s "Read from client: 1 bytes read"
1646
1647run_test "Small packet TLS 1.1 StreamCipher" \
1648 "$P_SRV" \
1649 "$P_CLI request_size=1 force_version=tls1_1 \
1650 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1651 0 \
1652 -s "Read from client: 1 bytes read"
1653
1654run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1655 "$P_SRV" \
1656 "$P_CLI request_size=1 force_version=tls1_1 \
1657 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1658 trunc_hmac=1" \
1659 0 \
1660 -s "Read from client: 1 bytes read"
1661
1662run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1663 "$P_SRV" \
1664 "$P_CLI request_size=1 force_version=tls1_1 \
1665 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1666 trunc_hmac=1" \
1667 0 \
1668 -s "Read from client: 1 bytes read"
1669
1670run_test "Small packet TLS 1.2 BlockCipher" \
1671 "$P_SRV" \
1672 "$P_CLI request_size=1 force_version=tls1_2 \
1673 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1674 0 \
1675 -s "Read from client: 1 bytes read"
1676
1677run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1678 "$P_SRV" \
1679 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1680 0 \
1681 -s "Read from client: 1 bytes read"
1682
1683run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1684 "$P_SRV" \
1685 "$P_CLI request_size=1 force_version=tls1_2 \
1686 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1687 trunc_hmac=1" \
1688 0 \
1689 -s "Read from client: 1 bytes read"
1690
1691run_test "Small packet TLS 1.2 StreamCipher" \
1692 "$P_SRV" \
1693 "$P_CLI request_size=1 force_version=tls1_2 \
1694 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1695 0 \
1696 -s "Read from client: 1 bytes read"
1697
1698run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1699 "$P_SRV" \
1700 "$P_CLI request_size=1 force_version=tls1_2 \
1701 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1702 trunc_hmac=1" \
1703 0 \
1704 -s "Read from client: 1 bytes read"
1705
1706run_test "Small packet TLS 1.2 AEAD" \
1707 "$P_SRV" \
1708 "$P_CLI request_size=1 force_version=tls1_2 \
1709 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1710 0 \
1711 -s "Read from client: 1 bytes read"
1712
1713run_test "Small packet TLS 1.2 AEAD shorter tag" \
1714 "$P_SRV" \
1715 "$P_CLI request_size=1 force_version=tls1_2 \
1716 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1717 0 \
1718 -s "Read from client: 1 bytes read"
1719
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001720# Test for large packets
1721
1722run_test "Large packet SSLv3 BlockCipher" \
1723 "$P_SRV" \
1724 "$P_CLI request_size=16384 force_version=ssl3 \
1725 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1726 0 \
1727 -s "Read from client: 16384 bytes read"
1728
1729run_test "Large packet SSLv3 StreamCipher" \
1730 "$P_SRV" \
1731 "$P_CLI request_size=16384 force_version=ssl3 \
1732 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1733 0 \
1734 -s "Read from client: 16384 bytes read"
1735
1736run_test "Large packet TLS 1.0 BlockCipher" \
1737 "$P_SRV" \
1738 "$P_CLI request_size=16384 force_version=tls1 \
1739 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1740 0 \
1741 -s "Read from client: 16384 bytes read"
1742
1743run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1744 "$P_SRV" \
1745 "$P_CLI request_size=16384 force_version=tls1 \
1746 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1747 trunc_hmac=1" \
1748 0 \
1749 -s "Read from client: 16384 bytes read"
1750
1751run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1752 "$P_SRV" \
1753 "$P_CLI request_size=16384 force_version=tls1 \
1754 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1755 trunc_hmac=1" \
1756 0 \
1757 -s "Read from client: 16384 bytes read"
1758
1759run_test "Large packet TLS 1.1 BlockCipher" \
1760 "$P_SRV" \
1761 "$P_CLI request_size=16384 force_version=tls1_1 \
1762 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1763 0 \
1764 -s "Read from client: 16384 bytes read"
1765
1766run_test "Large packet TLS 1.1 StreamCipher" \
1767 "$P_SRV" \
1768 "$P_CLI request_size=16384 force_version=tls1_1 \
1769 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1770 0 \
1771 -s "Read from client: 16384 bytes read"
1772
1773run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1774 "$P_SRV" \
1775 "$P_CLI request_size=16384 force_version=tls1_1 \
1776 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1777 trunc_hmac=1" \
1778 0 \
1779 -s "Read from client: 16384 bytes read"
1780
1781run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1782 "$P_SRV" \
1783 "$P_CLI request_size=16384 force_version=tls1_1 \
1784 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1785 trunc_hmac=1" \
1786 0 \
1787 -s "Read from client: 16384 bytes read"
1788
1789run_test "Large packet TLS 1.2 BlockCipher" \
1790 "$P_SRV" \
1791 "$P_CLI request_size=16384 force_version=tls1_2 \
1792 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1793 0 \
1794 -s "Read from client: 16384 bytes read"
1795
1796run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1797 "$P_SRV" \
1798 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1799 0 \
1800 -s "Read from client: 16384 bytes read"
1801
1802run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1803 "$P_SRV" \
1804 "$P_CLI request_size=16384 force_version=tls1_2 \
1805 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1806 trunc_hmac=1" \
1807 0 \
1808 -s "Read from client: 16384 bytes read"
1809
1810run_test "Large packet TLS 1.2 StreamCipher" \
1811 "$P_SRV" \
1812 "$P_CLI request_size=16384 force_version=tls1_2 \
1813 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1814 0 \
1815 -s "Read from client: 16384 bytes read"
1816
1817run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1818 "$P_SRV" \
1819 "$P_CLI request_size=16384 force_version=tls1_2 \
1820 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1821 trunc_hmac=1" \
1822 0 \
1823 -s "Read from client: 16384 bytes read"
1824
1825run_test "Large packet TLS 1.2 AEAD" \
1826 "$P_SRV" \
1827 "$P_CLI request_size=16384 force_version=tls1_2 \
1828 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1829 0 \
1830 -s "Read from client: 16384 bytes read"
1831
1832run_test "Large packet TLS 1.2 AEAD shorter tag" \
1833 "$P_SRV" \
1834 "$P_CLI request_size=16384 force_version=tls1_2 \
1835 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1836 0 \
1837 -s "Read from client: 16384 bytes read"
1838
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001839# Final report
1840
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001841echo "------------------------------------------------------------------------"
1842
1843if [ $FAILS = 0 ]; then
1844 echo -n "PASSED"
1845else
1846 echo -n "FAILED"
1847fi
1848PASSES=`echo $TESTS - $FAILS | bc`
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001849echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001850
1851exit $FAILS