blob: 14563382f820c0c764e98e48d4f4a24cf5dbc268 [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é-Gonnard8520dac2014-02-21 12:12:23 +0100858# Tests for auth_mode
859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200860run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100861 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100862 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200863 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100864 1 \
865 -c "x509_verify_cert() returned" \
866 -c "! self-signed or not signed by a trusted CA" \
867 -c "! ssl_handshake returned" \
868 -c "X509 - Certificate verification failed"
869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200870run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100871 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100872 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200873 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100874 0 \
875 -c "x509_verify_cert() returned" \
876 -c "! self-signed or not signed by a trusted CA" \
877 -C "! ssl_handshake returned" \
878 -C "X509 - Certificate verification failed"
879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200880run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100881 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100882 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200883 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100884 0 \
885 -C "x509_verify_cert() returned" \
886 -C "! self-signed or not signed by a trusted CA" \
887 -C "! ssl_handshake returned" \
888 -C "X509 - Certificate verification failed"
889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200890run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200891 "$P_SRV debug_level=3 auth_mode=required" \
892 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100893 key_file=data_files/server5.key" \
894 1 \
895 -S "skip write certificate request" \
896 -C "skip parse certificate request" \
897 -c "got a certificate request" \
898 -C "skip write certificate" \
899 -C "skip write certificate verify" \
900 -S "skip parse certificate verify" \
901 -s "x509_verify_cert() returned" \
902 -S "! self-signed or not signed by a trusted CA" \
903 -s "! ssl_handshake returned" \
904 -c "! ssl_handshake returned" \
905 -s "X509 - Certificate verification failed"
906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200907run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200908 "$P_SRV debug_level=3 auth_mode=optional" \
909 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100910 key_file=data_files/server5.key" \
911 0 \
912 -S "skip write certificate request" \
913 -C "skip parse certificate request" \
914 -c "got a certificate request" \
915 -C "skip write certificate" \
916 -C "skip write certificate verify" \
917 -S "skip parse certificate verify" \
918 -s "x509_verify_cert() returned" \
919 -s "! self-signed or not signed by a trusted CA" \
920 -S "! ssl_handshake returned" \
921 -C "! ssl_handshake returned" \
922 -S "X509 - Certificate verification failed"
923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200924run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200925 "$P_SRV debug_level=3 auth_mode=none" \
926 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100927 key_file=data_files/server5.key" \
928 0 \
929 -s "skip write certificate request" \
930 -C "skip parse certificate request" \
931 -c "got no certificate request" \
932 -c "skip write certificate" \
933 -c "skip write certificate verify" \
934 -s "skip parse certificate verify" \
935 -S "x509_verify_cert() returned" \
936 -S "! self-signed or not signed by a trusted CA" \
937 -S "! ssl_handshake returned" \
938 -C "! ssl_handshake returned" \
939 -S "X509 - Certificate verification failed"
940
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200941run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200942 "$P_SRV debug_level=3 auth_mode=optional" \
943 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100944 0 \
945 -S "skip write certificate request" \
946 -C "skip parse certificate request" \
947 -c "got a certificate request" \
948 -C "skip write certificate$" \
949 -C "got no certificate to send" \
950 -S "SSLv3 client has no certificate" \
951 -c "skip write certificate verify" \
952 -s "skip parse certificate verify" \
953 -s "! no client certificate sent" \
954 -S "! ssl_handshake returned" \
955 -C "! ssl_handshake returned" \
956 -S "X509 - Certificate verification failed"
957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200958run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200959 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100960 "$O_CLI" \
961 0 \
962 -S "skip write certificate request" \
963 -s "skip parse certificate verify" \
964 -s "! no client certificate sent" \
965 -S "! ssl_handshake returned" \
966 -S "X509 - Certificate verification failed"
967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200968run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100969 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200970 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100971 0 \
972 -C "skip parse certificate request" \
973 -c "got a certificate request" \
974 -C "skip write certificate$" \
975 -c "skip write certificate verify" \
976 -C "! ssl_handshake returned"
977
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200978run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200979 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
980 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100981 0 \
982 -S "skip write certificate request" \
983 -C "skip parse certificate request" \
984 -c "got a certificate request" \
985 -C "skip write certificate$" \
986 -c "skip write certificate verify" \
987 -c "got no certificate to send" \
988 -s "SSLv3 client has no certificate" \
989 -s "skip parse certificate verify" \
990 -s "! no client certificate sent" \
991 -S "! ssl_handshake returned" \
992 -C "! ssl_handshake returned" \
993 -S "X509 - Certificate verification failed"
994
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100995# tests for SNI
996
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200997run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200998 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100999 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001000 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001001 0 \
1002 -S "parse ServerName extension" \
1003 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1004 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001006run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001007 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001008 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001009 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 +02001010 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001011 0 \
1012 -s "parse ServerName extension" \
1013 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1014 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001016run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001017 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001018 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001019 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 +02001020 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001021 0 \
1022 -s "parse ServerName extension" \
1023 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001024 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001026run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001027 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001028 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001029 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 +02001030 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001031 1 \
1032 -s "parse ServerName extension" \
1033 -s "ssl_sni_wrapper() returned" \
1034 -s "ssl_handshake returned" \
1035 -c "ssl_handshake returned" \
1036 -c "SSL - A fatal alert message was received from our peer"
1037
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001038# Tests for non-blocking I/O: exercise a variety of handshake flows
1039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001040run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001041 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1042 "$P_CLI nbio=2 tickets=0" \
1043 0 \
1044 -S "ssl_handshake returned" \
1045 -C "ssl_handshake returned" \
1046 -c "Read from server: .* bytes read"
1047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001048run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001049 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1050 "$P_CLI nbio=2 tickets=0" \
1051 0 \
1052 -S "ssl_handshake returned" \
1053 -C "ssl_handshake returned" \
1054 -c "Read from server: .* bytes read"
1055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001056run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001057 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1058 "$P_CLI nbio=2 tickets=1" \
1059 0 \
1060 -S "ssl_handshake returned" \
1061 -C "ssl_handshake returned" \
1062 -c "Read from server: .* bytes read"
1063
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001064run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001065 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1066 "$P_CLI nbio=2 tickets=1" \
1067 0 \
1068 -S "ssl_handshake returned" \
1069 -C "ssl_handshake returned" \
1070 -c "Read from server: .* bytes read"
1071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001072run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001073 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1074 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1075 0 \
1076 -S "ssl_handshake returned" \
1077 -C "ssl_handshake returned" \
1078 -c "Read from server: .* bytes read"
1079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001080run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001081 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1082 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1083 0 \
1084 -S "ssl_handshake returned" \
1085 -C "ssl_handshake returned" \
1086 -c "Read from server: .* bytes read"
1087
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001088run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001089 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1090 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1091 0 \
1092 -S "ssl_handshake returned" \
1093 -C "ssl_handshake returned" \
1094 -c "Read from server: .* bytes read"
1095
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001096# Tests for version negotiation
1097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001098run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001099 "$P_SRV" \
1100 "$P_CLI" \
1101 0 \
1102 -S "ssl_handshake returned" \
1103 -C "ssl_handshake returned" \
1104 -s "Protocol is TLSv1.2" \
1105 -c "Protocol is TLSv1.2"
1106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001107run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001108 "$P_SRV" \
1109 "$P_CLI max_version=tls1_1" \
1110 0 \
1111 -S "ssl_handshake returned" \
1112 -C "ssl_handshake returned" \
1113 -s "Protocol is TLSv1.1" \
1114 -c "Protocol is TLSv1.1"
1115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001116run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001117 "$P_SRV max_version=tls1_1" \
1118 "$P_CLI" \
1119 0 \
1120 -S "ssl_handshake returned" \
1121 -C "ssl_handshake returned" \
1122 -s "Protocol is TLSv1.1" \
1123 -c "Protocol is TLSv1.1"
1124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001125run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001126 "$P_SRV max_version=tls1_1" \
1127 "$P_CLI max_version=tls1_1" \
1128 0 \
1129 -S "ssl_handshake returned" \
1130 -C "ssl_handshake returned" \
1131 -s "Protocol is TLSv1.1" \
1132 -c "Protocol is TLSv1.1"
1133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001134run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001135 "$P_SRV min_version=tls1_1" \
1136 "$P_CLI max_version=tls1_1" \
1137 0 \
1138 -S "ssl_handshake returned" \
1139 -C "ssl_handshake returned" \
1140 -s "Protocol is TLSv1.1" \
1141 -c "Protocol is TLSv1.1"
1142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001143run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001144 "$P_SRV max_version=tls1_1" \
1145 "$P_CLI min_version=tls1_1" \
1146 0 \
1147 -S "ssl_handshake returned" \
1148 -C "ssl_handshake returned" \
1149 -s "Protocol is TLSv1.1" \
1150 -c "Protocol is TLSv1.1"
1151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001152run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001153 "$P_SRV max_version=tls1_1" \
1154 "$P_CLI min_version=tls1_2" \
1155 1 \
1156 -s "ssl_handshake returned" \
1157 -c "ssl_handshake returned" \
1158 -c "SSL - Handshake protocol not within min/max boundaries"
1159
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001160run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001161 "$P_SRV min_version=tls1_2" \
1162 "$P_CLI max_version=tls1_1" \
1163 1 \
1164 -s "ssl_handshake returned" \
1165 -c "ssl_handshake returned" \
1166 -s "SSL - Handshake protocol not within min/max boundaries"
1167
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001168# Tests for ALPN extension
1169
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001170if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001172run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001173 "$P_SRV debug_level=3" \
1174 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001175 0 \
1176 -C "client hello, adding alpn extension" \
1177 -S "found alpn extension" \
1178 -C "got an alert message, type: \\[2:120]" \
1179 -S "server hello, adding alpn extension" \
1180 -C "found alpn extension " \
1181 -C "Application Layer Protocol is" \
1182 -S "Application Layer Protocol is"
1183
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001184run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001185 "$P_SRV debug_level=3" \
1186 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001187 0 \
1188 -c "client hello, adding alpn extension" \
1189 -s "found alpn extension" \
1190 -C "got an alert message, type: \\[2:120]" \
1191 -S "server hello, adding alpn extension" \
1192 -C "found alpn extension " \
1193 -c "Application Layer Protocol is (none)" \
1194 -S "Application Layer Protocol is"
1195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001196run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001197 "$P_SRV debug_level=3 alpn=abc,1234" \
1198 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001199 0 \
1200 -C "client hello, adding alpn extension" \
1201 -S "found alpn extension" \
1202 -C "got an alert message, type: \\[2:120]" \
1203 -S "server hello, adding alpn extension" \
1204 -C "found alpn extension " \
1205 -C "Application Layer Protocol is" \
1206 -s "Application Layer Protocol is (none)"
1207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001208run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001209 "$P_SRV debug_level=3 alpn=abc,1234" \
1210 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001211 0 \
1212 -c "client hello, adding alpn extension" \
1213 -s "found alpn extension" \
1214 -C "got an alert message, type: \\[2:120]" \
1215 -s "server hello, adding alpn extension" \
1216 -c "found alpn extension" \
1217 -c "Application Layer Protocol is abc" \
1218 -s "Application Layer Protocol is abc"
1219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001220run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001221 "$P_SRV debug_level=3 alpn=abc,1234" \
1222 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001223 0 \
1224 -c "client hello, adding alpn extension" \
1225 -s "found alpn extension" \
1226 -C "got an alert message, type: \\[2:120]" \
1227 -s "server hello, adding alpn extension" \
1228 -c "found alpn extension" \
1229 -c "Application Layer Protocol is abc" \
1230 -s "Application Layer Protocol is abc"
1231
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001232run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001233 "$P_SRV debug_level=3 alpn=abc,1234" \
1234 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001235 0 \
1236 -c "client hello, adding alpn extension" \
1237 -s "found alpn extension" \
1238 -C "got an alert message, type: \\[2:120]" \
1239 -s "server hello, adding alpn extension" \
1240 -c "found alpn extension" \
1241 -c "Application Layer Protocol is 1234" \
1242 -s "Application Layer Protocol is 1234"
1243
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001244run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001245 "$P_SRV debug_level=3 alpn=abc,123" \
1246 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001247 1 \
1248 -c "client hello, adding alpn extension" \
1249 -s "found alpn extension" \
1250 -c "got an alert message, type: \\[2:120]" \
1251 -S "server hello, adding alpn extension" \
1252 -C "found alpn extension" \
1253 -C "Application Layer Protocol is 1234" \
1254 -S "Application Layer Protocol is 1234"
1255
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001256fi
1257
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001258# Tests for keyUsage in leaf certificates, part 1:
1259# server-side certificate/suite selection
1260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001261run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001262 "$P_SRV key_file=data_files/server2.key \
1263 crt_file=data_files/server2.ku-ds.crt" \
1264 "$P_CLI" \
1265 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001266 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001267
1268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001269run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001270 "$P_SRV key_file=data_files/server2.key \
1271 crt_file=data_files/server2.ku-ke.crt" \
1272 "$P_CLI" \
1273 0 \
1274 -c "Ciphersuite is TLS-RSA-WITH-"
1275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001276run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001277 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001278 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001279 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001280 1 \
1281 -C "Ciphersuite is "
1282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001283run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001284 "$P_SRV key_file=data_files/server5.key \
1285 crt_file=data_files/server5.ku-ds.crt" \
1286 "$P_CLI" \
1287 0 \
1288 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1289
1290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001291run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001292 "$P_SRV key_file=data_files/server5.key \
1293 crt_file=data_files/server5.ku-ka.crt" \
1294 "$P_CLI" \
1295 0 \
1296 -c "Ciphersuite is TLS-ECDH-"
1297
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001298run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001299 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001300 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001301 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001302 1 \
1303 -C "Ciphersuite is "
1304
1305# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001306# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001307
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001308run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001309 "$O_SRV -key data_files/server2.key \
1310 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001311 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001312 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1313 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001314 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001315 -C "Processing of the Certificate handshake message failed" \
1316 -c "Ciphersuite is TLS-"
1317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001318run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001319 "$O_SRV -key data_files/server2.key \
1320 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001321 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001322 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1323 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001324 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001325 -C "Processing of the Certificate handshake message failed" \
1326 -c "Ciphersuite is TLS-"
1327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001328run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001329 "$O_SRV -key data_files/server2.key \
1330 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001331 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001332 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1333 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001334 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001335 -C "Processing of the Certificate handshake message failed" \
1336 -c "Ciphersuite is TLS-"
1337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001338run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001339 "$O_SRV -key data_files/server2.key \
1340 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001341 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001342 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1343 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001344 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001345 -c "Processing of the Certificate handshake message failed" \
1346 -C "Ciphersuite is TLS-"
1347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001348run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001349 "$O_SRV -key data_files/server2.key \
1350 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001351 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001352 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1353 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001354 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001355 -C "Processing of the Certificate handshake message failed" \
1356 -c "Ciphersuite is TLS-"
1357
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001358run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001359 "$O_SRV -key data_files/server2.key \
1360 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001361 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001362 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1363 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001364 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001365 -c "Processing of the Certificate handshake message failed" \
1366 -C "Ciphersuite is TLS-"
1367
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001368# Tests for keyUsage in leaf certificates, part 3:
1369# server-side checking of client cert
1370
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001371run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001372 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001373 "$O_CLI -key data_files/server2.key \
1374 -cert data_files/server2.ku-ds.crt" \
1375 0 \
1376 -S "bad certificate (usage extensions)" \
1377 -S "Processing of the Certificate handshake message failed"
1378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001379run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001380 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001381 "$O_CLI -key data_files/server2.key \
1382 -cert data_files/server2.ku-ke.crt" \
1383 0 \
1384 -s "bad certificate (usage extensions)" \
1385 -S "Processing of the Certificate handshake message failed"
1386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001387run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001388 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001389 "$O_CLI -key data_files/server2.key \
1390 -cert data_files/server2.ku-ke.crt" \
1391 1 \
1392 -s "bad certificate (usage extensions)" \
1393 -s "Processing of the Certificate handshake message failed"
1394
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001395run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001396 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001397 "$O_CLI -key data_files/server5.key \
1398 -cert data_files/server5.ku-ds.crt" \
1399 0 \
1400 -S "bad certificate (usage extensions)" \
1401 -S "Processing of the Certificate handshake message failed"
1402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001403run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001404 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001405 "$O_CLI -key data_files/server5.key \
1406 -cert data_files/server5.ku-ka.crt" \
1407 0 \
1408 -s "bad certificate (usage extensions)" \
1409 -S "Processing of the Certificate handshake message failed"
1410
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001411# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001413run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001414 "$P_SRV key_file=data_files/server5.key \
1415 crt_file=data_files/server5.eku-srv.crt" \
1416 "$P_CLI" \
1417 0
1418
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001419run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001420 "$P_SRV key_file=data_files/server5.key \
1421 crt_file=data_files/server5.eku-srv.crt" \
1422 "$P_CLI" \
1423 0
1424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001425run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001426 "$P_SRV key_file=data_files/server5.key \
1427 crt_file=data_files/server5.eku-cs_any.crt" \
1428 "$P_CLI" \
1429 0
1430
1431# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001432run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001433 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1434 crt_file=data_files/server5.eku-cli.crt" \
1435 "$P_CLI psk=badbad" \
1436 1
1437
1438# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001440run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001441 "$O_SRV -key data_files/server5.key \
1442 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001443 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001444 0 \
1445 -C "bad certificate (usage extensions)" \
1446 -C "Processing of the Certificate handshake message failed" \
1447 -c "Ciphersuite is TLS-"
1448
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001449run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001450 "$O_SRV -key data_files/server5.key \
1451 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001452 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001453 0 \
1454 -C "bad certificate (usage extensions)" \
1455 -C "Processing of the Certificate handshake message failed" \
1456 -c "Ciphersuite is TLS-"
1457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001458run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001459 "$O_SRV -key data_files/server5.key \
1460 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001461 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001462 0 \
1463 -C "bad certificate (usage extensions)" \
1464 -C "Processing of the Certificate handshake message failed" \
1465 -c "Ciphersuite is TLS-"
1466
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001467run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001468 "$O_SRV -key data_files/server5.key \
1469 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001470 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001471 1 \
1472 -c "bad certificate (usage extensions)" \
1473 -c "Processing of the Certificate handshake message failed" \
1474 -C "Ciphersuite is TLS-"
1475
1476# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001478run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001479 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001480 "$O_CLI -key data_files/server5.key \
1481 -cert data_files/server5.eku-cli.crt" \
1482 0 \
1483 -S "bad certificate (usage extensions)" \
1484 -S "Processing of the Certificate handshake message failed"
1485
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001486run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001487 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001488 "$O_CLI -key data_files/server5.key \
1489 -cert data_files/server5.eku-srv_cli.crt" \
1490 0 \
1491 -S "bad certificate (usage extensions)" \
1492 -S "Processing of the Certificate handshake message failed"
1493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001494run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001495 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001496 "$O_CLI -key data_files/server5.key \
1497 -cert data_files/server5.eku-cs_any.crt" \
1498 0 \
1499 -S "bad certificate (usage extensions)" \
1500 -S "Processing of the Certificate handshake message failed"
1501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001502run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001503 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001504 "$O_CLI -key data_files/server5.key \
1505 -cert data_files/server5.eku-cs.crt" \
1506 0 \
1507 -s "bad certificate (usage extensions)" \
1508 -S "Processing of the Certificate handshake message failed"
1509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001510run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001511 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001512 "$O_CLI -key data_files/server5.key \
1513 -cert data_files/server5.eku-cs.crt" \
1514 1 \
1515 -s "bad certificate (usage extensions)" \
1516 -s "Processing of the Certificate handshake message failed"
1517
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001518# Tests for DHM parameters loading
1519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001520run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001521 "$P_SRV" \
1522 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1523 debug_level=3" \
1524 0 \
1525 -c "value of 'DHM: P ' (2048 bits)" \
1526 -c "value of 'DHM: G ' (2048 bits)"
1527
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001528run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001529 "$P_SRV dhm_file=data_files/dhparams.pem" \
1530 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1531 debug_level=3" \
1532 0 \
1533 -c "value of 'DHM: P ' (1024 bits)" \
1534 -c "value of 'DHM: G ' (2 bits)"
1535
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001536# Tests for PSK callback
1537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001538run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001539 "$P_SRV psk=abc123 psk_identity=foo" \
1540 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1541 psk_identity=foo psk=abc123" \
1542 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001543 -S "SSL - The server has no ciphersuites in common" \
1544 -S "SSL - Unknown identity received" \
1545 -S "SSL - Verification of the message MAC failed"
1546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001547run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001548 "$P_SRV" \
1549 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1550 psk_identity=foo psk=abc123" \
1551 1 \
1552 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001553 -S "SSL - Unknown identity received" \
1554 -S "SSL - Verification of the message MAC failed"
1555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001556run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001557 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1558 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1559 psk_identity=foo psk=abc123" \
1560 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001561 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001562 -s "SSL - Unknown identity received" \
1563 -S "SSL - Verification of the message MAC failed"
1564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001565run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001566 "$P_SRV psk_list=abc,dead,def,beef" \
1567 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1568 psk_identity=abc psk=dead" \
1569 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001570 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001571 -S "SSL - Unknown identity received" \
1572 -S "SSL - Verification of the message MAC failed"
1573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001574run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001575 "$P_SRV psk_list=abc,dead,def,beef" \
1576 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1577 psk_identity=def psk=beef" \
1578 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001579 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001580 -S "SSL - Unknown identity received" \
1581 -S "SSL - Verification of the message MAC failed"
1582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001583run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001584 "$P_SRV psk_list=abc,dead,def,beef" \
1585 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1586 psk_identity=ghi psk=beef" \
1587 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001588 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001589 -s "SSL - Unknown identity received" \
1590 -S "SSL - Verification of the message MAC failed"
1591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001592run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001593 "$P_SRV psk_list=abc,dead,def,beef" \
1594 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1595 psk_identity=abc psk=beef" \
1596 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001597 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001598 -S "SSL - Unknown identity received" \
1599 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001600
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001601# Tests for ciphersuites per version
1602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001603run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001604 "$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" \
1605 "$P_CLI force_version=ssl3" \
1606 0 \
1607 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001609run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001610 "$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" \
1611 "$P_CLI force_version=tls1" \
1612 0 \
1613 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001615run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001616 "$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" \
1617 "$P_CLI force_version=tls1_1" \
1618 0 \
1619 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001621run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001622 "$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" \
1623 "$P_CLI force_version=tls1_2" \
1624 0 \
1625 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1626
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001627# Tests for ssl_get_bytes_avail()
1628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001629run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001630 "$P_SRV" \
1631 "$P_CLI request_size=100" \
1632 0 \
1633 -s "Read from client: 100 bytes read$"
1634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001635run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001636 "$P_SRV" \
1637 "$P_CLI request_size=500" \
1638 0 \
1639 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001640
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001641# Tests for small packets
1642
1643run_test "Small packet SSLv3 BlockCipher" \
1644 "$P_SRV" \
1645 "$P_CLI request_size=1 force_version=ssl3 \
1646 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1647 0 \
1648 -s "Read from client: 1 bytes read"
1649
1650run_test "Small packet SSLv3 StreamCipher" \
1651 "$P_SRV" \
1652 "$P_CLI request_size=1 force_version=ssl3 \
1653 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1654 0 \
1655 -s "Read from client: 1 bytes read"
1656
1657run_test "Small packet TLS 1.0 BlockCipher" \
1658 "$P_SRV" \
1659 "$P_CLI request_size=1 force_version=tls1 \
1660 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1661 0 \
1662 -s "Read from client: 1 bytes read"
1663
1664run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1665 "$P_SRV" \
1666 "$P_CLI request_size=1 force_version=tls1 \
1667 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1668 trunc_hmac=1" \
1669 0 \
1670 -s "Read from client: 1 bytes read"
1671
1672run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1673 "$P_SRV" \
1674 "$P_CLI request_size=1 force_version=tls1 \
1675 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1676 trunc_hmac=1" \
1677 0 \
1678 -s "Read from client: 1 bytes read"
1679
1680run_test "Small packet TLS 1.1 BlockCipher" \
1681 "$P_SRV" \
1682 "$P_CLI request_size=1 force_version=tls1_1 \
1683 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1684 0 \
1685 -s "Read from client: 1 bytes read"
1686
1687run_test "Small packet TLS 1.1 StreamCipher" \
1688 "$P_SRV" \
1689 "$P_CLI request_size=1 force_version=tls1_1 \
1690 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1691 0 \
1692 -s "Read from client: 1 bytes read"
1693
1694run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1695 "$P_SRV" \
1696 "$P_CLI request_size=1 force_version=tls1_1 \
1697 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1698 trunc_hmac=1" \
1699 0 \
1700 -s "Read from client: 1 bytes read"
1701
1702run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1703 "$P_SRV" \
1704 "$P_CLI request_size=1 force_version=tls1_1 \
1705 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1706 trunc_hmac=1" \
1707 0 \
1708 -s "Read from client: 1 bytes read"
1709
1710run_test "Small packet TLS 1.2 BlockCipher" \
1711 "$P_SRV" \
1712 "$P_CLI request_size=1 force_version=tls1_2 \
1713 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1714 0 \
1715 -s "Read from client: 1 bytes read"
1716
1717run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1718 "$P_SRV" \
1719 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1720 0 \
1721 -s "Read from client: 1 bytes read"
1722
1723run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1724 "$P_SRV" \
1725 "$P_CLI request_size=1 force_version=tls1_2 \
1726 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1727 trunc_hmac=1" \
1728 0 \
1729 -s "Read from client: 1 bytes read"
1730
1731run_test "Small packet TLS 1.2 StreamCipher" \
1732 "$P_SRV" \
1733 "$P_CLI request_size=1 force_version=tls1_2 \
1734 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1735 0 \
1736 -s "Read from client: 1 bytes read"
1737
1738run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1739 "$P_SRV" \
1740 "$P_CLI request_size=1 force_version=tls1_2 \
1741 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1742 trunc_hmac=1" \
1743 0 \
1744 -s "Read from client: 1 bytes read"
1745
1746run_test "Small packet TLS 1.2 AEAD" \
1747 "$P_SRV" \
1748 "$P_CLI request_size=1 force_version=tls1_2 \
1749 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1750 0 \
1751 -s "Read from client: 1 bytes read"
1752
1753run_test "Small packet TLS 1.2 AEAD shorter tag" \
1754 "$P_SRV" \
1755 "$P_CLI request_size=1 force_version=tls1_2 \
1756 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1757 0 \
1758 -s "Read from client: 1 bytes read"
1759
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001760# Test for large packets
1761
1762run_test "Large packet SSLv3 BlockCipher" \
1763 "$P_SRV" \
1764 "$P_CLI request_size=16384 force_version=ssl3 \
1765 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1766 0 \
1767 -s "Read from client: 16384 bytes read"
1768
1769run_test "Large packet SSLv3 StreamCipher" \
1770 "$P_SRV" \
1771 "$P_CLI request_size=16384 force_version=ssl3 \
1772 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1773 0 \
1774 -s "Read from client: 16384 bytes read"
1775
1776run_test "Large packet TLS 1.0 BlockCipher" \
1777 "$P_SRV" \
1778 "$P_CLI request_size=16384 force_version=tls1 \
1779 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1780 0 \
1781 -s "Read from client: 16384 bytes read"
1782
1783run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1784 "$P_SRV" \
1785 "$P_CLI request_size=16384 force_version=tls1 \
1786 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1787 trunc_hmac=1" \
1788 0 \
1789 -s "Read from client: 16384 bytes read"
1790
1791run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1792 "$P_SRV" \
1793 "$P_CLI request_size=16384 force_version=tls1 \
1794 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1795 trunc_hmac=1" \
1796 0 \
1797 -s "Read from client: 16384 bytes read"
1798
1799run_test "Large packet TLS 1.1 BlockCipher" \
1800 "$P_SRV" \
1801 "$P_CLI request_size=16384 force_version=tls1_1 \
1802 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1803 0 \
1804 -s "Read from client: 16384 bytes read"
1805
1806run_test "Large packet TLS 1.1 StreamCipher" \
1807 "$P_SRV" \
1808 "$P_CLI request_size=16384 force_version=tls1_1 \
1809 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1810 0 \
1811 -s "Read from client: 16384 bytes read"
1812
1813run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1814 "$P_SRV" \
1815 "$P_CLI request_size=16384 force_version=tls1_1 \
1816 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1817 trunc_hmac=1" \
1818 0 \
1819 -s "Read from client: 16384 bytes read"
1820
1821run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1822 "$P_SRV" \
1823 "$P_CLI request_size=16384 force_version=tls1_1 \
1824 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1825 trunc_hmac=1" \
1826 0 \
1827 -s "Read from client: 16384 bytes read"
1828
1829run_test "Large packet TLS 1.2 BlockCipher" \
1830 "$P_SRV" \
1831 "$P_CLI request_size=16384 force_version=tls1_2 \
1832 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1833 0 \
1834 -s "Read from client: 16384 bytes read"
1835
1836run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1837 "$P_SRV" \
1838 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1839 0 \
1840 -s "Read from client: 16384 bytes read"
1841
1842run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1843 "$P_SRV" \
1844 "$P_CLI request_size=16384 force_version=tls1_2 \
1845 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1846 trunc_hmac=1" \
1847 0 \
1848 -s "Read from client: 16384 bytes read"
1849
1850run_test "Large packet TLS 1.2 StreamCipher" \
1851 "$P_SRV" \
1852 "$P_CLI request_size=16384 force_version=tls1_2 \
1853 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1854 0 \
1855 -s "Read from client: 16384 bytes read"
1856
1857run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1858 "$P_SRV" \
1859 "$P_CLI request_size=16384 force_version=tls1_2 \
1860 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1861 trunc_hmac=1" \
1862 0 \
1863 -s "Read from client: 16384 bytes read"
1864
1865run_test "Large packet TLS 1.2 AEAD" \
1866 "$P_SRV" \
1867 "$P_CLI request_size=16384 force_version=tls1_2 \
1868 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1869 0 \
1870 -s "Read from client: 16384 bytes read"
1871
1872run_test "Large packet TLS 1.2 AEAD shorter tag" \
1873 "$P_SRV" \
1874 "$P_CLI request_size=16384 force_version=tls1_2 \
1875 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1876 0 \
1877 -s "Read from client: 16384 bytes read"
1878
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001879# Tests for DTLS HelloVerifyRequest
1880
1881run_test "DTLS cookie: enabled" \
1882 "$P_SRV dtls=1 debug_level=2" \
1883 "$P_CLI dtls=1 debug_level=2" \
1884 0 \
1885 -s "cookie verification failed" \
1886 -s "cookie verification passed" \
1887 -S "cookie verification skipped" \
1888 -c "received hello verify request" \
1889 -S "SSL - The requested feature is not available"
1890
1891run_test "DTLS cookie: disabled" \
1892 "$P_SRV dtls=1 debug_level=2 cookies=0" \
1893 "$P_CLI dtls=1 debug_level=2" \
1894 0 \
1895 -S "cookie verification failed" \
1896 -S "cookie verification passed" \
1897 -s "cookie verification skipped" \
1898 -C "received hello verify request" \
1899 -S "SSL - The requested feature is not available"
1900
1901# wait for client having a timeout, or server sending an alert
1902#run_test "DTLS cookie: default (failing)" \
1903# "$P_SRV dtls=1 debug_level=2 cookies=-1" \
1904# "$P_CLI dtls=1 debug_level=2" \
1905# 0 \
1906# -S "cookie verification failed" \
1907# -S "cookie verification passed" \
1908# -S "cookie verification skipped" \
1909# -C "received hello verify request" \
1910# -s "SSL - The requested feature is not available"
1911
1912requires_ipv6
1913run_test "DTLS cookie: enabled, IPv6" \
1914 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
1915 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
1916 0 \
1917 -s "cookie verification failed" \
1918 -s "cookie verification passed" \
1919 -S "cookie verification skipped" \
1920 -c "received hello verify request" \
1921 -S "SSL - The requested feature is not available"
1922
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001923# Final report
1924
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001925echo "------------------------------------------------------------------------"
1926
1927if [ $FAILS = 0 ]; then
1928 echo -n "PASSED"
1929else
1930 echo -n "FAILED"
1931fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02001932PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001933echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001934
1935exit $FAILS