blob: 1dac6d63b5569b8b102882f81d8e9ab67bf7b7a1 [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é-Gonnard74faf3c2014-03-13 18:47:44 +010020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
21O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
23G_CLI="$GNUTLS_CLI"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010037 echo -e " -h|--help\tPrint this help."
38 echo -e " -m|--memcheck\tCheck memory leaks and errors."
39 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
40 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
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
253 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100254 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200255 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200256
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200257 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200258 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
259 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100260
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200261 # kill the server
262 kill $SRV_PID
263 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100264
265 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200266 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100267 # expected client exit to incorrectly succeed in case of catastrophic
268 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100269 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200270 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100271 else
272 fail "server failed to start"
273 return
274 fi
275 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100276 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200277 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100278 else
279 fail "client failed to start"
280 return
281 fi
282 fi
283
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100284 # check server exit code
285 if [ $? != 0 ]; then
286 fail "server fail"
287 return
288 fi
289
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100290 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100291 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
292 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100293 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100294 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100295 return
296 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100297
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100298 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200299 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100300 while [ $# -gt 0 ]
301 do
302 case $1 in
303 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200304 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100305 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100306 return
307 fi
308 ;;
309
310 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200311 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100312 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100313 return
314 fi
315 ;;
316
317 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200318 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100319 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100320 return
321 fi
322 ;;
323
324 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200325 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100326 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100327 return
328 fi
329 ;;
330
331 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200332 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100333 exit 1
334 esac
335 shift 2
336 done
337
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100338 # check valgrind's results
339 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200340 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100341 fail "Server has memory errors"
342 return
343 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200344 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100345 fail "Client has memory errors"
346 return
347 fi
348 fi
349
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100350 # if we're here, everything is ok
351 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200352 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100353}
354
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100355cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200356 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200357 kill $SRV_PID >/dev/null 2>&1
358 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100359 exit 1
360}
361
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100362#
363# MAIN
364#
365
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100366get_options "$@"
367
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100368# sanity checks, avoid an avalanche of errors
369if [ ! -x "$P_SRV" ]; then
370 echo "Command '$P_SRV' is not an executable file"
371 exit 1
372fi
373if [ ! -x "$P_CLI" ]; then
374 echo "Command '$P_CLI' is not an executable file"
375 exit 1
376fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100377if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
378 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100379 exit 1
380fi
381
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200382# used by watchdog
383MAIN_PID="$$"
384
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200385# be more patient with valgrind
386if [ "$MEMCHECK" -gt 0 ]; then
387 START_DELAY=3
388 DOG_DELAY=30
389else
390 START_DELAY=1
391 DOG_DELAY=10
392fi
393
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200394# Pick a "unique" port in the range 10000-19999.
395PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200396PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200397
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200398# fix commands to use this port, force IPv4 while at it
399P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$PORT"
400P_CLI="$P_CLI server_addr=127.0.0.1 server_port=$PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200401O_SRV="$O_SRV -accept $PORT"
402O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200403G_SRV="$G_SRV -p $PORT"
404G_CLI="$G_CLI -p $PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200405
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200406# Also pick a unique name for intermediate files
407SRV_OUT="srv_out.$$"
408CLI_OUT="cli_out.$$"
409SESSION="session.$$"
410
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200411SKIP_NEXT="NO"
412
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100413trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100414
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200415# Basic test
416
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200417# Checks that:
418# - things work with all ciphersuites active (used with config-full in all.sh)
419# - the expected (highest security) parameters are selected
420# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200421run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200422 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200423 "$P_CLI" \
424 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200425 -s "Protocol is TLSv1.2" \
426 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
427 -s "client hello v3, signature_algorithm ext: 6" \
428 -s "ECDHE curve: secp521r1" \
429 -S "error" \
430 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200431
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100432# Test for SSLv2 ClientHello
433
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200434requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200435run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100436 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100437 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100438 0 \
439 -S "parse client hello v2" \
440 -S "ssl_handshake returned"
441
442# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200443requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200444run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200445 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100446 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100447 0 \
448 -s "parse client hello v2" \
449 -S "ssl_handshake returned"
450
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100451# Tests for Truncated HMAC extension
452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200453run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200454 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100455 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100456 0 \
457 -s "dumping 'computed mac' (20 bytes)"
458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200459run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200460 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100461 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100462 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100463 -s "dumping 'computed mac' (10 bytes)"
464
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100465# Tests for Session Tickets
466
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200467run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200468 "$P_SRV debug_level=3 tickets=1" \
469 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100470 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100471 -c "client hello, adding session ticket extension" \
472 -s "found session ticket extension" \
473 -s "server hello, adding session ticket extension" \
474 -c "found session_ticket extension" \
475 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100476 -S "session successfully restored from cache" \
477 -s "session successfully restored from ticket" \
478 -s "a session has been resumed" \
479 -c "a session has been resumed"
480
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200481run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200482 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
483 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100484 0 \
485 -c "client hello, adding session ticket extension" \
486 -s "found session ticket extension" \
487 -s "server hello, adding session ticket extension" \
488 -c "found session_ticket extension" \
489 -c "parse new session ticket" \
490 -S "session successfully restored from cache" \
491 -s "session successfully restored from ticket" \
492 -s "a session has been resumed" \
493 -c "a session has been resumed"
494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200495run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200496 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
497 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100498 0 \
499 -c "client hello, adding session ticket extension" \
500 -s "found session ticket extension" \
501 -s "server hello, adding session ticket extension" \
502 -c "found session_ticket extension" \
503 -c "parse new session ticket" \
504 -S "session successfully restored from cache" \
505 -S "session successfully restored from ticket" \
506 -S "a session has been resumed" \
507 -C "a session has been resumed"
508
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200509run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100510 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200511 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100512 0 \
513 -c "client hello, adding session ticket extension" \
514 -c "found session_ticket extension" \
515 -c "parse new session ticket" \
516 -c "a session has been resumed"
517
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200518run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200519 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200520 "( $O_CLI -sess_out $SESSION; \
521 $O_CLI -sess_in $SESSION; \
522 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100523 0 \
524 -s "found session ticket extension" \
525 -s "server hello, adding session ticket extension" \
526 -S "session successfully restored from cache" \
527 -s "session successfully restored from ticket" \
528 -s "a session has been resumed"
529
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100530# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200532run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200533 "$P_SRV debug_level=3 tickets=0" \
534 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100535 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100536 -c "client hello, adding session ticket extension" \
537 -s "found session ticket extension" \
538 -S "server hello, adding session ticket extension" \
539 -C "found session_ticket extension" \
540 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100541 -s "session successfully restored from cache" \
542 -S "session successfully restored from ticket" \
543 -s "a session has been resumed" \
544 -c "a session has been resumed"
545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200546run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200547 "$P_SRV debug_level=3 tickets=1" \
548 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100549 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100550 -C "client hello, adding session ticket extension" \
551 -S "found session ticket extension" \
552 -S "server hello, adding session ticket extension" \
553 -C "found session_ticket extension" \
554 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100555 -s "session successfully restored from cache" \
556 -S "session successfully restored from ticket" \
557 -s "a session has been resumed" \
558 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200560run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200561 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
562 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100563 0 \
564 -S "session successfully restored from cache" \
565 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100566 -S "a session has been resumed" \
567 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200569run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200570 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
571 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100572 0 \
573 -s "session successfully restored from cache" \
574 -S "session successfully restored from ticket" \
575 -s "a session has been resumed" \
576 -c "a session has been resumed"
577
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200578run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200579 "$P_SRV debug_level=3 tickets=0" \
580 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100581 0 \
582 -s "session successfully restored from cache" \
583 -S "session successfully restored from ticket" \
584 -s "a session has been resumed" \
585 -c "a session has been resumed"
586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200587run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200588 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
589 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100590 0 \
591 -S "session successfully restored from cache" \
592 -S "session successfully restored from ticket" \
593 -S "a session has been resumed" \
594 -C "a session has been resumed"
595
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200596run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200597 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
598 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100599 0 \
600 -s "session successfully restored from cache" \
601 -S "session successfully restored from ticket" \
602 -s "a session has been resumed" \
603 -c "a session has been resumed"
604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200605run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200606 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200607 "( $O_CLI -sess_out $SESSION; \
608 $O_CLI -sess_in $SESSION; \
609 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100610 0 \
611 -s "found session ticket extension" \
612 -S "server hello, adding session ticket extension" \
613 -s "session successfully restored from cache" \
614 -S "session successfully restored from ticket" \
615 -s "a session has been resumed"
616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200617run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100618 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200619 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100620 0 \
621 -C "found session_ticket extension" \
622 -C "parse new session ticket" \
623 -c "a session has been resumed"
624
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100625# Tests for Max Fragment Length extension
626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200627run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200628 "$P_SRV debug_level=3" \
629 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100630 0 \
631 -C "client hello, adding max_fragment_length extension" \
632 -S "found max fragment length extension" \
633 -S "server hello, max_fragment_length extension" \
634 -C "found max_fragment_length extension"
635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200636run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200637 "$P_SRV debug_level=3" \
638 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100639 0 \
640 -c "client hello, adding max_fragment_length extension" \
641 -s "found max fragment length extension" \
642 -s "server hello, max_fragment_length extension" \
643 -c "found max_fragment_length extension"
644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200645run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200646 "$P_SRV debug_level=3 max_frag_len=4096" \
647 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100648 0 \
649 -C "client hello, adding max_fragment_length extension" \
650 -S "found max fragment length extension" \
651 -S "server hello, max_fragment_length extension" \
652 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200654requires_gnutls
655run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200656 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200657 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200658 0 \
659 -c "client hello, adding max_fragment_length extension" \
660 -c "found max_fragment_length extension"
661
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100662# Tests for renegotiation
663
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200664run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200665 "$P_SRV debug_level=3 exchanges=2" \
666 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100667 0 \
668 -C "client hello, adding renegotiation extension" \
669 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
670 -S "found renegotiation extension" \
671 -s "server hello, secure renegotiation extension" \
672 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100673 -C "=> renegotiate" \
674 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100675 -S "write hello request"
676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200677run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200678 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
679 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100680 0 \
681 -c "client hello, adding renegotiation extension" \
682 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
683 -s "found renegotiation extension" \
684 -s "server hello, secure renegotiation extension" \
685 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100686 -c "=> renegotiate" \
687 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100688 -S "write hello request"
689
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200690run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200691 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
692 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100693 0 \
694 -c "client hello, adding renegotiation extension" \
695 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
696 -s "found renegotiation extension" \
697 -s "server hello, secure renegotiation extension" \
698 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100699 -c "=> renegotiate" \
700 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100701 -s "write hello request"
702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200703run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200704 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
705 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100706 0 \
707 -c "client hello, adding renegotiation extension" \
708 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
709 -s "found renegotiation extension" \
710 -s "server hello, secure renegotiation extension" \
711 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100712 -c "=> renegotiate" \
713 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100714 -s "write hello request"
715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200716run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200717 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
718 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100719 1 \
720 -c "client hello, adding renegotiation extension" \
721 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
722 -S "found renegotiation extension" \
723 -s "server hello, secure renegotiation extension" \
724 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100725 -c "=> renegotiate" \
726 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200727 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200728 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200729 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100730
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200731run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200732 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
733 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100734 0 \
735 -C "client hello, adding renegotiation extension" \
736 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
737 -S "found renegotiation extension" \
738 -s "server hello, secure renegotiation extension" \
739 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100740 -C "=> renegotiate" \
741 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100742 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200743 -S "SSL - An unexpected message was received from our peer" \
744 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200746run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200747 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200748 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200749 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200750 0 \
751 -C "client hello, adding renegotiation extension" \
752 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
753 -S "found renegotiation extension" \
754 -s "server hello, secure renegotiation extension" \
755 -c "found renegotiation extension" \
756 -C "=> renegotiate" \
757 -S "=> renegotiate" \
758 -s "write hello request" \
759 -S "SSL - An unexpected message was received from our peer" \
760 -S "failed"
761
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200762# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200763run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200764 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200765 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200766 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200767 0 \
768 -C "client hello, adding renegotiation extension" \
769 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
770 -S "found renegotiation extension" \
771 -s "server hello, secure renegotiation extension" \
772 -c "found renegotiation extension" \
773 -C "=> renegotiate" \
774 -S "=> renegotiate" \
775 -s "write hello request" \
776 -S "SSL - An unexpected message was received from our peer" \
777 -S "failed"
778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200779run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200780 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200781 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200782 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200783 0 \
784 -C "client hello, adding renegotiation extension" \
785 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
786 -S "found renegotiation extension" \
787 -s "server hello, secure renegotiation extension" \
788 -c "found renegotiation extension" \
789 -C "=> renegotiate" \
790 -S "=> renegotiate" \
791 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200792 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200794run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200795 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200796 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200797 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200798 0 \
799 -c "client hello, adding renegotiation extension" \
800 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
801 -s "found renegotiation extension" \
802 -s "server hello, secure renegotiation extension" \
803 -c "found renegotiation extension" \
804 -c "=> renegotiate" \
805 -s "=> renegotiate" \
806 -s "write hello request" \
807 -S "SSL - An unexpected message was received from our peer" \
808 -S "failed"
809
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200810run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200811 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
812 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200813 0 \
814 -c "client hello, adding renegotiation extension" \
815 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
816 -s "found renegotiation extension" \
817 -s "server hello, secure renegotiation extension" \
818 -c "found renegotiation extension" \
819 -c "=> renegotiate" \
820 -s "=> renegotiate" \
821 -S "write hello request"
822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200823run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200824 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
825 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200826 0 \
827 -c "client hello, adding renegotiation extension" \
828 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
829 -s "found renegotiation extension" \
830 -s "server hello, secure renegotiation extension" \
831 -c "found renegotiation extension" \
832 -c "=> renegotiate" \
833 -s "=> renegotiate" \
834 -s "write hello request"
835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200836run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200837 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200838 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200839 0 \
840 -c "client hello, adding renegotiation extension" \
841 -c "found renegotiation extension" \
842 -c "=> renegotiate" \
843 -C "ssl_handshake returned" \
844 -C "error" \
845 -c "HTTP/1.0 200 [Oo][Kk]"
846
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200847run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200848 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200849 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200850 0 \
851 -c "client hello, adding renegotiation extension" \
852 -c "found renegotiation extension" \
853 -c "=> renegotiate" \
854 -C "ssl_handshake returned" \
855 -C "error" \
856 -c "HTTP/1.0 200 [Oo][Kk]"
857
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +0200858run_test "Renegotiation: DTLS, client-initiated" \
859 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
860 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
861 0 \
862 -c "client hello, adding renegotiation extension" \
863 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
864 -s "found renegotiation extension" \
865 -s "server hello, secure renegotiation extension" \
866 -c "found renegotiation extension" \
867 -c "=> renegotiate" \
868 -s "=> renegotiate" \
869 -S "write hello request"
870
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +0200871run_test "Renegotiation: DTLS, server-initiated" \
872 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
873 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
874 0 \
875 -c "client hello, adding renegotiation extension" \
876 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
877 -s "found renegotiation extension" \
878 -s "server hello, secure renegotiation extension" \
879 -c "found renegotiation extension" \
880 -c "=> renegotiate" \
881 -s "=> renegotiate" \
882 -s "write hello request"
883
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100884# Tests for auth_mode
885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200886run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100887 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100888 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200889 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100890 1 \
891 -c "x509_verify_cert() returned" \
892 -c "! self-signed or not signed by a trusted CA" \
893 -c "! ssl_handshake returned" \
894 -c "X509 - Certificate verification failed"
895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200896run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100897 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100898 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200899 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100900 0 \
901 -c "x509_verify_cert() returned" \
902 -c "! self-signed or not signed by a trusted CA" \
903 -C "! ssl_handshake returned" \
904 -C "X509 - Certificate verification failed"
905
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200906run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100907 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100908 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200909 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100910 0 \
911 -C "x509_verify_cert() returned" \
912 -C "! self-signed or not signed by a trusted CA" \
913 -C "! ssl_handshake returned" \
914 -C "X509 - Certificate verification failed"
915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200916run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200917 "$P_SRV debug_level=3 auth_mode=required" \
918 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100919 key_file=data_files/server5.key" \
920 1 \
921 -S "skip write certificate request" \
922 -C "skip parse certificate request" \
923 -c "got a certificate request" \
924 -C "skip write certificate" \
925 -C "skip write certificate verify" \
926 -S "skip parse certificate verify" \
927 -s "x509_verify_cert() returned" \
928 -S "! self-signed or not signed by a trusted CA" \
929 -s "! ssl_handshake returned" \
930 -c "! ssl_handshake returned" \
931 -s "X509 - Certificate verification failed"
932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200933run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200934 "$P_SRV debug_level=3 auth_mode=optional" \
935 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100936 key_file=data_files/server5.key" \
937 0 \
938 -S "skip write certificate request" \
939 -C "skip parse certificate request" \
940 -c "got a certificate request" \
941 -C "skip write certificate" \
942 -C "skip write certificate verify" \
943 -S "skip parse certificate verify" \
944 -s "x509_verify_cert() returned" \
945 -s "! self-signed or not signed by a trusted CA" \
946 -S "! ssl_handshake returned" \
947 -C "! ssl_handshake returned" \
948 -S "X509 - Certificate verification failed"
949
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200950run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200951 "$P_SRV debug_level=3 auth_mode=none" \
952 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100953 key_file=data_files/server5.key" \
954 0 \
955 -s "skip write certificate request" \
956 -C "skip parse certificate request" \
957 -c "got no certificate request" \
958 -c "skip write certificate" \
959 -c "skip write certificate verify" \
960 -s "skip parse certificate verify" \
961 -S "x509_verify_cert() returned" \
962 -S "! self-signed or not signed by a trusted CA" \
963 -S "! ssl_handshake returned" \
964 -C "! ssl_handshake returned" \
965 -S "X509 - Certificate verification failed"
966
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200967run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200968 "$P_SRV debug_level=3 auth_mode=optional" \
969 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100970 0 \
971 -S "skip write certificate request" \
972 -C "skip parse certificate request" \
973 -c "got a certificate request" \
974 -C "skip write certificate$" \
975 -C "got no certificate to send" \
976 -S "SSLv3 client has no certificate" \
977 -c "skip write certificate verify" \
978 -s "skip parse certificate verify" \
979 -s "! no client certificate sent" \
980 -S "! ssl_handshake returned" \
981 -C "! ssl_handshake returned" \
982 -S "X509 - Certificate verification failed"
983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200984run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200985 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100986 "$O_CLI" \
987 0 \
988 -S "skip write certificate request" \
989 -s "skip parse certificate verify" \
990 -s "! no client certificate sent" \
991 -S "! ssl_handshake returned" \
992 -S "X509 - Certificate verification failed"
993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200994run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100995 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200996 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100997 0 \
998 -C "skip parse certificate request" \
999 -c "got a certificate request" \
1000 -C "skip write certificate$" \
1001 -c "skip write certificate verify" \
1002 -C "! ssl_handshake returned"
1003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001004run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001005 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1006 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001007 0 \
1008 -S "skip write certificate request" \
1009 -C "skip parse certificate request" \
1010 -c "got a certificate request" \
1011 -C "skip write certificate$" \
1012 -c "skip write certificate verify" \
1013 -c "got no certificate to send" \
1014 -s "SSLv3 client has no certificate" \
1015 -s "skip parse certificate verify" \
1016 -s "! no client certificate sent" \
1017 -S "! ssl_handshake returned" \
1018 -C "! ssl_handshake returned" \
1019 -S "X509 - Certificate verification failed"
1020
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001021# tests for SNI
1022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001023run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001024 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001025 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001026 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001027 0 \
1028 -S "parse ServerName extension" \
1029 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1030 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001032run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001033 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001034 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001035 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 +02001036 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001037 0 \
1038 -s "parse ServerName extension" \
1039 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1040 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001042run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001043 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001044 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001045 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 +02001046 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001047 0 \
1048 -s "parse ServerName extension" \
1049 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001050 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001052run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001053 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001054 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001055 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 +02001056 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001057 1 \
1058 -s "parse ServerName extension" \
1059 -s "ssl_sni_wrapper() returned" \
1060 -s "ssl_handshake returned" \
1061 -c "ssl_handshake returned" \
1062 -c "SSL - A fatal alert message was received from our peer"
1063
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001064# Tests for non-blocking I/O: exercise a variety of handshake flows
1065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001066run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001067 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1068 "$P_CLI nbio=2 tickets=0" \
1069 0 \
1070 -S "ssl_handshake returned" \
1071 -C "ssl_handshake returned" \
1072 -c "Read from server: .* bytes read"
1073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001074run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001075 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1076 "$P_CLI nbio=2 tickets=0" \
1077 0 \
1078 -S "ssl_handshake returned" \
1079 -C "ssl_handshake returned" \
1080 -c "Read from server: .* bytes read"
1081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001082run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001083 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1084 "$P_CLI nbio=2 tickets=1" \
1085 0 \
1086 -S "ssl_handshake returned" \
1087 -C "ssl_handshake returned" \
1088 -c "Read from server: .* bytes read"
1089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001090run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001091 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1092 "$P_CLI nbio=2 tickets=1" \
1093 0 \
1094 -S "ssl_handshake returned" \
1095 -C "ssl_handshake returned" \
1096 -c "Read from server: .* bytes read"
1097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001098run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001099 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1100 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1101 0 \
1102 -S "ssl_handshake returned" \
1103 -C "ssl_handshake returned" \
1104 -c "Read from server: .* bytes read"
1105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001106run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001107 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1108 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1109 0 \
1110 -S "ssl_handshake returned" \
1111 -C "ssl_handshake returned" \
1112 -c "Read from server: .* bytes read"
1113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001114run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001115 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1116 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1117 0 \
1118 -S "ssl_handshake returned" \
1119 -C "ssl_handshake returned" \
1120 -c "Read from server: .* bytes read"
1121
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001122# Tests for version negotiation
1123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001124run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001125 "$P_SRV" \
1126 "$P_CLI" \
1127 0 \
1128 -S "ssl_handshake returned" \
1129 -C "ssl_handshake returned" \
1130 -s "Protocol is TLSv1.2" \
1131 -c "Protocol is TLSv1.2"
1132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001133run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001134 "$P_SRV" \
1135 "$P_CLI max_version=tls1_1" \
1136 0 \
1137 -S "ssl_handshake returned" \
1138 -C "ssl_handshake returned" \
1139 -s "Protocol is TLSv1.1" \
1140 -c "Protocol is TLSv1.1"
1141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001142run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001143 "$P_SRV max_version=tls1_1" \
1144 "$P_CLI" \
1145 0 \
1146 -S "ssl_handshake returned" \
1147 -C "ssl_handshake returned" \
1148 -s "Protocol is TLSv1.1" \
1149 -c "Protocol is TLSv1.1"
1150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001151run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001152 "$P_SRV max_version=tls1_1" \
1153 "$P_CLI max_version=tls1_1" \
1154 0 \
1155 -S "ssl_handshake returned" \
1156 -C "ssl_handshake returned" \
1157 -s "Protocol is TLSv1.1" \
1158 -c "Protocol is TLSv1.1"
1159
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001160run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001161 "$P_SRV min_version=tls1_1" \
1162 "$P_CLI max_version=tls1_1" \
1163 0 \
1164 -S "ssl_handshake returned" \
1165 -C "ssl_handshake returned" \
1166 -s "Protocol is TLSv1.1" \
1167 -c "Protocol is TLSv1.1"
1168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001169run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001170 "$P_SRV max_version=tls1_1" \
1171 "$P_CLI min_version=tls1_1" \
1172 0 \
1173 -S "ssl_handshake returned" \
1174 -C "ssl_handshake returned" \
1175 -s "Protocol is TLSv1.1" \
1176 -c "Protocol is TLSv1.1"
1177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001178run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001179 "$P_SRV max_version=tls1_1" \
1180 "$P_CLI min_version=tls1_2" \
1181 1 \
1182 -s "ssl_handshake returned" \
1183 -c "ssl_handshake returned" \
1184 -c "SSL - Handshake protocol not within min/max boundaries"
1185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001186run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001187 "$P_SRV min_version=tls1_2" \
1188 "$P_CLI max_version=tls1_1" \
1189 1 \
1190 -s "ssl_handshake returned" \
1191 -c "ssl_handshake returned" \
1192 -s "SSL - Handshake protocol not within min/max boundaries"
1193
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001194# Tests for ALPN extension
1195
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001196if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001198run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001199 "$P_SRV debug_level=3" \
1200 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001201 0 \
1202 -C "client hello, adding alpn extension" \
1203 -S "found alpn extension" \
1204 -C "got an alert message, type: \\[2:120]" \
1205 -S "server hello, adding alpn extension" \
1206 -C "found alpn extension " \
1207 -C "Application Layer Protocol is" \
1208 -S "Application Layer Protocol is"
1209
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001210run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001211 "$P_SRV debug_level=3" \
1212 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001213 0 \
1214 -c "client hello, adding alpn extension" \
1215 -s "found alpn extension" \
1216 -C "got an alert message, type: \\[2:120]" \
1217 -S "server hello, adding alpn extension" \
1218 -C "found alpn extension " \
1219 -c "Application Layer Protocol is (none)" \
1220 -S "Application Layer Protocol is"
1221
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001222run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001223 "$P_SRV debug_level=3 alpn=abc,1234" \
1224 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001225 0 \
1226 -C "client hello, adding alpn extension" \
1227 -S "found alpn extension" \
1228 -C "got an alert message, type: \\[2:120]" \
1229 -S "server hello, adding alpn extension" \
1230 -C "found alpn extension " \
1231 -C "Application Layer Protocol is" \
1232 -s "Application Layer Protocol is (none)"
1233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001234run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001235 "$P_SRV debug_level=3 alpn=abc,1234" \
1236 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001237 0 \
1238 -c "client hello, adding alpn extension" \
1239 -s "found alpn extension" \
1240 -C "got an alert message, type: \\[2:120]" \
1241 -s "server hello, adding alpn extension" \
1242 -c "found alpn extension" \
1243 -c "Application Layer Protocol is abc" \
1244 -s "Application Layer Protocol is abc"
1245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001246run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001247 "$P_SRV debug_level=3 alpn=abc,1234" \
1248 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001249 0 \
1250 -c "client hello, adding alpn extension" \
1251 -s "found alpn extension" \
1252 -C "got an alert message, type: \\[2:120]" \
1253 -s "server hello, adding alpn extension" \
1254 -c "found alpn extension" \
1255 -c "Application Layer Protocol is abc" \
1256 -s "Application Layer Protocol is abc"
1257
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001258run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001259 "$P_SRV debug_level=3 alpn=abc,1234" \
1260 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001261 0 \
1262 -c "client hello, adding alpn extension" \
1263 -s "found alpn extension" \
1264 -C "got an alert message, type: \\[2:120]" \
1265 -s "server hello, adding alpn extension" \
1266 -c "found alpn extension" \
1267 -c "Application Layer Protocol is 1234" \
1268 -s "Application Layer Protocol is 1234"
1269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001270run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001271 "$P_SRV debug_level=3 alpn=abc,123" \
1272 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001273 1 \
1274 -c "client hello, adding alpn extension" \
1275 -s "found alpn extension" \
1276 -c "got an alert message, type: \\[2:120]" \
1277 -S "server hello, adding alpn extension" \
1278 -C "found alpn extension" \
1279 -C "Application Layer Protocol is 1234" \
1280 -S "Application Layer Protocol is 1234"
1281
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001282fi
1283
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001284# Tests for keyUsage in leaf certificates, part 1:
1285# server-side certificate/suite selection
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001288 "$P_SRV key_file=data_files/server2.key \
1289 crt_file=data_files/server2.ku-ds.crt" \
1290 "$P_CLI" \
1291 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001292 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001293
1294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001295run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001296 "$P_SRV key_file=data_files/server2.key \
1297 crt_file=data_files/server2.ku-ke.crt" \
1298 "$P_CLI" \
1299 0 \
1300 -c "Ciphersuite is TLS-RSA-WITH-"
1301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001302run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001303 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001304 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001305 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001306 1 \
1307 -C "Ciphersuite is "
1308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001309run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001310 "$P_SRV key_file=data_files/server5.key \
1311 crt_file=data_files/server5.ku-ds.crt" \
1312 "$P_CLI" \
1313 0 \
1314 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1315
1316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001317run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001318 "$P_SRV key_file=data_files/server5.key \
1319 crt_file=data_files/server5.ku-ka.crt" \
1320 "$P_CLI" \
1321 0 \
1322 -c "Ciphersuite is TLS-ECDH-"
1323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001324run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001325 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001326 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001327 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001328 1 \
1329 -C "Ciphersuite is "
1330
1331# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001332# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001333
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001334run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001335 "$O_SRV -key data_files/server2.key \
1336 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001337 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001338 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1339 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001340 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001341 -C "Processing of the Certificate handshake message failed" \
1342 -c "Ciphersuite is TLS-"
1343
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001344run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001345 "$O_SRV -key data_files/server2.key \
1346 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001348 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1349 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001350 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001351 -C "Processing of the Certificate handshake message failed" \
1352 -c "Ciphersuite is TLS-"
1353
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001354run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001355 "$O_SRV -key data_files/server2.key \
1356 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001357 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001358 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1359 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001360 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001361 -C "Processing of the Certificate handshake message failed" \
1362 -c "Ciphersuite is TLS-"
1363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001364run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001365 "$O_SRV -key data_files/server2.key \
1366 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001367 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001368 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1369 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001370 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001371 -c "Processing of the Certificate handshake message failed" \
1372 -C "Ciphersuite is TLS-"
1373
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001374run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001375 "$O_SRV -key data_files/server2.key \
1376 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001377 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001378 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1379 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001380 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001381 -C "Processing of the Certificate handshake message failed" \
1382 -c "Ciphersuite is TLS-"
1383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001384run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001385 "$O_SRV -key data_files/server2.key \
1386 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001387 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001388 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1389 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001390 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001391 -c "Processing of the Certificate handshake message failed" \
1392 -C "Ciphersuite is TLS-"
1393
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001394# Tests for keyUsage in leaf certificates, part 3:
1395# server-side checking of client cert
1396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001397run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001398 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001399 "$O_CLI -key data_files/server2.key \
1400 -cert data_files/server2.ku-ds.crt" \
1401 0 \
1402 -S "bad certificate (usage extensions)" \
1403 -S "Processing of the Certificate handshake message failed"
1404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001405run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001406 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001407 "$O_CLI -key data_files/server2.key \
1408 -cert data_files/server2.ku-ke.crt" \
1409 0 \
1410 -s "bad certificate (usage extensions)" \
1411 -S "Processing of the Certificate handshake message failed"
1412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001413run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001414 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001415 "$O_CLI -key data_files/server2.key \
1416 -cert data_files/server2.ku-ke.crt" \
1417 1 \
1418 -s "bad certificate (usage extensions)" \
1419 -s "Processing of the Certificate handshake message failed"
1420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001421run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001422 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001423 "$O_CLI -key data_files/server5.key \
1424 -cert data_files/server5.ku-ds.crt" \
1425 0 \
1426 -S "bad certificate (usage extensions)" \
1427 -S "Processing of the Certificate handshake message failed"
1428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001429run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001430 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001431 "$O_CLI -key data_files/server5.key \
1432 -cert data_files/server5.ku-ka.crt" \
1433 0 \
1434 -s "bad certificate (usage extensions)" \
1435 -S "Processing of the Certificate handshake message failed"
1436
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001437# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001439run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001440 "$P_SRV key_file=data_files/server5.key \
1441 crt_file=data_files/server5.eku-srv.crt" \
1442 "$P_CLI" \
1443 0
1444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001445run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001446 "$P_SRV key_file=data_files/server5.key \
1447 crt_file=data_files/server5.eku-srv.crt" \
1448 "$P_CLI" \
1449 0
1450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001451run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001452 "$P_SRV key_file=data_files/server5.key \
1453 crt_file=data_files/server5.eku-cs_any.crt" \
1454 "$P_CLI" \
1455 0
1456
1457# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001458run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001459 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1460 crt_file=data_files/server5.eku-cli.crt" \
1461 "$P_CLI psk=badbad" \
1462 1
1463
1464# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001466run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001467 "$O_SRV -key data_files/server5.key \
1468 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001469 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001470 0 \
1471 -C "bad certificate (usage extensions)" \
1472 -C "Processing of the Certificate handshake message failed" \
1473 -c "Ciphersuite is TLS-"
1474
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001475run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001476 "$O_SRV -key data_files/server5.key \
1477 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001478 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001479 0 \
1480 -C "bad certificate (usage extensions)" \
1481 -C "Processing of the Certificate handshake message failed" \
1482 -c "Ciphersuite is TLS-"
1483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001484run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001485 "$O_SRV -key data_files/server5.key \
1486 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001487 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001488 0 \
1489 -C "bad certificate (usage extensions)" \
1490 -C "Processing of the Certificate handshake message failed" \
1491 -c "Ciphersuite is TLS-"
1492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001493run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001494 "$O_SRV -key data_files/server5.key \
1495 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001496 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001497 1 \
1498 -c "bad certificate (usage extensions)" \
1499 -c "Processing of the Certificate handshake message failed" \
1500 -C "Ciphersuite is TLS-"
1501
1502# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001504run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001505 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001506 "$O_CLI -key data_files/server5.key \
1507 -cert data_files/server5.eku-cli.crt" \
1508 0 \
1509 -S "bad certificate (usage extensions)" \
1510 -S "Processing of the Certificate handshake message failed"
1511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001512run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001513 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001514 "$O_CLI -key data_files/server5.key \
1515 -cert data_files/server5.eku-srv_cli.crt" \
1516 0 \
1517 -S "bad certificate (usage extensions)" \
1518 -S "Processing of the Certificate handshake message failed"
1519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001520run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001521 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001522 "$O_CLI -key data_files/server5.key \
1523 -cert data_files/server5.eku-cs_any.crt" \
1524 0 \
1525 -S "bad certificate (usage extensions)" \
1526 -S "Processing of the Certificate handshake message failed"
1527
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001528run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001529 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001530 "$O_CLI -key data_files/server5.key \
1531 -cert data_files/server5.eku-cs.crt" \
1532 0 \
1533 -s "bad certificate (usage extensions)" \
1534 -S "Processing of the Certificate handshake message failed"
1535
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001536run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001537 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001538 "$O_CLI -key data_files/server5.key \
1539 -cert data_files/server5.eku-cs.crt" \
1540 1 \
1541 -s "bad certificate (usage extensions)" \
1542 -s "Processing of the Certificate handshake message failed"
1543
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001544# Tests for DHM parameters loading
1545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001546run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001547 "$P_SRV" \
1548 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1549 debug_level=3" \
1550 0 \
1551 -c "value of 'DHM: P ' (2048 bits)" \
1552 -c "value of 'DHM: G ' (2048 bits)"
1553
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001554run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001555 "$P_SRV dhm_file=data_files/dhparams.pem" \
1556 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1557 debug_level=3" \
1558 0 \
1559 -c "value of 'DHM: P ' (1024 bits)" \
1560 -c "value of 'DHM: G ' (2 bits)"
1561
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001562# Tests for PSK callback
1563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001564run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001565 "$P_SRV psk=abc123 psk_identity=foo" \
1566 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1567 psk_identity=foo psk=abc123" \
1568 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001569 -S "SSL - The server has no ciphersuites in common" \
1570 -S "SSL - Unknown identity received" \
1571 -S "SSL - Verification of the message MAC failed"
1572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001573run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001574 "$P_SRV" \
1575 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1576 psk_identity=foo psk=abc123" \
1577 1 \
1578 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001579 -S "SSL - Unknown identity received" \
1580 -S "SSL - Verification of the message MAC failed"
1581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001582run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001583 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1584 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1585 psk_identity=foo psk=abc123" \
1586 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001587 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001588 -s "SSL - Unknown identity received" \
1589 -S "SSL - Verification of the message MAC failed"
1590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001591run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001592 "$P_SRV psk_list=abc,dead,def,beef" \
1593 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1594 psk_identity=abc psk=dead" \
1595 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001596 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001597 -S "SSL - Unknown identity received" \
1598 -S "SSL - Verification of the message MAC failed"
1599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001600run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001601 "$P_SRV psk_list=abc,dead,def,beef" \
1602 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1603 psk_identity=def psk=beef" \
1604 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001605 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001606 -S "SSL - Unknown identity received" \
1607 -S "SSL - Verification of the message MAC failed"
1608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001609run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001610 "$P_SRV psk_list=abc,dead,def,beef" \
1611 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1612 psk_identity=ghi psk=beef" \
1613 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001614 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001615 -s "SSL - Unknown identity received" \
1616 -S "SSL - Verification of the message MAC failed"
1617
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001618run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001619 "$P_SRV psk_list=abc,dead,def,beef" \
1620 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1621 psk_identity=abc psk=beef" \
1622 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001623 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001624 -S "SSL - Unknown identity received" \
1625 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001626
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001627# Tests for ciphersuites per version
1628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001629run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001630 "$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" \
1631 "$P_CLI force_version=ssl3" \
1632 0 \
1633 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001635run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001636 "$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" \
1637 "$P_CLI force_version=tls1" \
1638 0 \
1639 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001641run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001642 "$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" \
1643 "$P_CLI force_version=tls1_1" \
1644 0 \
1645 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1646
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001647run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001648 "$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" \
1649 "$P_CLI force_version=tls1_2" \
1650 0 \
1651 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1652
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001653# Tests for ssl_get_bytes_avail()
1654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001655run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001656 "$P_SRV" \
1657 "$P_CLI request_size=100" \
1658 0 \
1659 -s "Read from client: 100 bytes read$"
1660
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001661run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001662 "$P_SRV" \
1663 "$P_CLI request_size=500" \
1664 0 \
1665 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001666
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001667# Tests for small packets
1668
1669run_test "Small packet SSLv3 BlockCipher" \
1670 "$P_SRV" \
1671 "$P_CLI request_size=1 force_version=ssl3 \
1672 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1673 0 \
1674 -s "Read from client: 1 bytes read"
1675
1676run_test "Small packet SSLv3 StreamCipher" \
1677 "$P_SRV" \
1678 "$P_CLI request_size=1 force_version=ssl3 \
1679 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1680 0 \
1681 -s "Read from client: 1 bytes read"
1682
1683run_test "Small packet TLS 1.0 BlockCipher" \
1684 "$P_SRV" \
1685 "$P_CLI request_size=1 force_version=tls1 \
1686 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1687 0 \
1688 -s "Read from client: 1 bytes read"
1689
1690run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1691 "$P_SRV" \
1692 "$P_CLI request_size=1 force_version=tls1 \
1693 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1694 trunc_hmac=1" \
1695 0 \
1696 -s "Read from client: 1 bytes read"
1697
1698run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1699 "$P_SRV" \
1700 "$P_CLI request_size=1 force_version=tls1 \
1701 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1702 trunc_hmac=1" \
1703 0 \
1704 -s "Read from client: 1 bytes read"
1705
1706run_test "Small packet TLS 1.1 BlockCipher" \
1707 "$P_SRV" \
1708 "$P_CLI request_size=1 force_version=tls1_1 \
1709 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1710 0 \
1711 -s "Read from client: 1 bytes read"
1712
1713run_test "Small packet TLS 1.1 StreamCipher" \
1714 "$P_SRV" \
1715 "$P_CLI request_size=1 force_version=tls1_1 \
1716 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1717 0 \
1718 -s "Read from client: 1 bytes read"
1719
1720run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1721 "$P_SRV" \
1722 "$P_CLI request_size=1 force_version=tls1_1 \
1723 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1724 trunc_hmac=1" \
1725 0 \
1726 -s "Read from client: 1 bytes read"
1727
1728run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1729 "$P_SRV" \
1730 "$P_CLI request_size=1 force_version=tls1_1 \
1731 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1732 trunc_hmac=1" \
1733 0 \
1734 -s "Read from client: 1 bytes read"
1735
1736run_test "Small packet TLS 1.2 BlockCipher" \
1737 "$P_SRV" \
1738 "$P_CLI request_size=1 force_version=tls1_2 \
1739 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1740 0 \
1741 -s "Read from client: 1 bytes read"
1742
1743run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1744 "$P_SRV" \
1745 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1746 0 \
1747 -s "Read from client: 1 bytes read"
1748
1749run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1750 "$P_SRV" \
1751 "$P_CLI request_size=1 force_version=tls1_2 \
1752 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1753 trunc_hmac=1" \
1754 0 \
1755 -s "Read from client: 1 bytes read"
1756
1757run_test "Small packet TLS 1.2 StreamCipher" \
1758 "$P_SRV" \
1759 "$P_CLI request_size=1 force_version=tls1_2 \
1760 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1761 0 \
1762 -s "Read from client: 1 bytes read"
1763
1764run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1765 "$P_SRV" \
1766 "$P_CLI request_size=1 force_version=tls1_2 \
1767 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1768 trunc_hmac=1" \
1769 0 \
1770 -s "Read from client: 1 bytes read"
1771
1772run_test "Small packet TLS 1.2 AEAD" \
1773 "$P_SRV" \
1774 "$P_CLI request_size=1 force_version=tls1_2 \
1775 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1776 0 \
1777 -s "Read from client: 1 bytes read"
1778
1779run_test "Small packet TLS 1.2 AEAD shorter tag" \
1780 "$P_SRV" \
1781 "$P_CLI request_size=1 force_version=tls1_2 \
1782 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1783 0 \
1784 -s "Read from client: 1 bytes read"
1785
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001786# Test for large packets
1787
1788run_test "Large packet SSLv3 BlockCipher" \
1789 "$P_SRV" \
1790 "$P_CLI request_size=16384 force_version=ssl3 \
1791 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1792 0 \
1793 -s "Read from client: 16384 bytes read"
1794
1795run_test "Large packet SSLv3 StreamCipher" \
1796 "$P_SRV" \
1797 "$P_CLI request_size=16384 force_version=ssl3 \
1798 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1799 0 \
1800 -s "Read from client: 16384 bytes read"
1801
1802run_test "Large packet TLS 1.0 BlockCipher" \
1803 "$P_SRV" \
1804 "$P_CLI request_size=16384 force_version=tls1 \
1805 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1806 0 \
1807 -s "Read from client: 16384 bytes read"
1808
1809run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1810 "$P_SRV" \
1811 "$P_CLI request_size=16384 force_version=tls1 \
1812 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1813 trunc_hmac=1" \
1814 0 \
1815 -s "Read from client: 16384 bytes read"
1816
1817run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1818 "$P_SRV" \
1819 "$P_CLI request_size=16384 force_version=tls1 \
1820 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1821 trunc_hmac=1" \
1822 0 \
1823 -s "Read from client: 16384 bytes read"
1824
1825run_test "Large packet TLS 1.1 BlockCipher" \
1826 "$P_SRV" \
1827 "$P_CLI request_size=16384 force_version=tls1_1 \
1828 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1829 0 \
1830 -s "Read from client: 16384 bytes read"
1831
1832run_test "Large packet TLS 1.1 StreamCipher" \
1833 "$P_SRV" \
1834 "$P_CLI request_size=16384 force_version=tls1_1 \
1835 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1836 0 \
1837 -s "Read from client: 16384 bytes read"
1838
1839run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1840 "$P_SRV" \
1841 "$P_CLI request_size=16384 force_version=tls1_1 \
1842 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1843 trunc_hmac=1" \
1844 0 \
1845 -s "Read from client: 16384 bytes read"
1846
1847run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1848 "$P_SRV" \
1849 "$P_CLI request_size=16384 force_version=tls1_1 \
1850 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1851 trunc_hmac=1" \
1852 0 \
1853 -s "Read from client: 16384 bytes read"
1854
1855run_test "Large packet TLS 1.2 BlockCipher" \
1856 "$P_SRV" \
1857 "$P_CLI request_size=16384 force_version=tls1_2 \
1858 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1859 0 \
1860 -s "Read from client: 16384 bytes read"
1861
1862run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1863 "$P_SRV" \
1864 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1865 0 \
1866 -s "Read from client: 16384 bytes read"
1867
1868run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1869 "$P_SRV" \
1870 "$P_CLI request_size=16384 force_version=tls1_2 \
1871 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1872 trunc_hmac=1" \
1873 0 \
1874 -s "Read from client: 16384 bytes read"
1875
1876run_test "Large packet TLS 1.2 StreamCipher" \
1877 "$P_SRV" \
1878 "$P_CLI request_size=16384 force_version=tls1_2 \
1879 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1880 0 \
1881 -s "Read from client: 16384 bytes read"
1882
1883run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1884 "$P_SRV" \
1885 "$P_CLI request_size=16384 force_version=tls1_2 \
1886 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1887 trunc_hmac=1" \
1888 0 \
1889 -s "Read from client: 16384 bytes read"
1890
1891run_test "Large packet TLS 1.2 AEAD" \
1892 "$P_SRV" \
1893 "$P_CLI request_size=16384 force_version=tls1_2 \
1894 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1895 0 \
1896 -s "Read from client: 16384 bytes read"
1897
1898run_test "Large packet TLS 1.2 AEAD shorter tag" \
1899 "$P_SRV" \
1900 "$P_CLI request_size=16384 force_version=tls1_2 \
1901 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1902 0 \
1903 -s "Read from client: 16384 bytes read"
1904
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001905# Tests for DTLS HelloVerifyRequest
1906
1907run_test "DTLS cookie: enabled" \
1908 "$P_SRV dtls=1 debug_level=2" \
1909 "$P_CLI dtls=1 debug_level=2" \
1910 0 \
1911 -s "cookie verification failed" \
1912 -s "cookie verification passed" \
1913 -S "cookie verification skipped" \
1914 -c "received hello verify request" \
1915 -S "SSL - The requested feature is not available"
1916
1917run_test "DTLS cookie: disabled" \
1918 "$P_SRV dtls=1 debug_level=2 cookies=0" \
1919 "$P_CLI dtls=1 debug_level=2" \
1920 0 \
1921 -S "cookie verification failed" \
1922 -S "cookie verification passed" \
1923 -s "cookie verification skipped" \
1924 -C "received hello verify request" \
1925 -S "SSL - The requested feature is not available"
1926
1927# wait for client having a timeout, or server sending an alert
1928#run_test "DTLS cookie: default (failing)" \
1929# "$P_SRV dtls=1 debug_level=2 cookies=-1" \
1930# "$P_CLI dtls=1 debug_level=2" \
1931# 0 \
1932# -S "cookie verification failed" \
1933# -S "cookie verification passed" \
1934# -S "cookie verification skipped" \
1935# -C "received hello verify request" \
1936# -s "SSL - The requested feature is not available"
1937
1938requires_ipv6
1939run_test "DTLS cookie: enabled, IPv6" \
1940 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
1941 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
1942 0 \
1943 -s "cookie verification failed" \
1944 -s "cookie verification passed" \
1945 -S "cookie verification skipped" \
1946 -c "received hello verify request" \
1947 -S "SSL - The requested feature is not available"
1948
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001949# Final report
1950
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001951echo "------------------------------------------------------------------------"
1952
1953if [ $FAILS = 0 ]; then
1954 echo -n "PASSED"
1955else
1956 echo -n "FAILED"
1957fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02001958PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001959echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001960
1961exit $FAILS