blob: cea5790e0b0ca14e31454be87da86986691e6663 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
21O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
23G_CLI="$GNUTLS_CLI"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010037 echo -e " -h|--help\tPrint this help."
38 echo -e " -m|--memcheck\tCheck memory leaks and errors."
39 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
40 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +020078
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020079 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
80 SKIP_NEXT="YES"
81 fi
82}
83
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020084# skip next test if GnuTLS isn't available
85requires_gnutls() {
86 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
87 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
88 GNUTLS_AVAILABLE="YES"
89 else
90 GNUTLS_AVAILABLE="NO"
91 fi
92 fi
93 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
94 SKIP_NEXT="YES"
95 fi
96}
97
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +020098# skip next test if IPv6 isn't available on this host
99requires_ipv6() {
100 if [ -z "${HAS_IPV6:-}" ]; then
101 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
102 SRV_PID=$!
103 sleep 1
104 kill $SRV_PID >/dev/null 2>&1
105 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
106 HAS_IPV6="NO"
107 else
108 HAS_IPV6="YES"
109 fi
110 rm -r $SRV_OUT
111 fi
112
113 if [ "$HAS_IPV6" = "NO" ]; then
114 SKIP_NEXT="YES"
115 fi
116}
117
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100118# print_name <name>
119print_name() {
120 echo -n "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200121 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100122 for i in `seq 1 $LEN`; do echo -n '.'; done
123 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100124
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200125 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100126}
127
128# fail <message>
129fail() {
130 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100131 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100132
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200133 mv $SRV_OUT o-srv-${TESTS}.log
134 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100135 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100136
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200137 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
138 echo " ! server output:"
139 cat o-srv-${TESTS}.log
140 echo " ! ============================================================"
141 echo " ! client output:"
142 cat o-cli-${TESTS}.log
143 fi
144
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200145 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100146}
147
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100148# is_polar <cmd_line>
149is_polar() {
150 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
151}
152
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100153# has_mem_err <log_file_name>
154has_mem_err() {
155 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
156 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
157 then
158 return 1 # false: does not have errors
159 else
160 return 0 # true: has errors
161 fi
162}
163
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200164# wait for server to start: two versions depending on lsof availability
165wait_server_start() {
166 if which lsof >/dev/null; then
167 # make sure we don't loop forever
168 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
169 WATCHDOG_PID=$!
170
171 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200172 if [ "$DTLS" -eq 1 ]; then
173 until lsof -nbi UDP:"$PORT" | grep UDP >/dev/null; do :; done
174 else
175 until lsof -nbi TCP:"$PORT" | grep LISTEN >/dev/null; do :; done
176 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200177
178 kill $WATCHDOG_PID
179 wait $WATCHDOG_PID
180 else
181 sleep "$START_DELAY"
182 fi
183}
184
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200185# wait for client to terminate and set CLI_EXIT
186# must be called right after starting the client
187wait_client_done() {
188 CLI_PID=$!
189
190 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
191 WATCHDOG_PID=$!
192
193 wait $CLI_PID
194 CLI_EXIT=$?
195
196 kill $WATCHDOG_PID
197 wait $WATCHDOG_PID
198
199 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
200}
201
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200202# check if the given command uses dtls and sets global variable DTLS
203detect_dtls() {
204 if echo "$1" | grep ' dtls=1 \| -dtls1\| -u ' >/dev/null; then
205 DTLS=1
206 else
207 DTLS=0
208 fi
209}
210
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100211# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100212# Options: -s pattern pattern that must be present in server output
213# -c pattern pattern that must be present in client output
214# -S pattern pattern that must be absent in server output
215# -C pattern pattern that must be absent in client output
216run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100217 NAME="$1"
218 SRV_CMD="$2"
219 CLI_CMD="$3"
220 CLI_EXPECT="$4"
221 shift 4
222
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100223 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
224 else
225 return
226 fi
227
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100228 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100229
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200230 # should we skip?
231 if [ "X$SKIP_NEXT" = "XYES" ]; then
232 SKIP_NEXT="NO"
233 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200234 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200235 return
236 fi
237
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200238 # update DTLS variable
239 detect_dtls "$SRV_CMD"
240
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100241 # prepend valgrind to our commands if active
242 if [ "$MEMCHECK" -gt 0 ]; then
243 if is_polar "$SRV_CMD"; then
244 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
245 fi
246 if is_polar "$CLI_CMD"; then
247 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
248 fi
249 fi
250
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100251 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200252 echo "$SRV_CMD" > $SRV_OUT
253 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100254 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200255 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200256
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200257 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200258 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
259 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100260
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200261 # kill the server
262 kill $SRV_PID
263 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100264
265 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200266 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100267 # expected client exit to incorrectly succeed in case of catastrophic
268 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100269 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200270 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100271 else
272 fail "server failed to start"
273 return
274 fi
275 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100276 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200277 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100278 else
279 fail "client failed to start"
280 return
281 fi
282 fi
283
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100284 # check server exit code
285 if [ $? != 0 ]; then
286 fail "server fail"
287 return
288 fi
289
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100290 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100291 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
292 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100293 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100294 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100295 return
296 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100297
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100298 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200299 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100300 while [ $# -gt 0 ]
301 do
302 case $1 in
303 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200304 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100305 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100306 return
307 fi
308 ;;
309
310 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200311 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100312 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100313 return
314 fi
315 ;;
316
317 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200318 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100319 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100320 return
321 fi
322 ;;
323
324 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200325 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100326 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100327 return
328 fi
329 ;;
330
331 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200332 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100333 exit 1
334 esac
335 shift 2
336 done
337
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100338 # check valgrind's results
339 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200340 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100341 fail "Server has memory errors"
342 return
343 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200344 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100345 fail "Client has memory errors"
346 return
347 fi
348 fi
349
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100350 # if we're here, everything is ok
351 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200352 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100353}
354
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100355cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200356 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200357 kill $SRV_PID >/dev/null 2>&1
358 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100359 exit 1
360}
361
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100362#
363# MAIN
364#
365
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100366get_options "$@"
367
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100368# sanity checks, avoid an avalanche of errors
369if [ ! -x "$P_SRV" ]; then
370 echo "Command '$P_SRV' is not an executable file"
371 exit 1
372fi
373if [ ! -x "$P_CLI" ]; then
374 echo "Command '$P_CLI' is not an executable file"
375 exit 1
376fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100377if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
378 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100379 exit 1
380fi
381
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200382# used by watchdog
383MAIN_PID="$$"
384
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200385# be more patient with valgrind
386if [ "$MEMCHECK" -gt 0 ]; then
387 START_DELAY=3
388 DOG_DELAY=30
389else
390 START_DELAY=1
391 DOG_DELAY=10
392fi
393
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200394# Pick a "unique" port in the range 10000-19999.
395PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200396PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200397
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200398# fix commands to use this port, force IPv4 while at it
399P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$PORT"
400P_CLI="$P_CLI server_addr=127.0.0.1 server_port=$PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200401O_SRV="$O_SRV -accept $PORT"
402O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200403G_SRV="$G_SRV -p $PORT"
404G_CLI="$G_CLI -p $PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200405
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200406# Also pick a unique name for intermediate files
407SRV_OUT="srv_out.$$"
408CLI_OUT="cli_out.$$"
409SESSION="session.$$"
410
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200411SKIP_NEXT="NO"
412
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100413trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100414
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200415# Basic test
416
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200417# Checks that:
418# - things work with all ciphersuites active (used with config-full in all.sh)
419# - the expected (highest security) parameters are selected
420# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200421run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200422 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200423 "$P_CLI" \
424 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200425 -s "Protocol is TLSv1.2" \
426 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
427 -s "client hello v3, signature_algorithm ext: 6" \
428 -s "ECDHE curve: secp521r1" \
429 -S "error" \
430 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200431
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100432# Test for SSLv2 ClientHello
433
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200434requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200435run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100436 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100437 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100438 0 \
439 -S "parse client hello v2" \
440 -S "ssl_handshake returned"
441
442# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200443requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200444run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200445 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100446 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100447 0 \
448 -s "parse client hello v2" \
449 -S "ssl_handshake returned"
450
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100451# Tests for Truncated HMAC extension
452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200453run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200454 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100455 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100456 0 \
457 -s "dumping 'computed mac' (20 bytes)"
458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200459run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200460 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100461 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100462 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100463 -s "dumping 'computed mac' (10 bytes)"
464
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100465# Tests for Session Tickets
466
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200467run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200468 "$P_SRV debug_level=3 tickets=1" \
469 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100470 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100471 -c "client hello, adding session ticket extension" \
472 -s "found session ticket extension" \
473 -s "server hello, adding session ticket extension" \
474 -c "found session_ticket extension" \
475 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100476 -S "session successfully restored from cache" \
477 -s "session successfully restored from ticket" \
478 -s "a session has been resumed" \
479 -c "a session has been resumed"
480
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200481run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200482 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
483 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100484 0 \
485 -c "client hello, adding session ticket extension" \
486 -s "found session ticket extension" \
487 -s "server hello, adding session ticket extension" \
488 -c "found session_ticket extension" \
489 -c "parse new session ticket" \
490 -S "session successfully restored from cache" \
491 -s "session successfully restored from ticket" \
492 -s "a session has been resumed" \
493 -c "a session has been resumed"
494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200495run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200496 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
497 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100498 0 \
499 -c "client hello, adding session ticket extension" \
500 -s "found session ticket extension" \
501 -s "server hello, adding session ticket extension" \
502 -c "found session_ticket extension" \
503 -c "parse new session ticket" \
504 -S "session successfully restored from cache" \
505 -S "session successfully restored from ticket" \
506 -S "a session has been resumed" \
507 -C "a session has been resumed"
508
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200509run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100510 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200511 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100512 0 \
513 -c "client hello, adding session ticket extension" \
514 -c "found session_ticket extension" \
515 -c "parse new session ticket" \
516 -c "a session has been resumed"
517
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200518run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200519 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200520 "( $O_CLI -sess_out $SESSION; \
521 $O_CLI -sess_in $SESSION; \
522 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100523 0 \
524 -s "found session ticket extension" \
525 -s "server hello, adding session ticket extension" \
526 -S "session successfully restored from cache" \
527 -s "session successfully restored from ticket" \
528 -s "a session has been resumed"
529
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100530# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200532run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200533 "$P_SRV debug_level=3 tickets=0" \
534 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100535 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100536 -c "client hello, adding session ticket extension" \
537 -s "found session ticket extension" \
538 -S "server hello, adding session ticket extension" \
539 -C "found session_ticket extension" \
540 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100541 -s "session successfully restored from cache" \
542 -S "session successfully restored from ticket" \
543 -s "a session has been resumed" \
544 -c "a session has been resumed"
545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200546run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200547 "$P_SRV debug_level=3 tickets=1" \
548 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100549 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100550 -C "client hello, adding session ticket extension" \
551 -S "found session ticket extension" \
552 -S "server hello, adding session ticket extension" \
553 -C "found session_ticket extension" \
554 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100555 -s "session successfully restored from cache" \
556 -S "session successfully restored from ticket" \
557 -s "a session has been resumed" \
558 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200560run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200561 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
562 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100563 0 \
564 -S "session successfully restored from cache" \
565 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100566 -S "a session has been resumed" \
567 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200569run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200570 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
571 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100572 0 \
573 -s "session successfully restored from cache" \
574 -S "session successfully restored from ticket" \
575 -s "a session has been resumed" \
576 -c "a session has been resumed"
577
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200578run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200579 "$P_SRV debug_level=3 tickets=0" \
580 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100581 0 \
582 -s "session successfully restored from cache" \
583 -S "session successfully restored from ticket" \
584 -s "a session has been resumed" \
585 -c "a session has been resumed"
586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200587run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200588 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
589 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100590 0 \
591 -S "session successfully restored from cache" \
592 -S "session successfully restored from ticket" \
593 -S "a session has been resumed" \
594 -C "a session has been resumed"
595
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200596run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200597 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
598 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100599 0 \
600 -s "session successfully restored from cache" \
601 -S "session successfully restored from ticket" \
602 -s "a session has been resumed" \
603 -c "a session has been resumed"
604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200605run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200606 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200607 "( $O_CLI -sess_out $SESSION; \
608 $O_CLI -sess_in $SESSION; \
609 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100610 0 \
611 -s "found session ticket extension" \
612 -S "server hello, adding session ticket extension" \
613 -s "session successfully restored from cache" \
614 -S "session successfully restored from ticket" \
615 -s "a session has been resumed"
616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200617run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100618 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200619 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100620 0 \
621 -C "found session_ticket extension" \
622 -C "parse new session ticket" \
623 -c "a session has been resumed"
624
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100625# Tests for Max Fragment Length extension
626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200627run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200628 "$P_SRV debug_level=3" \
629 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100630 0 \
631 -C "client hello, adding max_fragment_length extension" \
632 -S "found max fragment length extension" \
633 -S "server hello, max_fragment_length extension" \
634 -C "found max_fragment_length extension"
635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200636run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200637 "$P_SRV debug_level=3" \
638 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100639 0 \
640 -c "client hello, adding max_fragment_length extension" \
641 -s "found max fragment length extension" \
642 -s "server hello, max_fragment_length extension" \
643 -c "found max_fragment_length extension"
644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200645run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200646 "$P_SRV debug_level=3 max_frag_len=4096" \
647 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100648 0 \
649 -C "client hello, adding max_fragment_length extension" \
650 -S "found max fragment length extension" \
651 -S "server hello, max_fragment_length extension" \
652 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200654requires_gnutls
655run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200656 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200657 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200658 0 \
659 -c "client hello, adding max_fragment_length extension" \
660 -c "found max_fragment_length extension"
661
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100662# Tests for renegotiation
663
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200664run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200665 "$P_SRV debug_level=3 exchanges=2" \
666 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100667 0 \
668 -C "client hello, adding renegotiation extension" \
669 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
670 -S "found renegotiation extension" \
671 -s "server hello, secure renegotiation extension" \
672 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100673 -C "=> renegotiate" \
674 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100675 -S "write hello request"
676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200677run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200678 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
679 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100680 0 \
681 -c "client hello, adding renegotiation extension" \
682 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
683 -s "found renegotiation extension" \
684 -s "server hello, secure renegotiation extension" \
685 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100686 -c "=> renegotiate" \
687 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100688 -S "write hello request"
689
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200690run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200691 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
692 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100693 0 \
694 -c "client hello, adding renegotiation extension" \
695 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
696 -s "found renegotiation extension" \
697 -s "server hello, secure renegotiation extension" \
698 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100699 -c "=> renegotiate" \
700 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100701 -s "write hello request"
702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200703run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200704 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
705 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100706 0 \
707 -c "client hello, adding renegotiation extension" \
708 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
709 -s "found renegotiation extension" \
710 -s "server hello, secure renegotiation extension" \
711 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100712 -c "=> renegotiate" \
713 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100714 -s "write hello request"
715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200716run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200717 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
718 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100719 1 \
720 -c "client hello, adding renegotiation extension" \
721 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
722 -S "found renegotiation extension" \
723 -s "server hello, secure renegotiation extension" \
724 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100725 -c "=> renegotiate" \
726 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200727 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200728 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200729 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100730
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200731run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200732 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
733 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100734 0 \
735 -C "client hello, adding renegotiation extension" \
736 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
737 -S "found renegotiation extension" \
738 -s "server hello, secure renegotiation extension" \
739 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100740 -C "=> renegotiate" \
741 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100742 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200743 -S "SSL - An unexpected message was received from our peer" \
744 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200746run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200747 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200748 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200749 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200750 0 \
751 -C "client hello, adding renegotiation extension" \
752 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
753 -S "found renegotiation extension" \
754 -s "server hello, secure renegotiation extension" \
755 -c "found renegotiation extension" \
756 -C "=> renegotiate" \
757 -S "=> renegotiate" \
758 -s "write hello request" \
759 -S "SSL - An unexpected message was received from our peer" \
760 -S "failed"
761
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200762# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200763run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200764 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200765 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200766 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200767 0 \
768 -C "client hello, adding renegotiation extension" \
769 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
770 -S "found renegotiation extension" \
771 -s "server hello, secure renegotiation extension" \
772 -c "found renegotiation extension" \
773 -C "=> renegotiate" \
774 -S "=> renegotiate" \
775 -s "write hello request" \
776 -S "SSL - An unexpected message was received from our peer" \
777 -S "failed"
778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200779run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200780 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200781 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200782 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200783 0 \
784 -C "client hello, adding renegotiation extension" \
785 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
786 -S "found renegotiation extension" \
787 -s "server hello, secure renegotiation extension" \
788 -c "found renegotiation extension" \
789 -C "=> renegotiate" \
790 -S "=> renegotiate" \
791 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200792 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200794run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200795 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200796 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200797 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200798 0 \
799 -c "client hello, adding renegotiation extension" \
800 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
801 -s "found renegotiation extension" \
802 -s "server hello, secure renegotiation extension" \
803 -c "found renegotiation extension" \
804 -c "=> renegotiate" \
805 -s "=> renegotiate" \
806 -s "write hello request" \
807 -S "SSL - An unexpected message was received from our peer" \
808 -S "failed"
809
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200810run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200811 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
812 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200813 0 \
814 -c "client hello, adding renegotiation extension" \
815 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
816 -s "found renegotiation extension" \
817 -s "server hello, secure renegotiation extension" \
818 -c "found renegotiation extension" \
819 -c "=> renegotiate" \
820 -s "=> renegotiate" \
821 -S "write hello request"
822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200823run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200824 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
825 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200826 0 \
827 -c "client hello, adding renegotiation extension" \
828 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
829 -s "found renegotiation extension" \
830 -s "server hello, secure renegotiation extension" \
831 -c "found renegotiation extension" \
832 -c "=> renegotiate" \
833 -s "=> renegotiate" \
834 -s "write hello request"
835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200836run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200837 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200838 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200839 0 \
840 -c "client hello, adding renegotiation extension" \
841 -c "found renegotiation extension" \
842 -c "=> renegotiate" \
843 -C "ssl_handshake returned" \
844 -C "error" \
845 -c "HTTP/1.0 200 [Oo][Kk]"
846
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200847run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200848 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200849 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200850 0 \
851 -c "client hello, adding renegotiation extension" \
852 -c "found renegotiation extension" \
853 -c "=> renegotiate" \
854 -C "ssl_handshake returned" \
855 -C "error" \
856 -c "HTTP/1.0 200 [Oo][Kk]"
857
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +0200858run_test "Renegotiation: DTLS, client-initiated" \
859 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
860 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
861 0 \
862 -c "client hello, adding renegotiation extension" \
863 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
864 -s "found renegotiation extension" \
865 -s "server hello, secure renegotiation extension" \
866 -c "found renegotiation extension" \
867 -c "=> renegotiate" \
868 -s "=> renegotiate" \
869 -S "write hello request"
870
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100871# Tests for auth_mode
872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200873run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100874 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100875 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200876 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100877 1 \
878 -c "x509_verify_cert() returned" \
879 -c "! self-signed or not signed by a trusted CA" \
880 -c "! ssl_handshake returned" \
881 -c "X509 - Certificate verification failed"
882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200883run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100884 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100885 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200886 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100887 0 \
888 -c "x509_verify_cert() returned" \
889 -c "! self-signed or not signed by a trusted CA" \
890 -C "! ssl_handshake returned" \
891 -C "X509 - Certificate verification failed"
892
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200893run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100894 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100895 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200896 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100897 0 \
898 -C "x509_verify_cert() returned" \
899 -C "! self-signed or not signed by a trusted CA" \
900 -C "! ssl_handshake returned" \
901 -C "X509 - Certificate verification failed"
902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200903run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200904 "$P_SRV debug_level=3 auth_mode=required" \
905 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100906 key_file=data_files/server5.key" \
907 1 \
908 -S "skip write certificate request" \
909 -C "skip parse certificate request" \
910 -c "got a certificate request" \
911 -C "skip write certificate" \
912 -C "skip write certificate verify" \
913 -S "skip parse certificate verify" \
914 -s "x509_verify_cert() returned" \
915 -S "! self-signed or not signed by a trusted CA" \
916 -s "! ssl_handshake returned" \
917 -c "! ssl_handshake returned" \
918 -s "X509 - Certificate verification failed"
919
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200920run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200921 "$P_SRV debug_level=3 auth_mode=optional" \
922 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100923 key_file=data_files/server5.key" \
924 0 \
925 -S "skip write certificate request" \
926 -C "skip parse certificate request" \
927 -c "got a certificate request" \
928 -C "skip write certificate" \
929 -C "skip write certificate verify" \
930 -S "skip parse certificate verify" \
931 -s "x509_verify_cert() returned" \
932 -s "! self-signed or not signed by a trusted CA" \
933 -S "! ssl_handshake returned" \
934 -C "! ssl_handshake returned" \
935 -S "X509 - Certificate verification failed"
936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200937run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200938 "$P_SRV debug_level=3 auth_mode=none" \
939 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100940 key_file=data_files/server5.key" \
941 0 \
942 -s "skip write certificate request" \
943 -C "skip parse certificate request" \
944 -c "got no certificate request" \
945 -c "skip write certificate" \
946 -c "skip write certificate verify" \
947 -s "skip parse certificate verify" \
948 -S "x509_verify_cert() returned" \
949 -S "! self-signed or not signed by a trusted CA" \
950 -S "! ssl_handshake returned" \
951 -C "! ssl_handshake returned" \
952 -S "X509 - Certificate verification failed"
953
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200954run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200955 "$P_SRV debug_level=3 auth_mode=optional" \
956 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100957 0 \
958 -S "skip write certificate request" \
959 -C "skip parse certificate request" \
960 -c "got a certificate request" \
961 -C "skip write certificate$" \
962 -C "got no certificate to send" \
963 -S "SSLv3 client has no certificate" \
964 -c "skip write certificate verify" \
965 -s "skip parse certificate verify" \
966 -s "! no client certificate sent" \
967 -S "! ssl_handshake returned" \
968 -C "! ssl_handshake returned" \
969 -S "X509 - Certificate verification failed"
970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200971run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200972 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100973 "$O_CLI" \
974 0 \
975 -S "skip write certificate request" \
976 -s "skip parse certificate verify" \
977 -s "! no client certificate sent" \
978 -S "! ssl_handshake returned" \
979 -S "X509 - Certificate verification failed"
980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200981run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100982 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200983 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100984 0 \
985 -C "skip parse certificate request" \
986 -c "got a certificate request" \
987 -C "skip write certificate$" \
988 -c "skip write certificate verify" \
989 -C "! ssl_handshake returned"
990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200991run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200992 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
993 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100994 0 \
995 -S "skip write certificate request" \
996 -C "skip parse certificate request" \
997 -c "got a certificate request" \
998 -C "skip write certificate$" \
999 -c "skip write certificate verify" \
1000 -c "got no certificate to send" \
1001 -s "SSLv3 client has no certificate" \
1002 -s "skip parse certificate verify" \
1003 -s "! no client certificate sent" \
1004 -S "! ssl_handshake returned" \
1005 -C "! ssl_handshake returned" \
1006 -S "X509 - Certificate verification failed"
1007
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001008# tests for SNI
1009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001010run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001011 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001012 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001013 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001014 0 \
1015 -S "parse ServerName extension" \
1016 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1017 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001019run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001020 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001021 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001022 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 +02001023 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001024 0 \
1025 -s "parse ServerName extension" \
1026 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1027 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001029run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001030 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001031 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001032 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 +02001033 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001034 0 \
1035 -s "parse ServerName extension" \
1036 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001037 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001039run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001040 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001041 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001042 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 +02001043 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001044 1 \
1045 -s "parse ServerName extension" \
1046 -s "ssl_sni_wrapper() returned" \
1047 -s "ssl_handshake returned" \
1048 -c "ssl_handshake returned" \
1049 -c "SSL - A fatal alert message was received from our peer"
1050
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001051# Tests for non-blocking I/O: exercise a variety of handshake flows
1052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001053run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001054 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1055 "$P_CLI nbio=2 tickets=0" \
1056 0 \
1057 -S "ssl_handshake returned" \
1058 -C "ssl_handshake returned" \
1059 -c "Read from server: .* bytes read"
1060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001061run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001062 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1063 "$P_CLI nbio=2 tickets=0" \
1064 0 \
1065 -S "ssl_handshake returned" \
1066 -C "ssl_handshake returned" \
1067 -c "Read from server: .* bytes read"
1068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001069run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001070 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1071 "$P_CLI nbio=2 tickets=1" \
1072 0 \
1073 -S "ssl_handshake returned" \
1074 -C "ssl_handshake returned" \
1075 -c "Read from server: .* bytes read"
1076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001077run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001078 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1079 "$P_CLI nbio=2 tickets=1" \
1080 0 \
1081 -S "ssl_handshake returned" \
1082 -C "ssl_handshake returned" \
1083 -c "Read from server: .* bytes read"
1084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001085run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001086 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1087 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1088 0 \
1089 -S "ssl_handshake returned" \
1090 -C "ssl_handshake returned" \
1091 -c "Read from server: .* bytes read"
1092
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001093run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001094 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1095 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1096 0 \
1097 -S "ssl_handshake returned" \
1098 -C "ssl_handshake returned" \
1099 -c "Read from server: .* bytes read"
1100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001101run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001102 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1103 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1104 0 \
1105 -S "ssl_handshake returned" \
1106 -C "ssl_handshake returned" \
1107 -c "Read from server: .* bytes read"
1108
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001109# Tests for version negotiation
1110
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001111run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001112 "$P_SRV" \
1113 "$P_CLI" \
1114 0 \
1115 -S "ssl_handshake returned" \
1116 -C "ssl_handshake returned" \
1117 -s "Protocol is TLSv1.2" \
1118 -c "Protocol is TLSv1.2"
1119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001120run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001121 "$P_SRV" \
1122 "$P_CLI max_version=tls1_1" \
1123 0 \
1124 -S "ssl_handshake returned" \
1125 -C "ssl_handshake returned" \
1126 -s "Protocol is TLSv1.1" \
1127 -c "Protocol is TLSv1.1"
1128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001129run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001130 "$P_SRV max_version=tls1_1" \
1131 "$P_CLI" \
1132 0 \
1133 -S "ssl_handshake returned" \
1134 -C "ssl_handshake returned" \
1135 -s "Protocol is TLSv1.1" \
1136 -c "Protocol is TLSv1.1"
1137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001138run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001139 "$P_SRV max_version=tls1_1" \
1140 "$P_CLI max_version=tls1_1" \
1141 0 \
1142 -S "ssl_handshake returned" \
1143 -C "ssl_handshake returned" \
1144 -s "Protocol is TLSv1.1" \
1145 -c "Protocol is TLSv1.1"
1146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001147run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001148 "$P_SRV min_version=tls1_1" \
1149 "$P_CLI max_version=tls1_1" \
1150 0 \
1151 -S "ssl_handshake returned" \
1152 -C "ssl_handshake returned" \
1153 -s "Protocol is TLSv1.1" \
1154 -c "Protocol is TLSv1.1"
1155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001156run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001157 "$P_SRV max_version=tls1_1" \
1158 "$P_CLI min_version=tls1_1" \
1159 0 \
1160 -S "ssl_handshake returned" \
1161 -C "ssl_handshake returned" \
1162 -s "Protocol is TLSv1.1" \
1163 -c "Protocol is TLSv1.1"
1164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001165run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001166 "$P_SRV max_version=tls1_1" \
1167 "$P_CLI min_version=tls1_2" \
1168 1 \
1169 -s "ssl_handshake returned" \
1170 -c "ssl_handshake returned" \
1171 -c "SSL - Handshake protocol not within min/max boundaries"
1172
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001173run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001174 "$P_SRV min_version=tls1_2" \
1175 "$P_CLI max_version=tls1_1" \
1176 1 \
1177 -s "ssl_handshake returned" \
1178 -c "ssl_handshake returned" \
1179 -s "SSL - Handshake protocol not within min/max boundaries"
1180
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001181# Tests for ALPN extension
1182
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001183if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001185run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001186 "$P_SRV debug_level=3" \
1187 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001188 0 \
1189 -C "client hello, adding alpn extension" \
1190 -S "found alpn extension" \
1191 -C "got an alert message, type: \\[2:120]" \
1192 -S "server hello, adding alpn extension" \
1193 -C "found alpn extension " \
1194 -C "Application Layer Protocol is" \
1195 -S "Application Layer Protocol is"
1196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001197run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001198 "$P_SRV debug_level=3" \
1199 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001200 0 \
1201 -c "client hello, adding alpn extension" \
1202 -s "found alpn extension" \
1203 -C "got an alert message, type: \\[2:120]" \
1204 -S "server hello, adding alpn extension" \
1205 -C "found alpn extension " \
1206 -c "Application Layer Protocol is (none)" \
1207 -S "Application Layer Protocol is"
1208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001209run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001210 "$P_SRV debug_level=3 alpn=abc,1234" \
1211 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001212 0 \
1213 -C "client hello, adding alpn extension" \
1214 -S "found alpn extension" \
1215 -C "got an alert message, type: \\[2:120]" \
1216 -S "server hello, adding alpn extension" \
1217 -C "found alpn extension " \
1218 -C "Application Layer Protocol is" \
1219 -s "Application Layer Protocol is (none)"
1220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001221run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001222 "$P_SRV debug_level=3 alpn=abc,1234" \
1223 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001224 0 \
1225 -c "client hello, adding alpn extension" \
1226 -s "found alpn extension" \
1227 -C "got an alert message, type: \\[2:120]" \
1228 -s "server hello, adding alpn extension" \
1229 -c "found alpn extension" \
1230 -c "Application Layer Protocol is abc" \
1231 -s "Application Layer Protocol is abc"
1232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001233run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001234 "$P_SRV debug_level=3 alpn=abc,1234" \
1235 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001236 0 \
1237 -c "client hello, adding alpn extension" \
1238 -s "found alpn extension" \
1239 -C "got an alert message, type: \\[2:120]" \
1240 -s "server hello, adding alpn extension" \
1241 -c "found alpn extension" \
1242 -c "Application Layer Protocol is abc" \
1243 -s "Application Layer Protocol is abc"
1244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001245run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001246 "$P_SRV debug_level=3 alpn=abc,1234" \
1247 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001248 0 \
1249 -c "client hello, adding alpn extension" \
1250 -s "found alpn extension" \
1251 -C "got an alert message, type: \\[2:120]" \
1252 -s "server hello, adding alpn extension" \
1253 -c "found alpn extension" \
1254 -c "Application Layer Protocol is 1234" \
1255 -s "Application Layer Protocol is 1234"
1256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001257run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001258 "$P_SRV debug_level=3 alpn=abc,123" \
1259 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001260 1 \
1261 -c "client hello, adding alpn extension" \
1262 -s "found alpn extension" \
1263 -c "got an alert message, type: \\[2:120]" \
1264 -S "server hello, adding alpn extension" \
1265 -C "found alpn extension" \
1266 -C "Application Layer Protocol is 1234" \
1267 -S "Application Layer Protocol is 1234"
1268
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001269fi
1270
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001271# Tests for keyUsage in leaf certificates, part 1:
1272# server-side certificate/suite selection
1273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001274run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001275 "$P_SRV key_file=data_files/server2.key \
1276 crt_file=data_files/server2.ku-ds.crt" \
1277 "$P_CLI" \
1278 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001279 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001280
1281
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001282run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001283 "$P_SRV key_file=data_files/server2.key \
1284 crt_file=data_files/server2.ku-ke.crt" \
1285 "$P_CLI" \
1286 0 \
1287 -c "Ciphersuite is TLS-RSA-WITH-"
1288
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001289run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001290 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001291 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001292 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001293 1 \
1294 -C "Ciphersuite is "
1295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001296run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001297 "$P_SRV key_file=data_files/server5.key \
1298 crt_file=data_files/server5.ku-ds.crt" \
1299 "$P_CLI" \
1300 0 \
1301 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1302
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001305 "$P_SRV key_file=data_files/server5.key \
1306 crt_file=data_files/server5.ku-ka.crt" \
1307 "$P_CLI" \
1308 0 \
1309 -c "Ciphersuite is TLS-ECDH-"
1310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001311run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001312 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001313 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001314 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001315 1 \
1316 -C "Ciphersuite is "
1317
1318# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001319# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001321run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001322 "$O_SRV -key data_files/server2.key \
1323 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001324 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001325 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1326 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001327 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001328 -C "Processing of the Certificate handshake message failed" \
1329 -c "Ciphersuite is TLS-"
1330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001331run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001332 "$O_SRV -key data_files/server2.key \
1333 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001334 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001335 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1336 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001337 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001338 -C "Processing of the Certificate handshake message failed" \
1339 -c "Ciphersuite is TLS-"
1340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001341run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001342 "$O_SRV -key data_files/server2.key \
1343 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001344 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001345 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1346 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001347 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001348 -C "Processing of the Certificate handshake message failed" \
1349 -c "Ciphersuite is TLS-"
1350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001351run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001352 "$O_SRV -key data_files/server2.key \
1353 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001354 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001355 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1356 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001357 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001358 -c "Processing of the Certificate handshake message failed" \
1359 -C "Ciphersuite is TLS-"
1360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001361run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001362 "$O_SRV -key data_files/server2.key \
1363 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001365 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1366 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001367 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001368 -C "Processing of the Certificate handshake message failed" \
1369 -c "Ciphersuite is TLS-"
1370
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001371run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001372 "$O_SRV -key data_files/server2.key \
1373 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001374 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001375 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1376 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001377 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001378 -c "Processing of the Certificate handshake message failed" \
1379 -C "Ciphersuite is TLS-"
1380
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001381# Tests for keyUsage in leaf certificates, part 3:
1382# server-side checking of client cert
1383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001384run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001385 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001386 "$O_CLI -key data_files/server2.key \
1387 -cert data_files/server2.ku-ds.crt" \
1388 0 \
1389 -S "bad certificate (usage extensions)" \
1390 -S "Processing of the Certificate handshake message failed"
1391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001392run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001393 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001394 "$O_CLI -key data_files/server2.key \
1395 -cert data_files/server2.ku-ke.crt" \
1396 0 \
1397 -s "bad certificate (usage extensions)" \
1398 -S "Processing of the Certificate handshake message failed"
1399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001400run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001401 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001402 "$O_CLI -key data_files/server2.key \
1403 -cert data_files/server2.ku-ke.crt" \
1404 1 \
1405 -s "bad certificate (usage extensions)" \
1406 -s "Processing of the Certificate handshake message failed"
1407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001408run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001409 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001410 "$O_CLI -key data_files/server5.key \
1411 -cert data_files/server5.ku-ds.crt" \
1412 0 \
1413 -S "bad certificate (usage extensions)" \
1414 -S "Processing of the Certificate handshake message failed"
1415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001416run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001417 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001418 "$O_CLI -key data_files/server5.key \
1419 -cert data_files/server5.ku-ka.crt" \
1420 0 \
1421 -s "bad certificate (usage extensions)" \
1422 -S "Processing of the Certificate handshake message failed"
1423
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001424# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1425
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001426run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001427 "$P_SRV key_file=data_files/server5.key \
1428 crt_file=data_files/server5.eku-srv.crt" \
1429 "$P_CLI" \
1430 0
1431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001432run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001433 "$P_SRV key_file=data_files/server5.key \
1434 crt_file=data_files/server5.eku-srv.crt" \
1435 "$P_CLI" \
1436 0
1437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001438run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001439 "$P_SRV key_file=data_files/server5.key \
1440 crt_file=data_files/server5.eku-cs_any.crt" \
1441 "$P_CLI" \
1442 0
1443
1444# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001445run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001446 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1447 crt_file=data_files/server5.eku-cli.crt" \
1448 "$P_CLI psk=badbad" \
1449 1
1450
1451# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001453run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001454 "$O_SRV -key data_files/server5.key \
1455 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001456 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001457 0 \
1458 -C "bad certificate (usage extensions)" \
1459 -C "Processing of the Certificate handshake message failed" \
1460 -c "Ciphersuite is TLS-"
1461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001462run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001463 "$O_SRV -key data_files/server5.key \
1464 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001465 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001466 0 \
1467 -C "bad certificate (usage extensions)" \
1468 -C "Processing of the Certificate handshake message failed" \
1469 -c "Ciphersuite is TLS-"
1470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001471run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001472 "$O_SRV -key data_files/server5.key \
1473 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001474 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001475 0 \
1476 -C "bad certificate (usage extensions)" \
1477 -C "Processing of the Certificate handshake message failed" \
1478 -c "Ciphersuite is TLS-"
1479
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001480run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001481 "$O_SRV -key data_files/server5.key \
1482 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001483 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001484 1 \
1485 -c "bad certificate (usage extensions)" \
1486 -c "Processing of the Certificate handshake message failed" \
1487 -C "Ciphersuite is TLS-"
1488
1489# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1490
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001491run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001492 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001493 "$O_CLI -key data_files/server5.key \
1494 -cert data_files/server5.eku-cli.crt" \
1495 0 \
1496 -S "bad certificate (usage extensions)" \
1497 -S "Processing of the Certificate handshake message failed"
1498
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001499run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001500 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001501 "$O_CLI -key data_files/server5.key \
1502 -cert data_files/server5.eku-srv_cli.crt" \
1503 0 \
1504 -S "bad certificate (usage extensions)" \
1505 -S "Processing of the Certificate handshake message failed"
1506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001508 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001509 "$O_CLI -key data_files/server5.key \
1510 -cert data_files/server5.eku-cs_any.crt" \
1511 0 \
1512 -S "bad certificate (usage extensions)" \
1513 -S "Processing of the Certificate handshake message failed"
1514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001515run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001516 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001517 "$O_CLI -key data_files/server5.key \
1518 -cert data_files/server5.eku-cs.crt" \
1519 0 \
1520 -s "bad certificate (usage extensions)" \
1521 -S "Processing of the Certificate handshake message failed"
1522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001523run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001524 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001525 "$O_CLI -key data_files/server5.key \
1526 -cert data_files/server5.eku-cs.crt" \
1527 1 \
1528 -s "bad certificate (usage extensions)" \
1529 -s "Processing of the Certificate handshake message failed"
1530
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001531# Tests for DHM parameters loading
1532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001533run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001534 "$P_SRV" \
1535 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1536 debug_level=3" \
1537 0 \
1538 -c "value of 'DHM: P ' (2048 bits)" \
1539 -c "value of 'DHM: G ' (2048 bits)"
1540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001541run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001542 "$P_SRV dhm_file=data_files/dhparams.pem" \
1543 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1544 debug_level=3" \
1545 0 \
1546 -c "value of 'DHM: P ' (1024 bits)" \
1547 -c "value of 'DHM: G ' (2 bits)"
1548
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001549# Tests for PSK callback
1550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001551run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001552 "$P_SRV psk=abc123 psk_identity=foo" \
1553 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1554 psk_identity=foo psk=abc123" \
1555 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001556 -S "SSL - The server has no ciphersuites in common" \
1557 -S "SSL - Unknown identity received" \
1558 -S "SSL - Verification of the message MAC failed"
1559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001560run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001561 "$P_SRV" \
1562 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1563 psk_identity=foo psk=abc123" \
1564 1 \
1565 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001566 -S "SSL - Unknown identity received" \
1567 -S "SSL - Verification of the message MAC failed"
1568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001569run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001570 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1571 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1572 psk_identity=foo psk=abc123" \
1573 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001574 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001575 -s "SSL - Unknown identity received" \
1576 -S "SSL - Verification of the message MAC failed"
1577
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001578run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001579 "$P_SRV psk_list=abc,dead,def,beef" \
1580 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1581 psk_identity=abc psk=dead" \
1582 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001583 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001584 -S "SSL - Unknown identity received" \
1585 -S "SSL - Verification of the message MAC failed"
1586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001587run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001588 "$P_SRV psk_list=abc,dead,def,beef" \
1589 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1590 psk_identity=def psk=beef" \
1591 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001592 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001593 -S "SSL - Unknown identity received" \
1594 -S "SSL - Verification of the message MAC failed"
1595
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001596run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001597 "$P_SRV psk_list=abc,dead,def,beef" \
1598 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1599 psk_identity=ghi psk=beef" \
1600 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001601 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001602 -s "SSL - Unknown identity received" \
1603 -S "SSL - Verification of the message MAC failed"
1604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001605run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001606 "$P_SRV psk_list=abc,dead,def,beef" \
1607 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1608 psk_identity=abc psk=beef" \
1609 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001610 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001611 -S "SSL - Unknown identity received" \
1612 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001613
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001614# Tests for ciphersuites per version
1615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001616run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001617 "$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" \
1618 "$P_CLI force_version=ssl3" \
1619 0 \
1620 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001622run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001623 "$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" \
1624 "$P_CLI force_version=tls1" \
1625 0 \
1626 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001628run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001629 "$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" \
1630 "$P_CLI force_version=tls1_1" \
1631 0 \
1632 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001634run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001635 "$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" \
1636 "$P_CLI force_version=tls1_2" \
1637 0 \
1638 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1639
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001640# Tests for ssl_get_bytes_avail()
1641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001642run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001643 "$P_SRV" \
1644 "$P_CLI request_size=100" \
1645 0 \
1646 -s "Read from client: 100 bytes read$"
1647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001648run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001649 "$P_SRV" \
1650 "$P_CLI request_size=500" \
1651 0 \
1652 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001653
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001654# Tests for small packets
1655
1656run_test "Small packet SSLv3 BlockCipher" \
1657 "$P_SRV" \
1658 "$P_CLI request_size=1 force_version=ssl3 \
1659 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1660 0 \
1661 -s "Read from client: 1 bytes read"
1662
1663run_test "Small packet SSLv3 StreamCipher" \
1664 "$P_SRV" \
1665 "$P_CLI request_size=1 force_version=ssl3 \
1666 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1667 0 \
1668 -s "Read from client: 1 bytes read"
1669
1670run_test "Small packet TLS 1.0 BlockCipher" \
1671 "$P_SRV" \
1672 "$P_CLI request_size=1 force_version=tls1 \
1673 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1674 0 \
1675 -s "Read from client: 1 bytes read"
1676
1677run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1678 "$P_SRV" \
1679 "$P_CLI request_size=1 force_version=tls1 \
1680 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1681 trunc_hmac=1" \
1682 0 \
1683 -s "Read from client: 1 bytes read"
1684
1685run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1686 "$P_SRV" \
1687 "$P_CLI request_size=1 force_version=tls1 \
1688 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1689 trunc_hmac=1" \
1690 0 \
1691 -s "Read from client: 1 bytes read"
1692
1693run_test "Small packet TLS 1.1 BlockCipher" \
1694 "$P_SRV" \
1695 "$P_CLI request_size=1 force_version=tls1_1 \
1696 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1697 0 \
1698 -s "Read from client: 1 bytes read"
1699
1700run_test "Small packet TLS 1.1 StreamCipher" \
1701 "$P_SRV" \
1702 "$P_CLI request_size=1 force_version=tls1_1 \
1703 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1704 0 \
1705 -s "Read from client: 1 bytes read"
1706
1707run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1708 "$P_SRV" \
1709 "$P_CLI request_size=1 force_version=tls1_1 \
1710 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1711 trunc_hmac=1" \
1712 0 \
1713 -s "Read from client: 1 bytes read"
1714
1715run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1716 "$P_SRV" \
1717 "$P_CLI request_size=1 force_version=tls1_1 \
1718 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1719 trunc_hmac=1" \
1720 0 \
1721 -s "Read from client: 1 bytes read"
1722
1723run_test "Small packet TLS 1.2 BlockCipher" \
1724 "$P_SRV" \
1725 "$P_CLI request_size=1 force_version=tls1_2 \
1726 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1727 0 \
1728 -s "Read from client: 1 bytes read"
1729
1730run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1731 "$P_SRV" \
1732 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1733 0 \
1734 -s "Read from client: 1 bytes read"
1735
1736run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1737 "$P_SRV" \
1738 "$P_CLI request_size=1 force_version=tls1_2 \
1739 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1740 trunc_hmac=1" \
1741 0 \
1742 -s "Read from client: 1 bytes read"
1743
1744run_test "Small packet TLS 1.2 StreamCipher" \
1745 "$P_SRV" \
1746 "$P_CLI request_size=1 force_version=tls1_2 \
1747 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1748 0 \
1749 -s "Read from client: 1 bytes read"
1750
1751run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1752 "$P_SRV" \
1753 "$P_CLI request_size=1 force_version=tls1_2 \
1754 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1755 trunc_hmac=1" \
1756 0 \
1757 -s "Read from client: 1 bytes read"
1758
1759run_test "Small packet TLS 1.2 AEAD" \
1760 "$P_SRV" \
1761 "$P_CLI request_size=1 force_version=tls1_2 \
1762 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1763 0 \
1764 -s "Read from client: 1 bytes read"
1765
1766run_test "Small packet TLS 1.2 AEAD shorter tag" \
1767 "$P_SRV" \
1768 "$P_CLI request_size=1 force_version=tls1_2 \
1769 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1770 0 \
1771 -s "Read from client: 1 bytes read"
1772
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001773# Test for large packets
1774
1775run_test "Large packet SSLv3 BlockCipher" \
1776 "$P_SRV" \
1777 "$P_CLI request_size=16384 force_version=ssl3 \
1778 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1779 0 \
1780 -s "Read from client: 16384 bytes read"
1781
1782run_test "Large packet SSLv3 StreamCipher" \
1783 "$P_SRV" \
1784 "$P_CLI request_size=16384 force_version=ssl3 \
1785 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1786 0 \
1787 -s "Read from client: 16384 bytes read"
1788
1789run_test "Large packet TLS 1.0 BlockCipher" \
1790 "$P_SRV" \
1791 "$P_CLI request_size=16384 force_version=tls1 \
1792 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1793 0 \
1794 -s "Read from client: 16384 bytes read"
1795
1796run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1797 "$P_SRV" \
1798 "$P_CLI request_size=16384 force_version=tls1 \
1799 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1800 trunc_hmac=1" \
1801 0 \
1802 -s "Read from client: 16384 bytes read"
1803
1804run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1805 "$P_SRV" \
1806 "$P_CLI request_size=16384 force_version=tls1 \
1807 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1808 trunc_hmac=1" \
1809 0 \
1810 -s "Read from client: 16384 bytes read"
1811
1812run_test "Large packet TLS 1.1 BlockCipher" \
1813 "$P_SRV" \
1814 "$P_CLI request_size=16384 force_version=tls1_1 \
1815 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1816 0 \
1817 -s "Read from client: 16384 bytes read"
1818
1819run_test "Large packet TLS 1.1 StreamCipher" \
1820 "$P_SRV" \
1821 "$P_CLI request_size=16384 force_version=tls1_1 \
1822 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1823 0 \
1824 -s "Read from client: 16384 bytes read"
1825
1826run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1827 "$P_SRV" \
1828 "$P_CLI request_size=16384 force_version=tls1_1 \
1829 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1830 trunc_hmac=1" \
1831 0 \
1832 -s "Read from client: 16384 bytes read"
1833
1834run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1835 "$P_SRV" \
1836 "$P_CLI request_size=16384 force_version=tls1_1 \
1837 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1838 trunc_hmac=1" \
1839 0 \
1840 -s "Read from client: 16384 bytes read"
1841
1842run_test "Large packet TLS 1.2 BlockCipher" \
1843 "$P_SRV" \
1844 "$P_CLI request_size=16384 force_version=tls1_2 \
1845 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1846 0 \
1847 -s "Read from client: 16384 bytes read"
1848
1849run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1850 "$P_SRV" \
1851 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1852 0 \
1853 -s "Read from client: 16384 bytes read"
1854
1855run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1856 "$P_SRV" \
1857 "$P_CLI request_size=16384 force_version=tls1_2 \
1858 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1859 trunc_hmac=1" \
1860 0 \
1861 -s "Read from client: 16384 bytes read"
1862
1863run_test "Large packet TLS 1.2 StreamCipher" \
1864 "$P_SRV" \
1865 "$P_CLI request_size=16384 force_version=tls1_2 \
1866 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1867 0 \
1868 -s "Read from client: 16384 bytes read"
1869
1870run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1871 "$P_SRV" \
1872 "$P_CLI request_size=16384 force_version=tls1_2 \
1873 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1874 trunc_hmac=1" \
1875 0 \
1876 -s "Read from client: 16384 bytes read"
1877
1878run_test "Large packet TLS 1.2 AEAD" \
1879 "$P_SRV" \
1880 "$P_CLI request_size=16384 force_version=tls1_2 \
1881 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1882 0 \
1883 -s "Read from client: 16384 bytes read"
1884
1885run_test "Large packet TLS 1.2 AEAD shorter tag" \
1886 "$P_SRV" \
1887 "$P_CLI request_size=16384 force_version=tls1_2 \
1888 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1889 0 \
1890 -s "Read from client: 16384 bytes read"
1891
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001892# Tests for DTLS HelloVerifyRequest
1893
1894run_test "DTLS cookie: enabled" \
1895 "$P_SRV dtls=1 debug_level=2" \
1896 "$P_CLI dtls=1 debug_level=2" \
1897 0 \
1898 -s "cookie verification failed" \
1899 -s "cookie verification passed" \
1900 -S "cookie verification skipped" \
1901 -c "received hello verify request" \
1902 -S "SSL - The requested feature is not available"
1903
1904run_test "DTLS cookie: disabled" \
1905 "$P_SRV dtls=1 debug_level=2 cookies=0" \
1906 "$P_CLI dtls=1 debug_level=2" \
1907 0 \
1908 -S "cookie verification failed" \
1909 -S "cookie verification passed" \
1910 -s "cookie verification skipped" \
1911 -C "received hello verify request" \
1912 -S "SSL - The requested feature is not available"
1913
1914# wait for client having a timeout, or server sending an alert
1915#run_test "DTLS cookie: default (failing)" \
1916# "$P_SRV dtls=1 debug_level=2 cookies=-1" \
1917# "$P_CLI dtls=1 debug_level=2" \
1918# 0 \
1919# -S "cookie verification failed" \
1920# -S "cookie verification passed" \
1921# -S "cookie verification skipped" \
1922# -C "received hello verify request" \
1923# -s "SSL - The requested feature is not available"
1924
1925requires_ipv6
1926run_test "DTLS cookie: enabled, IPv6" \
1927 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
1928 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
1929 0 \
1930 -s "cookie verification failed" \
1931 -s "cookie verification passed" \
1932 -S "cookie verification skipped" \
1933 -c "received hello verify request" \
1934 -S "SSL - The requested feature is not available"
1935
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001936# Final report
1937
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001938echo "------------------------------------------------------------------------"
1939
1940if [ $FAILS = 0 ]; then
1941 echo -n "PASSED"
1942else
1943 echo -n "FAILED"
1944fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02001945PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001946echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001947
1948exit $FAILS