blob: d5b1a296daafa18d9d861764d919fe4164d2d378 [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#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
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é-Gonnarda7756172014-08-31 18:37:01 +020020O_SRV="$OPENSSL_CMD s_server -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010021O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
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
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +020078
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020079 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
80 SKIP_NEXT="YES"
81 fi
82}
83
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020084# skip next test if GnuTLS isn't available
85requires_gnutls() {
86 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
87 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
88 GNUTLS_AVAILABLE="YES"
89 else
90 GNUTLS_AVAILABLE="NO"
91 fi
92 fi
93 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
94 SKIP_NEXT="YES"
95 fi
96}
97
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +020098# skip next test if IPv6 isn't available on this host
99requires_ipv6() {
100 if [ -z "${HAS_IPV6:-}" ]; then
101 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
102 SRV_PID=$!
103 sleep 1
104 kill $SRV_PID >/dev/null 2>&1
105 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
106 HAS_IPV6="NO"
107 else
108 HAS_IPV6="YES"
109 fi
110 rm -r $SRV_OUT
111 fi
112
113 if [ "$HAS_IPV6" = "NO" ]; then
114 SKIP_NEXT="YES"
115 fi
116}
117
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100118# print_name <name>
119print_name() {
120 echo -n "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200121 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100122 for i in `seq 1 $LEN`; do echo -n '.'; done
123 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100124
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200125 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100126}
127
128# fail <message>
129fail() {
130 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100131 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100132
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200133 mv $SRV_OUT o-srv-${TESTS}.log
134 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100135 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100136
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200137 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
138 echo " ! server output:"
139 cat o-srv-${TESTS}.log
140 echo " ! ============================================================"
141 echo " ! client output:"
142 cat o-cli-${TESTS}.log
143 fi
144
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200145 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100146}
147
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100148# is_polar <cmd_line>
149is_polar() {
150 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
151}
152
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100153# has_mem_err <log_file_name>
154has_mem_err() {
155 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
156 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
157 then
158 return 1 # false: does not have errors
159 else
160 return 0 # true: has errors
161 fi
162}
163
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200164# wait for server to start: two versions depending on lsof availability
165wait_server_start() {
166 if which lsof >/dev/null; then
167 # make sure we don't loop forever
168 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
169 WATCHDOG_PID=$!
170
171 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200172 if [ "$DTLS" -eq 1 ]; then
173 until lsof -nbi UDP:"$PORT" | grep UDP >/dev/null; do :; done
174 else
175 until lsof -nbi TCP:"$PORT" | grep LISTEN >/dev/null; do :; done
176 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200177
178 kill $WATCHDOG_PID
179 wait $WATCHDOG_PID
180 else
181 sleep "$START_DELAY"
182 fi
183}
184
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200185# wait for client to terminate and set CLI_EXIT
186# must be called right after starting the client
187wait_client_done() {
188 CLI_PID=$!
189
190 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
191 WATCHDOG_PID=$!
192
193 wait $CLI_PID
194 CLI_EXIT=$?
195
196 kill $WATCHDOG_PID
197 wait $WATCHDOG_PID
198
199 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
200}
201
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200202# check if the given command uses dtls and sets global variable DTLS
203detect_dtls() {
204 if echo "$1" | grep ' dtls=1 \| -dtls1\| -u ' >/dev/null; then
205 DTLS=1
206 else
207 DTLS=0
208 fi
209}
210
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100211# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100212# Options: -s pattern pattern that must be present in server output
213# -c pattern pattern that must be present in client output
214# -S pattern pattern that must be absent in server output
215# -C pattern pattern that must be absent in client output
216run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100217 NAME="$1"
218 SRV_CMD="$2"
219 CLI_CMD="$3"
220 CLI_EXPECT="$4"
221 shift 4
222
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100223 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
224 else
225 return
226 fi
227
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100228 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100229
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200230 # should we skip?
231 if [ "X$SKIP_NEXT" = "XYES" ]; then
232 SKIP_NEXT="NO"
233 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200234 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200235 return
236 fi
237
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200238 # update DTLS variable
239 detect_dtls "$SRV_CMD"
240
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100241 # prepend valgrind to our commands if active
242 if [ "$MEMCHECK" -gt 0 ]; then
243 if is_polar "$SRV_CMD"; then
244 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
245 fi
246 if is_polar "$CLI_CMD"; then
247 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
248 fi
249 fi
250
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100251 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200252 echo "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +0200253 # for servers without -www, eg openssl with DTLS
254 yes blabla | $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100255 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200256 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200257
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200258 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200259 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
260 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100261
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200262 # kill the server
263 kill $SRV_PID
264 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100265
266 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200267 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100268 # expected client exit to incorrectly succeed in case of catastrophic
269 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100270 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200271 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100272 else
273 fail "server failed to start"
274 return
275 fi
276 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100277 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200278 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100279 else
280 fail "client failed to start"
281 return
282 fi
283 fi
284
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100285 # check server exit code
286 if [ $? != 0 ]; then
287 fail "server fail"
288 return
289 fi
290
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100291 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100292 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
293 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100294 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100295 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100296 return
297 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100298
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100299 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200300 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100301 while [ $# -gt 0 ]
302 do
303 case $1 in
304 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200305 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100306 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100307 return
308 fi
309 ;;
310
311 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200312 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100313 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100314 return
315 fi
316 ;;
317
318 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200319 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100320 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100321 return
322 fi
323 ;;
324
325 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200326 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100327 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100328 return
329 fi
330 ;;
331
332 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200333 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100334 exit 1
335 esac
336 shift 2
337 done
338
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100339 # check valgrind's results
340 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200341 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100342 fail "Server has memory errors"
343 return
344 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200345 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100346 fail "Client has memory errors"
347 return
348 fi
349 fi
350
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100351 # if we're here, everything is ok
352 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200353 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100354}
355
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100356cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200357 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200358 kill $SRV_PID >/dev/null 2>&1
359 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100360 exit 1
361}
362
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100363#
364# MAIN
365#
366
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100367get_options "$@"
368
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100369# sanity checks, avoid an avalanche of errors
370if [ ! -x "$P_SRV" ]; then
371 echo "Command '$P_SRV' is not an executable file"
372 exit 1
373fi
374if [ ! -x "$P_CLI" ]; then
375 echo "Command '$P_CLI' is not an executable file"
376 exit 1
377fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100378if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
379 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100380 exit 1
381fi
382
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200383# used by watchdog
384MAIN_PID="$$"
385
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200386# be more patient with valgrind
387if [ "$MEMCHECK" -gt 0 ]; then
388 START_DELAY=3
389 DOG_DELAY=30
390else
391 START_DELAY=1
392 DOG_DELAY=10
393fi
394
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200395# Pick a "unique" port in the range 10000-19999.
396PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200397PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200398
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200399# fix commands to use this port, force IPv4 while at it
400P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$PORT"
401P_CLI="$P_CLI server_addr=127.0.0.1 server_port=$PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200402O_SRV="$O_SRV -accept $PORT"
403O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200404G_SRV="$G_SRV -p $PORT"
405G_CLI="$G_CLI -p $PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200406
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200407# Also pick a unique name for intermediate files
408SRV_OUT="srv_out.$$"
409CLI_OUT="cli_out.$$"
410SESSION="session.$$"
411
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200412SKIP_NEXT="NO"
413
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100414trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100415
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200416# Basic test
417
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200418# Checks that:
419# - things work with all ciphersuites active (used with config-full in all.sh)
420# - the expected (highest security) parameters are selected
421# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200422run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200423 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200424 "$P_CLI" \
425 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200426 -s "Protocol is TLSv1.2" \
427 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
428 -s "client hello v3, signature_algorithm ext: 6" \
429 -s "ECDHE curve: secp521r1" \
430 -S "error" \
431 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200432
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100433# Test for SSLv2 ClientHello
434
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200435requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200436run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100437 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100438 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100439 0 \
440 -S "parse client hello v2" \
441 -S "ssl_handshake returned"
442
443# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200444requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200445run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200446 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100447 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100448 0 \
449 -s "parse client hello v2" \
450 -S "ssl_handshake returned"
451
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100452# Tests for Truncated HMAC extension
453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200454run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200455 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100456 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100457 0 \
458 -s "dumping 'computed mac' (20 bytes)"
459
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200460run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200461 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100462 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100463 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100464 -s "dumping 'computed mac' (10 bytes)"
465
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100466# Tests for Session Tickets
467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200468run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200469 "$P_SRV debug_level=3 tickets=1" \
470 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100471 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100472 -c "client hello, adding session ticket extension" \
473 -s "found session ticket extension" \
474 -s "server hello, adding session ticket extension" \
475 -c "found session_ticket extension" \
476 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100477 -S "session successfully restored from cache" \
478 -s "session successfully restored from ticket" \
479 -s "a session has been resumed" \
480 -c "a session has been resumed"
481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200482run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200483 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
484 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100485 0 \
486 -c "client hello, adding session ticket extension" \
487 -s "found session ticket extension" \
488 -s "server hello, adding session ticket extension" \
489 -c "found session_ticket extension" \
490 -c "parse new session ticket" \
491 -S "session successfully restored from cache" \
492 -s "session successfully restored from ticket" \
493 -s "a session has been resumed" \
494 -c "a session has been resumed"
495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200496run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200497 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
498 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100499 0 \
500 -c "client hello, adding session ticket extension" \
501 -s "found session ticket extension" \
502 -s "server hello, adding session ticket extension" \
503 -c "found session_ticket extension" \
504 -c "parse new session ticket" \
505 -S "session successfully restored from cache" \
506 -S "session successfully restored from ticket" \
507 -S "a session has been resumed" \
508 -C "a session has been resumed"
509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200510run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100511 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200512 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100513 0 \
514 -c "client hello, adding session ticket extension" \
515 -c "found session_ticket extension" \
516 -c "parse new session ticket" \
517 -c "a session has been resumed"
518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200519run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200520 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200521 "( $O_CLI -sess_out $SESSION; \
522 $O_CLI -sess_in $SESSION; \
523 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100524 0 \
525 -s "found session ticket extension" \
526 -s "server hello, adding session ticket extension" \
527 -S "session successfully restored from cache" \
528 -s "session successfully restored from ticket" \
529 -s "a session has been resumed"
530
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100531# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200533run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200534 "$P_SRV debug_level=3 tickets=0" \
535 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100536 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100537 -c "client hello, adding session ticket extension" \
538 -s "found session ticket extension" \
539 -S "server hello, adding session ticket extension" \
540 -C "found session_ticket extension" \
541 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100542 -s "session successfully restored from cache" \
543 -S "session successfully restored from ticket" \
544 -s "a session has been resumed" \
545 -c "a session has been resumed"
546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200547run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200548 "$P_SRV debug_level=3 tickets=1" \
549 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100550 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100551 -C "client hello, adding session ticket extension" \
552 -S "found session ticket extension" \
553 -S "server hello, adding session ticket extension" \
554 -C "found session_ticket extension" \
555 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100556 -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"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200561run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200562 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
563 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100564 0 \
565 -S "session successfully restored from cache" \
566 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100567 -S "a session has been resumed" \
568 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200570run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200571 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
572 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100573 0 \
574 -s "session successfully restored from cache" \
575 -S "session successfully restored from ticket" \
576 -s "a session has been resumed" \
577 -c "a session has been resumed"
578
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200579run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200580 "$P_SRV debug_level=3 tickets=0" \
581 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100582 0 \
583 -s "session successfully restored from cache" \
584 -S "session successfully restored from ticket" \
585 -s "a session has been resumed" \
586 -c "a session has been resumed"
587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200588run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200589 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
590 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100591 0 \
592 -S "session successfully restored from cache" \
593 -S "session successfully restored from ticket" \
594 -S "a session has been resumed" \
595 -C "a session has been resumed"
596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200597run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200598 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
599 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100600 0 \
601 -s "session successfully restored from cache" \
602 -S "session successfully restored from ticket" \
603 -s "a session has been resumed" \
604 -c "a session has been resumed"
605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200606run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200607 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200608 "( $O_CLI -sess_out $SESSION; \
609 $O_CLI -sess_in $SESSION; \
610 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100611 0 \
612 -s "found session ticket extension" \
613 -S "server hello, adding session ticket extension" \
614 -s "session successfully restored from cache" \
615 -S "session successfully restored from ticket" \
616 -s "a session has been resumed"
617
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200618run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100619 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200620 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100621 0 \
622 -C "found session_ticket extension" \
623 -C "parse new session ticket" \
624 -c "a session has been resumed"
625
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100626# Tests for Max Fragment Length extension
627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200628run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200629 "$P_SRV debug_level=3" \
630 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100631 0 \
632 -C "client hello, adding max_fragment_length extension" \
633 -S "found max fragment length extension" \
634 -S "server hello, max_fragment_length extension" \
635 -C "found max_fragment_length extension"
636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200637run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200638 "$P_SRV debug_level=3" \
639 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100640 0 \
641 -c "client hello, adding max_fragment_length extension" \
642 -s "found max fragment length extension" \
643 -s "server hello, max_fragment_length extension" \
644 -c "found max_fragment_length extension"
645
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200646run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200647 "$P_SRV debug_level=3 max_frag_len=4096" \
648 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100649 0 \
650 -C "client hello, adding max_fragment_length extension" \
651 -S "found max fragment length extension" \
652 -S "server hello, max_fragment_length extension" \
653 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200655requires_gnutls
656run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200657 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200658 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200659 0 \
660 -c "client hello, adding max_fragment_length extension" \
661 -c "found max_fragment_length extension"
662
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100663# Tests for renegotiation
664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200665run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200666 "$P_SRV debug_level=3 exchanges=2" \
667 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100668 0 \
669 -C "client hello, adding renegotiation extension" \
670 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
671 -S "found renegotiation extension" \
672 -s "server hello, secure renegotiation extension" \
673 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100674 -C "=> renegotiate" \
675 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100676 -S "write hello request"
677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200678run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200679 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
680 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100681 0 \
682 -c "client hello, adding renegotiation extension" \
683 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
684 -s "found renegotiation extension" \
685 -s "server hello, secure renegotiation extension" \
686 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100687 -c "=> renegotiate" \
688 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100689 -S "write hello request"
690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200691run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200692 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
693 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100694 0 \
695 -c "client hello, adding renegotiation extension" \
696 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
697 -s "found renegotiation extension" \
698 -s "server hello, secure renegotiation extension" \
699 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100700 -c "=> renegotiate" \
701 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100702 -s "write hello request"
703
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200704run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200705 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
706 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100707 0 \
708 -c "client hello, adding renegotiation extension" \
709 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
710 -s "found renegotiation extension" \
711 -s "server hello, secure renegotiation extension" \
712 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100713 -c "=> renegotiate" \
714 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100715 -s "write hello request"
716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200717run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200718 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
719 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100720 1 \
721 -c "client hello, adding renegotiation extension" \
722 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
723 -S "found renegotiation extension" \
724 -s "server hello, secure renegotiation extension" \
725 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100726 -c "=> renegotiate" \
727 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200728 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200729 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200730 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200732run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200733 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
734 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100735 0 \
736 -C "client hello, adding renegotiation extension" \
737 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
738 -S "found renegotiation extension" \
739 -s "server hello, secure renegotiation extension" \
740 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100741 -C "=> renegotiate" \
742 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100743 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200744 -S "SSL - An unexpected message was received from our peer" \
745 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200747run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200748 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200749 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200750 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200751 0 \
752 -C "client hello, adding renegotiation extension" \
753 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
754 -S "found renegotiation extension" \
755 -s "server hello, secure renegotiation extension" \
756 -c "found renegotiation extension" \
757 -C "=> renegotiate" \
758 -S "=> renegotiate" \
759 -s "write hello request" \
760 -S "SSL - An unexpected message was received from our peer" \
761 -S "failed"
762
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200763# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200764run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200765 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200766 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200767 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200768 0 \
769 -C "client hello, adding renegotiation extension" \
770 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
771 -S "found renegotiation extension" \
772 -s "server hello, secure renegotiation extension" \
773 -c "found renegotiation extension" \
774 -C "=> renegotiate" \
775 -S "=> renegotiate" \
776 -s "write hello request" \
777 -S "SSL - An unexpected message was received from our peer" \
778 -S "failed"
779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200780run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200781 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200782 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200783 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200784 0 \
785 -C "client hello, adding renegotiation extension" \
786 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
787 -S "found renegotiation extension" \
788 -s "server hello, secure renegotiation extension" \
789 -c "found renegotiation extension" \
790 -C "=> renegotiate" \
791 -S "=> renegotiate" \
792 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200793 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200795run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200796 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200797 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200798 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200799 0 \
800 -c "client hello, adding renegotiation extension" \
801 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
802 -s "found renegotiation extension" \
803 -s "server hello, secure renegotiation extension" \
804 -c "found renegotiation extension" \
805 -c "=> renegotiate" \
806 -s "=> renegotiate" \
807 -s "write hello request" \
808 -S "SSL - An unexpected message was received from our peer" \
809 -S "failed"
810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200811run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200812 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
813 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200814 0 \
815 -c "client hello, adding renegotiation extension" \
816 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
817 -s "found renegotiation extension" \
818 -s "server hello, secure renegotiation extension" \
819 -c "found renegotiation extension" \
820 -c "=> renegotiate" \
821 -s "=> renegotiate" \
822 -S "write hello request"
823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200824run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200825 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
826 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200827 0 \
828 -c "client hello, adding renegotiation extension" \
829 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
830 -s "found renegotiation extension" \
831 -s "server hello, secure renegotiation extension" \
832 -c "found renegotiation extension" \
833 -c "=> renegotiate" \
834 -s "=> renegotiate" \
835 -s "write hello request"
836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200837run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +0200838 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200839 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200840 0 \
841 -c "client hello, adding renegotiation extension" \
842 -c "found renegotiation extension" \
843 -c "=> renegotiate" \
844 -C "ssl_handshake returned" \
845 -C "error" \
846 -c "HTTP/1.0 200 [Oo][Kk]"
847
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200848run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200849 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200850 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200851 0 \
852 -c "client hello, adding renegotiation extension" \
853 -c "found renegotiation extension" \
854 -c "=> renegotiate" \
855 -C "ssl_handshake returned" \
856 -C "error" \
857 -c "HTTP/1.0 200 [Oo][Kk]"
858
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +0200859run_test "Renegotiation: DTLS, client-initiated" \
860 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
861 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
862 0 \
863 -c "client hello, adding renegotiation extension" \
864 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
865 -s "found renegotiation extension" \
866 -s "server hello, secure renegotiation extension" \
867 -c "found renegotiation extension" \
868 -c "=> renegotiate" \
869 -s "=> renegotiate" \
870 -S "write hello request"
871
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +0200872run_test "Renegotiation: DTLS, server-initiated" \
873 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
874 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
875 0 \
876 -c "client hello, adding renegotiation extension" \
877 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
878 -s "found renegotiation extension" \
879 -s "server hello, secure renegotiation extension" \
880 -c "found renegotiation extension" \
881 -c "=> renegotiate" \
882 -s "=> renegotiate" \
883 -s "write hello request"
884
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100885# Tests for auth_mode
886
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200887run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100888 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100889 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200890 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100891 1 \
892 -c "x509_verify_cert() returned" \
893 -c "! self-signed or not signed by a trusted CA" \
894 -c "! ssl_handshake returned" \
895 -c "X509 - Certificate verification failed"
896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200897run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100898 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100899 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200900 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100901 0 \
902 -c "x509_verify_cert() returned" \
903 -c "! self-signed or not signed by a trusted CA" \
904 -C "! ssl_handshake returned" \
905 -C "X509 - Certificate verification failed"
906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200907run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100908 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100909 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200910 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100911 0 \
912 -C "x509_verify_cert() returned" \
913 -C "! self-signed or not signed by a trusted CA" \
914 -C "! ssl_handshake returned" \
915 -C "X509 - Certificate verification failed"
916
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200917run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200918 "$P_SRV debug_level=3 auth_mode=required" \
919 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100920 key_file=data_files/server5.key" \
921 1 \
922 -S "skip write certificate request" \
923 -C "skip parse certificate request" \
924 -c "got a certificate request" \
925 -C "skip write certificate" \
926 -C "skip write certificate verify" \
927 -S "skip parse certificate verify" \
928 -s "x509_verify_cert() returned" \
929 -S "! self-signed or not signed by a trusted CA" \
930 -s "! ssl_handshake returned" \
931 -c "! ssl_handshake returned" \
932 -s "X509 - Certificate verification failed"
933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200934run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200935 "$P_SRV debug_level=3 auth_mode=optional" \
936 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100937 key_file=data_files/server5.key" \
938 0 \
939 -S "skip write certificate request" \
940 -C "skip parse certificate request" \
941 -c "got a certificate request" \
942 -C "skip write certificate" \
943 -C "skip write certificate verify" \
944 -S "skip parse certificate verify" \
945 -s "x509_verify_cert() returned" \
946 -s "! self-signed or not signed by a trusted CA" \
947 -S "! ssl_handshake returned" \
948 -C "! ssl_handshake returned" \
949 -S "X509 - Certificate verification failed"
950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200951run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200952 "$P_SRV debug_level=3 auth_mode=none" \
953 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100954 key_file=data_files/server5.key" \
955 0 \
956 -s "skip write certificate request" \
957 -C "skip parse certificate request" \
958 -c "got no certificate request" \
959 -c "skip write certificate" \
960 -c "skip write certificate verify" \
961 -s "skip parse certificate verify" \
962 -S "x509_verify_cert() returned" \
963 -S "! self-signed or not signed by a trusted CA" \
964 -S "! ssl_handshake returned" \
965 -C "! ssl_handshake returned" \
966 -S "X509 - Certificate verification failed"
967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200968run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200969 "$P_SRV debug_level=3 auth_mode=optional" \
970 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100971 0 \
972 -S "skip write certificate request" \
973 -C "skip parse certificate request" \
974 -c "got a certificate request" \
975 -C "skip write certificate$" \
976 -C "got no certificate to send" \
977 -S "SSLv3 client has no certificate" \
978 -c "skip write certificate verify" \
979 -s "skip parse certificate verify" \
980 -s "! no client certificate sent" \
981 -S "! ssl_handshake returned" \
982 -C "! ssl_handshake returned" \
983 -S "X509 - Certificate verification failed"
984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200985run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200986 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100987 "$O_CLI" \
988 0 \
989 -S "skip write certificate request" \
990 -s "skip parse certificate verify" \
991 -s "! no client certificate sent" \
992 -S "! ssl_handshake returned" \
993 -S "X509 - Certificate verification failed"
994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200995run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100996 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200997 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100998 0 \
999 -C "skip parse certificate request" \
1000 -c "got a certificate request" \
1001 -C "skip write certificate$" \
1002 -c "skip write certificate verify" \
1003 -C "! ssl_handshake returned"
1004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001005run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001006 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1007 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001008 0 \
1009 -S "skip write certificate request" \
1010 -C "skip parse certificate request" \
1011 -c "got a certificate request" \
1012 -C "skip write certificate$" \
1013 -c "skip write certificate verify" \
1014 -c "got no certificate to send" \
1015 -s "SSLv3 client has no certificate" \
1016 -s "skip parse certificate verify" \
1017 -s "! no client certificate sent" \
1018 -S "! ssl_handshake returned" \
1019 -C "! ssl_handshake returned" \
1020 -S "X509 - Certificate verification failed"
1021
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001022# tests for SNI
1023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001024run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001025 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001026 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001027 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001028 0 \
1029 -S "parse ServerName extension" \
1030 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1031 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001033run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001034 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001035 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001036 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001037 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001038 0 \
1039 -s "parse ServerName extension" \
1040 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1041 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1042
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001043run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001044 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001045 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001046 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001047 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001048 0 \
1049 -s "parse ServerName extension" \
1050 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001051 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001053run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001054 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001055 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001056 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001057 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001058 1 \
1059 -s "parse ServerName extension" \
1060 -s "ssl_sni_wrapper() returned" \
1061 -s "ssl_handshake returned" \
1062 -c "ssl_handshake returned" \
1063 -c "SSL - A fatal alert message was received from our peer"
1064
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001065# Tests for non-blocking I/O: exercise a variety of handshake flows
1066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001067run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001068 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1069 "$P_CLI nbio=2 tickets=0" \
1070 0 \
1071 -S "ssl_handshake returned" \
1072 -C "ssl_handshake returned" \
1073 -c "Read from server: .* bytes read"
1074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001075run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001076 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1077 "$P_CLI nbio=2 tickets=0" \
1078 0 \
1079 -S "ssl_handshake returned" \
1080 -C "ssl_handshake returned" \
1081 -c "Read from server: .* bytes read"
1082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001083run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001084 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1085 "$P_CLI nbio=2 tickets=1" \
1086 0 \
1087 -S "ssl_handshake returned" \
1088 -C "ssl_handshake returned" \
1089 -c "Read from server: .* bytes read"
1090
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001091run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001092 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1093 "$P_CLI nbio=2 tickets=1" \
1094 0 \
1095 -S "ssl_handshake returned" \
1096 -C "ssl_handshake returned" \
1097 -c "Read from server: .* bytes read"
1098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001099run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001100 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1101 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1102 0 \
1103 -S "ssl_handshake returned" \
1104 -C "ssl_handshake returned" \
1105 -c "Read from server: .* bytes read"
1106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001107run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001108 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1109 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1110 0 \
1111 -S "ssl_handshake returned" \
1112 -C "ssl_handshake returned" \
1113 -c "Read from server: .* bytes read"
1114
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001115run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001116 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1117 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1118 0 \
1119 -S "ssl_handshake returned" \
1120 -C "ssl_handshake returned" \
1121 -c "Read from server: .* bytes read"
1122
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001123# Tests for version negotiation
1124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001125run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001126 "$P_SRV" \
1127 "$P_CLI" \
1128 0 \
1129 -S "ssl_handshake returned" \
1130 -C "ssl_handshake returned" \
1131 -s "Protocol is TLSv1.2" \
1132 -c "Protocol is TLSv1.2"
1133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001134run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001135 "$P_SRV" \
1136 "$P_CLI max_version=tls1_1" \
1137 0 \
1138 -S "ssl_handshake returned" \
1139 -C "ssl_handshake returned" \
1140 -s "Protocol is TLSv1.1" \
1141 -c "Protocol is TLSv1.1"
1142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001143run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001144 "$P_SRV max_version=tls1_1" \
1145 "$P_CLI" \
1146 0 \
1147 -S "ssl_handshake returned" \
1148 -C "ssl_handshake returned" \
1149 -s "Protocol is TLSv1.1" \
1150 -c "Protocol is TLSv1.1"
1151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001152run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001153 "$P_SRV max_version=tls1_1" \
1154 "$P_CLI max_version=tls1_1" \
1155 0 \
1156 -S "ssl_handshake returned" \
1157 -C "ssl_handshake returned" \
1158 -s "Protocol is TLSv1.1" \
1159 -c "Protocol is TLSv1.1"
1160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001161run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001162 "$P_SRV min_version=tls1_1" \
1163 "$P_CLI max_version=tls1_1" \
1164 0 \
1165 -S "ssl_handshake returned" \
1166 -C "ssl_handshake returned" \
1167 -s "Protocol is TLSv1.1" \
1168 -c "Protocol is TLSv1.1"
1169
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001170run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001171 "$P_SRV max_version=tls1_1" \
1172 "$P_CLI min_version=tls1_1" \
1173 0 \
1174 -S "ssl_handshake returned" \
1175 -C "ssl_handshake returned" \
1176 -s "Protocol is TLSv1.1" \
1177 -c "Protocol is TLSv1.1"
1178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001179run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001180 "$P_SRV max_version=tls1_1" \
1181 "$P_CLI min_version=tls1_2" \
1182 1 \
1183 -s "ssl_handshake returned" \
1184 -c "ssl_handshake returned" \
1185 -c "SSL - Handshake protocol not within min/max boundaries"
1186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001187run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001188 "$P_SRV min_version=tls1_2" \
1189 "$P_CLI max_version=tls1_1" \
1190 1 \
1191 -s "ssl_handshake returned" \
1192 -c "ssl_handshake returned" \
1193 -s "SSL - Handshake protocol not within min/max boundaries"
1194
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001195# Tests for ALPN extension
1196
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001197if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001199run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001200 "$P_SRV debug_level=3" \
1201 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001202 0 \
1203 -C "client hello, adding alpn extension" \
1204 -S "found alpn extension" \
1205 -C "got an alert message, type: \\[2:120]" \
1206 -S "server hello, adding alpn extension" \
1207 -C "found alpn extension " \
1208 -C "Application Layer Protocol is" \
1209 -S "Application Layer Protocol is"
1210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001211run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001212 "$P_SRV debug_level=3" \
1213 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001214 0 \
1215 -c "client hello, adding alpn extension" \
1216 -s "found alpn extension" \
1217 -C "got an alert message, type: \\[2:120]" \
1218 -S "server hello, adding alpn extension" \
1219 -C "found alpn extension " \
1220 -c "Application Layer Protocol is (none)" \
1221 -S "Application Layer Protocol is"
1222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001223run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001224 "$P_SRV debug_level=3 alpn=abc,1234" \
1225 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001226 0 \
1227 -C "client hello, adding alpn extension" \
1228 -S "found alpn extension" \
1229 -C "got an alert message, type: \\[2:120]" \
1230 -S "server hello, adding alpn extension" \
1231 -C "found alpn extension " \
1232 -C "Application Layer Protocol is" \
1233 -s "Application Layer Protocol is (none)"
1234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001235run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001236 "$P_SRV debug_level=3 alpn=abc,1234" \
1237 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001238 0 \
1239 -c "client hello, adding alpn extension" \
1240 -s "found alpn extension" \
1241 -C "got an alert message, type: \\[2:120]" \
1242 -s "server hello, adding alpn extension" \
1243 -c "found alpn extension" \
1244 -c "Application Layer Protocol is abc" \
1245 -s "Application Layer Protocol is abc"
1246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001247run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001248 "$P_SRV debug_level=3 alpn=abc,1234" \
1249 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001250 0 \
1251 -c "client hello, adding alpn extension" \
1252 -s "found alpn extension" \
1253 -C "got an alert message, type: \\[2:120]" \
1254 -s "server hello, adding alpn extension" \
1255 -c "found alpn extension" \
1256 -c "Application Layer Protocol is abc" \
1257 -s "Application Layer Protocol is abc"
1258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001259run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001260 "$P_SRV debug_level=3 alpn=abc,1234" \
1261 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001262 0 \
1263 -c "client hello, adding alpn extension" \
1264 -s "found alpn extension" \
1265 -C "got an alert message, type: \\[2:120]" \
1266 -s "server hello, adding alpn extension" \
1267 -c "found alpn extension" \
1268 -c "Application Layer Protocol is 1234" \
1269 -s "Application Layer Protocol is 1234"
1270
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001271run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001272 "$P_SRV debug_level=3 alpn=abc,123" \
1273 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001274 1 \
1275 -c "client hello, adding alpn extension" \
1276 -s "found alpn extension" \
1277 -c "got an alert message, type: \\[2:120]" \
1278 -S "server hello, adding alpn extension" \
1279 -C "found alpn extension" \
1280 -C "Application Layer Protocol is 1234" \
1281 -S "Application Layer Protocol is 1234"
1282
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001283fi
1284
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001285# Tests for keyUsage in leaf certificates, part 1:
1286# server-side certificate/suite selection
1287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001288run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001289 "$P_SRV key_file=data_files/server2.key \
1290 crt_file=data_files/server2.ku-ds.crt" \
1291 "$P_CLI" \
1292 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001293 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001294
1295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001296run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001297 "$P_SRV key_file=data_files/server2.key \
1298 crt_file=data_files/server2.ku-ke.crt" \
1299 "$P_CLI" \
1300 0 \
1301 -c "Ciphersuite is TLS-RSA-WITH-"
1302
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001303run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001304 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001305 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001306 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001307 1 \
1308 -C "Ciphersuite is "
1309
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001310run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001311 "$P_SRV key_file=data_files/server5.key \
1312 crt_file=data_files/server5.ku-ds.crt" \
1313 "$P_CLI" \
1314 0 \
1315 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1316
1317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001318run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001319 "$P_SRV key_file=data_files/server5.key \
1320 crt_file=data_files/server5.ku-ka.crt" \
1321 "$P_CLI" \
1322 0 \
1323 -c "Ciphersuite is TLS-ECDH-"
1324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001325run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001326 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001327 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001328 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001329 1 \
1330 -C "Ciphersuite is "
1331
1332# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001333# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001335run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001336 "$O_SRV -key data_files/server2.key \
1337 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001338 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001339 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1340 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001341 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001342 -C "Processing of the Certificate handshake message failed" \
1343 -c "Ciphersuite is TLS-"
1344
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001345run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001346 "$O_SRV -key data_files/server2.key \
1347 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001348 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001349 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1350 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001351 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001352 -C "Processing of the Certificate handshake message failed" \
1353 -c "Ciphersuite is TLS-"
1354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001355run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001356 "$O_SRV -key data_files/server2.key \
1357 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001358 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001359 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1360 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001361 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001362 -C "Processing of the Certificate handshake message failed" \
1363 -c "Ciphersuite is TLS-"
1364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001365run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001366 "$O_SRV -key data_files/server2.key \
1367 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001368 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001369 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1370 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001371 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001372 -c "Processing of the Certificate handshake message failed" \
1373 -C "Ciphersuite is TLS-"
1374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001375run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001376 "$O_SRV -key data_files/server2.key \
1377 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001378 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001379 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1380 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001381 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001382 -C "Processing of the Certificate handshake message failed" \
1383 -c "Ciphersuite is TLS-"
1384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001385run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001386 "$O_SRV -key data_files/server2.key \
1387 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001388 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001389 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1390 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001391 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001392 -c "Processing of the Certificate handshake message failed" \
1393 -C "Ciphersuite is TLS-"
1394
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001395# Tests for keyUsage in leaf certificates, part 3:
1396# server-side checking of client cert
1397
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001398run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001399 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001400 "$O_CLI -key data_files/server2.key \
1401 -cert data_files/server2.ku-ds.crt" \
1402 0 \
1403 -S "bad certificate (usage extensions)" \
1404 -S "Processing of the Certificate handshake message failed"
1405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001406run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001407 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001408 "$O_CLI -key data_files/server2.key \
1409 -cert data_files/server2.ku-ke.crt" \
1410 0 \
1411 -s "bad certificate (usage extensions)" \
1412 -S "Processing of the Certificate handshake message failed"
1413
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001414run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001415 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001416 "$O_CLI -key data_files/server2.key \
1417 -cert data_files/server2.ku-ke.crt" \
1418 1 \
1419 -s "bad certificate (usage extensions)" \
1420 -s "Processing of the Certificate handshake message failed"
1421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001422run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001423 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001424 "$O_CLI -key data_files/server5.key \
1425 -cert data_files/server5.ku-ds.crt" \
1426 0 \
1427 -S "bad certificate (usage extensions)" \
1428 -S "Processing of the Certificate handshake message failed"
1429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001430run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001431 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001432 "$O_CLI -key data_files/server5.key \
1433 -cert data_files/server5.ku-ka.crt" \
1434 0 \
1435 -s "bad certificate (usage extensions)" \
1436 -S "Processing of the Certificate handshake message failed"
1437
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001438# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001440run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001441 "$P_SRV key_file=data_files/server5.key \
1442 crt_file=data_files/server5.eku-srv.crt" \
1443 "$P_CLI" \
1444 0
1445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001446run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001447 "$P_SRV key_file=data_files/server5.key \
1448 crt_file=data_files/server5.eku-srv.crt" \
1449 "$P_CLI" \
1450 0
1451
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001452run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001453 "$P_SRV key_file=data_files/server5.key \
1454 crt_file=data_files/server5.eku-cs_any.crt" \
1455 "$P_CLI" \
1456 0
1457
1458# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001459run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001460 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1461 crt_file=data_files/server5.eku-cli.crt" \
1462 "$P_CLI psk=badbad" \
1463 1
1464
1465# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1466
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001467run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001468 "$O_SRV -key data_files/server5.key \
1469 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001470 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001471 0 \
1472 -C "bad certificate (usage extensions)" \
1473 -C "Processing of the Certificate handshake message failed" \
1474 -c "Ciphersuite is TLS-"
1475
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001476run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001477 "$O_SRV -key data_files/server5.key \
1478 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001479 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001480 0 \
1481 -C "bad certificate (usage extensions)" \
1482 -C "Processing of the Certificate handshake message failed" \
1483 -c "Ciphersuite is TLS-"
1484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001485run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001486 "$O_SRV -key data_files/server5.key \
1487 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001488 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001489 0 \
1490 -C "bad certificate (usage extensions)" \
1491 -C "Processing of the Certificate handshake message failed" \
1492 -c "Ciphersuite is TLS-"
1493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001494run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001495 "$O_SRV -key data_files/server5.key \
1496 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001497 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001498 1 \
1499 -c "bad certificate (usage extensions)" \
1500 -c "Processing of the Certificate handshake message failed" \
1501 -C "Ciphersuite is TLS-"
1502
1503# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001505run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001506 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001507 "$O_CLI -key data_files/server5.key \
1508 -cert data_files/server5.eku-cli.crt" \
1509 0 \
1510 -S "bad certificate (usage extensions)" \
1511 -S "Processing of the Certificate handshake message failed"
1512
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001513run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001514 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001515 "$O_CLI -key data_files/server5.key \
1516 -cert data_files/server5.eku-srv_cli.crt" \
1517 0 \
1518 -S "bad certificate (usage extensions)" \
1519 -S "Processing of the Certificate handshake message failed"
1520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001521run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001522 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001523 "$O_CLI -key data_files/server5.key \
1524 -cert data_files/server5.eku-cs_any.crt" \
1525 0 \
1526 -S "bad certificate (usage extensions)" \
1527 -S "Processing of the Certificate handshake message failed"
1528
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001529run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001530 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001531 "$O_CLI -key data_files/server5.key \
1532 -cert data_files/server5.eku-cs.crt" \
1533 0 \
1534 -s "bad certificate (usage extensions)" \
1535 -S "Processing of the Certificate handshake message failed"
1536
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001537run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001538 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001539 "$O_CLI -key data_files/server5.key \
1540 -cert data_files/server5.eku-cs.crt" \
1541 1 \
1542 -s "bad certificate (usage extensions)" \
1543 -s "Processing of the Certificate handshake message failed"
1544
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001545# Tests for DHM parameters loading
1546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001547run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001548 "$P_SRV" \
1549 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1550 debug_level=3" \
1551 0 \
1552 -c "value of 'DHM: P ' (2048 bits)" \
1553 -c "value of 'DHM: G ' (2048 bits)"
1554
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001555run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001556 "$P_SRV dhm_file=data_files/dhparams.pem" \
1557 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1558 debug_level=3" \
1559 0 \
1560 -c "value of 'DHM: P ' (1024 bits)" \
1561 -c "value of 'DHM: G ' (2 bits)"
1562
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001563# Tests for PSK callback
1564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001565run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001566 "$P_SRV psk=abc123 psk_identity=foo" \
1567 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1568 psk_identity=foo psk=abc123" \
1569 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001570 -S "SSL - The server has no ciphersuites in common" \
1571 -S "SSL - Unknown identity received" \
1572 -S "SSL - Verification of the message MAC failed"
1573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001574run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001575 "$P_SRV" \
1576 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1577 psk_identity=foo psk=abc123" \
1578 1 \
1579 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001580 -S "SSL - Unknown identity received" \
1581 -S "SSL - Verification of the message MAC failed"
1582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001583run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001584 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1585 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1586 psk_identity=foo psk=abc123" \
1587 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001588 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001589 -s "SSL - Unknown identity received" \
1590 -S "SSL - Verification of the message MAC failed"
1591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001592run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001593 "$P_SRV psk_list=abc,dead,def,beef" \
1594 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1595 psk_identity=abc psk=dead" \
1596 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001597 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001598 -S "SSL - Unknown identity received" \
1599 -S "SSL - Verification of the message MAC failed"
1600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001601run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001602 "$P_SRV psk_list=abc,dead,def,beef" \
1603 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1604 psk_identity=def psk=beef" \
1605 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001606 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001607 -S "SSL - Unknown identity received" \
1608 -S "SSL - Verification of the message MAC failed"
1609
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001610run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001611 "$P_SRV psk_list=abc,dead,def,beef" \
1612 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1613 psk_identity=ghi psk=beef" \
1614 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001615 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001616 -s "SSL - Unknown identity received" \
1617 -S "SSL - Verification of the message MAC failed"
1618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001619run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001620 "$P_SRV psk_list=abc,dead,def,beef" \
1621 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1622 psk_identity=abc psk=beef" \
1623 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001624 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001625 -S "SSL - Unknown identity received" \
1626 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001627
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001628# Tests for ciphersuites per version
1629
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001630run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001631 "$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" \
1632 "$P_CLI force_version=ssl3" \
1633 0 \
1634 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001636run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001637 "$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" \
1638 "$P_CLI force_version=tls1" \
1639 0 \
1640 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001642run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001643 "$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" \
1644 "$P_CLI force_version=tls1_1" \
1645 0 \
1646 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001648run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001649 "$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" \
1650 "$P_CLI force_version=tls1_2" \
1651 0 \
1652 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1653
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001654# Tests for ssl_get_bytes_avail()
1655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001656run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001657 "$P_SRV" \
1658 "$P_CLI request_size=100" \
1659 0 \
1660 -s "Read from client: 100 bytes read$"
1661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001662run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001663 "$P_SRV" \
1664 "$P_CLI request_size=500" \
1665 0 \
1666 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001667
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001668# Tests for small packets
1669
1670run_test "Small packet SSLv3 BlockCipher" \
1671 "$P_SRV" \
1672 "$P_CLI request_size=1 force_version=ssl3 \
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 SSLv3 StreamCipher" \
1678 "$P_SRV" \
1679 "$P_CLI request_size=1 force_version=ssl3 \
1680 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1681 0 \
1682 -s "Read from client: 1 bytes read"
1683
1684run_test "Small packet TLS 1.0 BlockCipher" \
1685 "$P_SRV" \
1686 "$P_CLI request_size=1 force_version=tls1 \
1687 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1688 0 \
1689 -s "Read from client: 1 bytes read"
1690
1691run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1692 "$P_SRV" \
1693 "$P_CLI request_size=1 force_version=tls1 \
1694 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1695 trunc_hmac=1" \
1696 0 \
1697 -s "Read from client: 1 bytes read"
1698
1699run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1700 "$P_SRV" \
1701 "$P_CLI request_size=1 force_version=tls1 \
1702 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1703 trunc_hmac=1" \
1704 0 \
1705 -s "Read from client: 1 bytes read"
1706
1707run_test "Small packet TLS 1.1 BlockCipher" \
1708 "$P_SRV" \
1709 "$P_CLI request_size=1 force_version=tls1_1 \
1710 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1711 0 \
1712 -s "Read from client: 1 bytes read"
1713
1714run_test "Small packet TLS 1.1 StreamCipher" \
1715 "$P_SRV" \
1716 "$P_CLI request_size=1 force_version=tls1_1 \
1717 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1718 0 \
1719 -s "Read from client: 1 bytes read"
1720
1721run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1722 "$P_SRV" \
1723 "$P_CLI request_size=1 force_version=tls1_1 \
1724 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1725 trunc_hmac=1" \
1726 0 \
1727 -s "Read from client: 1 bytes read"
1728
1729run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1730 "$P_SRV" \
1731 "$P_CLI request_size=1 force_version=tls1_1 \
1732 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1733 trunc_hmac=1" \
1734 0 \
1735 -s "Read from client: 1 bytes read"
1736
1737run_test "Small packet TLS 1.2 BlockCipher" \
1738 "$P_SRV" \
1739 "$P_CLI request_size=1 force_version=tls1_2 \
1740 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1741 0 \
1742 -s "Read from client: 1 bytes read"
1743
1744run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1745 "$P_SRV" \
1746 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1747 0 \
1748 -s "Read from client: 1 bytes read"
1749
1750run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1751 "$P_SRV" \
1752 "$P_CLI request_size=1 force_version=tls1_2 \
1753 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1754 trunc_hmac=1" \
1755 0 \
1756 -s "Read from client: 1 bytes read"
1757
1758run_test "Small packet TLS 1.2 StreamCipher" \
1759 "$P_SRV" \
1760 "$P_CLI request_size=1 force_version=tls1_2 \
1761 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1762 0 \
1763 -s "Read from client: 1 bytes read"
1764
1765run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1766 "$P_SRV" \
1767 "$P_CLI request_size=1 force_version=tls1_2 \
1768 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1769 trunc_hmac=1" \
1770 0 \
1771 -s "Read from client: 1 bytes read"
1772
1773run_test "Small packet TLS 1.2 AEAD" \
1774 "$P_SRV" \
1775 "$P_CLI request_size=1 force_version=tls1_2 \
1776 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1777 0 \
1778 -s "Read from client: 1 bytes read"
1779
1780run_test "Small packet TLS 1.2 AEAD shorter tag" \
1781 "$P_SRV" \
1782 "$P_CLI request_size=1 force_version=tls1_2 \
1783 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1784 0 \
1785 -s "Read from client: 1 bytes read"
1786
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001787# Test for large packets
1788
1789run_test "Large packet SSLv3 BlockCipher" \
1790 "$P_SRV" \
1791 "$P_CLI request_size=16384 force_version=ssl3 \
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 SSLv3 StreamCipher" \
1797 "$P_SRV" \
1798 "$P_CLI request_size=16384 force_version=ssl3 \
1799 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1800 0 \
1801 -s "Read from client: 16384 bytes read"
1802
1803run_test "Large packet TLS 1.0 BlockCipher" \
1804 "$P_SRV" \
1805 "$P_CLI request_size=16384 force_version=tls1 \
1806 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1807 0 \
1808 -s "Read from client: 16384 bytes read"
1809
1810run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1811 "$P_SRV" \
1812 "$P_CLI request_size=16384 force_version=tls1 \
1813 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1814 trunc_hmac=1" \
1815 0 \
1816 -s "Read from client: 16384 bytes read"
1817
1818run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1819 "$P_SRV" \
1820 "$P_CLI request_size=16384 force_version=tls1 \
1821 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1822 trunc_hmac=1" \
1823 0 \
1824 -s "Read from client: 16384 bytes read"
1825
1826run_test "Large packet TLS 1.1 BlockCipher" \
1827 "$P_SRV" \
1828 "$P_CLI request_size=16384 force_version=tls1_1 \
1829 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1830 0 \
1831 -s "Read from client: 16384 bytes read"
1832
1833run_test "Large packet TLS 1.1 StreamCipher" \
1834 "$P_SRV" \
1835 "$P_CLI request_size=16384 force_version=tls1_1 \
1836 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1837 0 \
1838 -s "Read from client: 16384 bytes read"
1839
1840run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1841 "$P_SRV" \
1842 "$P_CLI request_size=16384 force_version=tls1_1 \
1843 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1844 trunc_hmac=1" \
1845 0 \
1846 -s "Read from client: 16384 bytes read"
1847
1848run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1849 "$P_SRV" \
1850 "$P_CLI request_size=16384 force_version=tls1_1 \
1851 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1852 trunc_hmac=1" \
1853 0 \
1854 -s "Read from client: 16384 bytes read"
1855
1856run_test "Large packet TLS 1.2 BlockCipher" \
1857 "$P_SRV" \
1858 "$P_CLI request_size=16384 force_version=tls1_2 \
1859 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1860 0 \
1861 -s "Read from client: 16384 bytes read"
1862
1863run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1864 "$P_SRV" \
1865 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1866 0 \
1867 -s "Read from client: 16384 bytes read"
1868
1869run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1870 "$P_SRV" \
1871 "$P_CLI request_size=16384 force_version=tls1_2 \
1872 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1873 trunc_hmac=1" \
1874 0 \
1875 -s "Read from client: 16384 bytes read"
1876
1877run_test "Large packet TLS 1.2 StreamCipher" \
1878 "$P_SRV" \
1879 "$P_CLI request_size=16384 force_version=tls1_2 \
1880 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1881 0 \
1882 -s "Read from client: 16384 bytes read"
1883
1884run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1885 "$P_SRV" \
1886 "$P_CLI request_size=16384 force_version=tls1_2 \
1887 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1888 trunc_hmac=1" \
1889 0 \
1890 -s "Read from client: 16384 bytes read"
1891
1892run_test "Large packet TLS 1.2 AEAD" \
1893 "$P_SRV" \
1894 "$P_CLI request_size=16384 force_version=tls1_2 \
1895 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1896 0 \
1897 -s "Read from client: 16384 bytes read"
1898
1899run_test "Large packet TLS 1.2 AEAD shorter tag" \
1900 "$P_SRV" \
1901 "$P_CLI request_size=16384 force_version=tls1_2 \
1902 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1903 0 \
1904 -s "Read from client: 16384 bytes read"
1905
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001906# Tests for DTLS HelloVerifyRequest
1907
1908run_test "DTLS cookie: enabled" \
1909 "$P_SRV dtls=1 debug_level=2" \
1910 "$P_CLI dtls=1 debug_level=2" \
1911 0 \
1912 -s "cookie verification failed" \
1913 -s "cookie verification passed" \
1914 -S "cookie verification skipped" \
1915 -c "received hello verify request" \
1916 -S "SSL - The requested feature is not available"
1917
1918run_test "DTLS cookie: disabled" \
1919 "$P_SRV dtls=1 debug_level=2 cookies=0" \
1920 "$P_CLI dtls=1 debug_level=2" \
1921 0 \
1922 -S "cookie verification failed" \
1923 -S "cookie verification passed" \
1924 -s "cookie verification skipped" \
1925 -C "received hello verify request" \
1926 -S "SSL - The requested feature is not available"
1927
1928# wait for client having a timeout, or server sending an alert
1929#run_test "DTLS cookie: default (failing)" \
1930# "$P_SRV dtls=1 debug_level=2 cookies=-1" \
1931# "$P_CLI dtls=1 debug_level=2" \
1932# 0 \
1933# -S "cookie verification failed" \
1934# -S "cookie verification passed" \
1935# -S "cookie verification skipped" \
1936# -C "received hello verify request" \
1937# -s "SSL - The requested feature is not available"
1938
1939requires_ipv6
1940run_test "DTLS cookie: enabled, IPv6" \
1941 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
1942 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
1943 0 \
1944 -s "cookie verification failed" \
1945 -s "cookie verification passed" \
1946 -S "cookie verification skipped" \
1947 -c "received hello verify request" \
1948 -S "SSL - The requested feature is not available"
1949
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02001950# Tests for receiving fragmented handshake messages with DTLS
1951
1952requires_gnutls
1953run_test "DTLS reassembly: no fragmentation (gnutls server)" \
1954 "$G_SRV -u --mtu 2048 -a" \
1955 "$P_CLI dtls=1 debug_level=2" \
1956 0 \
1957 -C "found fragmented DTLS handshake message" \
1958 -C "error"
1959
1960requires_gnutls
1961run_test "DTLS reassembly: some fragmentation (gnutls server)" \
1962 "$G_SRV -u --mtu 512" \
1963 "$P_CLI dtls=1 debug_level=2" \
1964 0 \
1965 -c "found fragmented DTLS handshake message" \
1966 -C "error"
1967
1968requires_gnutls
1969run_test "DTLS reassembly: more fragmentation (gnutls server)" \
1970 "$G_SRV -u --mtu 128" \
1971 "$P_CLI dtls=1 debug_level=2" \
1972 0 \
1973 -c "found fragmented DTLS handshake message" \
1974 -C "error"
1975
1976requires_gnutls
1977run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
1978 "$G_SRV -u --mtu 128" \
1979 "$P_CLI dtls=1 nbio=2 debug_level=2" \
1980 0 \
1981 -c "found fragmented DTLS handshake message" \
1982 -C "error"
1983
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001984run_test "DTLS reassembly: no fragmentation (openssl server)" \
1985 "$O_SRV -dtls1 -mtu 2048" \
1986 "$P_CLI dtls=1 debug_level=2" \
1987 0 \
1988 -C "found fragmented DTLS handshake message" \
1989 -C "error"
1990
1991# Not working yet
1992#run_test "DTLS reassembly: fragmentation (openssl server)" \
1993# "$O_SRV -dtls1 -mtu 256" \
1994# "$P_CLI dtls=1 debug_level=2" \
1995# 0 \
1996# -c "found fragmented DTLS handshake message" \
1997# -C "error"
1998#
1999#run_test "DTLS reassembly: fragmentation (openssl server)" \
2000# "$O_SRV -dtls1 -mtu 256" \
2001# "$P_CLI dtls=1 debug_level=2" \
2002# 0 \
2003# -c "found fragmented DTLS handshake message" \
2004# -C "error"
2005#
2006#run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2007# "$O_SRV -dtls1 -mtu 256" \
2008# "$P_CLI dtls=1 nbio=2 debug_level=2" \
2009# 0 \
2010# -c "found fragmented DTLS handshake message" \
2011# -C "error"
2012
2013# TODO: fragmentation with renegotiation, openssl + gnutls
2014
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002015# Final report
2016
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002017echo "------------------------------------------------------------------------"
2018
2019if [ $FAILS = 0 ]; then
2020 echo -n "PASSED"
2021else
2022 echo -n "FAILED"
2023fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002024PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002025echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002026
2027exit $FAILS