blob: f8c536d5e76c47a350291f28fbad0e8bee9892ae [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é-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010020
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020021O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010022O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020023G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
24G_CLI="$GNUTLS_CLI"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010025
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010026TESTS=0
27FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020028SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010029
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020030CONFIG_H='../include/polarssl/config.h'
31
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010032MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010033FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020034EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010035
36print_usage() {
37 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010038 printf " -h|--help\tPrint this help.\n"
39 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
40 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
41 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010042}
43
44get_options() {
45 while [ $# -gt 0 ]; do
46 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010047 -f|--filter)
48 shift; FILTER=$1
49 ;;
50 -e|--exclude)
51 shift; EXCLUDE=$1
52 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010053 -m|--memcheck)
54 MEMCHECK=1
55 ;;
56 -h|--help)
57 print_usage
58 exit 0
59 ;;
60 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020061 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 print_usage
63 exit 1
64 ;;
65 esac
66 shift
67 done
68}
69
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020070# skip next test if OpenSSL can't send SSLv2 ClientHello
71requires_openssl_with_sslv2() {
72 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020073 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020074 OPENSSL_HAS_SSL2="YES"
75 else
76 OPENSSL_HAS_SSL2="NO"
77 fi
78 fi
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +020079
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020080 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
81 SKIP_NEXT="YES"
82 fi
83}
84
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020085# skip next test if OpenSSL doesn't support FALLBACK_SCSV
86requires_openssl_with_fallback_scsv() {
87 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
88 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
89 then
90 OPENSSL_HAS_FBSCSV="YES"
91 else
92 OPENSSL_HAS_FBSCSV="NO"
93 fi
94 fi
95 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
96 SKIP_NEXT="YES"
97 fi
98}
99
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200100# skip next test if GnuTLS isn't available
101requires_gnutls() {
102 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
103 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
104 GNUTLS_AVAILABLE="YES"
105 else
106 GNUTLS_AVAILABLE="NO"
107 fi
108 fi
109 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
110 SKIP_NEXT="YES"
111 fi
112}
113
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200114# skip next test if IPv6 isn't available on this host
115requires_ipv6() {
116 if [ -z "${HAS_IPV6:-}" ]; then
117 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
118 SRV_PID=$!
119 sleep 1
120 kill $SRV_PID >/dev/null 2>&1
121 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
122 HAS_IPV6="NO"
123 else
124 HAS_IPV6="YES"
125 fi
126 rm -r $SRV_OUT
127 fi
128
129 if [ "$HAS_IPV6" = "NO" ]; then
130 SKIP_NEXT="YES"
131 fi
132}
133
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200134# skip the next test if valgrind is in use
135not_with_valgrind() {
136 if [ "$MEMCHECK" -gt 0 ]; then
137 SKIP_NEXT="YES"
138 fi
139}
140
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200141# multiply the client timeout delay by the given factor for the next test
142needs_more_time() {
143 CLI_DELAY_FACTOR=$1
144}
145
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100146# print_name <name>
147print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100148 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200149 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100150 for i in `seq 1 $LEN`; do printf '.'; done
151 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100152
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200153 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100154}
155
156# fail <message>
157fail() {
158 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100159 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100160
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200161 mv $SRV_OUT o-srv-${TESTS}.log
162 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200163 if [ -n "$PXY_CMD" ]; then
164 mv $PXY_OUT o-pxy-${TESTS}.log
165 fi
166 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100167
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200168 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
169 echo " ! server output:"
170 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200171 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200172 echo " ! client output:"
173 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200174 if [ -n "$PXY_CMD" ]; then
175 echo " ! ========================================================"
176 echo " ! proxy output:"
177 cat o-pxy-${TESTS}.log
178 fi
179 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200180 fi
181
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200182 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100183}
184
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100185# is_polar <cmd_line>
186is_polar() {
187 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
188}
189
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200190# openssl s_server doesn't have -www with DTLS
191check_osrv_dtls() {
192 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
193 NEEDS_INPUT=1
194 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
195 else
196 NEEDS_INPUT=0
197 fi
198}
199
200# provide input to commands that need it
201provide_input() {
202 if [ $NEEDS_INPUT -eq 0 ]; then
203 return
204 fi
205
206 while true; do
207 echo "HTTP/1.0 200 OK"
208 sleep 1
209 done
210}
211
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100212# has_mem_err <log_file_name>
213has_mem_err() {
214 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
215 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
216 then
217 return 1 # false: does not have errors
218 else
219 return 0 # true: has errors
220 fi
221}
222
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200223# wait for server to start: two versions depending on lsof availability
224wait_server_start() {
225 if which lsof >/dev/null; then
226 # make sure we don't loop forever
227 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200228 DOG_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200229
230 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200231 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnarda65d5082015-01-12 14:54:55 +0100232 until lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null;
233 do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200234 else
Manuel Pégourié-Gonnarda65d5082015-01-12 14:54:55 +0100235 until lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null;
236 do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200237 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200238
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200239 kill $DOG_PID >/dev/null 2>&1
240 wait $DOG_PID
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200241 else
242 sleep "$START_DELAY"
243 fi
244}
245
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200246# wait for client to terminate and set CLI_EXIT
247# must be called right after starting the client
248wait_client_done() {
249 CLI_PID=$!
250
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200251 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
252 CLI_DELAY_FACTOR=1
253
254 ( sleep $CLI_DELAY; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200255 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200256
257 wait $CLI_PID
258 CLI_EXIT=$?
259
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200260 kill $DOG_PID >/dev/null 2>&1
261 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200262
263 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
264}
265
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200266# check if the given command uses dtls and sets global variable DTLS
267detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200268 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200269 DTLS=1
270 else
271 DTLS=0
272 fi
273}
274
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200275# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100276# Options: -s pattern pattern that must be present in server output
277# -c pattern pattern that must be present in client output
278# -S pattern pattern that must be absent in server output
279# -C pattern pattern that must be absent in client output
280run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100281 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200282 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100283
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100284 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
285 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200286 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100287 return
288 fi
289
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100290 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100291
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200292 # should we skip?
293 if [ "X$SKIP_NEXT" = "XYES" ]; then
294 SKIP_NEXT="NO"
295 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200296 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200297 return
298 fi
299
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200300 # does this test use a proxy?
301 if [ "X$1" = "X-p" ]; then
302 PXY_CMD="$2"
303 shift 2
304 else
305 PXY_CMD=""
306 fi
307
308 # get commands and client output
309 SRV_CMD="$1"
310 CLI_CMD="$2"
311 CLI_EXPECT="$3"
312 shift 3
313
314 # fix client port
315 if [ -n "$PXY_CMD" ]; then
316 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
317 else
318 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
319 fi
320
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200321 # update DTLS variable
322 detect_dtls "$SRV_CMD"
323
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100324 # prepend valgrind to our commands if active
325 if [ "$MEMCHECK" -gt 0 ]; then
326 if is_polar "$SRV_CMD"; then
327 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
328 fi
329 if is_polar "$CLI_CMD"; then
330 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
331 fi
332 fi
333
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100334 # run the commands
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200335 if [ -n "$PXY_CMD" ]; then
336 echo "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200337 $PXY_CMD >> $PXY_OUT 2>&1 &
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200338 PXY_PID=$!
339 # assume proxy starts faster than server
340 fi
341
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200342 check_osrv_dtls
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200343 echo "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200344 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100345 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200346 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200347
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200348 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200349 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
350 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100351
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200352 # terminate the server (and the proxy)
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200353 kill $SRV_PID
354 wait $SRV_PID
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200355 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200356 kill $PXY_PID >/dev/null 2>&1
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200357 wait $PXY_PID
358 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100359
360 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200361 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100362 # expected client exit to incorrectly succeed in case of catastrophic
363 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100364 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200365 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100366 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100367 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100368 return
369 fi
370 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100371 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200372 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100373 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100374 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100375 return
376 fi
377 fi
378
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100379 # check server exit code
380 if [ $? != 0 ]; then
381 fail "server fail"
382 return
383 fi
384
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100385 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100386 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
387 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100388 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200389 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100390 return
391 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100392
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100393 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200394 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100395 while [ $# -gt 0 ]
396 do
397 case $1 in
398 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200399 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100400 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100401 return
402 fi
403 ;;
404
405 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200406 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100407 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100408 return
409 fi
410 ;;
411
412 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200413 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100414 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100415 return
416 fi
417 ;;
418
419 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200420 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100421 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100422 return
423 fi
424 ;;
425
426 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200427 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100428 exit 1
429 esac
430 shift 2
431 done
432
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100433 # check valgrind's results
434 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200435 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100436 fail "Server has memory errors"
437 return
438 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200439 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100440 fail "Client has memory errors"
441 return
442 fi
443 fi
444
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100445 # if we're here, everything is ok
446 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200447 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100448}
449
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100450cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200451 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200452 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
453 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
454 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
455 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100456 exit 1
457}
458
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100459#
460# MAIN
461#
462
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100463get_options "$@"
464
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100465# sanity checks, avoid an avalanche of errors
466if [ ! -x "$P_SRV" ]; then
467 echo "Command '$P_SRV' is not an executable file"
468 exit 1
469fi
470if [ ! -x "$P_CLI" ]; then
471 echo "Command '$P_CLI' is not an executable file"
472 exit 1
473fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200474if [ ! -x "$P_PXY" ]; then
475 echo "Command '$P_PXY' is not an executable file"
476 exit 1
477fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100478if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
479 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100480 exit 1
481fi
482
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200483# used by watchdog
484MAIN_PID="$$"
485
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200486# be more patient with valgrind
487if [ "$MEMCHECK" -gt 0 ]; then
488 START_DELAY=3
489 DOG_DELAY=30
490else
491 START_DELAY=1
492 DOG_DELAY=10
493fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200494CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200495
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200496# Pick a "unique" server port in the range 10000-19999, and a proxy port
497PORT_BASE="0000$$"
498PORT_BASE="$( echo -n $PORT_BASE | tail -c 4 )"
499SRV_PORT="1$PORT_BASE"
500PXY_PORT="2$PORT_BASE"
501unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200502
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200503# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200504P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
505P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
506P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
507O_SRV="$O_SRV -accept $SRV_PORT"
508O_CLI="$O_CLI -connect localhost:+SRV_PORT"
509G_SRV="$G_SRV -p $SRV_PORT"
510G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200511
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200512# Also pick a unique name for intermediate files
513SRV_OUT="srv_out.$$"
514CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200515PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200516SESSION="session.$$"
517
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200518SKIP_NEXT="NO"
519
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100520trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100521
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200522# Basic test
523
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200524# Checks that:
525# - things work with all ciphersuites active (used with config-full in all.sh)
526# - the expected (highest security) parameters are selected
527# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200528run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200529 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200530 "$P_CLI" \
531 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200532 -s "Protocol is TLSv1.2" \
533 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
534 -s "client hello v3, signature_algorithm ext: 6" \
535 -s "ECDHE curve: secp521r1" \
536 -S "error" \
537 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200538
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100539# Test for SSLv2 ClientHello
540
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200541requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200542run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100543 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100544 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100545 0 \
546 -S "parse client hello v2" \
547 -S "ssl_handshake returned"
548
549# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200550requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200551run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200552 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100553 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100554 0 \
555 -s "parse client hello v2" \
556 -S "ssl_handshake returned"
557
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100558# Tests for Truncated HMAC extension
559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200560run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200561 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100562 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100563 0 \
564 -s "dumping 'computed mac' (20 bytes)"
565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200566run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200567 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100568 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100569 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100570 -s "dumping 'computed mac' (10 bytes)"
571
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100572# Tests for Encrypt-then-MAC extension
573
574run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100575 "$P_SRV debug_level=3 \
576 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100577 "$P_CLI debug_level=3" \
578 0 \
579 -c "client hello, adding encrypt_then_mac extension" \
580 -s "found encrypt then mac extension" \
581 -s "server hello, adding encrypt then mac extension" \
582 -c "found encrypt_then_mac extension" \
583 -c "using encrypt then mac" \
584 -s "using encrypt then mac"
585
586run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100587 "$P_SRV debug_level=3 etm=0 \
588 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100589 "$P_CLI debug_level=3 etm=1" \
590 0 \
591 -c "client hello, adding encrypt_then_mac extension" \
592 -s "found encrypt then mac extension" \
593 -S "server hello, adding encrypt then mac extension" \
594 -C "found encrypt_then_mac extension" \
595 -C "using encrypt then mac" \
596 -S "using encrypt then mac"
597
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100598run_test "Encrypt then MAC: client enabled, aead cipher" \
599 "$P_SRV debug_level=3 etm=1 \
600 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
601 "$P_CLI debug_level=3 etm=1" \
602 0 \
603 -c "client hello, adding encrypt_then_mac extension" \
604 -s "found encrypt then mac extension" \
605 -S "server hello, adding encrypt then mac extension" \
606 -C "found encrypt_then_mac extension" \
607 -C "using encrypt then mac" \
608 -S "using encrypt then mac"
609
610run_test "Encrypt then MAC: client enabled, stream cipher" \
611 "$P_SRV debug_level=3 etm=1 \
612 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
613 "$P_CLI debug_level=3 etm=1" \
614 0 \
615 -c "client hello, adding encrypt_then_mac extension" \
616 -s "found encrypt then mac extension" \
617 -S "server hello, adding encrypt then mac extension" \
618 -C "found encrypt_then_mac extension" \
619 -C "using encrypt then mac" \
620 -S "using encrypt then mac"
621
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100622run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100623 "$P_SRV debug_level=3 etm=1 \
624 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100625 "$P_CLI debug_level=3 etm=0" \
626 0 \
627 -C "client hello, adding encrypt_then_mac extension" \
628 -S "found encrypt then mac extension" \
629 -S "server hello, adding encrypt then mac extension" \
630 -C "found encrypt_then_mac extension" \
631 -C "using encrypt then mac" \
632 -S "using encrypt then mac"
633
634run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100635 "$P_SRV debug_level=3 \
636 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100637 "$P_CLI debug_level=3 force_version=ssl3" \
638 0 \
639 -C "client hello, adding encrypt_then_mac extension" \
640 -S "found encrypt then mac extension" \
641 -S "server hello, adding encrypt then mac extension" \
642 -C "found encrypt_then_mac extension" \
643 -C "using encrypt then mac" \
644 -S "using encrypt then mac"
645
646run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100647 "$P_SRV debug_level=3 force_version=ssl3 \
648 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100649 "$P_CLI debug_level=3" \
650 0 \
651 -c "client hello, adding encrypt_then_mac extension" \
652 -s "found encrypt then mac extension" \
653 -S "server hello, adding encrypt then mac extension" \
654 -C "found encrypt_then_mac extension" \
655 -C "using encrypt then mac" \
656 -S "using encrypt then mac"
657
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200658# Tests for Extended Master Secret extension
659
660run_test "Extended Master Secret: default" \
661 "$P_SRV debug_level=3" \
662 "$P_CLI debug_level=3" \
663 0 \
664 -c "client hello, adding extended_master_secret extension" \
665 -s "found extended master secret extension" \
666 -s "server hello, adding extended master secret extension" \
667 -c "found extended_master_secret extension" \
668 -c "using extended master secret" \
669 -s "using extended master secret"
670
671run_test "Extended Master Secret: client enabled, server disabled" \
672 "$P_SRV debug_level=3 extended_ms=0" \
673 "$P_CLI debug_level=3 extended_ms=1" \
674 0 \
675 -c "client hello, adding extended_master_secret extension" \
676 -s "found extended master secret extension" \
677 -S "server hello, adding extended master secret extension" \
678 -C "found extended_master_secret extension" \
679 -C "using extended master secret" \
680 -S "using extended master secret"
681
682run_test "Extended Master Secret: client disabled, server enabled" \
683 "$P_SRV debug_level=3 extended_ms=1" \
684 "$P_CLI debug_level=3 extended_ms=0" \
685 0 \
686 -C "client hello, adding extended_master_secret extension" \
687 -S "found extended master secret extension" \
688 -S "server hello, adding extended master secret extension" \
689 -C "found extended_master_secret extension" \
690 -C "using extended master secret" \
691 -S "using extended master secret"
692
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200693run_test "Extended Master Secret: client SSLv3, server enabled" \
694 "$P_SRV debug_level=3" \
695 "$P_CLI debug_level=3 force_version=ssl3" \
696 0 \
697 -C "client hello, adding extended_master_secret extension" \
698 -S "found extended master secret extension" \
699 -S "server hello, adding extended master secret extension" \
700 -C "found extended_master_secret extension" \
701 -C "using extended master secret" \
702 -S "using extended master secret"
703
704run_test "Extended Master Secret: client enabled, server SSLv3" \
705 "$P_SRV debug_level=3 force_version=ssl3" \
706 "$P_CLI debug_level=3" \
707 0 \
708 -c "client hello, adding extended_master_secret extension" \
709 -s "found extended master secret extension" \
710 -S "server hello, adding extended master secret extension" \
711 -C "found extended_master_secret extension" \
712 -C "using extended master secret" \
713 -S "using extended master secret"
714
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200715# Tests for FALLBACK_SCSV
716
717run_test "Fallback SCSV: default" \
718 "$P_SRV" \
719 "$P_CLI debug_level=3 force_version=tls1_1" \
720 0 \
721 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200722 -S "received FALLBACK_SCSV" \
723 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200724 -C "is a fatal alert message (msg 86)"
725
726run_test "Fallback SCSV: explicitly disabled" \
727 "$P_SRV" \
728 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
729 0 \
730 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200731 -S "received FALLBACK_SCSV" \
732 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200733 -C "is a fatal alert message (msg 86)"
734
735run_test "Fallback SCSV: enabled" \
736 "$P_SRV" \
737 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200738 1 \
739 -c "adding FALLBACK_SCSV" \
740 -s "received FALLBACK_SCSV" \
741 -s "inapropriate fallback" \
742 -c "is a fatal alert message (msg 86)"
743
744run_test "Fallback SCSV: enabled, max version" \
745 "$P_SRV" \
746 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200747 0 \
748 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200749 -s "received FALLBACK_SCSV" \
750 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200751 -C "is a fatal alert message (msg 86)"
752
753requires_openssl_with_fallback_scsv
754run_test "Fallback SCSV: default, openssl server" \
755 "$O_SRV" \
756 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
757 0 \
758 -C "adding FALLBACK_SCSV" \
759 -C "is a fatal alert message (msg 86)"
760
761requires_openssl_with_fallback_scsv
762run_test "Fallback SCSV: enabled, openssl server" \
763 "$O_SRV" \
764 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
765 1 \
766 -c "adding FALLBACK_SCSV" \
767 -c "is a fatal alert message (msg 86)"
768
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200769requires_openssl_with_fallback_scsv
770run_test "Fallback SCSV: disabled, openssl client" \
771 "$P_SRV" \
772 "$O_CLI -tls1_1" \
773 0 \
774 -S "received FALLBACK_SCSV" \
775 -S "inapropriate fallback"
776
777requires_openssl_with_fallback_scsv
778run_test "Fallback SCSV: enabled, openssl client" \
779 "$P_SRV" \
780 "$O_CLI -tls1_1 -fallback_scsv" \
781 1 \
782 -s "received FALLBACK_SCSV" \
783 -s "inapropriate fallback"
784
785requires_openssl_with_fallback_scsv
786run_test "Fallback SCSV: enabled, max version, openssl client" \
787 "$P_SRV" \
788 "$O_CLI -fallback_scsv" \
789 0 \
790 -s "received FALLBACK_SCSV" \
791 -S "inapropriate fallback"
792
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100793# Tests for Session Tickets
794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200795run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200796 "$P_SRV debug_level=3 tickets=1" \
797 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100798 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100799 -c "client hello, adding session ticket extension" \
800 -s "found session ticket extension" \
801 -s "server hello, adding session ticket extension" \
802 -c "found session_ticket extension" \
803 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100804 -S "session successfully restored from cache" \
805 -s "session successfully restored from ticket" \
806 -s "a session has been resumed" \
807 -c "a session has been resumed"
808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200809run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200810 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
811 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100812 0 \
813 -c "client hello, adding session ticket extension" \
814 -s "found session ticket extension" \
815 -s "server hello, adding session ticket extension" \
816 -c "found session_ticket extension" \
817 -c "parse new session ticket" \
818 -S "session successfully restored from cache" \
819 -s "session successfully restored from ticket" \
820 -s "a session has been resumed" \
821 -c "a session has been resumed"
822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200823run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200824 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
825 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100826 0 \
827 -c "client hello, adding session ticket extension" \
828 -s "found session ticket extension" \
829 -s "server hello, adding session ticket extension" \
830 -c "found session_ticket extension" \
831 -c "parse new session ticket" \
832 -S "session successfully restored from cache" \
833 -S "session successfully restored from ticket" \
834 -S "a session has been resumed" \
835 -C "a session has been resumed"
836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200837run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100838 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200839 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100840 0 \
841 -c "client hello, adding session ticket extension" \
842 -c "found session_ticket extension" \
843 -c "parse new session ticket" \
844 -c "a session has been resumed"
845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200846run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200847 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200848 "( $O_CLI -sess_out $SESSION; \
849 $O_CLI -sess_in $SESSION; \
850 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100851 0 \
852 -s "found session ticket extension" \
853 -s "server hello, adding session ticket extension" \
854 -S "session successfully restored from cache" \
855 -s "session successfully restored from ticket" \
856 -s "a session has been resumed"
857
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100858# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200860run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200861 "$P_SRV debug_level=3 tickets=0" \
862 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100863 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100864 -c "client hello, adding session ticket extension" \
865 -s "found session ticket extension" \
866 -S "server hello, adding session ticket extension" \
867 -C "found session_ticket extension" \
868 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100869 -s "session successfully restored from cache" \
870 -S "session successfully restored from ticket" \
871 -s "a session has been resumed" \
872 -c "a session has been resumed"
873
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200874run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200875 "$P_SRV debug_level=3 tickets=1" \
876 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100877 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100878 -C "client hello, adding session ticket extension" \
879 -S "found session ticket extension" \
880 -S "server hello, adding session ticket extension" \
881 -C "found session_ticket extension" \
882 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100883 -s "session successfully restored from cache" \
884 -S "session successfully restored from ticket" \
885 -s "a session has been resumed" \
886 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200888run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200889 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
890 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100891 0 \
892 -S "session successfully restored from cache" \
893 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100894 -S "a session has been resumed" \
895 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200897run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200898 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
899 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100900 0 \
901 -s "session successfully restored from cache" \
902 -S "session successfully restored from ticket" \
903 -s "a session has been resumed" \
904 -c "a session has been resumed"
905
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200906run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200907 "$P_SRV debug_level=3 tickets=0" \
908 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100909 0 \
910 -s "session successfully restored from cache" \
911 -S "session successfully restored from ticket" \
912 -s "a session has been resumed" \
913 -c "a session has been resumed"
914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200915run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200916 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
917 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100918 0 \
919 -S "session successfully restored from cache" \
920 -S "session successfully restored from ticket" \
921 -S "a session has been resumed" \
922 -C "a session has been resumed"
923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200924run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200925 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
926 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100927 0 \
928 -s "session successfully restored from cache" \
929 -S "session successfully restored from ticket" \
930 -s "a session has been resumed" \
931 -c "a session has been resumed"
932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200933run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200934 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200935 "( $O_CLI -sess_out $SESSION; \
936 $O_CLI -sess_in $SESSION; \
937 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100938 0 \
939 -s "found session ticket extension" \
940 -S "server hello, adding session ticket extension" \
941 -s "session successfully restored from cache" \
942 -S "session successfully restored from ticket" \
943 -s "a session has been resumed"
944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200945run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100946 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200947 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100948 0 \
949 -C "found session_ticket extension" \
950 -C "parse new session ticket" \
951 -c "a session has been resumed"
952
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100953# Tests for Max Fragment Length extension
954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200955run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200956 "$P_SRV debug_level=3" \
957 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100958 0 \
959 -C "client hello, adding max_fragment_length extension" \
960 -S "found max fragment length extension" \
961 -S "server hello, max_fragment_length extension" \
962 -C "found max_fragment_length extension"
963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200964run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200965 "$P_SRV debug_level=3" \
966 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100967 0 \
968 -c "client hello, adding max_fragment_length extension" \
969 -s "found max fragment length extension" \
970 -s "server hello, max_fragment_length extension" \
971 -c "found max_fragment_length extension"
972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200973run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200974 "$P_SRV debug_level=3 max_frag_len=4096" \
975 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100976 0 \
977 -C "client hello, adding max_fragment_length extension" \
978 -S "found max fragment length extension" \
979 -S "server hello, max_fragment_length extension" \
980 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200982requires_gnutls
983run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200984 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200985 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200986 0 \
987 -c "client hello, adding max_fragment_length extension" \
988 -c "found max_fragment_length extension"
989
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +0200990run_test "Max fragment length: client, message just fits" \
991 "$P_SRV debug_level=3" \
992 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
993 0 \
994 -c "client hello, adding max_fragment_length extension" \
995 -s "found max fragment length extension" \
996 -s "server hello, max_fragment_length extension" \
997 -c "found max_fragment_length extension" \
998 -c "2048 bytes written in 1 fragments" \
999 -s "2048 bytes read"
1000
1001run_test "Max fragment length: client, larger message" \
1002 "$P_SRV debug_level=3" \
1003 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1004 0 \
1005 -c "client hello, adding max_fragment_length extension" \
1006 -s "found max fragment length extension" \
1007 -s "server hello, max_fragment_length extension" \
1008 -c "found max_fragment_length extension" \
1009 -c "2345 bytes written in 2 fragments" \
1010 -s "2048 bytes read" \
1011 -s "297 bytes read"
1012
1013run_test "Max fragment length: client, larger message" \
1014 "$P_SRV debug_level=3 dtls=1" \
1015 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1016 1 \
1017 -c "client hello, adding max_fragment_length extension" \
1018 -s "found max fragment length extension" \
1019 -s "server hello, max_fragment_length extension" \
1020 -c "found max_fragment_length extension" \
1021 -c "fragment larger than.*maximum"
1022
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001023# Tests for renegotiation
1024
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001025run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001026 "$P_SRV debug_level=3 exchanges=2" \
1027 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001028 0 \
1029 -C "client hello, adding renegotiation extension" \
1030 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1031 -S "found renegotiation extension" \
1032 -s "server hello, secure renegotiation extension" \
1033 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001034 -C "=> renegotiate" \
1035 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001036 -S "write hello request"
1037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001038run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001039 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
1040 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001041 0 \
1042 -c "client hello, adding renegotiation extension" \
1043 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1044 -s "found renegotiation extension" \
1045 -s "server hello, secure renegotiation extension" \
1046 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001047 -c "=> renegotiate" \
1048 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001049 -S "write hello request"
1050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001051run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001052 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1053 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001054 0 \
1055 -c "client hello, adding renegotiation extension" \
1056 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1057 -s "found renegotiation extension" \
1058 -s "server hello, secure renegotiation extension" \
1059 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001060 -c "=> renegotiate" \
1061 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001062 -s "write hello request"
1063
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001064run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001065 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1066 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001067 0 \
1068 -c "client hello, adding renegotiation extension" \
1069 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1070 -s "found renegotiation extension" \
1071 -s "server hello, secure renegotiation extension" \
1072 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001073 -c "=> renegotiate" \
1074 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001075 -s "write hello request"
1076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001077run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001078 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1079 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001080 1 \
1081 -c "client hello, adding renegotiation extension" \
1082 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1083 -S "found renegotiation extension" \
1084 -s "server hello, secure renegotiation extension" \
1085 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001086 -c "=> renegotiate" \
1087 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001088 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001089 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001090 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001092run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001093 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1094 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001095 0 \
1096 -C "client hello, adding renegotiation extension" \
1097 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1098 -S "found renegotiation extension" \
1099 -s "server hello, secure renegotiation extension" \
1100 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001101 -C "=> renegotiate" \
1102 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001103 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001104 -S "SSL - An unexpected message was received from our peer" \
1105 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001107run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001108 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001109 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001110 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001111 0 \
1112 -C "client hello, adding renegotiation extension" \
1113 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1114 -S "found renegotiation extension" \
1115 -s "server hello, secure renegotiation extension" \
1116 -c "found renegotiation extension" \
1117 -C "=> renegotiate" \
1118 -S "=> renegotiate" \
1119 -s "write hello request" \
1120 -S "SSL - An unexpected message was received from our peer" \
1121 -S "failed"
1122
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001123# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001124run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001125 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001126 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001127 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001128 0 \
1129 -C "client hello, adding renegotiation extension" \
1130 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1131 -S "found renegotiation extension" \
1132 -s "server hello, secure renegotiation extension" \
1133 -c "found renegotiation extension" \
1134 -C "=> renegotiate" \
1135 -S "=> renegotiate" \
1136 -s "write hello request" \
1137 -S "SSL - An unexpected message was received from our peer" \
1138 -S "failed"
1139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001140run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001141 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001142 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001143 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001144 0 \
1145 -C "client hello, adding renegotiation extension" \
1146 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1147 -S "found renegotiation extension" \
1148 -s "server hello, secure renegotiation extension" \
1149 -c "found renegotiation extension" \
1150 -C "=> renegotiate" \
1151 -S "=> renegotiate" \
1152 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001153 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001155run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001156 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001157 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001158 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001159 0 \
1160 -c "client hello, adding renegotiation extension" \
1161 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1162 -s "found renegotiation extension" \
1163 -s "server hello, secure renegotiation extension" \
1164 -c "found renegotiation extension" \
1165 -c "=> renegotiate" \
1166 -s "=> renegotiate" \
1167 -s "write hello request" \
1168 -S "SSL - An unexpected message was received from our peer" \
1169 -S "failed"
1170
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001171run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001172 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1173 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001174 0 \
1175 -c "client hello, adding renegotiation extension" \
1176 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1177 -s "found renegotiation extension" \
1178 -s "server hello, secure renegotiation extension" \
1179 -c "found renegotiation extension" \
1180 -c "=> renegotiate" \
1181 -s "=> renegotiate" \
1182 -S "write hello request"
1183
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001184run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001185 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1186 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001187 0 \
1188 -c "client hello, adding renegotiation extension" \
1189 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1190 -s "found renegotiation extension" \
1191 -s "server hello, secure renegotiation extension" \
1192 -c "found renegotiation extension" \
1193 -c "=> renegotiate" \
1194 -s "=> renegotiate" \
1195 -s "write hello request"
1196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001197run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001198 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001199 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001200 0 \
1201 -c "client hello, adding renegotiation extension" \
1202 -c "found renegotiation extension" \
1203 -c "=> renegotiate" \
1204 -C "ssl_handshake returned" \
1205 -C "error" \
1206 -c "HTTP/1.0 200 [Oo][Kk]"
1207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001208run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001209 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001210 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001211 0 \
1212 -c "client hello, adding renegotiation extension" \
1213 -c "found renegotiation extension" \
1214 -c "=> renegotiate" \
1215 -C "ssl_handshake returned" \
1216 -C "error" \
1217 -c "HTTP/1.0 200 [Oo][Kk]"
1218
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001219run_test "Renegotiation: DTLS, client-initiated" \
1220 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1221 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1222 0 \
1223 -c "client hello, adding renegotiation extension" \
1224 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1225 -s "found renegotiation extension" \
1226 -s "server hello, secure renegotiation extension" \
1227 -c "found renegotiation extension" \
1228 -c "=> renegotiate" \
1229 -s "=> renegotiate" \
1230 -S "write hello request"
1231
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001232run_test "Renegotiation: DTLS, server-initiated" \
1233 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001234 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1235 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001236 0 \
1237 -c "client hello, adding renegotiation extension" \
1238 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1239 -s "found renegotiation extension" \
1240 -s "server hello, secure renegotiation extension" \
1241 -c "found renegotiation extension" \
1242 -c "=> renegotiate" \
1243 -s "=> renegotiate" \
1244 -s "write hello request"
1245
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001246run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1247 "$G_SRV -u --mtu 4096" \
1248 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1249 0 \
1250 -c "client hello, adding renegotiation extension" \
1251 -c "found renegotiation extension" \
1252 -c "=> renegotiate" \
1253 -C "ssl_handshake returned" \
1254 -C "error" \
1255 -s "Extra-header:"
1256
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001257# Tests for auth_mode
1258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001259run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001260 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001261 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001262 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001263 1 \
1264 -c "x509_verify_cert() returned" \
1265 -c "! self-signed or not signed by a trusted CA" \
1266 -c "! ssl_handshake returned" \
1267 -c "X509 - Certificate verification failed"
1268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001269run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001270 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001271 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001272 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001273 0 \
1274 -c "x509_verify_cert() returned" \
1275 -c "! self-signed or not signed by a trusted CA" \
1276 -C "! ssl_handshake returned" \
1277 -C "X509 - Certificate verification failed"
1278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001279run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001280 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001281 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001282 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001283 0 \
1284 -C "x509_verify_cert() returned" \
1285 -C "! self-signed or not signed by a trusted CA" \
1286 -C "! ssl_handshake returned" \
1287 -C "X509 - Certificate verification failed"
1288
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001289run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001290 "$P_SRV debug_level=3 auth_mode=required" \
1291 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001292 key_file=data_files/server5.key" \
1293 1 \
1294 -S "skip write certificate request" \
1295 -C "skip parse certificate request" \
1296 -c "got a certificate request" \
1297 -C "skip write certificate" \
1298 -C "skip write certificate verify" \
1299 -S "skip parse certificate verify" \
1300 -s "x509_verify_cert() returned" \
1301 -S "! self-signed or not signed by a trusted CA" \
1302 -s "! ssl_handshake returned" \
1303 -c "! ssl_handshake returned" \
1304 -s "X509 - Certificate verification failed"
1305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001306run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001307 "$P_SRV debug_level=3 auth_mode=optional" \
1308 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001309 key_file=data_files/server5.key" \
1310 0 \
1311 -S "skip write certificate request" \
1312 -C "skip parse certificate request" \
1313 -c "got a certificate request" \
1314 -C "skip write certificate" \
1315 -C "skip write certificate verify" \
1316 -S "skip parse certificate verify" \
1317 -s "x509_verify_cert() returned" \
1318 -s "! self-signed or not signed by a trusted CA" \
1319 -S "! ssl_handshake returned" \
1320 -C "! ssl_handshake returned" \
1321 -S "X509 - Certificate verification failed"
1322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001323run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001324 "$P_SRV debug_level=3 auth_mode=none" \
1325 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001326 key_file=data_files/server5.key" \
1327 0 \
1328 -s "skip write certificate request" \
1329 -C "skip parse certificate request" \
1330 -c "got no certificate request" \
1331 -c "skip write certificate" \
1332 -c "skip write certificate verify" \
1333 -s "skip parse certificate verify" \
1334 -S "x509_verify_cert() returned" \
1335 -S "! self-signed or not signed by a trusted CA" \
1336 -S "! ssl_handshake returned" \
1337 -C "! ssl_handshake returned" \
1338 -S "X509 - Certificate verification failed"
1339
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001340run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001341 "$P_SRV debug_level=3 auth_mode=optional" \
1342 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001343 0 \
1344 -S "skip write certificate request" \
1345 -C "skip parse certificate request" \
1346 -c "got a certificate request" \
1347 -C "skip write certificate$" \
1348 -C "got no certificate to send" \
1349 -S "SSLv3 client has no certificate" \
1350 -c "skip write certificate verify" \
1351 -s "skip parse certificate verify" \
1352 -s "! no client certificate sent" \
1353 -S "! ssl_handshake returned" \
1354 -C "! ssl_handshake returned" \
1355 -S "X509 - Certificate verification failed"
1356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001357run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001358 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001359 "$O_CLI" \
1360 0 \
1361 -S "skip write certificate request" \
1362 -s "skip parse certificate verify" \
1363 -s "! no client certificate sent" \
1364 -S "! ssl_handshake returned" \
1365 -S "X509 - Certificate verification failed"
1366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001367run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001368 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001369 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001370 0 \
1371 -C "skip parse certificate request" \
1372 -c "got a certificate request" \
1373 -C "skip write certificate$" \
1374 -c "skip write certificate verify" \
1375 -C "! ssl_handshake returned"
1376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001377run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001378 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1379 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001380 0 \
1381 -S "skip write certificate request" \
1382 -C "skip parse certificate request" \
1383 -c "got a certificate request" \
1384 -C "skip write certificate$" \
1385 -c "skip write certificate verify" \
1386 -c "got no certificate to send" \
1387 -s "SSLv3 client has no certificate" \
1388 -s "skip parse certificate verify" \
1389 -s "! no client certificate sent" \
1390 -S "! ssl_handshake returned" \
1391 -C "! ssl_handshake returned" \
1392 -S "X509 - Certificate verification failed"
1393
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001394# tests for SNI
1395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001396run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001397 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001398 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001399 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001400 0 \
1401 -S "parse ServerName extension" \
1402 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1403 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001405run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001406 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001407 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001408 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 +02001409 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001410 0 \
1411 -s "parse ServerName extension" \
1412 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1413 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1414
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001415run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001416 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001417 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001418 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 +02001419 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001420 0 \
1421 -s "parse ServerName extension" \
1422 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001423 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001425run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001426 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001427 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001428 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 +02001429 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001430 1 \
1431 -s "parse ServerName extension" \
1432 -s "ssl_sni_wrapper() returned" \
1433 -s "ssl_handshake returned" \
1434 -c "ssl_handshake returned" \
1435 -c "SSL - A fatal alert message was received from our peer"
1436
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001437# Tests for non-blocking I/O: exercise a variety of handshake flows
1438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001439run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001440 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1441 "$P_CLI nbio=2 tickets=0" \
1442 0 \
1443 -S "ssl_handshake returned" \
1444 -C "ssl_handshake returned" \
1445 -c "Read from server: .* bytes read"
1446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001447run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001448 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1449 "$P_CLI nbio=2 tickets=0" \
1450 0 \
1451 -S "ssl_handshake returned" \
1452 -C "ssl_handshake returned" \
1453 -c "Read from server: .* bytes read"
1454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001455run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001456 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1457 "$P_CLI nbio=2 tickets=1" \
1458 0 \
1459 -S "ssl_handshake returned" \
1460 -C "ssl_handshake returned" \
1461 -c "Read from server: .* bytes read"
1462
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001463run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001464 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1465 "$P_CLI nbio=2 tickets=1" \
1466 0 \
1467 -S "ssl_handshake returned" \
1468 -C "ssl_handshake returned" \
1469 -c "Read from server: .* bytes read"
1470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001471run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001472 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1473 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1474 0 \
1475 -S "ssl_handshake returned" \
1476 -C "ssl_handshake returned" \
1477 -c "Read from server: .* bytes read"
1478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001479run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001480 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1481 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1482 0 \
1483 -S "ssl_handshake returned" \
1484 -C "ssl_handshake returned" \
1485 -c "Read from server: .* bytes read"
1486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001487run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001488 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1489 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1490 0 \
1491 -S "ssl_handshake returned" \
1492 -C "ssl_handshake returned" \
1493 -c "Read from server: .* bytes read"
1494
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001495# Tests for version negotiation
1496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001497run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001498 "$P_SRV" \
1499 "$P_CLI" \
1500 0 \
1501 -S "ssl_handshake returned" \
1502 -C "ssl_handshake returned" \
1503 -s "Protocol is TLSv1.2" \
1504 -c "Protocol is TLSv1.2"
1505
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001506run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001507 "$P_SRV" \
1508 "$P_CLI max_version=tls1_1" \
1509 0 \
1510 -S "ssl_handshake returned" \
1511 -C "ssl_handshake returned" \
1512 -s "Protocol is TLSv1.1" \
1513 -c "Protocol is TLSv1.1"
1514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001515run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001516 "$P_SRV max_version=tls1_1" \
1517 "$P_CLI" \
1518 0 \
1519 -S "ssl_handshake returned" \
1520 -C "ssl_handshake returned" \
1521 -s "Protocol is TLSv1.1" \
1522 -c "Protocol is TLSv1.1"
1523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001524run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001525 "$P_SRV max_version=tls1_1" \
1526 "$P_CLI max_version=tls1_1" \
1527 0 \
1528 -S "ssl_handshake returned" \
1529 -C "ssl_handshake returned" \
1530 -s "Protocol is TLSv1.1" \
1531 -c "Protocol is TLSv1.1"
1532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001533run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001534 "$P_SRV min_version=tls1_1" \
1535 "$P_CLI max_version=tls1_1" \
1536 0 \
1537 -S "ssl_handshake returned" \
1538 -C "ssl_handshake returned" \
1539 -s "Protocol is TLSv1.1" \
1540 -c "Protocol is TLSv1.1"
1541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001542run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001543 "$P_SRV max_version=tls1_1" \
1544 "$P_CLI min_version=tls1_1" \
1545 0 \
1546 -S "ssl_handshake returned" \
1547 -C "ssl_handshake returned" \
1548 -s "Protocol is TLSv1.1" \
1549 -c "Protocol is TLSv1.1"
1550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001551run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001552 "$P_SRV max_version=tls1_1" \
1553 "$P_CLI min_version=tls1_2" \
1554 1 \
1555 -s "ssl_handshake returned" \
1556 -c "ssl_handshake returned" \
1557 -c "SSL - Handshake protocol not within min/max boundaries"
1558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001559run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001560 "$P_SRV min_version=tls1_2" \
1561 "$P_CLI max_version=tls1_1" \
1562 1 \
1563 -s "ssl_handshake returned" \
1564 -c "ssl_handshake returned" \
1565 -s "SSL - Handshake protocol not within min/max boundaries"
1566
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001567# Tests for ALPN extension
1568
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001569if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1570
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001571run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001572 "$P_SRV debug_level=3" \
1573 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001574 0 \
1575 -C "client hello, adding alpn extension" \
1576 -S "found alpn extension" \
1577 -C "got an alert message, type: \\[2:120]" \
1578 -S "server hello, adding alpn extension" \
1579 -C "found alpn extension " \
1580 -C "Application Layer Protocol is" \
1581 -S "Application Layer Protocol is"
1582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001583run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001584 "$P_SRV debug_level=3" \
1585 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001586 0 \
1587 -c "client hello, adding alpn extension" \
1588 -s "found alpn extension" \
1589 -C "got an alert message, type: \\[2:120]" \
1590 -S "server hello, adding alpn extension" \
1591 -C "found alpn extension " \
1592 -c "Application Layer Protocol is (none)" \
1593 -S "Application Layer Protocol is"
1594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001595run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001596 "$P_SRV debug_level=3 alpn=abc,1234" \
1597 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001598 0 \
1599 -C "client hello, adding alpn extension" \
1600 -S "found alpn extension" \
1601 -C "got an alert message, type: \\[2:120]" \
1602 -S "server hello, adding alpn extension" \
1603 -C "found alpn extension " \
1604 -C "Application Layer Protocol is" \
1605 -s "Application Layer Protocol is (none)"
1606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001607run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001608 "$P_SRV debug_level=3 alpn=abc,1234" \
1609 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001610 0 \
1611 -c "client hello, adding alpn extension" \
1612 -s "found alpn extension" \
1613 -C "got an alert message, type: \\[2:120]" \
1614 -s "server hello, adding alpn extension" \
1615 -c "found alpn extension" \
1616 -c "Application Layer Protocol is abc" \
1617 -s "Application Layer Protocol is abc"
1618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001619run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001620 "$P_SRV debug_level=3 alpn=abc,1234" \
1621 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001622 0 \
1623 -c "client hello, adding alpn extension" \
1624 -s "found alpn extension" \
1625 -C "got an alert message, type: \\[2:120]" \
1626 -s "server hello, adding alpn extension" \
1627 -c "found alpn extension" \
1628 -c "Application Layer Protocol is abc" \
1629 -s "Application Layer Protocol is abc"
1630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001631run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001632 "$P_SRV debug_level=3 alpn=abc,1234" \
1633 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001634 0 \
1635 -c "client hello, adding alpn extension" \
1636 -s "found alpn extension" \
1637 -C "got an alert message, type: \\[2:120]" \
1638 -s "server hello, adding alpn extension" \
1639 -c "found alpn extension" \
1640 -c "Application Layer Protocol is 1234" \
1641 -s "Application Layer Protocol is 1234"
1642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001643run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001644 "$P_SRV debug_level=3 alpn=abc,123" \
1645 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001646 1 \
1647 -c "client hello, adding alpn extension" \
1648 -s "found alpn extension" \
1649 -c "got an alert message, type: \\[2:120]" \
1650 -S "server hello, adding alpn extension" \
1651 -C "found alpn extension" \
1652 -C "Application Layer Protocol is 1234" \
1653 -S "Application Layer Protocol is 1234"
1654
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001655fi
1656
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001657# Tests for keyUsage in leaf certificates, part 1:
1658# server-side certificate/suite selection
1659
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001660run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001661 "$P_SRV key_file=data_files/server2.key \
1662 crt_file=data_files/server2.ku-ds.crt" \
1663 "$P_CLI" \
1664 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001665 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001666
1667
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001668run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001669 "$P_SRV key_file=data_files/server2.key \
1670 crt_file=data_files/server2.ku-ke.crt" \
1671 "$P_CLI" \
1672 0 \
1673 -c "Ciphersuite is TLS-RSA-WITH-"
1674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001675run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001676 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001677 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001678 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001679 1 \
1680 -C "Ciphersuite is "
1681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001682run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001683 "$P_SRV key_file=data_files/server5.key \
1684 crt_file=data_files/server5.ku-ds.crt" \
1685 "$P_CLI" \
1686 0 \
1687 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1688
1689
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001690run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001691 "$P_SRV key_file=data_files/server5.key \
1692 crt_file=data_files/server5.ku-ka.crt" \
1693 "$P_CLI" \
1694 0 \
1695 -c "Ciphersuite is TLS-ECDH-"
1696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001697run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001698 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001699 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001700 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001701 1 \
1702 -C "Ciphersuite is "
1703
1704# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001705# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001707run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001708 "$O_SRV -key data_files/server2.key \
1709 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001710 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001711 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1712 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001713 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001714 -C "Processing of the Certificate handshake message failed" \
1715 -c "Ciphersuite is TLS-"
1716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001717run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001718 "$O_SRV -key data_files/server2.key \
1719 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001720 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001721 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1722 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001723 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001724 -C "Processing of the Certificate handshake message failed" \
1725 -c "Ciphersuite is TLS-"
1726
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001727run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001728 "$O_SRV -key data_files/server2.key \
1729 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001730 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001731 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1732 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001733 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001734 -C "Processing of the Certificate handshake message failed" \
1735 -c "Ciphersuite is TLS-"
1736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001737run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001738 "$O_SRV -key data_files/server2.key \
1739 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001740 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001741 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1742 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001743 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001744 -c "Processing of the Certificate handshake message failed" \
1745 -C "Ciphersuite is TLS-"
1746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001747run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001748 "$O_SRV -key data_files/server2.key \
1749 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001750 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001751 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1752 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001753 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001754 -C "Processing of the Certificate handshake message failed" \
1755 -c "Ciphersuite is TLS-"
1756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001757run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001758 "$O_SRV -key data_files/server2.key \
1759 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001760 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001761 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1762 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001763 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001764 -c "Processing of the Certificate handshake message failed" \
1765 -C "Ciphersuite is TLS-"
1766
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001767# Tests for keyUsage in leaf certificates, part 3:
1768# server-side checking of client cert
1769
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001770run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001771 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001772 "$O_CLI -key data_files/server2.key \
1773 -cert data_files/server2.ku-ds.crt" \
1774 0 \
1775 -S "bad certificate (usage extensions)" \
1776 -S "Processing of the Certificate handshake message failed"
1777
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001778run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001779 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001780 "$O_CLI -key data_files/server2.key \
1781 -cert data_files/server2.ku-ke.crt" \
1782 0 \
1783 -s "bad certificate (usage extensions)" \
1784 -S "Processing of the Certificate handshake message failed"
1785
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001786run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001787 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001788 "$O_CLI -key data_files/server2.key \
1789 -cert data_files/server2.ku-ke.crt" \
1790 1 \
1791 -s "bad certificate (usage extensions)" \
1792 -s "Processing of the Certificate handshake message failed"
1793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001794run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001795 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001796 "$O_CLI -key data_files/server5.key \
1797 -cert data_files/server5.ku-ds.crt" \
1798 0 \
1799 -S "bad certificate (usage extensions)" \
1800 -S "Processing of the Certificate handshake message failed"
1801
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001802run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001803 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001804 "$O_CLI -key data_files/server5.key \
1805 -cert data_files/server5.ku-ka.crt" \
1806 0 \
1807 -s "bad certificate (usage extensions)" \
1808 -S "Processing of the Certificate handshake message failed"
1809
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001810# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001812run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001813 "$P_SRV key_file=data_files/server5.key \
1814 crt_file=data_files/server5.eku-srv.crt" \
1815 "$P_CLI" \
1816 0
1817
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001818run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001819 "$P_SRV key_file=data_files/server5.key \
1820 crt_file=data_files/server5.eku-srv.crt" \
1821 "$P_CLI" \
1822 0
1823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001824run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001825 "$P_SRV key_file=data_files/server5.key \
1826 crt_file=data_files/server5.eku-cs_any.crt" \
1827 "$P_CLI" \
1828 0
1829
1830# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001831run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001832 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1833 crt_file=data_files/server5.eku-cli.crt" \
1834 "$P_CLI psk=badbad" \
1835 1
1836
1837# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001839run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001840 "$O_SRV -key data_files/server5.key \
1841 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001842 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001843 0 \
1844 -C "bad certificate (usage extensions)" \
1845 -C "Processing of the Certificate handshake message failed" \
1846 -c "Ciphersuite is TLS-"
1847
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001848run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001849 "$O_SRV -key data_files/server5.key \
1850 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001851 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001852 0 \
1853 -C "bad certificate (usage extensions)" \
1854 -C "Processing of the Certificate handshake message failed" \
1855 -c "Ciphersuite is TLS-"
1856
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001857run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001858 "$O_SRV -key data_files/server5.key \
1859 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001860 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001861 0 \
1862 -C "bad certificate (usage extensions)" \
1863 -C "Processing of the Certificate handshake message failed" \
1864 -c "Ciphersuite is TLS-"
1865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001866run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001867 "$O_SRV -key data_files/server5.key \
1868 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001869 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001870 1 \
1871 -c "bad certificate (usage extensions)" \
1872 -c "Processing of the Certificate handshake message failed" \
1873 -C "Ciphersuite is TLS-"
1874
1875# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001877run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001878 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001879 "$O_CLI -key data_files/server5.key \
1880 -cert data_files/server5.eku-cli.crt" \
1881 0 \
1882 -S "bad certificate (usage extensions)" \
1883 -S "Processing of the Certificate handshake message failed"
1884
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001885run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001886 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001887 "$O_CLI -key data_files/server5.key \
1888 -cert data_files/server5.eku-srv_cli.crt" \
1889 0 \
1890 -S "bad certificate (usage extensions)" \
1891 -S "Processing of the Certificate handshake message failed"
1892
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001893run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001894 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001895 "$O_CLI -key data_files/server5.key \
1896 -cert data_files/server5.eku-cs_any.crt" \
1897 0 \
1898 -S "bad certificate (usage extensions)" \
1899 -S "Processing of the Certificate handshake message failed"
1900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001901run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001902 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001903 "$O_CLI -key data_files/server5.key \
1904 -cert data_files/server5.eku-cs.crt" \
1905 0 \
1906 -s "bad certificate (usage extensions)" \
1907 -S "Processing of the Certificate handshake message failed"
1908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001909run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001910 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001911 "$O_CLI -key data_files/server5.key \
1912 -cert data_files/server5.eku-cs.crt" \
1913 1 \
1914 -s "bad certificate (usage extensions)" \
1915 -s "Processing of the Certificate handshake message failed"
1916
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001917# Tests for DHM parameters loading
1918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001919run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001920 "$P_SRV" \
1921 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1922 debug_level=3" \
1923 0 \
1924 -c "value of 'DHM: P ' (2048 bits)" \
1925 -c "value of 'DHM: G ' (2048 bits)"
1926
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001927run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001928 "$P_SRV dhm_file=data_files/dhparams.pem" \
1929 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1930 debug_level=3" \
1931 0 \
1932 -c "value of 'DHM: P ' (1024 bits)" \
1933 -c "value of 'DHM: G ' (2 bits)"
1934
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001935# Tests for PSK callback
1936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001937run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001938 "$P_SRV psk=abc123 psk_identity=foo" \
1939 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1940 psk_identity=foo psk=abc123" \
1941 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001942 -S "SSL - The server has no ciphersuites in common" \
1943 -S "SSL - Unknown identity received" \
1944 -S "SSL - Verification of the message MAC failed"
1945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001946run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001947 "$P_SRV" \
1948 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1949 psk_identity=foo psk=abc123" \
1950 1 \
1951 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001952 -S "SSL - Unknown identity received" \
1953 -S "SSL - Verification of the message MAC failed"
1954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001955run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001956 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1957 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1958 psk_identity=foo psk=abc123" \
1959 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001960 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001961 -s "SSL - Unknown identity received" \
1962 -S "SSL - Verification of the message MAC failed"
1963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001964run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001965 "$P_SRV psk_list=abc,dead,def,beef" \
1966 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1967 psk_identity=abc psk=dead" \
1968 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001969 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001970 -S "SSL - Unknown identity received" \
1971 -S "SSL - Verification of the message MAC failed"
1972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001973run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001974 "$P_SRV psk_list=abc,dead,def,beef" \
1975 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1976 psk_identity=def psk=beef" \
1977 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001978 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001979 -S "SSL - Unknown identity received" \
1980 -S "SSL - Verification of the message MAC failed"
1981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001982run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001983 "$P_SRV psk_list=abc,dead,def,beef" \
1984 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1985 psk_identity=ghi psk=beef" \
1986 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001987 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001988 -s "SSL - Unknown identity received" \
1989 -S "SSL - Verification of the message MAC failed"
1990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001991run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001992 "$P_SRV psk_list=abc,dead,def,beef" \
1993 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1994 psk_identity=abc psk=beef" \
1995 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001996 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001997 -S "SSL - Unknown identity received" \
1998 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001999
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002000# Tests for ciphersuites per version
2001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002002run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002003 "$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" \
2004 "$P_CLI force_version=ssl3" \
2005 0 \
2006 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002008run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002009 "$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" \
2010 "$P_CLI force_version=tls1" \
2011 0 \
2012 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002014run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002015 "$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" \
2016 "$P_CLI force_version=tls1_1" \
2017 0 \
2018 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002020run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002021 "$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" \
2022 "$P_CLI force_version=tls1_2" \
2023 0 \
2024 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2025
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002026# Tests for ssl_get_bytes_avail()
2027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002028run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002029 "$P_SRV" \
2030 "$P_CLI request_size=100" \
2031 0 \
2032 -s "Read from client: 100 bytes read$"
2033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002034run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002035 "$P_SRV" \
2036 "$P_CLI request_size=500" \
2037 0 \
2038 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002039
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002040# Tests for small packets
2041
2042run_test "Small packet SSLv3 BlockCipher" \
2043 "$P_SRV" \
2044 "$P_CLI request_size=1 force_version=ssl3 \
2045 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2046 0 \
2047 -s "Read from client: 1 bytes read"
2048
2049run_test "Small packet SSLv3 StreamCipher" \
2050 "$P_SRV" \
2051 "$P_CLI request_size=1 force_version=ssl3 \
2052 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2053 0 \
2054 -s "Read from client: 1 bytes read"
2055
2056run_test "Small packet TLS 1.0 BlockCipher" \
2057 "$P_SRV" \
2058 "$P_CLI request_size=1 force_version=tls1 \
2059 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2060 0 \
2061 -s "Read from client: 1 bytes read"
2062
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002063run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2064 "$P_SRV" \
2065 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2066 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2067 0 \
2068 -s "Read from client: 1 bytes read"
2069
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002070run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2071 "$P_SRV" \
2072 "$P_CLI request_size=1 force_version=tls1 \
2073 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2074 trunc_hmac=1" \
2075 0 \
2076 -s "Read from client: 1 bytes read"
2077
2078run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
2079 "$P_SRV" \
2080 "$P_CLI request_size=1 force_version=tls1 \
2081 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2082 trunc_hmac=1" \
2083 0 \
2084 -s "Read from client: 1 bytes read"
2085
2086run_test "Small packet TLS 1.1 BlockCipher" \
2087 "$P_SRV" \
2088 "$P_CLI request_size=1 force_version=tls1_1 \
2089 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2090 0 \
2091 -s "Read from client: 1 bytes read"
2092
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002093run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2094 "$P_SRV" \
2095 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2096 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2097 0 \
2098 -s "Read from client: 1 bytes read"
2099
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002100run_test "Small packet TLS 1.1 StreamCipher" \
2101 "$P_SRV" \
2102 "$P_CLI request_size=1 force_version=tls1_1 \
2103 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2104 0 \
2105 -s "Read from client: 1 bytes read"
2106
2107run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2108 "$P_SRV" \
2109 "$P_CLI request_size=1 force_version=tls1_1 \
2110 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2111 trunc_hmac=1" \
2112 0 \
2113 -s "Read from client: 1 bytes read"
2114
2115run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
2116 "$P_SRV" \
2117 "$P_CLI request_size=1 force_version=tls1_1 \
2118 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2119 trunc_hmac=1" \
2120 0 \
2121 -s "Read from client: 1 bytes read"
2122
2123run_test "Small packet TLS 1.2 BlockCipher" \
2124 "$P_SRV" \
2125 "$P_CLI request_size=1 force_version=tls1_2 \
2126 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2127 0 \
2128 -s "Read from client: 1 bytes read"
2129
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002130run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2131 "$P_SRV" \
2132 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2133 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2134 0 \
2135 -s "Read from client: 1 bytes read"
2136
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002137run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2138 "$P_SRV" \
2139 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
2140 0 \
2141 -s "Read from client: 1 bytes read"
2142
2143run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2144 "$P_SRV" \
2145 "$P_CLI request_size=1 force_version=tls1_2 \
2146 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2147 trunc_hmac=1" \
2148 0 \
2149 -s "Read from client: 1 bytes read"
2150
2151run_test "Small packet TLS 1.2 StreamCipher" \
2152 "$P_SRV" \
2153 "$P_CLI request_size=1 force_version=tls1_2 \
2154 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2155 0 \
2156 -s "Read from client: 1 bytes read"
2157
2158run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
2159 "$P_SRV" \
2160 "$P_CLI request_size=1 force_version=tls1_2 \
2161 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2162 trunc_hmac=1" \
2163 0 \
2164 -s "Read from client: 1 bytes read"
2165
2166run_test "Small packet TLS 1.2 AEAD" \
2167 "$P_SRV" \
2168 "$P_CLI request_size=1 force_version=tls1_2 \
2169 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2170 0 \
2171 -s "Read from client: 1 bytes read"
2172
2173run_test "Small packet TLS 1.2 AEAD shorter tag" \
2174 "$P_SRV" \
2175 "$P_CLI request_size=1 force_version=tls1_2 \
2176 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2177 0 \
2178 -s "Read from client: 1 bytes read"
2179
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002180# Test for large packets
2181
2182run_test "Large packet SSLv3 BlockCipher" \
2183 "$P_SRV" \
2184 "$P_CLI request_size=16384 force_version=ssl3 \
2185 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2186 0 \
2187 -s "Read from client: 16384 bytes read"
2188
2189run_test "Large packet SSLv3 StreamCipher" \
2190 "$P_SRV" \
2191 "$P_CLI request_size=16384 force_version=ssl3 \
2192 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2193 0 \
2194 -s "Read from client: 16384 bytes read"
2195
2196run_test "Large packet TLS 1.0 BlockCipher" \
2197 "$P_SRV" \
2198 "$P_CLI request_size=16384 force_version=tls1 \
2199 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2200 0 \
2201 -s "Read from client: 16384 bytes read"
2202
2203run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2204 "$P_SRV" \
2205 "$P_CLI request_size=16384 force_version=tls1 \
2206 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2207 trunc_hmac=1" \
2208 0 \
2209 -s "Read from client: 16384 bytes read"
2210
2211run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
2212 "$P_SRV" \
2213 "$P_CLI request_size=16384 force_version=tls1 \
2214 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2215 trunc_hmac=1" \
2216 0 \
2217 -s "Read from client: 16384 bytes read"
2218
2219run_test "Large packet TLS 1.1 BlockCipher" \
2220 "$P_SRV" \
2221 "$P_CLI request_size=16384 force_version=tls1_1 \
2222 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2223 0 \
2224 -s "Read from client: 16384 bytes read"
2225
2226run_test "Large packet TLS 1.1 StreamCipher" \
2227 "$P_SRV" \
2228 "$P_CLI request_size=16384 force_version=tls1_1 \
2229 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2230 0 \
2231 -s "Read from client: 16384 bytes read"
2232
2233run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2234 "$P_SRV" \
2235 "$P_CLI request_size=16384 force_version=tls1_1 \
2236 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2237 trunc_hmac=1" \
2238 0 \
2239 -s "Read from client: 16384 bytes read"
2240
2241run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
2242 "$P_SRV" \
2243 "$P_CLI request_size=16384 force_version=tls1_1 \
2244 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2245 trunc_hmac=1" \
2246 0 \
2247 -s "Read from client: 16384 bytes read"
2248
2249run_test "Large packet TLS 1.2 BlockCipher" \
2250 "$P_SRV" \
2251 "$P_CLI request_size=16384 force_version=tls1_2 \
2252 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2253 0 \
2254 -s "Read from client: 16384 bytes read"
2255
2256run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2257 "$P_SRV" \
2258 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
2259 0 \
2260 -s "Read from client: 16384 bytes read"
2261
2262run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2263 "$P_SRV" \
2264 "$P_CLI request_size=16384 force_version=tls1_2 \
2265 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2266 trunc_hmac=1" \
2267 0 \
2268 -s "Read from client: 16384 bytes read"
2269
2270run_test "Large packet TLS 1.2 StreamCipher" \
2271 "$P_SRV" \
2272 "$P_CLI request_size=16384 force_version=tls1_2 \
2273 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2274 0 \
2275 -s "Read from client: 16384 bytes read"
2276
2277run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
2278 "$P_SRV" \
2279 "$P_CLI request_size=16384 force_version=tls1_2 \
2280 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2281 trunc_hmac=1" \
2282 0 \
2283 -s "Read from client: 16384 bytes read"
2284
2285run_test "Large packet TLS 1.2 AEAD" \
2286 "$P_SRV" \
2287 "$P_CLI request_size=16384 force_version=tls1_2 \
2288 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2289 0 \
2290 -s "Read from client: 16384 bytes read"
2291
2292run_test "Large packet TLS 1.2 AEAD shorter tag" \
2293 "$P_SRV" \
2294 "$P_CLI request_size=16384 force_version=tls1_2 \
2295 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2296 0 \
2297 -s "Read from client: 16384 bytes read"
2298
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002299# Tests for DTLS HelloVerifyRequest
2300
2301run_test "DTLS cookie: enabled" \
2302 "$P_SRV dtls=1 debug_level=2" \
2303 "$P_CLI dtls=1 debug_level=2" \
2304 0 \
2305 -s "cookie verification failed" \
2306 -s "cookie verification passed" \
2307 -S "cookie verification skipped" \
2308 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002309 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002310 -S "SSL - The requested feature is not available"
2311
2312run_test "DTLS cookie: disabled" \
2313 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2314 "$P_CLI dtls=1 debug_level=2" \
2315 0 \
2316 -S "cookie verification failed" \
2317 -S "cookie verification passed" \
2318 -s "cookie verification skipped" \
2319 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002320 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002321 -S "SSL - The requested feature is not available"
2322
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002323run_test "DTLS cookie: default (failing)" \
2324 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2325 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2326 1 \
2327 -s "cookie verification failed" \
2328 -S "cookie verification passed" \
2329 -S "cookie verification skipped" \
2330 -C "received hello verify request" \
2331 -S "hello verification requested" \
2332 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002333
2334requires_ipv6
2335run_test "DTLS cookie: enabled, IPv6" \
2336 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2337 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2338 0 \
2339 -s "cookie verification failed" \
2340 -s "cookie verification passed" \
2341 -S "cookie verification skipped" \
2342 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002343 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002344 -S "SSL - The requested feature is not available"
2345
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002346run_test "DTLS cookie: enabled, nbio" \
2347 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2348 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2349 0 \
2350 -s "cookie verification failed" \
2351 -s "cookie verification passed" \
2352 -S "cookie verification skipped" \
2353 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002354 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002355 -S "SSL - The requested feature is not available"
2356
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002357# Tests for various cases of client authentication with DTLS
2358# (focused on handshake flows and message parsing)
2359
2360run_test "DTLS client auth: required" \
2361 "$P_SRV dtls=1 auth_mode=required" \
2362 "$P_CLI dtls=1" \
2363 0 \
2364 -s "Verifying peer X.509 certificate... ok"
2365
2366run_test "DTLS client auth: optional, client has no cert" \
2367 "$P_SRV dtls=1 auth_mode=optional" \
2368 "$P_CLI dtls=1 crt_file=none key_file=none" \
2369 0 \
2370 -s "! no client certificate sent"
2371
2372run_test "DTLS client auth: optional, client has no cert" \
2373 "$P_SRV dtls=1 auth_mode=none" \
2374 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2375 0 \
2376 -c "skip write certificate$" \
2377 -s "! no client certificate sent"
2378
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002379# Tests for receiving fragmented handshake messages with DTLS
2380
2381requires_gnutls
2382run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2383 "$G_SRV -u --mtu 2048 -a" \
2384 "$P_CLI dtls=1 debug_level=2" \
2385 0 \
2386 -C "found fragmented DTLS handshake message" \
2387 -C "error"
2388
2389requires_gnutls
2390run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2391 "$G_SRV -u --mtu 512" \
2392 "$P_CLI dtls=1 debug_level=2" \
2393 0 \
2394 -c "found fragmented DTLS handshake message" \
2395 -C "error"
2396
2397requires_gnutls
2398run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2399 "$G_SRV -u --mtu 128" \
2400 "$P_CLI dtls=1 debug_level=2" \
2401 0 \
2402 -c "found fragmented DTLS handshake message" \
2403 -C "error"
2404
2405requires_gnutls
2406run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2407 "$G_SRV -u --mtu 128" \
2408 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2409 0 \
2410 -c "found fragmented DTLS handshake message" \
2411 -C "error"
2412
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002413requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002414run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2415 "$G_SRV -u --mtu 256" \
2416 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2417 0 \
2418 -c "found fragmented DTLS handshake message" \
2419 -c "client hello, adding renegotiation extension" \
2420 -c "found renegotiation extension" \
2421 -c "=> renegotiate" \
2422 -C "ssl_handshake returned" \
2423 -C "error" \
2424 -s "Extra-header:"
2425
2426requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002427run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2428 "$G_SRV -u --mtu 256" \
2429 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2430 0 \
2431 -c "found fragmented DTLS handshake message" \
2432 -c "client hello, adding renegotiation extension" \
2433 -c "found renegotiation extension" \
2434 -c "=> renegotiate" \
2435 -C "ssl_handshake returned" \
2436 -C "error" \
2437 -s "Extra-header:"
2438
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002439run_test "DTLS reassembly: no fragmentation (openssl server)" \
2440 "$O_SRV -dtls1 -mtu 2048" \
2441 "$P_CLI dtls=1 debug_level=2" \
2442 0 \
2443 -C "found fragmented DTLS handshake message" \
2444 -C "error"
2445
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002446run_test "DTLS reassembly: some fragmentation (openssl server)" \
2447 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002448 "$P_CLI dtls=1 debug_level=2" \
2449 0 \
2450 -c "found fragmented DTLS handshake message" \
2451 -C "error"
2452
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002453run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002454 "$O_SRV -dtls1 -mtu 256" \
2455 "$P_CLI dtls=1 debug_level=2" \
2456 0 \
2457 -c "found fragmented DTLS handshake message" \
2458 -C "error"
2459
2460run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2461 "$O_SRV -dtls1 -mtu 256" \
2462 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2463 0 \
2464 -c "found fragmented DTLS handshake message" \
2465 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002466
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002467# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002468
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002469not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002470run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002471 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002472 "$P_SRV dtls=1 debug_level=2" \
2473 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002474 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002475 -C "replayed record" \
2476 -S "replayed record" \
2477 -C "record from another epoch" \
2478 -S "record from another epoch" \
2479 -C "discarding invalid record" \
2480 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002481 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002482 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002483 -c "HTTP/1.0 200 OK"
2484
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002485not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002486run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002487 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002488 "$P_SRV dtls=1 debug_level=2" \
2489 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002490 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002491 -c "replayed record" \
2492 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002493 -c "discarding invalid record" \
2494 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002495 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002496 -s "Extra-header:" \
2497 -c "HTTP/1.0 200 OK"
2498
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002499run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2500 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002501 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2502 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002503 0 \
2504 -c "replayed record" \
2505 -S "replayed record" \
2506 -c "discarding invalid record" \
2507 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002508 -c "resend" \
2509 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002510 -s "Extra-header:" \
2511 -c "HTTP/1.0 200 OK"
2512
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002513run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002514 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002515 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002516 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002517 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002518 -c "discarding invalid record (mac)" \
2519 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002520 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002521 -c "HTTP/1.0 200 OK" \
2522 -S "too many records with bad MAC" \
2523 -S "Verification of the message MAC failed"
2524
2525run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
2526 -p "$P_PXY bad_ad=1" \
2527 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
2528 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2529 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002530 -C "discarding invalid record (mac)" \
2531 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002532 -S "Extra-header:" \
2533 -C "HTTP/1.0 200 OK" \
2534 -s "too many records with bad MAC" \
2535 -s "Verification of the message MAC failed"
2536
2537run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
2538 -p "$P_PXY bad_ad=1" \
2539 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
2540 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2541 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002542 -c "discarding invalid record (mac)" \
2543 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002544 -s "Extra-header:" \
2545 -c "HTTP/1.0 200 OK" \
2546 -S "too many records with bad MAC" \
2547 -S "Verification of the message MAC failed"
2548
2549run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
2550 -p "$P_PXY bad_ad=1" \
2551 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
2552 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
2553 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002554 -c "discarding invalid record (mac)" \
2555 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002556 -s "Extra-header:" \
2557 -c "HTTP/1.0 200 OK" \
2558 -s "too many records with bad MAC" \
2559 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002560
2561run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002562 -p "$P_PXY delay_ccs=1" \
2563 "$P_SRV dtls=1 debug_level=1" \
2564 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002565 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002566 -c "record from another epoch" \
2567 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002568 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002569 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002570 -s "Extra-header:" \
2571 -c "HTTP/1.0 200 OK"
2572
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002573# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002574
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002575needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002576run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002577 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002578 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2579 psk=abc123" \
2580 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002581 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2582 0 \
2583 -s "Extra-header:" \
2584 -c "HTTP/1.0 200 OK"
2585
2586needs_more_time 2
2587run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
2588 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002589 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2590 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002591 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2592 0 \
2593 -s "Extra-header:" \
2594 -c "HTTP/1.0 200 OK"
2595
2596needs_more_time 2
2597run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
2598 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002599 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2600 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002601 0 \
2602 -s "Extra-header:" \
2603 -c "HTTP/1.0 200 OK"
2604
2605needs_more_time 2
2606run_test "DTLS proxy: 3d, FS, client auth" \
2607 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002608 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
2609 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002610 0 \
2611 -s "Extra-header:" \
2612 -c "HTTP/1.0 200 OK"
2613
2614needs_more_time 2
2615run_test "DTLS proxy: 3d, FS, ticket" \
2616 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002617 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
2618 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002619 0 \
2620 -s "Extra-header:" \
2621 -c "HTTP/1.0 200 OK"
2622
2623needs_more_time 2
2624run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
2625 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002626 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
2627 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002628 0 \
2629 -s "Extra-header:" \
2630 -c "HTTP/1.0 200 OK"
2631
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002632needs_more_time 2
2633run_test "DTLS proxy: 3d, max handshake, nbio" \
2634 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002635 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
2636 auth_mode=required" \
2637 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002638 0 \
2639 -s "Extra-header:" \
2640 -c "HTTP/1.0 200 OK"
2641
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002642needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02002643run_test "DTLS proxy: 3d, min handshake, resumption" \
2644 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2645 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2646 psk=abc123 debug_level=3" \
2647 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2648 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2649 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2650 0 \
2651 -s "a session has been resumed" \
2652 -c "a session has been resumed" \
2653 -s "Extra-header:" \
2654 -c "HTTP/1.0 200 OK"
2655
2656needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02002657run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
2658 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2659 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2660 psk=abc123 debug_level=3 nbio=2" \
2661 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2662 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2663 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
2664 0 \
2665 -s "a session has been resumed" \
2666 -c "a session has been resumed" \
2667 -s "Extra-header:" \
2668 -c "HTTP/1.0 200 OK"
2669
2670needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002671run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002672 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002673 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2674 psk=abc123 renegotiation=1 debug_level=2" \
2675 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2676 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002677 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2678 0 \
2679 -c "=> renegotiate" \
2680 -s "=> renegotiate" \
2681 -s "Extra-header:" \
2682 -c "HTTP/1.0 200 OK"
2683
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002684needs_more_time 4
2685run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
2686 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002687 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2688 psk=abc123 renegotiation=1 debug_level=2" \
2689 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2690 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002691 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2692 0 \
2693 -c "=> renegotiate" \
2694 -s "=> renegotiate" \
2695 -s "Extra-header:" \
2696 -c "HTTP/1.0 200 OK"
2697
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002698needs_more_time 4
2699run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02002700 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002701 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02002702 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002703 debug_level=2" \
2704 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02002705 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002706 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2707 0 \
2708 -c "=> renegotiate" \
2709 -s "=> renegotiate" \
2710 -s "Extra-header:" \
2711 -c "HTTP/1.0 200 OK"
2712
2713needs_more_time 4
2714run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02002715 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002716 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02002717 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002718 debug_level=2 nbio=2" \
2719 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02002720 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002721 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2722 0 \
2723 -c "=> renegotiate" \
2724 -s "=> renegotiate" \
2725 -s "Extra-header:" \
2726 -c "HTTP/1.0 200 OK"
2727
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002728needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002729run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02002730 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
2731 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02002732 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02002733 0 \
2734 -s "Extra-header:" \
2735 -c "HTTP/1.0 200 OK"
2736
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002737needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002738run_test "DTLS proxy: 3d, openssl server, fragmentation" \
2739 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
2740 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02002741 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002742 0 \
2743 -s "Extra-header:" \
2744 -c "HTTP/1.0 200 OK"
2745
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002746needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002747run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
2748 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
2749 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02002750 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002751 0 \
2752 -s "Extra-header:" \
2753 -c "HTTP/1.0 200 OK"
2754
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002755needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002756run_test "DTLS proxy: 3d, gnutls server" \
2757 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2758 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02002759 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002760 0 \
2761 -s "Extra-header:" \
2762 -c "Extra-header:"
2763
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002764needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002765run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
2766 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2767 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02002768 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002769 0 \
2770 -s "Extra-header:" \
2771 -c "Extra-header:"
2772
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002773needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002774run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
2775 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2776 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02002777 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002778 0 \
2779 -s "Extra-header:" \
2780 -c "Extra-header:"
2781
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002782# Final report
2783
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002784echo "------------------------------------------------------------------------"
2785
2786if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002787 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002788else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002789 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002790fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002791PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002792echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002793
2794exit $FAILS