blob: b594c3e2347e32f6bd7ced4529949e7868799907 [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é-Gonnard417d46c2014-03-13 19:17:53 +010038 echo -e " -h|--help\tPrint this help."
39 echo -e " -m|--memcheck\tCheck memory leaks and errors."
40 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
41 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
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() {
148 echo -n "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200149 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100150 for i in `seq 1 $LEN`; do echo -n '.'; done
151 echo -n ' '
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é-Gonnardbe9eb872014-09-05 17:45:19 +0200232 until lsof -nbi UDP:"$SRV_PORT" | grep UDP >/dev/null; do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200233 else
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200234 until lsof -nbi TCP:"$SRV_PORT" | grep LISTEN >/dev/null; do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200235 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200236
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200237 kill $DOG_PID >/dev/null 2>&1
238 wait $DOG_PID
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200239 else
240 sleep "$START_DELAY"
241 fi
242}
243
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200244# wait for client to terminate and set CLI_EXIT
245# must be called right after starting the client
246wait_client_done() {
247 CLI_PID=$!
248
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200249 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
250 CLI_DELAY_FACTOR=1
251
252 ( sleep $CLI_DELAY; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200253 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200254
255 wait $CLI_PID
256 CLI_EXIT=$?
257
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200258 kill $DOG_PID >/dev/null 2>&1
259 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200260
261 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
262}
263
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200264# check if the given command uses dtls and sets global variable DTLS
265detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200266 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200267 DTLS=1
268 else
269 DTLS=0
270 fi
271}
272
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200273# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100274# Options: -s pattern pattern that must be present in server output
275# -c pattern pattern that must be present in client output
276# -S pattern pattern that must be absent in server output
277# -C pattern pattern that must be absent in client output
278run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100279 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200280 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100281
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100282 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
283 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200284 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100285 return
286 fi
287
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100288 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100289
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200290 # should we skip?
291 if [ "X$SKIP_NEXT" = "XYES" ]; then
292 SKIP_NEXT="NO"
293 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200294 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200295 return
296 fi
297
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200298 # does this test use a proxy?
299 if [ "X$1" = "X-p" ]; then
300 PXY_CMD="$2"
301 shift 2
302 else
303 PXY_CMD=""
304 fi
305
306 # get commands and client output
307 SRV_CMD="$1"
308 CLI_CMD="$2"
309 CLI_EXPECT="$3"
310 shift 3
311
312 # fix client port
313 if [ -n "$PXY_CMD" ]; then
314 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
315 else
316 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
317 fi
318
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200319 # update DTLS variable
320 detect_dtls "$SRV_CMD"
321
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100322 # prepend valgrind to our commands if active
323 if [ "$MEMCHECK" -gt 0 ]; then
324 if is_polar "$SRV_CMD"; then
325 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
326 fi
327 if is_polar "$CLI_CMD"; then
328 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
329 fi
330 fi
331
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100332 # run the commands
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200333 if [ -n "$PXY_CMD" ]; then
334 echo "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200335 $PXY_CMD >> $PXY_OUT 2>&1 &
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200336 PXY_PID=$!
337 # assume proxy starts faster than server
338 fi
339
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200340 check_osrv_dtls
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200341 echo "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200342 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100343 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200344 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200345
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200346 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200347 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
348 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100349
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200350 # terminate the server (and the proxy)
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200351 kill $SRV_PID
352 wait $SRV_PID
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200353 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200354 kill $PXY_PID >/dev/null 2>&1
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200355 wait $PXY_PID
356 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100357
358 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200359 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100360 # expected client exit to incorrectly succeed in case of catastrophic
361 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100362 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200363 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100364 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100365 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100366 return
367 fi
368 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100369 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200370 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100371 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100372 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100373 return
374 fi
375 fi
376
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100377 # check server exit code
378 if [ $? != 0 ]; then
379 fail "server fail"
380 return
381 fi
382
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100383 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100384 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
385 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100386 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200387 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100388 return
389 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100390
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100391 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200392 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100393 while [ $# -gt 0 ]
394 do
395 case $1 in
396 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200397 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100398 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100399 return
400 fi
401 ;;
402
403 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200404 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100405 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100406 return
407 fi
408 ;;
409
410 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200411 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100412 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100413 return
414 fi
415 ;;
416
417 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200418 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100419 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100420 return
421 fi
422 ;;
423
424 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200425 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426 exit 1
427 esac
428 shift 2
429 done
430
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100431 # check valgrind's results
432 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200433 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100434 fail "Server has memory errors"
435 return
436 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200437 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100438 fail "Client has memory errors"
439 return
440 fi
441 fi
442
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100443 # if we're here, everything is ok
444 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200445 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100446}
447
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100448cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200449 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200450 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
451 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
452 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
453 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100454 exit 1
455}
456
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100457#
458# MAIN
459#
460
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100461get_options "$@"
462
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100463# sanity checks, avoid an avalanche of errors
464if [ ! -x "$P_SRV" ]; then
465 echo "Command '$P_SRV' is not an executable file"
466 exit 1
467fi
468if [ ! -x "$P_CLI" ]; then
469 echo "Command '$P_CLI' is not an executable file"
470 exit 1
471fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200472if [ ! -x "$P_PXY" ]; then
473 echo "Command '$P_PXY' is not an executable file"
474 exit 1
475fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100476if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
477 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100478 exit 1
479fi
480
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200481# used by watchdog
482MAIN_PID="$$"
483
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200484# be more patient with valgrind
485if [ "$MEMCHECK" -gt 0 ]; then
486 START_DELAY=3
487 DOG_DELAY=30
488else
489 START_DELAY=1
490 DOG_DELAY=10
491fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200492CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200493
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200494# Pick a "unique" server port in the range 10000-19999, and a proxy port
495PORT_BASE="0000$$"
496PORT_BASE="$( echo -n $PORT_BASE | tail -c 4 )"
497SRV_PORT="1$PORT_BASE"
498PXY_PORT="2$PORT_BASE"
499unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200500
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200501# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200502P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
503P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
504P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
505O_SRV="$O_SRV -accept $SRV_PORT"
506O_CLI="$O_CLI -connect localhost:+SRV_PORT"
507G_SRV="$G_SRV -p $SRV_PORT"
508G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200509
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200510# Also pick a unique name for intermediate files
511SRV_OUT="srv_out.$$"
512CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200513PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200514SESSION="session.$$"
515
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200516SKIP_NEXT="NO"
517
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100518trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100519
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200520# Basic test
521
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200522# Checks that:
523# - things work with all ciphersuites active (used with config-full in all.sh)
524# - the expected (highest security) parameters are selected
525# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200526run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200527 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200528 "$P_CLI" \
529 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200530 -s "Protocol is TLSv1.2" \
531 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
532 -s "client hello v3, signature_algorithm ext: 6" \
533 -s "ECDHE curve: secp521r1" \
534 -S "error" \
535 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200536
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100537# Test for SSLv2 ClientHello
538
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200539requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200540run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100541 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100542 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100543 0 \
544 -S "parse client hello v2" \
545 -S "ssl_handshake returned"
546
547# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200548requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200549run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200550 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100551 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100552 0 \
553 -s "parse client hello v2" \
554 -S "ssl_handshake returned"
555
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100556# Tests for Truncated HMAC extension
557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200558run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200559 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100560 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100561 0 \
562 -s "dumping 'computed mac' (20 bytes)"
563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200564run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200565 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100566 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100567 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100568 -s "dumping 'computed mac' (10 bytes)"
569
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100570# Tests for Encrypt-then-MAC extension
571
572run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100573 "$P_SRV debug_level=3 \
574 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100575 "$P_CLI debug_level=3" \
576 0 \
577 -c "client hello, adding encrypt_then_mac extension" \
578 -s "found encrypt then mac extension" \
579 -s "server hello, adding encrypt then mac extension" \
580 -c "found encrypt_then_mac extension" \
581 -c "using encrypt then mac" \
582 -s "using encrypt then mac"
583
584run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100585 "$P_SRV debug_level=3 etm=0 \
586 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100587 "$P_CLI debug_level=3 etm=1" \
588 0 \
589 -c "client hello, adding encrypt_then_mac extension" \
590 -s "found encrypt then mac extension" \
591 -S "server hello, adding encrypt then mac extension" \
592 -C "found encrypt_then_mac extension" \
593 -C "using encrypt then mac" \
594 -S "using encrypt then mac"
595
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100596run_test "Encrypt then MAC: client enabled, aead cipher" \
597 "$P_SRV debug_level=3 etm=1 \
598 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
599 "$P_CLI debug_level=3 etm=1" \
600 0 \
601 -c "client hello, adding encrypt_then_mac extension" \
602 -s "found encrypt then mac extension" \
603 -S "server hello, adding encrypt then mac extension" \
604 -C "found encrypt_then_mac extension" \
605 -C "using encrypt then mac" \
606 -S "using encrypt then mac"
607
608run_test "Encrypt then MAC: client enabled, stream cipher" \
609 "$P_SRV debug_level=3 etm=1 \
610 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
611 "$P_CLI debug_level=3 etm=1" \
612 0 \
613 -c "client hello, adding encrypt_then_mac extension" \
614 -s "found encrypt then mac extension" \
615 -S "server hello, adding encrypt then mac extension" \
616 -C "found encrypt_then_mac extension" \
617 -C "using encrypt then mac" \
618 -S "using encrypt then mac"
619
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100620run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100621 "$P_SRV debug_level=3 etm=1 \
622 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100623 "$P_CLI debug_level=3 etm=0" \
624 0 \
625 -C "client hello, adding encrypt_then_mac extension" \
626 -S "found encrypt then mac extension" \
627 -S "server hello, adding encrypt then mac extension" \
628 -C "found encrypt_then_mac extension" \
629 -C "using encrypt then mac" \
630 -S "using encrypt then mac"
631
632run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100633 "$P_SRV debug_level=3 \
634 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100635 "$P_CLI debug_level=3 force_version=ssl3" \
636 0 \
637 -C "client hello, adding encrypt_then_mac extension" \
638 -S "found encrypt then mac extension" \
639 -S "server hello, adding encrypt then mac extension" \
640 -C "found encrypt_then_mac extension" \
641 -C "using encrypt then mac" \
642 -S "using encrypt then mac"
643
644run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100645 "$P_SRV debug_level=3 force_version=ssl3 \
646 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100647 "$P_CLI debug_level=3" \
648 0 \
649 -c "client hello, adding encrypt_then_mac extension" \
650 -s "found encrypt then mac extension" \
651 -S "server hello, adding encrypt then mac extension" \
652 -C "found encrypt_then_mac extension" \
653 -C "using encrypt then mac" \
654 -S "using encrypt then mac"
655
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200656# Tests for Extended Master Secret extension
657
658run_test "Extended Master Secret: default" \
659 "$P_SRV debug_level=3" \
660 "$P_CLI debug_level=3" \
661 0 \
662 -c "client hello, adding extended_master_secret extension" \
663 -s "found extended master secret extension" \
664 -s "server hello, adding extended master secret extension" \
665 -c "found extended_master_secret extension" \
666 -c "using extended master secret" \
667 -s "using extended master secret"
668
669run_test "Extended Master Secret: client enabled, server disabled" \
670 "$P_SRV debug_level=3 extended_ms=0" \
671 "$P_CLI debug_level=3 extended_ms=1" \
672 0 \
673 -c "client hello, adding extended_master_secret extension" \
674 -s "found extended master secret extension" \
675 -S "server hello, adding extended master secret extension" \
676 -C "found extended_master_secret extension" \
677 -C "using extended master secret" \
678 -S "using extended master secret"
679
680run_test "Extended Master Secret: client disabled, server enabled" \
681 "$P_SRV debug_level=3 extended_ms=1" \
682 "$P_CLI debug_level=3 extended_ms=0" \
683 0 \
684 -C "client hello, adding extended_master_secret extension" \
685 -S "found extended master secret extension" \
686 -S "server hello, adding extended master secret extension" \
687 -C "found extended_master_secret extension" \
688 -C "using extended master secret" \
689 -S "using extended master secret"
690
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200691run_test "Extended Master Secret: client SSLv3, server enabled" \
692 "$P_SRV debug_level=3" \
693 "$P_CLI debug_level=3 force_version=ssl3" \
694 0 \
695 -C "client hello, adding extended_master_secret extension" \
696 -S "found extended master secret extension" \
697 -S "server hello, adding extended master secret extension" \
698 -C "found extended_master_secret extension" \
699 -C "using extended master secret" \
700 -S "using extended master secret"
701
702run_test "Extended Master Secret: client enabled, server SSLv3" \
703 "$P_SRV debug_level=3 force_version=ssl3" \
704 "$P_CLI debug_level=3" \
705 0 \
706 -c "client hello, adding extended_master_secret extension" \
707 -s "found extended master secret extension" \
708 -S "server hello, adding extended master secret extension" \
709 -C "found extended_master_secret extension" \
710 -C "using extended master secret" \
711 -S "using extended master secret"
712
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200713# Tests for FALLBACK_SCSV
714
715run_test "Fallback SCSV: default" \
716 "$P_SRV" \
717 "$P_CLI debug_level=3 force_version=tls1_1" \
718 0 \
719 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200720 -S "received FALLBACK_SCSV" \
721 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200722 -C "is a fatal alert message (msg 86)"
723
724run_test "Fallback SCSV: explicitly disabled" \
725 "$P_SRV" \
726 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
727 0 \
728 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200729 -S "received FALLBACK_SCSV" \
730 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200731 -C "is a fatal alert message (msg 86)"
732
733run_test "Fallback SCSV: enabled" \
734 "$P_SRV" \
735 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200736 1 \
737 -c "adding FALLBACK_SCSV" \
738 -s "received FALLBACK_SCSV" \
739 -s "inapropriate fallback" \
740 -c "is a fatal alert message (msg 86)"
741
742run_test "Fallback SCSV: enabled, max version" \
743 "$P_SRV" \
744 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200745 0 \
746 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200747 -s "received FALLBACK_SCSV" \
748 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200749 -C "is a fatal alert message (msg 86)"
750
751requires_openssl_with_fallback_scsv
752run_test "Fallback SCSV: default, openssl server" \
753 "$O_SRV" \
754 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
755 0 \
756 -C "adding FALLBACK_SCSV" \
757 -C "is a fatal alert message (msg 86)"
758
759requires_openssl_with_fallback_scsv
760run_test "Fallback SCSV: enabled, openssl server" \
761 "$O_SRV" \
762 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
763 1 \
764 -c "adding FALLBACK_SCSV" \
765 -c "is a fatal alert message (msg 86)"
766
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200767requires_openssl_with_fallback_scsv
768run_test "Fallback SCSV: disabled, openssl client" \
769 "$P_SRV" \
770 "$O_CLI -tls1_1" \
771 0 \
772 -S "received FALLBACK_SCSV" \
773 -S "inapropriate fallback"
774
775requires_openssl_with_fallback_scsv
776run_test "Fallback SCSV: enabled, openssl client" \
777 "$P_SRV" \
778 "$O_CLI -tls1_1 -fallback_scsv" \
779 1 \
780 -s "received FALLBACK_SCSV" \
781 -s "inapropriate fallback"
782
783requires_openssl_with_fallback_scsv
784run_test "Fallback SCSV: enabled, max version, openssl client" \
785 "$P_SRV" \
786 "$O_CLI -fallback_scsv" \
787 0 \
788 -s "received FALLBACK_SCSV" \
789 -S "inapropriate fallback"
790
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100791# Tests for Session Tickets
792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200793run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200794 "$P_SRV debug_level=3 tickets=1" \
795 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100796 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100797 -c "client hello, adding session ticket extension" \
798 -s "found session ticket extension" \
799 -s "server hello, adding session ticket extension" \
800 -c "found session_ticket extension" \
801 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100802 -S "session successfully restored from cache" \
803 -s "session successfully restored from ticket" \
804 -s "a session has been resumed" \
805 -c "a session has been resumed"
806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200807run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200808 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
809 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100810 0 \
811 -c "client hello, adding session ticket extension" \
812 -s "found session ticket extension" \
813 -s "server hello, adding session ticket extension" \
814 -c "found session_ticket extension" \
815 -c "parse new session ticket" \
816 -S "session successfully restored from cache" \
817 -s "session successfully restored from ticket" \
818 -s "a session has been resumed" \
819 -c "a session has been resumed"
820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200821run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200822 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
823 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100824 0 \
825 -c "client hello, adding session ticket extension" \
826 -s "found session ticket extension" \
827 -s "server hello, adding session ticket extension" \
828 -c "found session_ticket extension" \
829 -c "parse new session ticket" \
830 -S "session successfully restored from cache" \
831 -S "session successfully restored from ticket" \
832 -S "a session has been resumed" \
833 -C "a session has been resumed"
834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200835run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100836 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200837 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100838 0 \
839 -c "client hello, adding session ticket extension" \
840 -c "found session_ticket extension" \
841 -c "parse new session ticket" \
842 -c "a session has been resumed"
843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200844run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200845 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200846 "( $O_CLI -sess_out $SESSION; \
847 $O_CLI -sess_in $SESSION; \
848 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100849 0 \
850 -s "found session ticket extension" \
851 -s "server hello, adding session ticket extension" \
852 -S "session successfully restored from cache" \
853 -s "session successfully restored from ticket" \
854 -s "a session has been resumed"
855
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100856# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200858run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200859 "$P_SRV debug_level=3 tickets=0" \
860 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100861 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100862 -c "client hello, adding session ticket extension" \
863 -s "found session ticket extension" \
864 -S "server hello, adding session ticket extension" \
865 -C "found session_ticket extension" \
866 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100867 -s "session successfully restored from cache" \
868 -S "session successfully restored from ticket" \
869 -s "a session has been resumed" \
870 -c "a session has been resumed"
871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200872run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200873 "$P_SRV debug_level=3 tickets=1" \
874 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100875 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100876 -C "client hello, adding session ticket extension" \
877 -S "found session ticket extension" \
878 -S "server hello, adding session ticket extension" \
879 -C "found session_ticket extension" \
880 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100881 -s "session successfully restored from cache" \
882 -S "session successfully restored from ticket" \
883 -s "a session has been resumed" \
884 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200886run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200887 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
888 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100889 0 \
890 -S "session successfully restored from cache" \
891 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100892 -S "a session has been resumed" \
893 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100894
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200895run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200896 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
897 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100898 0 \
899 -s "session successfully restored from cache" \
900 -S "session successfully restored from ticket" \
901 -s "a session has been resumed" \
902 -c "a session has been resumed"
903
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200904run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200905 "$P_SRV debug_level=3 tickets=0" \
906 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100907 0 \
908 -s "session successfully restored from cache" \
909 -S "session successfully restored from ticket" \
910 -s "a session has been resumed" \
911 -c "a session has been resumed"
912
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200913run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200914 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
915 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100916 0 \
917 -S "session successfully restored from cache" \
918 -S "session successfully restored from ticket" \
919 -S "a session has been resumed" \
920 -C "a session has been resumed"
921
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200922run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200923 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
924 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100925 0 \
926 -s "session successfully restored from cache" \
927 -S "session successfully restored from ticket" \
928 -s "a session has been resumed" \
929 -c "a session has been resumed"
930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200931run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200932 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200933 "( $O_CLI -sess_out $SESSION; \
934 $O_CLI -sess_in $SESSION; \
935 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100936 0 \
937 -s "found session ticket extension" \
938 -S "server hello, adding session ticket extension" \
939 -s "session successfully restored from cache" \
940 -S "session successfully restored from ticket" \
941 -s "a session has been resumed"
942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200943run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100944 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200945 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100946 0 \
947 -C "found session_ticket extension" \
948 -C "parse new session ticket" \
949 -c "a session has been resumed"
950
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100951# Tests for Max Fragment Length extension
952
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200953run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200954 "$P_SRV debug_level=3" \
955 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100956 0 \
957 -C "client hello, adding max_fragment_length extension" \
958 -S "found max fragment length extension" \
959 -S "server hello, max_fragment_length extension" \
960 -C "found max_fragment_length extension"
961
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200962run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200963 "$P_SRV debug_level=3" \
964 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100965 0 \
966 -c "client hello, adding max_fragment_length extension" \
967 -s "found max fragment length extension" \
968 -s "server hello, max_fragment_length extension" \
969 -c "found max_fragment_length extension"
970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200971run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200972 "$P_SRV debug_level=3 max_frag_len=4096" \
973 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100974 0 \
975 -C "client hello, adding max_fragment_length extension" \
976 -S "found max fragment length extension" \
977 -S "server hello, max_fragment_length extension" \
978 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200980requires_gnutls
981run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200982 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200983 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200984 0 \
985 -c "client hello, adding max_fragment_length extension" \
986 -c "found max_fragment_length extension"
987
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +0200988run_test "Max fragment length: client, message just fits" \
989 "$P_SRV debug_level=3" \
990 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
991 0 \
992 -c "client hello, adding max_fragment_length extension" \
993 -s "found max fragment length extension" \
994 -s "server hello, max_fragment_length extension" \
995 -c "found max_fragment_length extension" \
996 -c "2048 bytes written in 1 fragments" \
997 -s "2048 bytes read"
998
999run_test "Max fragment length: client, larger message" \
1000 "$P_SRV debug_level=3" \
1001 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1002 0 \
1003 -c "client hello, adding max_fragment_length extension" \
1004 -s "found max fragment length extension" \
1005 -s "server hello, max_fragment_length extension" \
1006 -c "found max_fragment_length extension" \
1007 -c "2345 bytes written in 2 fragments" \
1008 -s "2048 bytes read" \
1009 -s "297 bytes read"
1010
1011run_test "Max fragment length: client, larger message" \
1012 "$P_SRV debug_level=3 dtls=1" \
1013 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1014 1 \
1015 -c "client hello, adding max_fragment_length extension" \
1016 -s "found max fragment length extension" \
1017 -s "server hello, max_fragment_length extension" \
1018 -c "found max_fragment_length extension" \
1019 -c "fragment larger than.*maximum"
1020
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001021# Tests for renegotiation
1022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001023run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001024 "$P_SRV debug_level=3 exchanges=2" \
1025 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001026 0 \
1027 -C "client hello, adding renegotiation extension" \
1028 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1029 -S "found renegotiation extension" \
1030 -s "server hello, secure renegotiation extension" \
1031 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001032 -C "=> renegotiate" \
1033 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001034 -S "write hello request"
1035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001036run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001037 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
1038 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001039 0 \
1040 -c "client hello, adding renegotiation extension" \
1041 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1042 -s "found renegotiation extension" \
1043 -s "server hello, secure renegotiation extension" \
1044 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001045 -c "=> renegotiate" \
1046 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001047 -S "write hello request"
1048
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001049run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001050 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1051 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001052 0 \
1053 -c "client hello, adding renegotiation extension" \
1054 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1055 -s "found renegotiation extension" \
1056 -s "server hello, secure renegotiation extension" \
1057 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001058 -c "=> renegotiate" \
1059 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001060 -s "write hello request"
1061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001062run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001063 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1064 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001065 0 \
1066 -c "client hello, adding renegotiation extension" \
1067 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1068 -s "found renegotiation extension" \
1069 -s "server hello, secure renegotiation extension" \
1070 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001071 -c "=> renegotiate" \
1072 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001073 -s "write hello request"
1074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001075run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001076 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1077 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001078 1 \
1079 -c "client hello, adding renegotiation extension" \
1080 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1081 -S "found renegotiation extension" \
1082 -s "server hello, secure renegotiation extension" \
1083 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001084 -c "=> renegotiate" \
1085 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001086 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001087 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001088 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001090run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001091 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1092 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001093 0 \
1094 -C "client hello, adding renegotiation extension" \
1095 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1096 -S "found renegotiation extension" \
1097 -s "server hello, secure renegotiation extension" \
1098 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001099 -C "=> renegotiate" \
1100 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001101 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001102 -S "SSL - An unexpected message was received from our peer" \
1103 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001104
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001105run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001106 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001107 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001108 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001109 0 \
1110 -C "client hello, adding renegotiation extension" \
1111 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1112 -S "found renegotiation extension" \
1113 -s "server hello, secure renegotiation extension" \
1114 -c "found renegotiation extension" \
1115 -C "=> renegotiate" \
1116 -S "=> renegotiate" \
1117 -s "write hello request" \
1118 -S "SSL - An unexpected message was received from our peer" \
1119 -S "failed"
1120
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001121# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001122run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001123 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001124 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001125 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001126 0 \
1127 -C "client hello, adding renegotiation extension" \
1128 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1129 -S "found renegotiation extension" \
1130 -s "server hello, secure renegotiation extension" \
1131 -c "found renegotiation extension" \
1132 -C "=> renegotiate" \
1133 -S "=> renegotiate" \
1134 -s "write hello request" \
1135 -S "SSL - An unexpected message was received from our peer" \
1136 -S "failed"
1137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001138run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001139 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001140 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001141 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001142 0 \
1143 -C "client hello, adding renegotiation extension" \
1144 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1145 -S "found renegotiation extension" \
1146 -s "server hello, secure renegotiation extension" \
1147 -c "found renegotiation extension" \
1148 -C "=> renegotiate" \
1149 -S "=> renegotiate" \
1150 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001151 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001153run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001154 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001155 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001156 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001157 0 \
1158 -c "client hello, adding renegotiation extension" \
1159 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1160 -s "found renegotiation extension" \
1161 -s "server hello, secure renegotiation extension" \
1162 -c "found renegotiation extension" \
1163 -c "=> renegotiate" \
1164 -s "=> renegotiate" \
1165 -s "write hello request" \
1166 -S "SSL - An unexpected message was received from our peer" \
1167 -S "failed"
1168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001169run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001170 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1171 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001172 0 \
1173 -c "client hello, adding renegotiation extension" \
1174 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1175 -s "found renegotiation extension" \
1176 -s "server hello, secure renegotiation extension" \
1177 -c "found renegotiation extension" \
1178 -c "=> renegotiate" \
1179 -s "=> renegotiate" \
1180 -S "write hello request"
1181
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001182run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001183 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1184 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001185 0 \
1186 -c "client hello, adding renegotiation extension" \
1187 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1188 -s "found renegotiation extension" \
1189 -s "server hello, secure renegotiation extension" \
1190 -c "found renegotiation extension" \
1191 -c "=> renegotiate" \
1192 -s "=> renegotiate" \
1193 -s "write hello request"
1194
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001195run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001196 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001197 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001198 0 \
1199 -c "client hello, adding renegotiation extension" \
1200 -c "found renegotiation extension" \
1201 -c "=> renegotiate" \
1202 -C "ssl_handshake returned" \
1203 -C "error" \
1204 -c "HTTP/1.0 200 [Oo][Kk]"
1205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001206run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001207 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001208 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001209 0 \
1210 -c "client hello, adding renegotiation extension" \
1211 -c "found renegotiation extension" \
1212 -c "=> renegotiate" \
1213 -C "ssl_handshake returned" \
1214 -C "error" \
1215 -c "HTTP/1.0 200 [Oo][Kk]"
1216
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001217run_test "Renegotiation: DTLS, client-initiated" \
1218 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1219 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1220 0 \
1221 -c "client hello, adding renegotiation extension" \
1222 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1223 -s "found renegotiation extension" \
1224 -s "server hello, secure renegotiation extension" \
1225 -c "found renegotiation extension" \
1226 -c "=> renegotiate" \
1227 -s "=> renegotiate" \
1228 -S "write hello request"
1229
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001230run_test "Renegotiation: DTLS, server-initiated" \
1231 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001232 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1233 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001234 0 \
1235 -c "client hello, adding renegotiation extension" \
1236 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1237 -s "found renegotiation extension" \
1238 -s "server hello, secure renegotiation extension" \
1239 -c "found renegotiation extension" \
1240 -c "=> renegotiate" \
1241 -s "=> renegotiate" \
1242 -s "write hello request"
1243
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001244run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1245 "$G_SRV -u --mtu 4096" \
1246 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1247 0 \
1248 -c "client hello, adding renegotiation extension" \
1249 -c "found renegotiation extension" \
1250 -c "=> renegotiate" \
1251 -C "ssl_handshake returned" \
1252 -C "error" \
1253 -s "Extra-header:"
1254
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001255# Tests for auth_mode
1256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001257run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001258 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001259 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001260 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001261 1 \
1262 -c "x509_verify_cert() returned" \
1263 -c "! self-signed or not signed by a trusted CA" \
1264 -c "! ssl_handshake returned" \
1265 -c "X509 - Certificate verification failed"
1266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001267run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001268 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001269 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001270 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001271 0 \
1272 -c "x509_verify_cert() returned" \
1273 -c "! self-signed or not signed by a trusted CA" \
1274 -C "! ssl_handshake returned" \
1275 -C "X509 - Certificate verification failed"
1276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001277run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001278 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001279 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001280 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001281 0 \
1282 -C "x509_verify_cert() returned" \
1283 -C "! self-signed or not signed by a trusted CA" \
1284 -C "! ssl_handshake returned" \
1285 -C "X509 - Certificate verification failed"
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_SRV debug_level=3 auth_mode=required" \
1289 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001290 key_file=data_files/server5.key" \
1291 1 \
1292 -S "skip write certificate request" \
1293 -C "skip parse certificate request" \
1294 -c "got a certificate request" \
1295 -C "skip write certificate" \
1296 -C "skip write certificate verify" \
1297 -S "skip parse certificate verify" \
1298 -s "x509_verify_cert() returned" \
1299 -S "! self-signed or not signed by a trusted CA" \
1300 -s "! ssl_handshake returned" \
1301 -c "! ssl_handshake returned" \
1302 -s "X509 - Certificate verification failed"
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001305 "$P_SRV debug_level=3 auth_mode=optional" \
1306 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001307 key_file=data_files/server5.key" \
1308 0 \
1309 -S "skip write certificate request" \
1310 -C "skip parse certificate request" \
1311 -c "got a certificate request" \
1312 -C "skip write certificate" \
1313 -C "skip write certificate verify" \
1314 -S "skip parse certificate verify" \
1315 -s "x509_verify_cert() returned" \
1316 -s "! self-signed or not signed by a trusted CA" \
1317 -S "! ssl_handshake returned" \
1318 -C "! ssl_handshake returned" \
1319 -S "X509 - Certificate verification failed"
1320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001321run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001322 "$P_SRV debug_level=3 auth_mode=none" \
1323 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001324 key_file=data_files/server5.key" \
1325 0 \
1326 -s "skip write certificate request" \
1327 -C "skip parse certificate request" \
1328 -c "got no certificate request" \
1329 -c "skip write certificate" \
1330 -c "skip write certificate verify" \
1331 -s "skip parse certificate verify" \
1332 -S "x509_verify_cert() returned" \
1333 -S "! self-signed or not signed by a trusted CA" \
1334 -S "! ssl_handshake returned" \
1335 -C "! ssl_handshake returned" \
1336 -S "X509 - Certificate verification failed"
1337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001338run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001339 "$P_SRV debug_level=3 auth_mode=optional" \
1340 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001341 0 \
1342 -S "skip write certificate request" \
1343 -C "skip parse certificate request" \
1344 -c "got a certificate request" \
1345 -C "skip write certificate$" \
1346 -C "got no certificate to send" \
1347 -S "SSLv3 client has no certificate" \
1348 -c "skip write certificate verify" \
1349 -s "skip parse certificate verify" \
1350 -s "! no client certificate sent" \
1351 -S "! ssl_handshake returned" \
1352 -C "! ssl_handshake returned" \
1353 -S "X509 - Certificate verification failed"
1354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001355run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001356 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001357 "$O_CLI" \
1358 0 \
1359 -S "skip write certificate request" \
1360 -s "skip parse certificate verify" \
1361 -s "! no client certificate sent" \
1362 -S "! ssl_handshake returned" \
1363 -S "X509 - Certificate verification failed"
1364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001365run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001366 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001367 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001368 0 \
1369 -C "skip parse certificate request" \
1370 -c "got a certificate request" \
1371 -C "skip write certificate$" \
1372 -c "skip write certificate verify" \
1373 -C "! ssl_handshake returned"
1374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001375run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001376 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1377 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001378 0 \
1379 -S "skip write certificate request" \
1380 -C "skip parse certificate request" \
1381 -c "got a certificate request" \
1382 -C "skip write certificate$" \
1383 -c "skip write certificate verify" \
1384 -c "got no certificate to send" \
1385 -s "SSLv3 client has no certificate" \
1386 -s "skip parse certificate verify" \
1387 -s "! no client certificate sent" \
1388 -S "! ssl_handshake returned" \
1389 -C "! ssl_handshake returned" \
1390 -S "X509 - Certificate verification failed"
1391
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001392# tests for SNI
1393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001394run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001395 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001396 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001397 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001398 0 \
1399 -S "parse ServerName extension" \
1400 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1401 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001403run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001404 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001405 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001406 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 +02001407 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001408 0 \
1409 -s "parse ServerName extension" \
1410 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1411 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001413run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001414 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001415 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001416 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 +02001417 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001418 0 \
1419 -s "parse ServerName extension" \
1420 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001421 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001423run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001424 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001425 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001426 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 +02001427 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001428 1 \
1429 -s "parse ServerName extension" \
1430 -s "ssl_sni_wrapper() returned" \
1431 -s "ssl_handshake returned" \
1432 -c "ssl_handshake returned" \
1433 -c "SSL - A fatal alert message was received from our peer"
1434
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001435# Tests for non-blocking I/O: exercise a variety of handshake flows
1436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001437run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001438 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1439 "$P_CLI nbio=2 tickets=0" \
1440 0 \
1441 -S "ssl_handshake returned" \
1442 -C "ssl_handshake returned" \
1443 -c "Read from server: .* bytes read"
1444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001445run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001446 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1447 "$P_CLI nbio=2 tickets=0" \
1448 0 \
1449 -S "ssl_handshake returned" \
1450 -C "ssl_handshake returned" \
1451 -c "Read from server: .* bytes read"
1452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001453run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001454 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1455 "$P_CLI nbio=2 tickets=1" \
1456 0 \
1457 -S "ssl_handshake returned" \
1458 -C "ssl_handshake returned" \
1459 -c "Read from server: .* bytes read"
1460
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001461run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001462 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1463 "$P_CLI nbio=2 tickets=1" \
1464 0 \
1465 -S "ssl_handshake returned" \
1466 -C "ssl_handshake returned" \
1467 -c "Read from server: .* bytes read"
1468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001469run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001470 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1471 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1472 0 \
1473 -S "ssl_handshake returned" \
1474 -C "ssl_handshake returned" \
1475 -c "Read from server: .* bytes read"
1476
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001477run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001478 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1479 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1480 0 \
1481 -S "ssl_handshake returned" \
1482 -C "ssl_handshake returned" \
1483 -c "Read from server: .* bytes read"
1484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001485run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001486 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1487 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1488 0 \
1489 -S "ssl_handshake returned" \
1490 -C "ssl_handshake returned" \
1491 -c "Read from server: .* bytes read"
1492
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001493# Tests for version negotiation
1494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001495run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001496 "$P_SRV" \
1497 "$P_CLI" \
1498 0 \
1499 -S "ssl_handshake returned" \
1500 -C "ssl_handshake returned" \
1501 -s "Protocol is TLSv1.2" \
1502 -c "Protocol is TLSv1.2"
1503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001504run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001505 "$P_SRV" \
1506 "$P_CLI max_version=tls1_1" \
1507 0 \
1508 -S "ssl_handshake returned" \
1509 -C "ssl_handshake returned" \
1510 -s "Protocol is TLSv1.1" \
1511 -c "Protocol is TLSv1.1"
1512
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001513run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001514 "$P_SRV max_version=tls1_1" \
1515 "$P_CLI" \
1516 0 \
1517 -S "ssl_handshake returned" \
1518 -C "ssl_handshake returned" \
1519 -s "Protocol is TLSv1.1" \
1520 -c "Protocol is TLSv1.1"
1521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001522run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001523 "$P_SRV max_version=tls1_1" \
1524 "$P_CLI max_version=tls1_1" \
1525 0 \
1526 -S "ssl_handshake returned" \
1527 -C "ssl_handshake returned" \
1528 -s "Protocol is TLSv1.1" \
1529 -c "Protocol is TLSv1.1"
1530
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001531run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001532 "$P_SRV min_version=tls1_1" \
1533 "$P_CLI max_version=tls1_1" \
1534 0 \
1535 -S "ssl_handshake returned" \
1536 -C "ssl_handshake returned" \
1537 -s "Protocol is TLSv1.1" \
1538 -c "Protocol is TLSv1.1"
1539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001540run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001541 "$P_SRV max_version=tls1_1" \
1542 "$P_CLI min_version=tls1_1" \
1543 0 \
1544 -S "ssl_handshake returned" \
1545 -C "ssl_handshake returned" \
1546 -s "Protocol is TLSv1.1" \
1547 -c "Protocol is TLSv1.1"
1548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001549run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001550 "$P_SRV max_version=tls1_1" \
1551 "$P_CLI min_version=tls1_2" \
1552 1 \
1553 -s "ssl_handshake returned" \
1554 -c "ssl_handshake returned" \
1555 -c "SSL - Handshake protocol not within min/max boundaries"
1556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001557run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001558 "$P_SRV min_version=tls1_2" \
1559 "$P_CLI max_version=tls1_1" \
1560 1 \
1561 -s "ssl_handshake returned" \
1562 -c "ssl_handshake returned" \
1563 -s "SSL - Handshake protocol not within min/max boundaries"
1564
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001565# Tests for ALPN extension
1566
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001567if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001569run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001570 "$P_SRV debug_level=3" \
1571 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001572 0 \
1573 -C "client hello, adding alpn extension" \
1574 -S "found alpn extension" \
1575 -C "got an alert message, type: \\[2:120]" \
1576 -S "server hello, adding alpn extension" \
1577 -C "found alpn extension " \
1578 -C "Application Layer Protocol is" \
1579 -S "Application Layer Protocol is"
1580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001581run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001582 "$P_SRV debug_level=3" \
1583 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001584 0 \
1585 -c "client hello, adding alpn extension" \
1586 -s "found alpn extension" \
1587 -C "got an alert message, type: \\[2:120]" \
1588 -S "server hello, adding alpn extension" \
1589 -C "found alpn extension " \
1590 -c "Application Layer Protocol is (none)" \
1591 -S "Application Layer Protocol is"
1592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001593run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001594 "$P_SRV debug_level=3 alpn=abc,1234" \
1595 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001596 0 \
1597 -C "client hello, adding alpn extension" \
1598 -S "found alpn extension" \
1599 -C "got an alert message, type: \\[2:120]" \
1600 -S "server hello, adding alpn extension" \
1601 -C "found alpn extension " \
1602 -C "Application Layer Protocol is" \
1603 -s "Application Layer Protocol is (none)"
1604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001605run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001606 "$P_SRV debug_level=3 alpn=abc,1234" \
1607 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001608 0 \
1609 -c "client hello, adding alpn extension" \
1610 -s "found alpn extension" \
1611 -C "got an alert message, type: \\[2:120]" \
1612 -s "server hello, adding alpn extension" \
1613 -c "found alpn extension" \
1614 -c "Application Layer Protocol is abc" \
1615 -s "Application Layer Protocol is abc"
1616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001617run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001618 "$P_SRV debug_level=3 alpn=abc,1234" \
1619 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001620 0 \
1621 -c "client hello, adding alpn extension" \
1622 -s "found alpn extension" \
1623 -C "got an alert message, type: \\[2:120]" \
1624 -s "server hello, adding alpn extension" \
1625 -c "found alpn extension" \
1626 -c "Application Layer Protocol is abc" \
1627 -s "Application Layer Protocol is abc"
1628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001629run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001630 "$P_SRV debug_level=3 alpn=abc,1234" \
1631 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001632 0 \
1633 -c "client hello, adding alpn extension" \
1634 -s "found alpn extension" \
1635 -C "got an alert message, type: \\[2:120]" \
1636 -s "server hello, adding alpn extension" \
1637 -c "found alpn extension" \
1638 -c "Application Layer Protocol is 1234" \
1639 -s "Application Layer Protocol is 1234"
1640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001641run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001642 "$P_SRV debug_level=3 alpn=abc,123" \
1643 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001644 1 \
1645 -c "client hello, adding alpn extension" \
1646 -s "found alpn extension" \
1647 -c "got an alert message, type: \\[2:120]" \
1648 -S "server hello, adding alpn extension" \
1649 -C "found alpn extension" \
1650 -C "Application Layer Protocol is 1234" \
1651 -S "Application Layer Protocol is 1234"
1652
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001653fi
1654
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001655# Tests for keyUsage in leaf certificates, part 1:
1656# server-side certificate/suite selection
1657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001658run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001659 "$P_SRV key_file=data_files/server2.key \
1660 crt_file=data_files/server2.ku-ds.crt" \
1661 "$P_CLI" \
1662 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001663 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001664
1665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001666run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001667 "$P_SRV key_file=data_files/server2.key \
1668 crt_file=data_files/server2.ku-ke.crt" \
1669 "$P_CLI" \
1670 0 \
1671 -c "Ciphersuite is TLS-RSA-WITH-"
1672
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001673run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001674 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001675 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001676 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001677 1 \
1678 -C "Ciphersuite is "
1679
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001680run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001681 "$P_SRV key_file=data_files/server5.key \
1682 crt_file=data_files/server5.ku-ds.crt" \
1683 "$P_CLI" \
1684 0 \
1685 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1686
1687
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001688run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001689 "$P_SRV key_file=data_files/server5.key \
1690 crt_file=data_files/server5.ku-ka.crt" \
1691 "$P_CLI" \
1692 0 \
1693 -c "Ciphersuite is TLS-ECDH-"
1694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001695run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001696 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001697 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001698 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001699 1 \
1700 -C "Ciphersuite is "
1701
1702# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001703# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001705run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001706 "$O_SRV -key data_files/server2.key \
1707 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001708 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001709 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1710 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001711 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001712 -C "Processing of the Certificate handshake message failed" \
1713 -c "Ciphersuite is TLS-"
1714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001715run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001716 "$O_SRV -key data_files/server2.key \
1717 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001718 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001719 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1720 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001721 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001722 -C "Processing of the Certificate handshake message failed" \
1723 -c "Ciphersuite is TLS-"
1724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001725run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001726 "$O_SRV -key data_files/server2.key \
1727 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001728 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001729 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1730 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001731 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001732 -C "Processing of the Certificate handshake message failed" \
1733 -c "Ciphersuite is TLS-"
1734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001735run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001736 "$O_SRV -key data_files/server2.key \
1737 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001738 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001739 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1740 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001741 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001742 -c "Processing of the Certificate handshake message failed" \
1743 -C "Ciphersuite is TLS-"
1744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001745run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001746 "$O_SRV -key data_files/server2.key \
1747 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001748 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001749 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1750 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001751 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001752 -C "Processing of the Certificate handshake message failed" \
1753 -c "Ciphersuite is TLS-"
1754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001755run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001756 "$O_SRV -key data_files/server2.key \
1757 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001758 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001759 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1760 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001761 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001762 -c "Processing of the Certificate handshake message failed" \
1763 -C "Ciphersuite is TLS-"
1764
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001765# Tests for keyUsage in leaf certificates, part 3:
1766# server-side checking of client cert
1767
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001768run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001769 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001770 "$O_CLI -key data_files/server2.key \
1771 -cert data_files/server2.ku-ds.crt" \
1772 0 \
1773 -S "bad certificate (usage extensions)" \
1774 -S "Processing of the Certificate handshake message failed"
1775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001776run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001777 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001778 "$O_CLI -key data_files/server2.key \
1779 -cert data_files/server2.ku-ke.crt" \
1780 0 \
1781 -s "bad certificate (usage extensions)" \
1782 -S "Processing of the Certificate handshake message failed"
1783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001784run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001785 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001786 "$O_CLI -key data_files/server2.key \
1787 -cert data_files/server2.ku-ke.crt" \
1788 1 \
1789 -s "bad certificate (usage extensions)" \
1790 -s "Processing of the Certificate handshake message failed"
1791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001792run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001793 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001794 "$O_CLI -key data_files/server5.key \
1795 -cert data_files/server5.ku-ds.crt" \
1796 0 \
1797 -S "bad certificate (usage extensions)" \
1798 -S "Processing of the Certificate handshake message failed"
1799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001800run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001801 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001802 "$O_CLI -key data_files/server5.key \
1803 -cert data_files/server5.ku-ka.crt" \
1804 0 \
1805 -s "bad certificate (usage extensions)" \
1806 -S "Processing of the Certificate handshake message failed"
1807
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001808# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1809
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001810run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001811 "$P_SRV key_file=data_files/server5.key \
1812 crt_file=data_files/server5.eku-srv.crt" \
1813 "$P_CLI" \
1814 0
1815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001816run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001817 "$P_SRV key_file=data_files/server5.key \
1818 crt_file=data_files/server5.eku-srv.crt" \
1819 "$P_CLI" \
1820 0
1821
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001822run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001823 "$P_SRV key_file=data_files/server5.key \
1824 crt_file=data_files/server5.eku-cs_any.crt" \
1825 "$P_CLI" \
1826 0
1827
1828# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001829run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001830 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1831 crt_file=data_files/server5.eku-cli.crt" \
1832 "$P_CLI psk=badbad" \
1833 1
1834
1835# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001837run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001838 "$O_SRV -key data_files/server5.key \
1839 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001840 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001841 0 \
1842 -C "bad certificate (usage extensions)" \
1843 -C "Processing of the Certificate handshake message failed" \
1844 -c "Ciphersuite is TLS-"
1845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001846run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001847 "$O_SRV -key data_files/server5.key \
1848 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001849 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001850 0 \
1851 -C "bad certificate (usage extensions)" \
1852 -C "Processing of the Certificate handshake message failed" \
1853 -c "Ciphersuite is TLS-"
1854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001855run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001856 "$O_SRV -key data_files/server5.key \
1857 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001858 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001859 0 \
1860 -C "bad certificate (usage extensions)" \
1861 -C "Processing of the Certificate handshake message failed" \
1862 -c "Ciphersuite is TLS-"
1863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001864run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001865 "$O_SRV -key data_files/server5.key \
1866 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001867 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001868 1 \
1869 -c "bad certificate (usage extensions)" \
1870 -c "Processing of the Certificate handshake message failed" \
1871 -C "Ciphersuite is TLS-"
1872
1873# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1874
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001875run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001876 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001877 "$O_CLI -key data_files/server5.key \
1878 -cert data_files/server5.eku-cli.crt" \
1879 0 \
1880 -S "bad certificate (usage extensions)" \
1881 -S "Processing of the Certificate handshake message failed"
1882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001883run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001884 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001885 "$O_CLI -key data_files/server5.key \
1886 -cert data_files/server5.eku-srv_cli.crt" \
1887 0 \
1888 -S "bad certificate (usage extensions)" \
1889 -S "Processing of the Certificate handshake message failed"
1890
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001891run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001892 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001893 "$O_CLI -key data_files/server5.key \
1894 -cert data_files/server5.eku-cs_any.crt" \
1895 0 \
1896 -S "bad certificate (usage extensions)" \
1897 -S "Processing of the Certificate handshake message failed"
1898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001899run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001900 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001901 "$O_CLI -key data_files/server5.key \
1902 -cert data_files/server5.eku-cs.crt" \
1903 0 \
1904 -s "bad certificate (usage extensions)" \
1905 -S "Processing of the Certificate handshake message failed"
1906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001907run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001908 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001909 "$O_CLI -key data_files/server5.key \
1910 -cert data_files/server5.eku-cs.crt" \
1911 1 \
1912 -s "bad certificate (usage extensions)" \
1913 -s "Processing of the Certificate handshake message failed"
1914
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001915# Tests for DHM parameters loading
1916
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001917run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001918 "$P_SRV" \
1919 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1920 debug_level=3" \
1921 0 \
1922 -c "value of 'DHM: P ' (2048 bits)" \
1923 -c "value of 'DHM: G ' (2048 bits)"
1924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001925run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001926 "$P_SRV dhm_file=data_files/dhparams.pem" \
1927 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1928 debug_level=3" \
1929 0 \
1930 -c "value of 'DHM: P ' (1024 bits)" \
1931 -c "value of 'DHM: G ' (2 bits)"
1932
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001933# Tests for PSK callback
1934
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001935run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001936 "$P_SRV psk=abc123 psk_identity=foo" \
1937 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1938 psk_identity=foo psk=abc123" \
1939 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001940 -S "SSL - The server has no ciphersuites in common" \
1941 -S "SSL - Unknown identity received" \
1942 -S "SSL - Verification of the message MAC failed"
1943
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001944run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001945 "$P_SRV" \
1946 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1947 psk_identity=foo psk=abc123" \
1948 1 \
1949 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001950 -S "SSL - Unknown identity received" \
1951 -S "SSL - Verification of the message MAC failed"
1952
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001953run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001954 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1955 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1956 psk_identity=foo psk=abc123" \
1957 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001958 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001959 -s "SSL - Unknown identity received" \
1960 -S "SSL - Verification of the message MAC failed"
1961
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001962run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001963 "$P_SRV psk_list=abc,dead,def,beef" \
1964 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1965 psk_identity=abc psk=dead" \
1966 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001967 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001968 -S "SSL - Unknown identity received" \
1969 -S "SSL - Verification of the message MAC failed"
1970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001971run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001972 "$P_SRV psk_list=abc,dead,def,beef" \
1973 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1974 psk_identity=def psk=beef" \
1975 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001976 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001977 -S "SSL - Unknown identity received" \
1978 -S "SSL - Verification of the message MAC failed"
1979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001980run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001981 "$P_SRV psk_list=abc,dead,def,beef" \
1982 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1983 psk_identity=ghi psk=beef" \
1984 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001985 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001986 -s "SSL - Unknown identity received" \
1987 -S "SSL - Verification of the message MAC failed"
1988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001989run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001990 "$P_SRV psk_list=abc,dead,def,beef" \
1991 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1992 psk_identity=abc psk=beef" \
1993 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001994 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001995 -S "SSL - Unknown identity received" \
1996 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001997
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001998# Tests for ciphersuites per version
1999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002000run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002001 "$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" \
2002 "$P_CLI force_version=ssl3" \
2003 0 \
2004 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002006run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002007 "$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" \
2008 "$P_CLI force_version=tls1" \
2009 0 \
2010 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002012run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002013 "$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" \
2014 "$P_CLI force_version=tls1_1" \
2015 0 \
2016 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2017
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002018run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002019 "$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" \
2020 "$P_CLI force_version=tls1_2" \
2021 0 \
2022 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2023
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002024# Tests for ssl_get_bytes_avail()
2025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002026run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002027 "$P_SRV" \
2028 "$P_CLI request_size=100" \
2029 0 \
2030 -s "Read from client: 100 bytes read$"
2031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002032run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002033 "$P_SRV" \
2034 "$P_CLI request_size=500" \
2035 0 \
2036 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002037
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002038# Tests for small packets
2039
2040run_test "Small packet SSLv3 BlockCipher" \
2041 "$P_SRV" \
2042 "$P_CLI request_size=1 force_version=ssl3 \
2043 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2044 0 \
2045 -s "Read from client: 1 bytes read"
2046
2047run_test "Small packet SSLv3 StreamCipher" \
2048 "$P_SRV" \
2049 "$P_CLI request_size=1 force_version=ssl3 \
2050 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2051 0 \
2052 -s "Read from client: 1 bytes read"
2053
2054run_test "Small packet TLS 1.0 BlockCipher" \
2055 "$P_SRV" \
2056 "$P_CLI request_size=1 force_version=tls1 \
2057 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2058 0 \
2059 -s "Read from client: 1 bytes read"
2060
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002061run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2062 "$P_SRV" \
2063 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2064 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2065 0 \
2066 -s "Read from client: 1 bytes read"
2067
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002068run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2069 "$P_SRV" \
2070 "$P_CLI request_size=1 force_version=tls1 \
2071 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2072 trunc_hmac=1" \
2073 0 \
2074 -s "Read from client: 1 bytes read"
2075
2076run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
2077 "$P_SRV" \
2078 "$P_CLI request_size=1 force_version=tls1 \
2079 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2080 trunc_hmac=1" \
2081 0 \
2082 -s "Read from client: 1 bytes read"
2083
2084run_test "Small packet TLS 1.1 BlockCipher" \
2085 "$P_SRV" \
2086 "$P_CLI request_size=1 force_version=tls1_1 \
2087 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2088 0 \
2089 -s "Read from client: 1 bytes read"
2090
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002091run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2092 "$P_SRV" \
2093 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2094 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2095 0 \
2096 -s "Read from client: 1 bytes read"
2097
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002098run_test "Small packet TLS 1.1 StreamCipher" \
2099 "$P_SRV" \
2100 "$P_CLI request_size=1 force_version=tls1_1 \
2101 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2102 0 \
2103 -s "Read from client: 1 bytes read"
2104
2105run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2106 "$P_SRV" \
2107 "$P_CLI request_size=1 force_version=tls1_1 \
2108 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2109 trunc_hmac=1" \
2110 0 \
2111 -s "Read from client: 1 bytes read"
2112
2113run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
2114 "$P_SRV" \
2115 "$P_CLI request_size=1 force_version=tls1_1 \
2116 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2117 trunc_hmac=1" \
2118 0 \
2119 -s "Read from client: 1 bytes read"
2120
2121run_test "Small packet TLS 1.2 BlockCipher" \
2122 "$P_SRV" \
2123 "$P_CLI request_size=1 force_version=tls1_2 \
2124 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2125 0 \
2126 -s "Read from client: 1 bytes read"
2127
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002128run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2129 "$P_SRV" \
2130 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2131 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2132 0 \
2133 -s "Read from client: 1 bytes read"
2134
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002135run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2136 "$P_SRV" \
2137 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
2138 0 \
2139 -s "Read from client: 1 bytes read"
2140
2141run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2142 "$P_SRV" \
2143 "$P_CLI request_size=1 force_version=tls1_2 \
2144 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2145 trunc_hmac=1" \
2146 0 \
2147 -s "Read from client: 1 bytes read"
2148
2149run_test "Small packet TLS 1.2 StreamCipher" \
2150 "$P_SRV" \
2151 "$P_CLI request_size=1 force_version=tls1_2 \
2152 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2153 0 \
2154 -s "Read from client: 1 bytes read"
2155
2156run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
2157 "$P_SRV" \
2158 "$P_CLI request_size=1 force_version=tls1_2 \
2159 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2160 trunc_hmac=1" \
2161 0 \
2162 -s "Read from client: 1 bytes read"
2163
2164run_test "Small packet TLS 1.2 AEAD" \
2165 "$P_SRV" \
2166 "$P_CLI request_size=1 force_version=tls1_2 \
2167 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2168 0 \
2169 -s "Read from client: 1 bytes read"
2170
2171run_test "Small packet TLS 1.2 AEAD shorter tag" \
2172 "$P_SRV" \
2173 "$P_CLI request_size=1 force_version=tls1_2 \
2174 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2175 0 \
2176 -s "Read from client: 1 bytes read"
2177
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002178# Test for large packets
2179
2180run_test "Large packet SSLv3 BlockCipher" \
2181 "$P_SRV" \
2182 "$P_CLI request_size=16384 force_version=ssl3 \
2183 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2184 0 \
2185 -s "Read from client: 16384 bytes read"
2186
2187run_test "Large packet SSLv3 StreamCipher" \
2188 "$P_SRV" \
2189 "$P_CLI request_size=16384 force_version=ssl3 \
2190 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2191 0 \
2192 -s "Read from client: 16384 bytes read"
2193
2194run_test "Large packet TLS 1.0 BlockCipher" \
2195 "$P_SRV" \
2196 "$P_CLI request_size=16384 force_version=tls1 \
2197 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2198 0 \
2199 -s "Read from client: 16384 bytes read"
2200
2201run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2202 "$P_SRV" \
2203 "$P_CLI request_size=16384 force_version=tls1 \
2204 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2205 trunc_hmac=1" \
2206 0 \
2207 -s "Read from client: 16384 bytes read"
2208
2209run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
2210 "$P_SRV" \
2211 "$P_CLI request_size=16384 force_version=tls1 \
2212 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2213 trunc_hmac=1" \
2214 0 \
2215 -s "Read from client: 16384 bytes read"
2216
2217run_test "Large packet TLS 1.1 BlockCipher" \
2218 "$P_SRV" \
2219 "$P_CLI request_size=16384 force_version=tls1_1 \
2220 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2221 0 \
2222 -s "Read from client: 16384 bytes read"
2223
2224run_test "Large packet TLS 1.1 StreamCipher" \
2225 "$P_SRV" \
2226 "$P_CLI request_size=16384 force_version=tls1_1 \
2227 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2228 0 \
2229 -s "Read from client: 16384 bytes read"
2230
2231run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2232 "$P_SRV" \
2233 "$P_CLI request_size=16384 force_version=tls1_1 \
2234 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2235 trunc_hmac=1" \
2236 0 \
2237 -s "Read from client: 16384 bytes read"
2238
2239run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
2240 "$P_SRV" \
2241 "$P_CLI request_size=16384 force_version=tls1_1 \
2242 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2243 trunc_hmac=1" \
2244 0 \
2245 -s "Read from client: 16384 bytes read"
2246
2247run_test "Large packet TLS 1.2 BlockCipher" \
2248 "$P_SRV" \
2249 "$P_CLI request_size=16384 force_version=tls1_2 \
2250 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2251 0 \
2252 -s "Read from client: 16384 bytes read"
2253
2254run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2255 "$P_SRV" \
2256 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
2257 0 \
2258 -s "Read from client: 16384 bytes read"
2259
2260run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2261 "$P_SRV" \
2262 "$P_CLI request_size=16384 force_version=tls1_2 \
2263 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2264 trunc_hmac=1" \
2265 0 \
2266 -s "Read from client: 16384 bytes read"
2267
2268run_test "Large packet TLS 1.2 StreamCipher" \
2269 "$P_SRV" \
2270 "$P_CLI request_size=16384 force_version=tls1_2 \
2271 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2272 0 \
2273 -s "Read from client: 16384 bytes read"
2274
2275run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
2276 "$P_SRV" \
2277 "$P_CLI request_size=16384 force_version=tls1_2 \
2278 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2279 trunc_hmac=1" \
2280 0 \
2281 -s "Read from client: 16384 bytes read"
2282
2283run_test "Large packet TLS 1.2 AEAD" \
2284 "$P_SRV" \
2285 "$P_CLI request_size=16384 force_version=tls1_2 \
2286 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2287 0 \
2288 -s "Read from client: 16384 bytes read"
2289
2290run_test "Large packet TLS 1.2 AEAD shorter tag" \
2291 "$P_SRV" \
2292 "$P_CLI request_size=16384 force_version=tls1_2 \
2293 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2294 0 \
2295 -s "Read from client: 16384 bytes read"
2296
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002297# Tests for DTLS HelloVerifyRequest
2298
2299run_test "DTLS cookie: enabled" \
2300 "$P_SRV dtls=1 debug_level=2" \
2301 "$P_CLI dtls=1 debug_level=2" \
2302 0 \
2303 -s "cookie verification failed" \
2304 -s "cookie verification passed" \
2305 -S "cookie verification skipped" \
2306 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002307 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002308 -S "SSL - The requested feature is not available"
2309
2310run_test "DTLS cookie: disabled" \
2311 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2312 "$P_CLI dtls=1 debug_level=2" \
2313 0 \
2314 -S "cookie verification failed" \
2315 -S "cookie verification passed" \
2316 -s "cookie verification skipped" \
2317 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002318 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002319 -S "SSL - The requested feature is not available"
2320
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002321run_test "DTLS cookie: default (failing)" \
2322 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2323 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2324 1 \
2325 -s "cookie verification failed" \
2326 -S "cookie verification passed" \
2327 -S "cookie verification skipped" \
2328 -C "received hello verify request" \
2329 -S "hello verification requested" \
2330 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002331
2332requires_ipv6
2333run_test "DTLS cookie: enabled, IPv6" \
2334 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2335 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2336 0 \
2337 -s "cookie verification failed" \
2338 -s "cookie verification passed" \
2339 -S "cookie verification skipped" \
2340 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002341 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002342 -S "SSL - The requested feature is not available"
2343
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002344run_test "DTLS cookie: enabled, nbio" \
2345 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2346 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2347 0 \
2348 -s "cookie verification failed" \
2349 -s "cookie verification passed" \
2350 -S "cookie verification skipped" \
2351 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002352 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002353 -S "SSL - The requested feature is not available"
2354
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002355# Tests for various cases of client authentication with DTLS
2356# (focused on handshake flows and message parsing)
2357
2358run_test "DTLS client auth: required" \
2359 "$P_SRV dtls=1 auth_mode=required" \
2360 "$P_CLI dtls=1" \
2361 0 \
2362 -s "Verifying peer X.509 certificate... ok"
2363
2364run_test "DTLS client auth: optional, client has no cert" \
2365 "$P_SRV dtls=1 auth_mode=optional" \
2366 "$P_CLI dtls=1 crt_file=none key_file=none" \
2367 0 \
2368 -s "! no client certificate sent"
2369
2370run_test "DTLS client auth: optional, client has no cert" \
2371 "$P_SRV dtls=1 auth_mode=none" \
2372 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2373 0 \
2374 -c "skip write certificate$" \
2375 -s "! no client certificate sent"
2376
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002377# Tests for receiving fragmented handshake messages with DTLS
2378
2379requires_gnutls
2380run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2381 "$G_SRV -u --mtu 2048 -a" \
2382 "$P_CLI dtls=1 debug_level=2" \
2383 0 \
2384 -C "found fragmented DTLS handshake message" \
2385 -C "error"
2386
2387requires_gnutls
2388run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2389 "$G_SRV -u --mtu 512" \
2390 "$P_CLI dtls=1 debug_level=2" \
2391 0 \
2392 -c "found fragmented DTLS handshake message" \
2393 -C "error"
2394
2395requires_gnutls
2396run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2397 "$G_SRV -u --mtu 128" \
2398 "$P_CLI dtls=1 debug_level=2" \
2399 0 \
2400 -c "found fragmented DTLS handshake message" \
2401 -C "error"
2402
2403requires_gnutls
2404run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2405 "$G_SRV -u --mtu 128" \
2406 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2407 0 \
2408 -c "found fragmented DTLS handshake message" \
2409 -C "error"
2410
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002411requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002412run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2413 "$G_SRV -u --mtu 256" \
2414 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2415 0 \
2416 -c "found fragmented DTLS handshake message" \
2417 -c "client hello, adding renegotiation extension" \
2418 -c "found renegotiation extension" \
2419 -c "=> renegotiate" \
2420 -C "ssl_handshake returned" \
2421 -C "error" \
2422 -s "Extra-header:"
2423
2424requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002425run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2426 "$G_SRV -u --mtu 256" \
2427 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2428 0 \
2429 -c "found fragmented DTLS handshake message" \
2430 -c "client hello, adding renegotiation extension" \
2431 -c "found renegotiation extension" \
2432 -c "=> renegotiate" \
2433 -C "ssl_handshake returned" \
2434 -C "error" \
2435 -s "Extra-header:"
2436
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002437run_test "DTLS reassembly: no fragmentation (openssl server)" \
2438 "$O_SRV -dtls1 -mtu 2048" \
2439 "$P_CLI dtls=1 debug_level=2" \
2440 0 \
2441 -C "found fragmented DTLS handshake message" \
2442 -C "error"
2443
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002444run_test "DTLS reassembly: some fragmentation (openssl server)" \
2445 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002446 "$P_CLI dtls=1 debug_level=2" \
2447 0 \
2448 -c "found fragmented DTLS handshake message" \
2449 -C "error"
2450
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002451run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002452 "$O_SRV -dtls1 -mtu 256" \
2453 "$P_CLI dtls=1 debug_level=2" \
2454 0 \
2455 -c "found fragmented DTLS handshake message" \
2456 -C "error"
2457
2458run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2459 "$O_SRV -dtls1 -mtu 256" \
2460 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2461 0 \
2462 -c "found fragmented DTLS handshake message" \
2463 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002464
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002465# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002466
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002467not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002468run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002469 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002470 "$P_SRV dtls=1 debug_level=2" \
2471 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002472 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002473 -C "replayed record" \
2474 -S "replayed record" \
2475 -C "record from another epoch" \
2476 -S "record from another epoch" \
2477 -C "discarding invalid record" \
2478 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002479 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002480 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002481 -c "HTTP/1.0 200 OK"
2482
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002483not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002484run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002485 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002486 "$P_SRV dtls=1 debug_level=2" \
2487 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002488 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002489 -c "replayed record" \
2490 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002491 -c "discarding invalid record" \
2492 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002493 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002494 -s "Extra-header:" \
2495 -c "HTTP/1.0 200 OK"
2496
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002497run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2498 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002499 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2500 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002501 0 \
2502 -c "replayed record" \
2503 -S "replayed record" \
2504 -c "discarding invalid record" \
2505 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002506 -c "resend" \
2507 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002508 -s "Extra-header:" \
2509 -c "HTTP/1.0 200 OK"
2510
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002511run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002512 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002513 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002514 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002515 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002516 -c "discarding invalid record (mac)" \
2517 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002518 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002519 -c "HTTP/1.0 200 OK" \
2520 -S "too many records with bad MAC" \
2521 -S "Verification of the message MAC failed"
2522
2523run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
2524 -p "$P_PXY bad_ad=1" \
2525 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
2526 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2527 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002528 -C "discarding invalid record (mac)" \
2529 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002530 -S "Extra-header:" \
2531 -C "HTTP/1.0 200 OK" \
2532 -s "too many records with bad MAC" \
2533 -s "Verification of the message MAC failed"
2534
2535run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
2536 -p "$P_PXY bad_ad=1" \
2537 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
2538 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2539 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002540 -c "discarding invalid record (mac)" \
2541 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002542 -s "Extra-header:" \
2543 -c "HTTP/1.0 200 OK" \
2544 -S "too many records with bad MAC" \
2545 -S "Verification of the message MAC failed"
2546
2547run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
2548 -p "$P_PXY bad_ad=1" \
2549 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
2550 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
2551 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002552 -c "discarding invalid record (mac)" \
2553 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002554 -s "Extra-header:" \
2555 -c "HTTP/1.0 200 OK" \
2556 -s "too many records with bad MAC" \
2557 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002558
2559run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002560 -p "$P_PXY delay_ccs=1" \
2561 "$P_SRV dtls=1 debug_level=1" \
2562 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002563 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002564 -c "record from another epoch" \
2565 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002566 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002567 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002568 -s "Extra-header:" \
2569 -c "HTTP/1.0 200 OK"
2570
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002571# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002572
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002573needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002574run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002575 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002576 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2577 psk=abc123" \
2578 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002579 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2580 0 \
2581 -s "Extra-header:" \
2582 -c "HTTP/1.0 200 OK"
2583
2584needs_more_time 2
2585run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
2586 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002587 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2588 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002589 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2590 0 \
2591 -s "Extra-header:" \
2592 -c "HTTP/1.0 200 OK"
2593
2594needs_more_time 2
2595run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
2596 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002597 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2598 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002599 0 \
2600 -s "Extra-header:" \
2601 -c "HTTP/1.0 200 OK"
2602
2603needs_more_time 2
2604run_test "DTLS proxy: 3d, FS, client auth" \
2605 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002606 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
2607 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002608 0 \
2609 -s "Extra-header:" \
2610 -c "HTTP/1.0 200 OK"
2611
2612needs_more_time 2
2613run_test "DTLS proxy: 3d, FS, ticket" \
2614 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002615 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
2616 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002617 0 \
2618 -s "Extra-header:" \
2619 -c "HTTP/1.0 200 OK"
2620
2621needs_more_time 2
2622run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
2623 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002624 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
2625 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002626 0 \
2627 -s "Extra-header:" \
2628 -c "HTTP/1.0 200 OK"
2629
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002630needs_more_time 2
2631run_test "DTLS proxy: 3d, max handshake, nbio" \
2632 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002633 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
2634 auth_mode=required" \
2635 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002636 0 \
2637 -s "Extra-header:" \
2638 -c "HTTP/1.0 200 OK"
2639
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002640needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02002641run_test "DTLS proxy: 3d, min handshake, resumption" \
2642 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2643 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2644 psk=abc123 debug_level=3" \
2645 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2646 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2647 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2648 0 \
2649 -s "a session has been resumed" \
2650 -c "a session has been resumed" \
2651 -s "Extra-header:" \
2652 -c "HTTP/1.0 200 OK"
2653
2654needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02002655run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
2656 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2657 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2658 psk=abc123 debug_level=3 nbio=2" \
2659 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2660 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2661 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
2662 0 \
2663 -s "a session has been resumed" \
2664 -c "a session has been resumed" \
2665 -s "Extra-header:" \
2666 -c "HTTP/1.0 200 OK"
2667
2668needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002669run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002670 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002671 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2672 psk=abc123 renegotiation=1 debug_level=2" \
2673 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2674 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002675 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2676 0 \
2677 -c "=> renegotiate" \
2678 -s "=> renegotiate" \
2679 -s "Extra-header:" \
2680 -c "HTTP/1.0 200 OK"
2681
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002682needs_more_time 4
2683run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
2684 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002685 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2686 psk=abc123 renegotiation=1 debug_level=2" \
2687 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2688 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002689 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2690 0 \
2691 -c "=> renegotiate" \
2692 -s "=> renegotiate" \
2693 -s "Extra-header:" \
2694 -c "HTTP/1.0 200 OK"
2695
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002696needs_more_time 4
2697run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02002698 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002699 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02002700 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002701 debug_level=2" \
2702 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02002703 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002704 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2705 0 \
2706 -c "=> renegotiate" \
2707 -s "=> renegotiate" \
2708 -s "Extra-header:" \
2709 -c "HTTP/1.0 200 OK"
2710
2711needs_more_time 4
2712run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02002713 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002714 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02002715 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002716 debug_level=2 nbio=2" \
2717 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02002718 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002719 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2720 0 \
2721 -c "=> renegotiate" \
2722 -s "=> renegotiate" \
2723 -s "Extra-header:" \
2724 -c "HTTP/1.0 200 OK"
2725
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002726needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002727run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02002728 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
2729 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02002730 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02002731 0 \
2732 -s "Extra-header:" \
2733 -c "HTTP/1.0 200 OK"
2734
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002735needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002736run_test "DTLS proxy: 3d, openssl server, fragmentation" \
2737 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
2738 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02002739 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002740 0 \
2741 -s "Extra-header:" \
2742 -c "HTTP/1.0 200 OK"
2743
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002744needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002745run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
2746 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
2747 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02002748 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002749 0 \
2750 -s "Extra-header:" \
2751 -c "HTTP/1.0 200 OK"
2752
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002753needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002754run_test "DTLS proxy: 3d, gnutls server" \
2755 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2756 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02002757 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002758 0 \
2759 -s "Extra-header:" \
2760 -c "Extra-header:"
2761
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002762needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002763run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
2764 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2765 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02002766 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002767 0 \
2768 -s "Extra-header:" \
2769 -c "Extra-header:"
2770
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002771needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002772run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
2773 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2774 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02002775 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002776 0 \
2777 -s "Extra-header:" \
2778 -c "Extra-header:"
2779
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002780# Final report
2781
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002782echo "------------------------------------------------------------------------"
2783
2784if [ $FAILS = 0 ]; then
2785 echo -n "PASSED"
2786else
2787 echo -n "FAILED"
2788fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002789PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002790echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002791
2792exit $FAILS