blob: 6d24a61d8237d18a90b1d3b25d56317c6a74eeb0 [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"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010024G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010025
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010026TESTS=0
27FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020028SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010029
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020030CONFIG_H='../include/polarssl/config.h'
31
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010032MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010033FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020034EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010035
36print_usage() {
37 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010038 printf " -h|--help\tPrint this help.\n"
39 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
40 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
41 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010042}
43
44get_options() {
45 while [ $# -gt 0 ]; do
46 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010047 -f|--filter)
48 shift; FILTER=$1
49 ;;
50 -e|--exclude)
51 shift; EXCLUDE=$1
52 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010053 -m|--memcheck)
54 MEMCHECK=1
55 ;;
56 -h|--help)
57 print_usage
58 exit 0
59 ;;
60 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020061 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 print_usage
63 exit 1
64 ;;
65 esac
66 shift
67 done
68}
69
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020070# skip next test if OpenSSL can't send SSLv2 ClientHello
71requires_openssl_with_sslv2() {
72 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020073 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020074 OPENSSL_HAS_SSL2="YES"
75 else
76 OPENSSL_HAS_SSL2="NO"
77 fi
78 fi
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +020079
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020080 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
81 SKIP_NEXT="YES"
82 fi
83}
84
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020085# skip next test if OpenSSL doesn't support FALLBACK_SCSV
86requires_openssl_with_fallback_scsv() {
87 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
88 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
89 then
90 OPENSSL_HAS_FBSCSV="YES"
91 else
92 OPENSSL_HAS_FBSCSV="NO"
93 fi
94 fi
95 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
96 SKIP_NEXT="YES"
97 fi
98}
99
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200100# skip next test if GnuTLS isn't available
101requires_gnutls() {
102 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
103 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
104 GNUTLS_AVAILABLE="YES"
105 else
106 GNUTLS_AVAILABLE="NO"
107 fi
108 fi
109 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
110 SKIP_NEXT="YES"
111 fi
112}
113
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200114# skip next test if IPv6 isn't available on this host
115requires_ipv6() {
116 if [ -z "${HAS_IPV6:-}" ]; then
117 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
118 SRV_PID=$!
119 sleep 1
120 kill $SRV_PID >/dev/null 2>&1
121 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
122 HAS_IPV6="NO"
123 else
124 HAS_IPV6="YES"
125 fi
126 rm -r $SRV_OUT
127 fi
128
129 if [ "$HAS_IPV6" = "NO" ]; then
130 SKIP_NEXT="YES"
131 fi
132}
133
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200134# skip the next test if valgrind is in use
135not_with_valgrind() {
136 if [ "$MEMCHECK" -gt 0 ]; then
137 SKIP_NEXT="YES"
138 fi
139}
140
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200141# multiply the client timeout delay by the given factor for the next test
142needs_more_time() {
143 CLI_DELAY_FACTOR=$1
144}
145
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100146# print_name <name>
147print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100148 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200149 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100150 for i in `seq 1 $LEN`; do printf '.'; done
151 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100152
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200153 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100154}
155
156# fail <message>
157fail() {
158 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100159 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100160
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200161 mv $SRV_OUT o-srv-${TESTS}.log
162 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200163 if [ -n "$PXY_CMD" ]; then
164 mv $PXY_OUT o-pxy-${TESTS}.log
165 fi
166 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100167
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200168 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
169 echo " ! server output:"
170 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200171 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200172 echo " ! client output:"
173 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200174 if [ -n "$PXY_CMD" ]; then
175 echo " ! ========================================================"
176 echo " ! proxy output:"
177 cat o-pxy-${TESTS}.log
178 fi
179 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200180 fi
181
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200182 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100183}
184
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100185# is_polar <cmd_line>
186is_polar() {
187 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
188}
189
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200190# openssl s_server doesn't have -www with DTLS
191check_osrv_dtls() {
192 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
193 NEEDS_INPUT=1
194 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
195 else
196 NEEDS_INPUT=0
197 fi
198}
199
200# provide input to commands that need it
201provide_input() {
202 if [ $NEEDS_INPUT -eq 0 ]; then
203 return
204 fi
205
206 while true; do
207 echo "HTTP/1.0 200 OK"
208 sleep 1
209 done
210}
211
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100212# has_mem_err <log_file_name>
213has_mem_err() {
214 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
215 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
216 then
217 return 1 # false: does not have errors
218 else
219 return 0 # true: has errors
220 fi
221}
222
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200223# wait for server to start: two versions depending on lsof availability
224wait_server_start() {
225 if which lsof >/dev/null; then
226 # make sure we don't loop forever
227 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200228 DOG_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200229
230 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200231 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnarda65d5082015-01-12 14:54:55 +0100232 until lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null;
233 do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200234 else
Manuel Pégourié-Gonnarda65d5082015-01-12 14:54:55 +0100235 until lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null;
236 do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200237 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200238
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200239 kill $DOG_PID >/dev/null 2>&1
240 wait $DOG_PID
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200241 else
242 sleep "$START_DELAY"
243 fi
244}
245
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200246# wait for client to terminate and set CLI_EXIT
247# must be called right after starting the client
248wait_client_done() {
249 CLI_PID=$!
250
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200251 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
252 CLI_DELAY_FACTOR=1
253
254 ( sleep $CLI_DELAY; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200255 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200256
257 wait $CLI_PID
258 CLI_EXIT=$?
259
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200260 kill $DOG_PID >/dev/null 2>&1
261 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200262
263 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
264}
265
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200266# check if the given command uses dtls and sets global variable DTLS
267detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200268 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200269 DTLS=1
270 else
271 DTLS=0
272 fi
273}
274
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200275# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100276# Options: -s pattern pattern that must be present in server output
277# -c pattern pattern that must be present in client output
278# -S pattern pattern that must be absent in server output
279# -C pattern pattern that must be absent in client output
280run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100281 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200282 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100283
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100284 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
285 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200286 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100287 return
288 fi
289
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100290 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100291
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200292 # should we skip?
293 if [ "X$SKIP_NEXT" = "XYES" ]; then
294 SKIP_NEXT="NO"
295 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200296 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200297 return
298 fi
299
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200300 # does this test use a proxy?
301 if [ "X$1" = "X-p" ]; then
302 PXY_CMD="$2"
303 shift 2
304 else
305 PXY_CMD=""
306 fi
307
308 # get commands and client output
309 SRV_CMD="$1"
310 CLI_CMD="$2"
311 CLI_EXPECT="$3"
312 shift 3
313
314 # fix client port
315 if [ -n "$PXY_CMD" ]; then
316 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
317 else
318 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
319 fi
320
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200321 # update DTLS variable
322 detect_dtls "$SRV_CMD"
323
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100324 # prepend valgrind to our commands if active
325 if [ "$MEMCHECK" -gt 0 ]; then
326 if is_polar "$SRV_CMD"; then
327 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
328 fi
329 if is_polar "$CLI_CMD"; then
330 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
331 fi
332 fi
333
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100334 # run the commands
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200335 if [ -n "$PXY_CMD" ]; then
336 echo "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200337 $PXY_CMD >> $PXY_OUT 2>&1 &
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200338 PXY_PID=$!
339 # assume proxy starts faster than server
340 fi
341
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200342 check_osrv_dtls
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200343 echo "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200344 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100345 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200346 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200347
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200348 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200349 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
350 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100351
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200352 # terminate the server (and the proxy)
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200353 kill $SRV_PID
354 wait $SRV_PID
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200355 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200356 kill $PXY_PID >/dev/null 2>&1
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200357 wait $PXY_PID
358 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100359
360 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200361 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100362 # expected client exit to incorrectly succeed in case of catastrophic
363 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100364 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200365 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100366 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100367 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100368 return
369 fi
370 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100371 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200372 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100373 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100374 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100375 return
376 fi
377 fi
378
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100379 # check server exit code
380 if [ $? != 0 ]; then
381 fail "server fail"
382 return
383 fi
384
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100385 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100386 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
387 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100388 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200389 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100390 return
391 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100392
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100393 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200394 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100395 while [ $# -gt 0 ]
396 do
397 case $1 in
398 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200399 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100400 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100401 return
402 fi
403 ;;
404
405 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200406 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100407 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100408 return
409 fi
410 ;;
411
412 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200413 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100414 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100415 return
416 fi
417 ;;
418
419 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200420 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100421 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100422 return
423 fi
424 ;;
425
426 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200427 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100428 exit 1
429 esac
430 shift 2
431 done
432
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100433 # check valgrind's results
434 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200435 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100436 fail "Server has memory errors"
437 return
438 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200439 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100440 fail "Client has memory errors"
441 return
442 fi
443 fi
444
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100445 # if we're here, everything is ok
446 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200447 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100448}
449
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100450cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200451 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200452 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
453 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
454 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
455 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100456 exit 1
457}
458
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100459#
460# MAIN
461#
462
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100463get_options "$@"
464
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100465# sanity checks, avoid an avalanche of errors
466if [ ! -x "$P_SRV" ]; then
467 echo "Command '$P_SRV' is not an executable file"
468 exit 1
469fi
470if [ ! -x "$P_CLI" ]; then
471 echo "Command '$P_CLI' is not an executable file"
472 exit 1
473fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200474if [ ! -x "$P_PXY" ]; then
475 echo "Command '$P_PXY' is not an executable file"
476 exit 1
477fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100478if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
479 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100480 exit 1
481fi
482
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200483# used by watchdog
484MAIN_PID="$$"
485
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200486# be more patient with valgrind
487if [ "$MEMCHECK" -gt 0 ]; then
488 START_DELAY=3
489 DOG_DELAY=30
490else
491 START_DELAY=1
492 DOG_DELAY=10
493fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200494CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200495
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200496# Pick a "unique" server port in the range 10000-19999, and a proxy port
497PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000498PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200499SRV_PORT="1$PORT_BASE"
500PXY_PORT="2$PORT_BASE"
501unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200502
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200503# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000504# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200505P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
506P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
507P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
508O_SRV="$O_SRV -accept $SRV_PORT"
509O_CLI="$O_CLI -connect localhost:+SRV_PORT"
510G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000511G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200512
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200513# Also pick a unique name for intermediate files
514SRV_OUT="srv_out.$$"
515CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200516PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200517SESSION="session.$$"
518
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200519SKIP_NEXT="NO"
520
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100521trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100522
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200523# Basic test
524
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200525# Checks that:
526# - things work with all ciphersuites active (used with config-full in all.sh)
527# - the expected (highest security) parameters are selected
528# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200529run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200530 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200531 "$P_CLI" \
532 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200533 -s "Protocol is TLSv1.2" \
534 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
535 -s "client hello v3, signature_algorithm ext: 6" \
536 -s "ECDHE curve: secp521r1" \
537 -S "error" \
538 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200539
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000540run_test "Default, DTLS" \
541 "$P_SRV dtls=1" \
542 "$P_CLI dtls=1" \
543 0 \
544 -s "Protocol is DTLSv1.2" \
545 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
546
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100547# Tests for rc4 option
548
549run_test "RC4: server disabled, client enabled" \
550 "$P_SRV" \
551 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
552 1 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100553 -s "SSL - None of the common ciphersuites is usable"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100554
555run_test "RC4: server enabled, client disabled" \
556 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
557 "$P_CLI" \
558 1 \
559 -s "SSL - The server has no ciphersuites in common"
560
561run_test "RC4: both enabled" \
562 "$P_SRV arc4=1" \
563 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
564 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100565 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100566 -S "SSL - The server has no ciphersuites in common"
567
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100568# Test for SSLv2 ClientHello
569
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200570requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200571run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100572 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100573 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100574 0 \
575 -S "parse client hello v2" \
576 -S "ssl_handshake returned"
577
578# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200579requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200580run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200581 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100582 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100583 0 \
584 -s "parse client hello v2" \
585 -S "ssl_handshake returned"
586
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100587# Tests for Truncated HMAC extension
588
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100589run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200590 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100591 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100592 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100593 -s "dumping 'computed mac' (20 bytes)" \
594 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100595
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100596run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200597 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100598 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
599 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100600 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100601 -s "dumping 'computed mac' (20 bytes)" \
602 -S "dumping 'computed mac' (10 bytes)"
603
604run_test "Truncated HMAC: client enabled, server default" \
605 "$P_SRV debug_level=4" \
606 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
607 trunc_hmac=1" \
608 0 \
609 -S "dumping 'computed mac' (20 bytes)" \
610 -s "dumping 'computed mac' (10 bytes)"
611
612run_test "Truncated HMAC: client enabled, server disabled" \
613 "$P_SRV debug_level=4 trunc_hmac=0" \
614 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
615 trunc_hmac=1" \
616 0 \
617 -s "dumping 'computed mac' (20 bytes)" \
618 -S "dumping 'computed mac' (10 bytes)"
619
620run_test "Truncated HMAC: client enabled, server enabled" \
621 "$P_SRV debug_level=4 trunc_hmac=1" \
622 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
623 trunc_hmac=1" \
624 0 \
625 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100626 -s "dumping 'computed mac' (10 bytes)"
627
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100628# Tests for Encrypt-then-MAC extension
629
630run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100631 "$P_SRV debug_level=3 \
632 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100633 "$P_CLI debug_level=3" \
634 0 \
635 -c "client hello, adding encrypt_then_mac extension" \
636 -s "found encrypt then mac extension" \
637 -s "server hello, adding encrypt then mac extension" \
638 -c "found encrypt_then_mac extension" \
639 -c "using encrypt then mac" \
640 -s "using encrypt then mac"
641
642run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100643 "$P_SRV debug_level=3 etm=0 \
644 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100645 "$P_CLI debug_level=3 etm=1" \
646 0 \
647 -c "client hello, adding encrypt_then_mac extension" \
648 -s "found encrypt then mac extension" \
649 -S "server hello, adding encrypt then mac extension" \
650 -C "found encrypt_then_mac extension" \
651 -C "using encrypt then mac" \
652 -S "using encrypt then mac"
653
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100654run_test "Encrypt then MAC: client enabled, aead cipher" \
655 "$P_SRV debug_level=3 etm=1 \
656 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
657 "$P_CLI debug_level=3 etm=1" \
658 0 \
659 -c "client hello, adding encrypt_then_mac extension" \
660 -s "found encrypt then mac extension" \
661 -S "server hello, adding encrypt then mac extension" \
662 -C "found encrypt_then_mac extension" \
663 -C "using encrypt then mac" \
664 -S "using encrypt then mac"
665
666run_test "Encrypt then MAC: client enabled, stream cipher" \
667 "$P_SRV debug_level=3 etm=1 \
668 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100669 "$P_CLI debug_level=3 etm=1 arc4=1" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100670 0 \
671 -c "client hello, adding encrypt_then_mac extension" \
672 -s "found encrypt then mac extension" \
673 -S "server hello, adding encrypt then mac extension" \
674 -C "found encrypt_then_mac extension" \
675 -C "using encrypt then mac" \
676 -S "using encrypt then mac"
677
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100678run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100679 "$P_SRV debug_level=3 etm=1 \
680 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100681 "$P_CLI debug_level=3 etm=0" \
682 0 \
683 -C "client hello, adding encrypt_then_mac extension" \
684 -S "found encrypt then mac extension" \
685 -S "server hello, adding encrypt then mac extension" \
686 -C "found encrypt_then_mac extension" \
687 -C "using encrypt then mac" \
688 -S "using encrypt then mac"
689
690run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100691 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100692 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100693 "$P_CLI debug_level=3 force_version=ssl3" \
694 0 \
695 -C "client hello, adding encrypt_then_mac extension" \
696 -S "found encrypt then mac extension" \
697 -S "server hello, adding encrypt then mac extension" \
698 -C "found encrypt_then_mac extension" \
699 -C "using encrypt then mac" \
700 -S "using encrypt then mac"
701
702run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100703 "$P_SRV debug_level=3 force_version=ssl3 \
704 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100705 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100706 0 \
707 -c "client hello, adding encrypt_then_mac extension" \
708 -s "found encrypt then mac extension" \
709 -S "server hello, adding encrypt then mac extension" \
710 -C "found encrypt_then_mac extension" \
711 -C "using encrypt then mac" \
712 -S "using encrypt then mac"
713
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200714# Tests for Extended Master Secret extension
715
716run_test "Extended Master Secret: default" \
717 "$P_SRV debug_level=3" \
718 "$P_CLI debug_level=3" \
719 0 \
720 -c "client hello, adding extended_master_secret extension" \
721 -s "found extended master secret extension" \
722 -s "server hello, adding extended master secret extension" \
723 -c "found extended_master_secret extension" \
724 -c "using extended master secret" \
725 -s "using extended master secret"
726
727run_test "Extended Master Secret: client enabled, server disabled" \
728 "$P_SRV debug_level=3 extended_ms=0" \
729 "$P_CLI debug_level=3 extended_ms=1" \
730 0 \
731 -c "client hello, adding extended_master_secret extension" \
732 -s "found extended master secret extension" \
733 -S "server hello, adding extended master secret extension" \
734 -C "found extended_master_secret extension" \
735 -C "using extended master secret" \
736 -S "using extended master secret"
737
738run_test "Extended Master Secret: client disabled, server enabled" \
739 "$P_SRV debug_level=3 extended_ms=1" \
740 "$P_CLI debug_level=3 extended_ms=0" \
741 0 \
742 -C "client hello, adding extended_master_secret extension" \
743 -S "found extended master secret extension" \
744 -S "server hello, adding extended master secret extension" \
745 -C "found extended_master_secret extension" \
746 -C "using extended master secret" \
747 -S "using extended master secret"
748
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200749run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100750 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200751 "$P_CLI debug_level=3 force_version=ssl3" \
752 0 \
753 -C "client hello, adding extended_master_secret extension" \
754 -S "found extended master secret extension" \
755 -S "server hello, adding extended master secret extension" \
756 -C "found extended_master_secret extension" \
757 -C "using extended master secret" \
758 -S "using extended master secret"
759
760run_test "Extended Master Secret: client enabled, server SSLv3" \
761 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100762 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200763 0 \
764 -c "client hello, adding extended_master_secret extension" \
765 -s "found extended master secret extension" \
766 -S "server hello, adding extended master secret extension" \
767 -C "found extended_master_secret extension" \
768 -C "using extended master secret" \
769 -S "using extended master secret"
770
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200771# Tests for FALLBACK_SCSV
772
773run_test "Fallback SCSV: default" \
774 "$P_SRV" \
775 "$P_CLI debug_level=3 force_version=tls1_1" \
776 0 \
777 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200778 -S "received FALLBACK_SCSV" \
779 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200780 -C "is a fatal alert message (msg 86)"
781
782run_test "Fallback SCSV: explicitly disabled" \
783 "$P_SRV" \
784 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
785 0 \
786 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200787 -S "received FALLBACK_SCSV" \
788 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200789 -C "is a fatal alert message (msg 86)"
790
791run_test "Fallback SCSV: enabled" \
792 "$P_SRV" \
793 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200794 1 \
795 -c "adding FALLBACK_SCSV" \
796 -s "received FALLBACK_SCSV" \
797 -s "inapropriate fallback" \
798 -c "is a fatal alert message (msg 86)"
799
800run_test "Fallback SCSV: enabled, max version" \
801 "$P_SRV" \
802 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200803 0 \
804 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200805 -s "received FALLBACK_SCSV" \
806 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200807 -C "is a fatal alert message (msg 86)"
808
809requires_openssl_with_fallback_scsv
810run_test "Fallback SCSV: default, openssl server" \
811 "$O_SRV" \
812 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
813 0 \
814 -C "adding FALLBACK_SCSV" \
815 -C "is a fatal alert message (msg 86)"
816
817requires_openssl_with_fallback_scsv
818run_test "Fallback SCSV: enabled, openssl server" \
819 "$O_SRV" \
820 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
821 1 \
822 -c "adding FALLBACK_SCSV" \
823 -c "is a fatal alert message (msg 86)"
824
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200825requires_openssl_with_fallback_scsv
826run_test "Fallback SCSV: disabled, openssl client" \
827 "$P_SRV" \
828 "$O_CLI -tls1_1" \
829 0 \
830 -S "received FALLBACK_SCSV" \
831 -S "inapropriate fallback"
832
833requires_openssl_with_fallback_scsv
834run_test "Fallback SCSV: enabled, openssl client" \
835 "$P_SRV" \
836 "$O_CLI -tls1_1 -fallback_scsv" \
837 1 \
838 -s "received FALLBACK_SCSV" \
839 -s "inapropriate fallback"
840
841requires_openssl_with_fallback_scsv
842run_test "Fallback SCSV: enabled, max version, openssl client" \
843 "$P_SRV" \
844 "$O_CLI -fallback_scsv" \
845 0 \
846 -s "received FALLBACK_SCSV" \
847 -S "inapropriate fallback"
848
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100849# Tests for CBC 1/n-1 record splitting
850
851run_test "CBC Record splitting: TLS 1.2, no splitting" \
852 "$P_SRV" \
853 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
854 request_size=123 force_version=tls1_2" \
855 0 \
856 -s "Read from client: 123 bytes read" \
857 -S "Read from client: 1 bytes read" \
858 -S "122 bytes read"
859
860run_test "CBC Record splitting: TLS 1.1, no splitting" \
861 "$P_SRV" \
862 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
863 request_size=123 force_version=tls1_1" \
864 0 \
865 -s "Read from client: 123 bytes read" \
866 -S "Read from client: 1 bytes read" \
867 -S "122 bytes read"
868
869run_test "CBC Record splitting: TLS 1.0, splitting" \
870 "$P_SRV" \
871 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
872 request_size=123 force_version=tls1" \
873 0 \
874 -S "Read from client: 123 bytes read" \
875 -s "Read from client: 1 bytes read" \
876 -s "122 bytes read"
877
878run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100879 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100880 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
881 request_size=123 force_version=ssl3" \
882 0 \
883 -S "Read from client: 123 bytes read" \
884 -s "Read from client: 1 bytes read" \
885 -s "122 bytes read"
886
887run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100888 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100889 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
890 request_size=123 force_version=tls1" \
891 0 \
892 -s "Read from client: 123 bytes read" \
893 -S "Read from client: 1 bytes read" \
894 -S "122 bytes read"
895
896run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
897 "$P_SRV" \
898 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
899 request_size=123 force_version=tls1 recsplit=0" \
900 0 \
901 -s "Read from client: 123 bytes read" \
902 -S "Read from client: 1 bytes read" \
903 -S "122 bytes read"
904
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100905run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
906 "$P_SRV nbio=2" \
907 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
908 request_size=123 force_version=tls1" \
909 0 \
910 -S "Read from client: 123 bytes read" \
911 -s "Read from client: 1 bytes read" \
912 -s "122 bytes read"
913
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100914# Tests for Session Tickets
915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200916run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200917 "$P_SRV debug_level=3 tickets=1" \
918 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100919 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100920 -c "client hello, adding session ticket extension" \
921 -s "found session ticket extension" \
922 -s "server hello, adding session ticket extension" \
923 -c "found session_ticket extension" \
924 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100925 -S "session successfully restored from cache" \
926 -s "session successfully restored from ticket" \
927 -s "a session has been resumed" \
928 -c "a session has been resumed"
929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200930run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200931 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
932 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100933 0 \
934 -c "client hello, adding session ticket extension" \
935 -s "found session ticket extension" \
936 -s "server hello, adding session ticket extension" \
937 -c "found session_ticket extension" \
938 -c "parse new session ticket" \
939 -S "session successfully restored from cache" \
940 -s "session successfully restored from ticket" \
941 -s "a session has been resumed" \
942 -c "a session has been resumed"
943
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200944run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200945 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
946 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100947 0 \
948 -c "client hello, adding session ticket extension" \
949 -s "found session ticket extension" \
950 -s "server hello, adding session ticket extension" \
951 -c "found session_ticket extension" \
952 -c "parse new session ticket" \
953 -S "session successfully restored from cache" \
954 -S "session successfully restored from ticket" \
955 -S "a session has been resumed" \
956 -C "a session has been resumed"
957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200958run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100959 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200960 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100961 0 \
962 -c "client hello, adding session ticket extension" \
963 -c "found session_ticket extension" \
964 -c "parse new session ticket" \
965 -c "a session has been resumed"
966
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200967run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200968 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200969 "( $O_CLI -sess_out $SESSION; \
970 $O_CLI -sess_in $SESSION; \
971 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100972 0 \
973 -s "found session ticket extension" \
974 -s "server hello, adding session ticket extension" \
975 -S "session successfully restored from cache" \
976 -s "session successfully restored from ticket" \
977 -s "a session has been resumed"
978
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100979# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200981run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200982 "$P_SRV debug_level=3 tickets=0" \
983 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100984 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100985 -c "client hello, adding session ticket extension" \
986 -s "found session ticket extension" \
987 -S "server hello, adding session ticket extension" \
988 -C "found session_ticket extension" \
989 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100990 -s "session successfully restored from cache" \
991 -S "session successfully restored from ticket" \
992 -s "a session has been resumed" \
993 -c "a session has been resumed"
994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200995run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200996 "$P_SRV debug_level=3 tickets=1" \
997 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100998 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100999 -C "client hello, adding session ticket extension" \
1000 -S "found session ticket extension" \
1001 -S "server hello, adding session ticket extension" \
1002 -C "found session_ticket extension" \
1003 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001004 -s "session successfully restored from cache" \
1005 -S "session successfully restored from ticket" \
1006 -s "a session has been resumed" \
1007 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001008
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001009run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001010 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1011 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001012 0 \
1013 -S "session successfully restored from cache" \
1014 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001015 -S "a session has been resumed" \
1016 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001017
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001018run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001019 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1020 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001021 0 \
1022 -s "session successfully restored from cache" \
1023 -S "session successfully restored from ticket" \
1024 -s "a session has been resumed" \
1025 -c "a session has been resumed"
1026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001027run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001028 "$P_SRV debug_level=3 tickets=0" \
1029 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001030 0 \
1031 -s "session successfully restored from cache" \
1032 -S "session successfully restored from ticket" \
1033 -s "a session has been resumed" \
1034 -c "a session has been resumed"
1035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001036run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001037 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1038 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001039 0 \
1040 -S "session successfully restored from cache" \
1041 -S "session successfully restored from ticket" \
1042 -S "a session has been resumed" \
1043 -C "a session has been resumed"
1044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001045run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001046 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1047 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001048 0 \
1049 -s "session successfully restored from cache" \
1050 -S "session successfully restored from ticket" \
1051 -s "a session has been resumed" \
1052 -c "a session has been resumed"
1053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001054run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001055 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001056 "( $O_CLI -sess_out $SESSION; \
1057 $O_CLI -sess_in $SESSION; \
1058 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001059 0 \
1060 -s "found session ticket extension" \
1061 -S "server hello, adding session ticket extension" \
1062 -s "session successfully restored from cache" \
1063 -S "session successfully restored from ticket" \
1064 -s "a session has been resumed"
1065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001066run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001067 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001068 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001069 0 \
1070 -C "found session_ticket extension" \
1071 -C "parse new session ticket" \
1072 -c "a session has been resumed"
1073
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001074# Tests for Max Fragment Length extension
1075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001076run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001077 "$P_SRV debug_level=3" \
1078 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001079 0 \
1080 -C "client hello, adding max_fragment_length extension" \
1081 -S "found max fragment length extension" \
1082 -S "server hello, max_fragment_length extension" \
1083 -C "found max_fragment_length extension"
1084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001085run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001086 "$P_SRV debug_level=3" \
1087 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001088 0 \
1089 -c "client hello, adding max_fragment_length extension" \
1090 -s "found max fragment length extension" \
1091 -s "server hello, max_fragment_length extension" \
1092 -c "found max_fragment_length extension"
1093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001094run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001095 "$P_SRV debug_level=3 max_frag_len=4096" \
1096 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001097 0 \
1098 -C "client hello, adding max_fragment_length extension" \
1099 -S "found max fragment length extension" \
1100 -S "server hello, max_fragment_length extension" \
1101 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001103requires_gnutls
1104run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001105 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001106 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001107 0 \
1108 -c "client hello, adding max_fragment_length extension" \
1109 -c "found max_fragment_length extension"
1110
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001111run_test "Max fragment length: client, message just fits" \
1112 "$P_SRV debug_level=3" \
1113 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1114 0 \
1115 -c "client hello, adding max_fragment_length extension" \
1116 -s "found max fragment length extension" \
1117 -s "server hello, max_fragment_length extension" \
1118 -c "found max_fragment_length extension" \
1119 -c "2048 bytes written in 1 fragments" \
1120 -s "2048 bytes read"
1121
1122run_test "Max fragment length: client, larger message" \
1123 "$P_SRV debug_level=3" \
1124 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1125 0 \
1126 -c "client hello, adding max_fragment_length extension" \
1127 -s "found max fragment length extension" \
1128 -s "server hello, max_fragment_length extension" \
1129 -c "found max_fragment_length extension" \
1130 -c "2345 bytes written in 2 fragments" \
1131 -s "2048 bytes read" \
1132 -s "297 bytes read"
1133
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001134run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001135 "$P_SRV debug_level=3 dtls=1" \
1136 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1137 1 \
1138 -c "client hello, adding max_fragment_length extension" \
1139 -s "found max fragment length extension" \
1140 -s "server hello, max_fragment_length extension" \
1141 -c "found max_fragment_length extension" \
1142 -c "fragment larger than.*maximum"
1143
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001144# Tests for renegotiation
1145
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001146run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001147 "$P_SRV debug_level=3 exchanges=2" \
1148 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001149 0 \
1150 -C "client hello, adding renegotiation extension" \
1151 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1152 -S "found renegotiation extension" \
1153 -s "server hello, secure renegotiation extension" \
1154 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001155 -C "=> renegotiate" \
1156 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001157 -S "write hello request"
1158
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001159run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001160 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
1161 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001162 0 \
1163 -c "client hello, adding renegotiation extension" \
1164 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1165 -s "found renegotiation extension" \
1166 -s "server hello, secure renegotiation extension" \
1167 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001168 -c "=> renegotiate" \
1169 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001170 -S "write hello request"
1171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001172run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001173 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1174 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001175 0 \
1176 -c "client hello, adding renegotiation extension" \
1177 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1178 -s "found renegotiation extension" \
1179 -s "server hello, secure renegotiation extension" \
1180 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001181 -c "=> renegotiate" \
1182 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001183 -s "write hello request"
1184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001185run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001186 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1187 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001188 0 \
1189 -c "client hello, adding renegotiation extension" \
1190 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1191 -s "found renegotiation extension" \
1192 -s "server hello, secure renegotiation extension" \
1193 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001194 -c "=> renegotiate" \
1195 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001196 -s "write hello request"
1197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001198run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001199 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1200 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001201 1 \
1202 -c "client hello, adding renegotiation extension" \
1203 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1204 -S "found renegotiation extension" \
1205 -s "server hello, secure renegotiation extension" \
1206 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001207 -c "=> renegotiate" \
1208 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001209 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001210 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001211 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001212
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001213run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001214 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1215 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001216 0 \
1217 -C "client hello, adding renegotiation extension" \
1218 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1219 -S "found renegotiation extension" \
1220 -s "server hello, secure renegotiation extension" \
1221 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001222 -C "=> renegotiate" \
1223 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001224 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001225 -S "SSL - An unexpected message was received from our peer" \
1226 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001228run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001229 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001230 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001231 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001232 0 \
1233 -C "client hello, adding renegotiation extension" \
1234 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1235 -S "found renegotiation extension" \
1236 -s "server hello, secure renegotiation extension" \
1237 -c "found renegotiation extension" \
1238 -C "=> renegotiate" \
1239 -S "=> renegotiate" \
1240 -s "write hello request" \
1241 -S "SSL - An unexpected message was received from our peer" \
1242 -S "failed"
1243
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001244# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001245run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001246 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001247 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001248 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001249 0 \
1250 -C "client hello, adding renegotiation extension" \
1251 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1252 -S "found renegotiation extension" \
1253 -s "server hello, secure renegotiation extension" \
1254 -c "found renegotiation extension" \
1255 -C "=> renegotiate" \
1256 -S "=> renegotiate" \
1257 -s "write hello request" \
1258 -S "SSL - An unexpected message was received from our peer" \
1259 -S "failed"
1260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001261run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001262 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001263 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001264 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001265 0 \
1266 -C "client hello, adding renegotiation extension" \
1267 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1268 -S "found renegotiation extension" \
1269 -s "server hello, secure renegotiation extension" \
1270 -c "found renegotiation extension" \
1271 -C "=> renegotiate" \
1272 -S "=> renegotiate" \
1273 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001274 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001276run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001277 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001278 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001279 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001280 0 \
1281 -c "client hello, adding renegotiation extension" \
1282 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1283 -s "found renegotiation extension" \
1284 -s "server hello, secure renegotiation extension" \
1285 -c "found renegotiation extension" \
1286 -c "=> renegotiate" \
1287 -s "=> renegotiate" \
1288 -s "write hello request" \
1289 -S "SSL - An unexpected message was received from our peer" \
1290 -S "failed"
1291
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001292run_test "Renegotiation: periodic, just below period" \
1293 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1294 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1295 0 \
1296 -C "client hello, adding renegotiation extension" \
1297 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1298 -S "found renegotiation extension" \
1299 -s "server hello, secure renegotiation extension" \
1300 -c "found renegotiation extension" \
1301 -S "record counter limit reached: renegotiate" \
1302 -C "=> renegotiate" \
1303 -S "=> renegotiate" \
1304 -S "write hello request" \
1305 -S "SSL - An unexpected message was received from our peer" \
1306 -S "failed"
1307
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001308# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001309run_test "Renegotiation: periodic, just above period" \
1310 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001311 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001312 0 \
1313 -c "client hello, adding renegotiation extension" \
1314 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1315 -s "found renegotiation extension" \
1316 -s "server hello, secure renegotiation extension" \
1317 -c "found renegotiation extension" \
1318 -s "record counter limit reached: renegotiate" \
1319 -c "=> renegotiate" \
1320 -s "=> renegotiate" \
1321 -s "write hello request" \
1322 -S "SSL - An unexpected message was received from our peer" \
1323 -S "failed"
1324
1325run_test "Renegotiation: periodic, two times period" \
1326 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001327 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001328 0 \
1329 -c "client hello, adding renegotiation extension" \
1330 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1331 -s "found renegotiation extension" \
1332 -s "server hello, secure renegotiation extension" \
1333 -c "found renegotiation extension" \
1334 -s "record counter limit reached: renegotiate" \
1335 -c "=> renegotiate" \
1336 -s "=> renegotiate" \
1337 -s "write hello request" \
1338 -S "SSL - An unexpected message was received from our peer" \
1339 -S "failed"
1340
1341run_test "Renegotiation: periodic, above period, disabled" \
1342 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1343 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1344 0 \
1345 -C "client hello, adding renegotiation extension" \
1346 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1347 -S "found renegotiation extension" \
1348 -s "server hello, secure renegotiation extension" \
1349 -c "found renegotiation extension" \
1350 -S "record counter limit reached: renegotiate" \
1351 -C "=> renegotiate" \
1352 -S "=> renegotiate" \
1353 -S "write hello request" \
1354 -S "SSL - An unexpected message was received from our peer" \
1355 -S "failed"
1356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001357run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001358 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1359 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001360 0 \
1361 -c "client hello, adding renegotiation extension" \
1362 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1363 -s "found renegotiation extension" \
1364 -s "server hello, secure renegotiation extension" \
1365 -c "found renegotiation extension" \
1366 -c "=> renegotiate" \
1367 -s "=> renegotiate" \
1368 -S "write hello request"
1369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001370run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001371 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1372 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001373 0 \
1374 -c "client hello, adding renegotiation extension" \
1375 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1376 -s "found renegotiation extension" \
1377 -s "server hello, secure renegotiation extension" \
1378 -c "found renegotiation extension" \
1379 -c "=> renegotiate" \
1380 -s "=> renegotiate" \
1381 -s "write hello request"
1382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001383run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001384 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001385 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001386 0 \
1387 -c "client hello, adding renegotiation extension" \
1388 -c "found renegotiation extension" \
1389 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001390 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001391 -C "error" \
1392 -c "HTTP/1.0 200 [Oo][Kk]"
1393
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001394run_test "Renegotiation: gnutls server strict, client-initiated" \
1395 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001396 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001397 0 \
1398 -c "client hello, adding renegotiation extension" \
1399 -c "found renegotiation extension" \
1400 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001401 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001402 -C "error" \
1403 -c "HTTP/1.0 200 [Oo][Kk]"
1404
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001405run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1406 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1407 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1408 1 \
1409 -c "client hello, adding renegotiation extension" \
1410 -C "found renegotiation extension" \
1411 -c "=> renegotiate" \
1412 -c "ssl_handshake() returned" \
1413 -c "error" \
1414 -C "HTTP/1.0 200 [Oo][Kk]"
1415
1416run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1417 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1418 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1419 allow_legacy=0" \
1420 1 \
1421 -c "client hello, adding renegotiation extension" \
1422 -C "found renegotiation extension" \
1423 -c "=> renegotiate" \
1424 -c "ssl_handshake() returned" \
1425 -c "error" \
1426 -C "HTTP/1.0 200 [Oo][Kk]"
1427
1428run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1429 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1430 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1431 allow_legacy=1" \
1432 0 \
1433 -c "client hello, adding renegotiation extension" \
1434 -C "found renegotiation extension" \
1435 -c "=> renegotiate" \
1436 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001437 -C "error" \
1438 -c "HTTP/1.0 200 [Oo][Kk]"
1439
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001440run_test "Renegotiation: DTLS, client-initiated" \
1441 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1442 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1443 0 \
1444 -c "client hello, adding renegotiation extension" \
1445 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1446 -s "found renegotiation extension" \
1447 -s "server hello, secure renegotiation extension" \
1448 -c "found renegotiation extension" \
1449 -c "=> renegotiate" \
1450 -s "=> renegotiate" \
1451 -S "write hello request"
1452
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001453run_test "Renegotiation: DTLS, server-initiated" \
1454 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001455 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1456 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001457 0 \
1458 -c "client hello, adding renegotiation extension" \
1459 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1460 -s "found renegotiation extension" \
1461 -s "server hello, secure renegotiation extension" \
1462 -c "found renegotiation extension" \
1463 -c "=> renegotiate" \
1464 -s "=> renegotiate" \
1465 -s "write hello request"
1466
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001467run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1468 "$G_SRV -u --mtu 4096" \
1469 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1470 0 \
1471 -c "client hello, adding renegotiation extension" \
1472 -c "found renegotiation extension" \
1473 -c "=> renegotiate" \
1474 -C "ssl_handshake returned" \
1475 -C "error" \
1476 -s "Extra-header:"
1477
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001478# Test for the "secure renegotation" extension only (no actual renegotiation)
1479
1480run_test "Renego ext: gnutls server strict, client default" \
1481 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1482 "$P_CLI debug_level=3" \
1483 0 \
1484 -c "found renegotiation extension" \
1485 -C "error" \
1486 -c "HTTP/1.0 200 [Oo][Kk]"
1487
1488run_test "Renego ext: gnutls server unsafe, client default" \
1489 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1490 "$P_CLI debug_level=3" \
1491 0 \
1492 -C "found renegotiation extension" \
1493 -C "error" \
1494 -c "HTTP/1.0 200 [Oo][Kk]"
1495
1496run_test "Renego ext: gnutls server unsafe, client break legacy" \
1497 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1498 "$P_CLI debug_level=3 allow_legacy=-1" \
1499 1 \
1500 -C "found renegotiation extension" \
1501 -c "error" \
1502 -C "HTTP/1.0 200 [Oo][Kk]"
1503
1504run_test "Renego ext: gnutls client strict, server default" \
1505 "$P_SRV debug_level=3" \
1506 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1507 0 \
1508 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1509 -s "server hello, secure renegotiation extension"
1510
1511run_test "Renego ext: gnutls client unsafe, server default" \
1512 "$P_SRV debug_level=3" \
1513 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1514 0 \
1515 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1516 -S "server hello, secure renegotiation extension"
1517
1518run_test "Renego ext: gnutls client unsafe, server break legacy" \
1519 "$P_SRV debug_level=3 allow_legacy=-1" \
1520 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1521 1 \
1522 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1523 -S "server hello, secure renegotiation extension"
1524
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001525# Tests for auth_mode
1526
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001527run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001528 "$P_SRV crt_file=data_files/server5-badsign.crt \
1529 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001530 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001531 1 \
1532 -c "x509_verify_cert() returned" \
1533 -c "! self-signed or not signed by a trusted CA" \
1534 -c "! ssl_handshake returned" \
1535 -c "X509 - Certificate verification failed"
1536
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001537run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001538 "$P_SRV crt_file=data_files/server5-badsign.crt \
1539 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001540 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001541 0 \
1542 -c "x509_verify_cert() returned" \
1543 -c "! self-signed or not signed by a trusted CA" \
1544 -C "! ssl_handshake returned" \
1545 -C "X509 - Certificate verification failed"
1546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001547run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001548 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001549 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001550 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001551 0 \
1552 -C "x509_verify_cert() returned" \
1553 -C "! self-signed or not signed by a trusted CA" \
1554 -C "! ssl_handshake returned" \
1555 -C "X509 - Certificate verification failed"
1556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001557run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001558 "$P_SRV debug_level=3 auth_mode=required" \
1559 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001560 key_file=data_files/server5.key" \
1561 1 \
1562 -S "skip write certificate request" \
1563 -C "skip parse certificate request" \
1564 -c "got a certificate request" \
1565 -C "skip write certificate" \
1566 -C "skip write certificate verify" \
1567 -S "skip parse certificate verify" \
1568 -s "x509_verify_cert() returned" \
1569 -S "! self-signed or not signed by a trusted CA" \
1570 -s "! ssl_handshake returned" \
1571 -c "! ssl_handshake returned" \
1572 -s "X509 - Certificate verification failed"
1573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001574run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001575 "$P_SRV debug_level=3 auth_mode=optional" \
1576 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001577 key_file=data_files/server5.key" \
1578 0 \
1579 -S "skip write certificate request" \
1580 -C "skip parse certificate request" \
1581 -c "got a certificate request" \
1582 -C "skip write certificate" \
1583 -C "skip write certificate verify" \
1584 -S "skip parse certificate verify" \
1585 -s "x509_verify_cert() returned" \
1586 -s "! self-signed or not signed by a trusted CA" \
1587 -S "! ssl_handshake returned" \
1588 -C "! ssl_handshake returned" \
1589 -S "X509 - Certificate verification failed"
1590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001591run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001592 "$P_SRV debug_level=3 auth_mode=none" \
1593 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001594 key_file=data_files/server5.key" \
1595 0 \
1596 -s "skip write certificate request" \
1597 -C "skip parse certificate request" \
1598 -c "got no certificate request" \
1599 -c "skip write certificate" \
1600 -c "skip write certificate verify" \
1601 -s "skip parse certificate verify" \
1602 -S "x509_verify_cert() returned" \
1603 -S "! self-signed or not signed by a trusted CA" \
1604 -S "! ssl_handshake returned" \
1605 -C "! ssl_handshake returned" \
1606 -S "X509 - Certificate verification failed"
1607
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001608run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001609 "$P_SRV debug_level=3 auth_mode=optional" \
1610 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001611 0 \
1612 -S "skip write certificate request" \
1613 -C "skip parse certificate request" \
1614 -c "got a certificate request" \
1615 -C "skip write certificate$" \
1616 -C "got no certificate to send" \
1617 -S "SSLv3 client has no certificate" \
1618 -c "skip write certificate verify" \
1619 -s "skip parse certificate verify" \
1620 -s "! no client certificate sent" \
1621 -S "! ssl_handshake returned" \
1622 -C "! ssl_handshake returned" \
1623 -S "X509 - Certificate verification failed"
1624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001625run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001626 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001627 "$O_CLI" \
1628 0 \
1629 -S "skip write certificate request" \
1630 -s "skip parse certificate verify" \
1631 -s "! no client certificate sent" \
1632 -S "! ssl_handshake returned" \
1633 -S "X509 - Certificate verification failed"
1634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001635run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001636 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001637 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001638 0 \
1639 -C "skip parse certificate request" \
1640 -c "got a certificate request" \
1641 -C "skip write certificate$" \
1642 -c "skip write certificate verify" \
1643 -C "! ssl_handshake returned"
1644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001645run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001646 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001647 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001648 0 \
1649 -S "skip write certificate request" \
1650 -C "skip parse certificate request" \
1651 -c "got a certificate request" \
1652 -C "skip write certificate$" \
1653 -c "skip write certificate verify" \
1654 -c "got no certificate to send" \
1655 -s "SSLv3 client has no certificate" \
1656 -s "skip parse certificate verify" \
1657 -s "! no client certificate sent" \
1658 -S "! ssl_handshake returned" \
1659 -C "! ssl_handshake returned" \
1660 -S "X509 - Certificate verification failed"
1661
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001662# Tests for certificate selection based on SHA verson
1663
1664run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1665 "$P_SRV crt_file=data_files/server5.crt \
1666 key_file=data_files/server5.key \
1667 crt_file2=data_files/server5-sha1.crt \
1668 key_file2=data_files/server5.key" \
1669 "$P_CLI force_version=tls1_2" \
1670 0 \
1671 -c "signed using.*ECDSA with SHA256" \
1672 -C "signed using.*ECDSA with SHA1"
1673
1674run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1675 "$P_SRV crt_file=data_files/server5.crt \
1676 key_file=data_files/server5.key \
1677 crt_file2=data_files/server5-sha1.crt \
1678 key_file2=data_files/server5.key" \
1679 "$P_CLI force_version=tls1_1" \
1680 0 \
1681 -C "signed using.*ECDSA with SHA256" \
1682 -c "signed using.*ECDSA with SHA1"
1683
1684run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1685 "$P_SRV crt_file=data_files/server5.crt \
1686 key_file=data_files/server5.key \
1687 crt_file2=data_files/server5-sha1.crt \
1688 key_file2=data_files/server5.key" \
1689 "$P_CLI force_version=tls1" \
1690 0 \
1691 -C "signed using.*ECDSA with SHA256" \
1692 -c "signed using.*ECDSA with SHA1"
1693
1694run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1695 "$P_SRV crt_file=data_files/server5.crt \
1696 key_file=data_files/server5.key \
1697 crt_file2=data_files/server6.crt \
1698 key_file2=data_files/server6.key" \
1699 "$P_CLI force_version=tls1_1" \
1700 0 \
1701 -c "serial number.*09" \
1702 -c "signed using.*ECDSA with SHA256" \
1703 -C "signed using.*ECDSA with SHA1"
1704
1705run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1706 "$P_SRV crt_file=data_files/server6.crt \
1707 key_file=data_files/server6.key \
1708 crt_file2=data_files/server5.crt \
1709 key_file2=data_files/server5.key" \
1710 "$P_CLI force_version=tls1_1" \
1711 0 \
1712 -c "serial number.*0A" \
1713 -c "signed using.*ECDSA with SHA256" \
1714 -C "signed using.*ECDSA with SHA1"
1715
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001716# tests for SNI
1717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001718run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001719 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001720 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001721 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001722 0 \
1723 -S "parse ServerName extension" \
1724 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1725 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1726
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001727run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001728 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001729 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001730 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 +02001731 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001732 0 \
1733 -s "parse ServerName extension" \
1734 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1735 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001737run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001738 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001739 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001740 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 +02001741 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001742 0 \
1743 -s "parse ServerName extension" \
1744 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001745 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001747run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001748 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001749 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001750 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 +02001751 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001752 1 \
1753 -s "parse ServerName extension" \
1754 -s "ssl_sni_wrapper() returned" \
1755 -s "ssl_handshake returned" \
1756 -c "ssl_handshake returned" \
1757 -c "SSL - A fatal alert message was received from our peer"
1758
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001759# Tests for non-blocking I/O: exercise a variety of handshake flows
1760
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001761run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001762 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1763 "$P_CLI nbio=2 tickets=0" \
1764 0 \
1765 -S "ssl_handshake returned" \
1766 -C "ssl_handshake returned" \
1767 -c "Read from server: .* bytes read"
1768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001769run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001770 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1771 "$P_CLI nbio=2 tickets=0" \
1772 0 \
1773 -S "ssl_handshake returned" \
1774 -C "ssl_handshake returned" \
1775 -c "Read from server: .* bytes read"
1776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001778 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1779 "$P_CLI nbio=2 tickets=1" \
1780 0 \
1781 -S "ssl_handshake returned" \
1782 -C "ssl_handshake returned" \
1783 -c "Read from server: .* bytes read"
1784
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001785run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001786 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1787 "$P_CLI nbio=2 tickets=1" \
1788 0 \
1789 -S "ssl_handshake returned" \
1790 -C "ssl_handshake returned" \
1791 -c "Read from server: .* bytes read"
1792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001793run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001794 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1795 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1796 0 \
1797 -S "ssl_handshake returned" \
1798 -C "ssl_handshake returned" \
1799 -c "Read from server: .* bytes read"
1800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001801run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001802 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1803 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1804 0 \
1805 -S "ssl_handshake returned" \
1806 -C "ssl_handshake returned" \
1807 -c "Read from server: .* bytes read"
1808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001809run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001810 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1811 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1812 0 \
1813 -S "ssl_handshake returned" \
1814 -C "ssl_handshake returned" \
1815 -c "Read from server: .* bytes read"
1816
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001817# Tests for version negotiation
1818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001819run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001820 "$P_SRV" \
1821 "$P_CLI" \
1822 0 \
1823 -S "ssl_handshake returned" \
1824 -C "ssl_handshake returned" \
1825 -s "Protocol is TLSv1.2" \
1826 -c "Protocol is TLSv1.2"
1827
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001828run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001829 "$P_SRV" \
1830 "$P_CLI max_version=tls1_1" \
1831 0 \
1832 -S "ssl_handshake returned" \
1833 -C "ssl_handshake returned" \
1834 -s "Protocol is TLSv1.1" \
1835 -c "Protocol is TLSv1.1"
1836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001837run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001838 "$P_SRV max_version=tls1_1" \
1839 "$P_CLI" \
1840 0 \
1841 -S "ssl_handshake returned" \
1842 -C "ssl_handshake returned" \
1843 -s "Protocol is TLSv1.1" \
1844 -c "Protocol is TLSv1.1"
1845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001846run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001847 "$P_SRV max_version=tls1_1" \
1848 "$P_CLI max_version=tls1_1" \
1849 0 \
1850 -S "ssl_handshake returned" \
1851 -C "ssl_handshake returned" \
1852 -s "Protocol is TLSv1.1" \
1853 -c "Protocol is TLSv1.1"
1854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001855run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001856 "$P_SRV min_version=tls1_1" \
1857 "$P_CLI max_version=tls1_1" \
1858 0 \
1859 -S "ssl_handshake returned" \
1860 -C "ssl_handshake returned" \
1861 -s "Protocol is TLSv1.1" \
1862 -c "Protocol is TLSv1.1"
1863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001864run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001865 "$P_SRV max_version=tls1_1" \
1866 "$P_CLI min_version=tls1_1" \
1867 0 \
1868 -S "ssl_handshake returned" \
1869 -C "ssl_handshake returned" \
1870 -s "Protocol is TLSv1.1" \
1871 -c "Protocol is TLSv1.1"
1872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001873run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001874 "$P_SRV max_version=tls1_1" \
1875 "$P_CLI min_version=tls1_2" \
1876 1 \
1877 -s "ssl_handshake returned" \
1878 -c "ssl_handshake returned" \
1879 -c "SSL - Handshake protocol not within min/max boundaries"
1880
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001881run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001882 "$P_SRV min_version=tls1_2" \
1883 "$P_CLI max_version=tls1_1" \
1884 1 \
1885 -s "ssl_handshake returned" \
1886 -c "ssl_handshake returned" \
1887 -s "SSL - Handshake protocol not within min/max boundaries"
1888
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001889# Tests for ALPN extension
1890
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001891if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1892
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001893run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001894 "$P_SRV debug_level=3" \
1895 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001896 0 \
1897 -C "client hello, adding alpn extension" \
1898 -S "found alpn extension" \
1899 -C "got an alert message, type: \\[2:120]" \
1900 -S "server hello, adding alpn extension" \
1901 -C "found alpn extension " \
1902 -C "Application Layer Protocol is" \
1903 -S "Application Layer Protocol is"
1904
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001905run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001906 "$P_SRV debug_level=3" \
1907 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001908 0 \
1909 -c "client hello, adding alpn extension" \
1910 -s "found alpn extension" \
1911 -C "got an alert message, type: \\[2:120]" \
1912 -S "server hello, adding alpn extension" \
1913 -C "found alpn extension " \
1914 -c "Application Layer Protocol is (none)" \
1915 -S "Application Layer Protocol is"
1916
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001917run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001918 "$P_SRV debug_level=3 alpn=abc,1234" \
1919 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001920 0 \
1921 -C "client hello, adding alpn extension" \
1922 -S "found alpn extension" \
1923 -C "got an alert message, type: \\[2:120]" \
1924 -S "server hello, adding alpn extension" \
1925 -C "found alpn extension " \
1926 -C "Application Layer Protocol is" \
1927 -s "Application Layer Protocol is (none)"
1928
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001929run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001930 "$P_SRV debug_level=3 alpn=abc,1234" \
1931 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001932 0 \
1933 -c "client hello, adding alpn extension" \
1934 -s "found alpn extension" \
1935 -C "got an alert message, type: \\[2:120]" \
1936 -s "server hello, adding alpn extension" \
1937 -c "found alpn extension" \
1938 -c "Application Layer Protocol is abc" \
1939 -s "Application Layer Protocol is abc"
1940
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001941run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001942 "$P_SRV debug_level=3 alpn=abc,1234" \
1943 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001944 0 \
1945 -c "client hello, adding alpn extension" \
1946 -s "found alpn extension" \
1947 -C "got an alert message, type: \\[2:120]" \
1948 -s "server hello, adding alpn extension" \
1949 -c "found alpn extension" \
1950 -c "Application Layer Protocol is abc" \
1951 -s "Application Layer Protocol is abc"
1952
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001953run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001954 "$P_SRV debug_level=3 alpn=abc,1234" \
1955 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001956 0 \
1957 -c "client hello, adding alpn extension" \
1958 -s "found alpn extension" \
1959 -C "got an alert message, type: \\[2:120]" \
1960 -s "server hello, adding alpn extension" \
1961 -c "found alpn extension" \
1962 -c "Application Layer Protocol is 1234" \
1963 -s "Application Layer Protocol is 1234"
1964
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001965run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001966 "$P_SRV debug_level=3 alpn=abc,123" \
1967 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001968 1 \
1969 -c "client hello, adding alpn extension" \
1970 -s "found alpn extension" \
1971 -c "got an alert message, type: \\[2:120]" \
1972 -S "server hello, adding alpn extension" \
1973 -C "found alpn extension" \
1974 -C "Application Layer Protocol is 1234" \
1975 -S "Application Layer Protocol is 1234"
1976
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001977fi
1978
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001979# Tests for keyUsage in leaf certificates, part 1:
1980# server-side certificate/suite selection
1981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001982run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001983 "$P_SRV key_file=data_files/server2.key \
1984 crt_file=data_files/server2.ku-ds.crt" \
1985 "$P_CLI" \
1986 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001987 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001988
1989
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001990run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001991 "$P_SRV key_file=data_files/server2.key \
1992 crt_file=data_files/server2.ku-ke.crt" \
1993 "$P_CLI" \
1994 0 \
1995 -c "Ciphersuite is TLS-RSA-WITH-"
1996
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001997run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001998 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001999 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002000 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002001 1 \
2002 -C "Ciphersuite is "
2003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002004run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002005 "$P_SRV key_file=data_files/server5.key \
2006 crt_file=data_files/server5.ku-ds.crt" \
2007 "$P_CLI" \
2008 0 \
2009 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2010
2011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002012run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002013 "$P_SRV key_file=data_files/server5.key \
2014 crt_file=data_files/server5.ku-ka.crt" \
2015 "$P_CLI" \
2016 0 \
2017 -c "Ciphersuite is TLS-ECDH-"
2018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002019run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002020 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002021 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002022 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002023 1 \
2024 -C "Ciphersuite is "
2025
2026# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002027# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002029run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002030 "$O_SRV -key data_files/server2.key \
2031 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002032 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002033 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2034 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002035 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002036 -C "Processing of the Certificate handshake message failed" \
2037 -c "Ciphersuite is TLS-"
2038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002039run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002040 "$O_SRV -key data_files/server2.key \
2041 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002042 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002043 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2044 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002045 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002046 -C "Processing of the Certificate handshake message failed" \
2047 -c "Ciphersuite is TLS-"
2048
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002049run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002050 "$O_SRV -key data_files/server2.key \
2051 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002052 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002053 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2054 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002055 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002056 -C "Processing of the Certificate handshake message failed" \
2057 -c "Ciphersuite is TLS-"
2058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002059run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002060 "$O_SRV -key data_files/server2.key \
2061 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002062 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002063 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2064 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002065 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002066 -c "Processing of the Certificate handshake message failed" \
2067 -C "Ciphersuite is TLS-"
2068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002069run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002070 "$O_SRV -key data_files/server2.key \
2071 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002072 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002073 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2074 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002075 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002076 -C "Processing of the Certificate handshake message failed" \
2077 -c "Ciphersuite is TLS-"
2078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002079run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002080 "$O_SRV -key data_files/server2.key \
2081 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002082 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002083 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2084 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002085 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002086 -c "Processing of the Certificate handshake message failed" \
2087 -C "Ciphersuite is TLS-"
2088
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002089# Tests for keyUsage in leaf certificates, part 3:
2090# server-side checking of client cert
2091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002092run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002093 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002094 "$O_CLI -key data_files/server2.key \
2095 -cert data_files/server2.ku-ds.crt" \
2096 0 \
2097 -S "bad certificate (usage extensions)" \
2098 -S "Processing of the Certificate handshake message failed"
2099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002100run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002101 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002102 "$O_CLI -key data_files/server2.key \
2103 -cert data_files/server2.ku-ke.crt" \
2104 0 \
2105 -s "bad certificate (usage extensions)" \
2106 -S "Processing of the Certificate handshake message failed"
2107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002108run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002109 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002110 "$O_CLI -key data_files/server2.key \
2111 -cert data_files/server2.ku-ke.crt" \
2112 1 \
2113 -s "bad certificate (usage extensions)" \
2114 -s "Processing of the Certificate handshake message failed"
2115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002116run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002117 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002118 "$O_CLI -key data_files/server5.key \
2119 -cert data_files/server5.ku-ds.crt" \
2120 0 \
2121 -S "bad certificate (usage extensions)" \
2122 -S "Processing of the Certificate handshake message failed"
2123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002124run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002125 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002126 "$O_CLI -key data_files/server5.key \
2127 -cert data_files/server5.ku-ka.crt" \
2128 0 \
2129 -s "bad certificate (usage extensions)" \
2130 -S "Processing of the Certificate handshake message failed"
2131
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002132# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002134run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002135 "$P_SRV key_file=data_files/server5.key \
2136 crt_file=data_files/server5.eku-srv.crt" \
2137 "$P_CLI" \
2138 0
2139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002140run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002141 "$P_SRV key_file=data_files/server5.key \
2142 crt_file=data_files/server5.eku-srv.crt" \
2143 "$P_CLI" \
2144 0
2145
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002146run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002147 "$P_SRV key_file=data_files/server5.key \
2148 crt_file=data_files/server5.eku-cs_any.crt" \
2149 "$P_CLI" \
2150 0
2151
2152# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002153run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002154 "$P_SRV psk=abc123 key_file=data_files/server5.key \
2155 crt_file=data_files/server5.eku-cli.crt" \
2156 "$P_CLI psk=badbad" \
2157 1
2158
2159# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002161run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002162 "$O_SRV -key data_files/server5.key \
2163 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002164 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002165 0 \
2166 -C "bad certificate (usage extensions)" \
2167 -C "Processing of the Certificate handshake message failed" \
2168 -c "Ciphersuite is TLS-"
2169
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002170run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002171 "$O_SRV -key data_files/server5.key \
2172 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002173 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002174 0 \
2175 -C "bad certificate (usage extensions)" \
2176 -C "Processing of the Certificate handshake message failed" \
2177 -c "Ciphersuite is TLS-"
2178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002179run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002180 "$O_SRV -key data_files/server5.key \
2181 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002182 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002183 0 \
2184 -C "bad certificate (usage extensions)" \
2185 -C "Processing of the Certificate handshake message failed" \
2186 -c "Ciphersuite is TLS-"
2187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002188run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002189 "$O_SRV -key data_files/server5.key \
2190 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002191 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002192 1 \
2193 -c "bad certificate (usage extensions)" \
2194 -c "Processing of the Certificate handshake message failed" \
2195 -C "Ciphersuite is TLS-"
2196
2197# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002199run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002200 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002201 "$O_CLI -key data_files/server5.key \
2202 -cert data_files/server5.eku-cli.crt" \
2203 0 \
2204 -S "bad certificate (usage extensions)" \
2205 -S "Processing of the Certificate handshake message failed"
2206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002207run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002208 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002209 "$O_CLI -key data_files/server5.key \
2210 -cert data_files/server5.eku-srv_cli.crt" \
2211 0 \
2212 -S "bad certificate (usage extensions)" \
2213 -S "Processing of the Certificate handshake message failed"
2214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002215run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002216 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002217 "$O_CLI -key data_files/server5.key \
2218 -cert data_files/server5.eku-cs_any.crt" \
2219 0 \
2220 -S "bad certificate (usage extensions)" \
2221 -S "Processing of the Certificate handshake message failed"
2222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002223run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002224 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002225 "$O_CLI -key data_files/server5.key \
2226 -cert data_files/server5.eku-cs.crt" \
2227 0 \
2228 -s "bad certificate (usage extensions)" \
2229 -S "Processing of the Certificate handshake message failed"
2230
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002231run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002232 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002233 "$O_CLI -key data_files/server5.key \
2234 -cert data_files/server5.eku-cs.crt" \
2235 1 \
2236 -s "bad certificate (usage extensions)" \
2237 -s "Processing of the Certificate handshake message failed"
2238
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002239# Tests for DHM parameters loading
2240
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002241run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002242 "$P_SRV" \
2243 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2244 debug_level=3" \
2245 0 \
2246 -c "value of 'DHM: P ' (2048 bits)" \
2247 -c "value of 'DHM: G ' (2048 bits)"
2248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002249run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002250 "$P_SRV dhm_file=data_files/dhparams.pem" \
2251 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2252 debug_level=3" \
2253 0 \
2254 -c "value of 'DHM: P ' (1024 bits)" \
2255 -c "value of 'DHM: G ' (2 bits)"
2256
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002257# Tests for PSK callback
2258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002259run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002260 "$P_SRV psk=abc123 psk_identity=foo" \
2261 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2262 psk_identity=foo psk=abc123" \
2263 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002264 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002265 -S "SSL - Unknown identity received" \
2266 -S "SSL - Verification of the message MAC failed"
2267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002268run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002269 "$P_SRV" \
2270 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2271 psk_identity=foo psk=abc123" \
2272 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002273 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002274 -S "SSL - Unknown identity received" \
2275 -S "SSL - Verification of the message MAC failed"
2276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002277run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002278 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2279 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2280 psk_identity=foo psk=abc123" \
2281 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002282 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002283 -s "SSL - Unknown identity received" \
2284 -S "SSL - Verification of the message MAC failed"
2285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002286run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002287 "$P_SRV psk_list=abc,dead,def,beef" \
2288 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2289 psk_identity=abc psk=dead" \
2290 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002291 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002292 -S "SSL - Unknown identity received" \
2293 -S "SSL - Verification of the message MAC failed"
2294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002295run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002296 "$P_SRV psk_list=abc,dead,def,beef" \
2297 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2298 psk_identity=def psk=beef" \
2299 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002300 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002301 -S "SSL - Unknown identity received" \
2302 -S "SSL - Verification of the message MAC failed"
2303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002304run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002305 "$P_SRV psk_list=abc,dead,def,beef" \
2306 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2307 psk_identity=ghi psk=beef" \
2308 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002309 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002310 -s "SSL - Unknown identity received" \
2311 -S "SSL - Verification of the message MAC failed"
2312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002313run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002314 "$P_SRV psk_list=abc,dead,def,beef" \
2315 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2316 psk_identity=abc psk=beef" \
2317 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002318 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002319 -S "SSL - Unknown identity received" \
2320 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002321
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002322# Tests for ciphersuites per version
2323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002324run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002325 "$P_SRV min_version=ssl3 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" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002326 "$P_CLI force_version=ssl3" \
2327 0 \
2328 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002330run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002331 "$P_SRV arc4=1 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" \
2332 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002333 0 \
2334 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002336run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002337 "$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" \
2338 "$P_CLI force_version=tls1_1" \
2339 0 \
2340 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002342run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002343 "$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" \
2344 "$P_CLI force_version=tls1_2" \
2345 0 \
2346 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2347
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002348# Tests for ssl_get_bytes_avail()
2349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002350run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002351 "$P_SRV" \
2352 "$P_CLI request_size=100" \
2353 0 \
2354 -s "Read from client: 100 bytes read$"
2355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002356run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002357 "$P_SRV" \
2358 "$P_CLI request_size=500" \
2359 0 \
2360 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002361
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002362# Tests for small packets
2363
2364run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002365 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002366 "$P_CLI request_size=1 force_version=ssl3 \
2367 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2368 0 \
2369 -s "Read from client: 1 bytes read"
2370
2371run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002372 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002373 "$P_CLI request_size=1 force_version=ssl3 \
2374 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2375 0 \
2376 -s "Read from client: 1 bytes read"
2377
2378run_test "Small packet TLS 1.0 BlockCipher" \
2379 "$P_SRV" \
2380 "$P_CLI request_size=1 force_version=tls1 \
2381 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2382 0 \
2383 -s "Read from client: 1 bytes read"
2384
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002385run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2386 "$P_SRV" \
2387 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2388 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2389 0 \
2390 -s "Read from client: 1 bytes read"
2391
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002392run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2393 "$P_SRV" \
2394 "$P_CLI request_size=1 force_version=tls1 \
2395 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2396 trunc_hmac=1" \
2397 0 \
2398 -s "Read from client: 1 bytes read"
2399
2400run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002401 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002402 "$P_CLI request_size=1 force_version=tls1 \
2403 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2404 trunc_hmac=1" \
2405 0 \
2406 -s "Read from client: 1 bytes read"
2407
2408run_test "Small packet TLS 1.1 BlockCipher" \
2409 "$P_SRV" \
2410 "$P_CLI request_size=1 force_version=tls1_1 \
2411 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2412 0 \
2413 -s "Read from client: 1 bytes read"
2414
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002415run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2416 "$P_SRV" \
2417 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2418 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2419 0 \
2420 -s "Read from client: 1 bytes read"
2421
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002422run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002423 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002424 "$P_CLI request_size=1 force_version=tls1_1 \
2425 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2426 0 \
2427 -s "Read from client: 1 bytes read"
2428
2429run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2430 "$P_SRV" \
2431 "$P_CLI request_size=1 force_version=tls1_1 \
2432 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2433 trunc_hmac=1" \
2434 0 \
2435 -s "Read from client: 1 bytes read"
2436
2437run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002438 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002439 "$P_CLI request_size=1 force_version=tls1_1 \
2440 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2441 trunc_hmac=1" \
2442 0 \
2443 -s "Read from client: 1 bytes read"
2444
2445run_test "Small packet TLS 1.2 BlockCipher" \
2446 "$P_SRV" \
2447 "$P_CLI request_size=1 force_version=tls1_2 \
2448 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2449 0 \
2450 -s "Read from client: 1 bytes read"
2451
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002452run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2453 "$P_SRV" \
2454 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2455 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2456 0 \
2457 -s "Read from client: 1 bytes read"
2458
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002459run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2460 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002461 "$P_CLI request_size=1 force_version=tls1_2 \
2462 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002463 0 \
2464 -s "Read from client: 1 bytes read"
2465
2466run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2467 "$P_SRV" \
2468 "$P_CLI request_size=1 force_version=tls1_2 \
2469 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2470 trunc_hmac=1" \
2471 0 \
2472 -s "Read from client: 1 bytes read"
2473
2474run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002475 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002476 "$P_CLI request_size=1 force_version=tls1_2 \
2477 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2478 0 \
2479 -s "Read from client: 1 bytes read"
2480
2481run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002482 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002483 "$P_CLI request_size=1 force_version=tls1_2 \
2484 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2485 trunc_hmac=1" \
2486 0 \
2487 -s "Read from client: 1 bytes read"
2488
2489run_test "Small packet TLS 1.2 AEAD" \
2490 "$P_SRV" \
2491 "$P_CLI request_size=1 force_version=tls1_2 \
2492 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2493 0 \
2494 -s "Read from client: 1 bytes read"
2495
2496run_test "Small packet TLS 1.2 AEAD shorter tag" \
2497 "$P_SRV" \
2498 "$P_CLI request_size=1 force_version=tls1_2 \
2499 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2500 0 \
2501 -s "Read from client: 1 bytes read"
2502
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002503# Test for large packets
2504
2505run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002506 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002507 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002508 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2509 0 \
2510 -s "Read from client: 16384 bytes read"
2511
2512run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002513 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002514 "$P_CLI request_size=16384 force_version=ssl3 \
2515 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2516 0 \
2517 -s "Read from client: 16384 bytes read"
2518
2519run_test "Large packet TLS 1.0 BlockCipher" \
2520 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002521 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002522 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2523 0 \
2524 -s "Read from client: 16384 bytes read"
2525
2526run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2527 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002528 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002529 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2530 trunc_hmac=1" \
2531 0 \
2532 -s "Read from client: 16384 bytes read"
2533
2534run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002535 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002536 "$P_CLI request_size=16384 force_version=tls1 \
2537 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2538 trunc_hmac=1" \
2539 0 \
2540 -s "Read from client: 16384 bytes read"
2541
2542run_test "Large packet TLS 1.1 BlockCipher" \
2543 "$P_SRV" \
2544 "$P_CLI request_size=16384 force_version=tls1_1 \
2545 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2546 0 \
2547 -s "Read from client: 16384 bytes read"
2548
2549run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002550 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002551 "$P_CLI request_size=16384 force_version=tls1_1 \
2552 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2553 0 \
2554 -s "Read from client: 16384 bytes read"
2555
2556run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2557 "$P_SRV" \
2558 "$P_CLI request_size=16384 force_version=tls1_1 \
2559 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2560 trunc_hmac=1" \
2561 0 \
2562 -s "Read from client: 16384 bytes read"
2563
2564run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002565 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002566 "$P_CLI request_size=16384 force_version=tls1_1 \
2567 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2568 trunc_hmac=1" \
2569 0 \
2570 -s "Read from client: 16384 bytes read"
2571
2572run_test "Large packet TLS 1.2 BlockCipher" \
2573 "$P_SRV" \
2574 "$P_CLI request_size=16384 force_version=tls1_2 \
2575 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2576 0 \
2577 -s "Read from client: 16384 bytes read"
2578
2579run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2580 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002581 "$P_CLI request_size=16384 force_version=tls1_2 \
2582 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002583 0 \
2584 -s "Read from client: 16384 bytes read"
2585
2586run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2587 "$P_SRV" \
2588 "$P_CLI request_size=16384 force_version=tls1_2 \
2589 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2590 trunc_hmac=1" \
2591 0 \
2592 -s "Read from client: 16384 bytes read"
2593
2594run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002595 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002596 "$P_CLI request_size=16384 force_version=tls1_2 \
2597 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2598 0 \
2599 -s "Read from client: 16384 bytes read"
2600
2601run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002602 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002603 "$P_CLI request_size=16384 force_version=tls1_2 \
2604 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2605 trunc_hmac=1" \
2606 0 \
2607 -s "Read from client: 16384 bytes read"
2608
2609run_test "Large packet TLS 1.2 AEAD" \
2610 "$P_SRV" \
2611 "$P_CLI request_size=16384 force_version=tls1_2 \
2612 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2613 0 \
2614 -s "Read from client: 16384 bytes read"
2615
2616run_test "Large packet TLS 1.2 AEAD shorter tag" \
2617 "$P_SRV" \
2618 "$P_CLI request_size=16384 force_version=tls1_2 \
2619 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2620 0 \
2621 -s "Read from client: 16384 bytes read"
2622
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002623# Tests for DTLS HelloVerifyRequest
2624
2625run_test "DTLS cookie: enabled" \
2626 "$P_SRV dtls=1 debug_level=2" \
2627 "$P_CLI dtls=1 debug_level=2" \
2628 0 \
2629 -s "cookie verification failed" \
2630 -s "cookie verification passed" \
2631 -S "cookie verification skipped" \
2632 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002633 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002634 -S "SSL - The requested feature is not available"
2635
2636run_test "DTLS cookie: disabled" \
2637 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2638 "$P_CLI dtls=1 debug_level=2" \
2639 0 \
2640 -S "cookie verification failed" \
2641 -S "cookie verification passed" \
2642 -s "cookie verification skipped" \
2643 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002644 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002645 -S "SSL - The requested feature is not available"
2646
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002647run_test "DTLS cookie: default (failing)" \
2648 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2649 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2650 1 \
2651 -s "cookie verification failed" \
2652 -S "cookie verification passed" \
2653 -S "cookie verification skipped" \
2654 -C "received hello verify request" \
2655 -S "hello verification requested" \
2656 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002657
2658requires_ipv6
2659run_test "DTLS cookie: enabled, IPv6" \
2660 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2661 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2662 0 \
2663 -s "cookie verification failed" \
2664 -s "cookie verification passed" \
2665 -S "cookie verification skipped" \
2666 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002667 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002668 -S "SSL - The requested feature is not available"
2669
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002670run_test "DTLS cookie: enabled, nbio" \
2671 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2672 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2673 0 \
2674 -s "cookie verification failed" \
2675 -s "cookie verification passed" \
2676 -S "cookie verification skipped" \
2677 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002678 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002679 -S "SSL - The requested feature is not available"
2680
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002681# Tests for various cases of client authentication with DTLS
2682# (focused on handshake flows and message parsing)
2683
2684run_test "DTLS client auth: required" \
2685 "$P_SRV dtls=1 auth_mode=required" \
2686 "$P_CLI dtls=1" \
2687 0 \
2688 -s "Verifying peer X.509 certificate... ok"
2689
2690run_test "DTLS client auth: optional, client has no cert" \
2691 "$P_SRV dtls=1 auth_mode=optional" \
2692 "$P_CLI dtls=1 crt_file=none key_file=none" \
2693 0 \
2694 -s "! no client certificate sent"
2695
2696run_test "DTLS client auth: optional, client has no cert" \
2697 "$P_SRV dtls=1 auth_mode=none" \
2698 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2699 0 \
2700 -c "skip write certificate$" \
2701 -s "! no client certificate sent"
2702
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002703# Tests for receiving fragmented handshake messages with DTLS
2704
2705requires_gnutls
2706run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2707 "$G_SRV -u --mtu 2048 -a" \
2708 "$P_CLI dtls=1 debug_level=2" \
2709 0 \
2710 -C "found fragmented DTLS handshake message" \
2711 -C "error"
2712
2713requires_gnutls
2714run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2715 "$G_SRV -u --mtu 512" \
2716 "$P_CLI dtls=1 debug_level=2" \
2717 0 \
2718 -c "found fragmented DTLS handshake message" \
2719 -C "error"
2720
2721requires_gnutls
2722run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2723 "$G_SRV -u --mtu 128" \
2724 "$P_CLI dtls=1 debug_level=2" \
2725 0 \
2726 -c "found fragmented DTLS handshake message" \
2727 -C "error"
2728
2729requires_gnutls
2730run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2731 "$G_SRV -u --mtu 128" \
2732 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2733 0 \
2734 -c "found fragmented DTLS handshake message" \
2735 -C "error"
2736
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002737requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002738run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2739 "$G_SRV -u --mtu 256" \
2740 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2741 0 \
2742 -c "found fragmented DTLS handshake message" \
2743 -c "client hello, adding renegotiation extension" \
2744 -c "found renegotiation extension" \
2745 -c "=> renegotiate" \
2746 -C "ssl_handshake returned" \
2747 -C "error" \
2748 -s "Extra-header:"
2749
2750requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002751run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2752 "$G_SRV -u --mtu 256" \
2753 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2754 0 \
2755 -c "found fragmented DTLS handshake message" \
2756 -c "client hello, adding renegotiation extension" \
2757 -c "found renegotiation extension" \
2758 -c "=> renegotiate" \
2759 -C "ssl_handshake returned" \
2760 -C "error" \
2761 -s "Extra-header:"
2762
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002763run_test "DTLS reassembly: no fragmentation (openssl server)" \
2764 "$O_SRV -dtls1 -mtu 2048" \
2765 "$P_CLI dtls=1 debug_level=2" \
2766 0 \
2767 -C "found fragmented DTLS handshake message" \
2768 -C "error"
2769
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002770run_test "DTLS reassembly: some fragmentation (openssl server)" \
2771 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002772 "$P_CLI dtls=1 debug_level=2" \
2773 0 \
2774 -c "found fragmented DTLS handshake message" \
2775 -C "error"
2776
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002777run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002778 "$O_SRV -dtls1 -mtu 256" \
2779 "$P_CLI dtls=1 debug_level=2" \
2780 0 \
2781 -c "found fragmented DTLS handshake message" \
2782 -C "error"
2783
2784run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2785 "$O_SRV -dtls1 -mtu 256" \
2786 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2787 0 \
2788 -c "found fragmented DTLS handshake message" \
2789 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002790
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002791# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002792
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002793not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002794run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002795 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002796 "$P_SRV dtls=1 debug_level=2" \
2797 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002798 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002799 -C "replayed record" \
2800 -S "replayed record" \
2801 -C "record from another epoch" \
2802 -S "record from another epoch" \
2803 -C "discarding invalid record" \
2804 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002805 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002806 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002807 -c "HTTP/1.0 200 OK"
2808
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002809not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002810run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002811 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002812 "$P_SRV dtls=1 debug_level=2" \
2813 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002814 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002815 -c "replayed record" \
2816 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002817 -c "discarding invalid record" \
2818 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002819 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002820 -s "Extra-header:" \
2821 -c "HTTP/1.0 200 OK"
2822
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002823run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2824 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002825 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2826 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002827 0 \
2828 -c "replayed record" \
2829 -S "replayed record" \
2830 -c "discarding invalid record" \
2831 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002832 -c "resend" \
2833 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002834 -s "Extra-header:" \
2835 -c "HTTP/1.0 200 OK"
2836
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002837run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002838 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002839 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002840 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002841 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002842 -c "discarding invalid record (mac)" \
2843 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002844 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002845 -c "HTTP/1.0 200 OK" \
2846 -S "too many records with bad MAC" \
2847 -S "Verification of the message MAC failed"
2848
2849run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
2850 -p "$P_PXY bad_ad=1" \
2851 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
2852 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2853 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002854 -C "discarding invalid record (mac)" \
2855 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002856 -S "Extra-header:" \
2857 -C "HTTP/1.0 200 OK" \
2858 -s "too many records with bad MAC" \
2859 -s "Verification of the message MAC failed"
2860
2861run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
2862 -p "$P_PXY bad_ad=1" \
2863 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
2864 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2865 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002866 -c "discarding invalid record (mac)" \
2867 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002868 -s "Extra-header:" \
2869 -c "HTTP/1.0 200 OK" \
2870 -S "too many records with bad MAC" \
2871 -S "Verification of the message MAC failed"
2872
2873run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
2874 -p "$P_PXY bad_ad=1" \
2875 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
2876 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
2877 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002878 -c "discarding invalid record (mac)" \
2879 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002880 -s "Extra-header:" \
2881 -c "HTTP/1.0 200 OK" \
2882 -s "too many records with bad MAC" \
2883 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002884
2885run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002886 -p "$P_PXY delay_ccs=1" \
2887 "$P_SRV dtls=1 debug_level=1" \
2888 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002889 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002890 -c "record from another epoch" \
2891 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002892 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002893 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002894 -s "Extra-header:" \
2895 -c "HTTP/1.0 200 OK"
2896
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002897# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002898
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002899needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002900run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002901 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002902 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2903 psk=abc123" \
2904 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002905 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2906 0 \
2907 -s "Extra-header:" \
2908 -c "HTTP/1.0 200 OK"
2909
2910needs_more_time 2
2911run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
2912 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002913 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2914 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002915 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2916 0 \
2917 -s "Extra-header:" \
2918 -c "HTTP/1.0 200 OK"
2919
2920needs_more_time 2
2921run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
2922 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002923 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2924 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002925 0 \
2926 -s "Extra-header:" \
2927 -c "HTTP/1.0 200 OK"
2928
2929needs_more_time 2
2930run_test "DTLS proxy: 3d, FS, client auth" \
2931 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002932 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
2933 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002934 0 \
2935 -s "Extra-header:" \
2936 -c "HTTP/1.0 200 OK"
2937
2938needs_more_time 2
2939run_test "DTLS proxy: 3d, FS, ticket" \
2940 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002941 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
2942 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002943 0 \
2944 -s "Extra-header:" \
2945 -c "HTTP/1.0 200 OK"
2946
2947needs_more_time 2
2948run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
2949 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002950 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
2951 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002952 0 \
2953 -s "Extra-header:" \
2954 -c "HTTP/1.0 200 OK"
2955
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002956needs_more_time 2
2957run_test "DTLS proxy: 3d, max handshake, nbio" \
2958 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002959 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
2960 auth_mode=required" \
2961 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002962 0 \
2963 -s "Extra-header:" \
2964 -c "HTTP/1.0 200 OK"
2965
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002966needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02002967run_test "DTLS proxy: 3d, min handshake, resumption" \
2968 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2969 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2970 psk=abc123 debug_level=3" \
2971 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2972 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2973 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2974 0 \
2975 -s "a session has been resumed" \
2976 -c "a session has been resumed" \
2977 -s "Extra-header:" \
2978 -c "HTTP/1.0 200 OK"
2979
2980needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02002981run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
2982 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2983 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2984 psk=abc123 debug_level=3 nbio=2" \
2985 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2986 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2987 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
2988 0 \
2989 -s "a session has been resumed" \
2990 -c "a session has been resumed" \
2991 -s "Extra-header:" \
2992 -c "HTTP/1.0 200 OK"
2993
2994needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002995run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002996 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002997 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2998 psk=abc123 renegotiation=1 debug_level=2" \
2999 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3000 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003001 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3002 0 \
3003 -c "=> renegotiate" \
3004 -s "=> renegotiate" \
3005 -s "Extra-header:" \
3006 -c "HTTP/1.0 200 OK"
3007
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003008needs_more_time 4
3009run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3010 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003011 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3012 psk=abc123 renegotiation=1 debug_level=2" \
3013 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3014 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003015 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3016 0 \
3017 -c "=> renegotiate" \
3018 -s "=> renegotiate" \
3019 -s "Extra-header:" \
3020 -c "HTTP/1.0 200 OK"
3021
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003022needs_more_time 4
3023run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003024 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003025 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003026 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003027 debug_level=2" \
3028 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003029 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003030 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3031 0 \
3032 -c "=> renegotiate" \
3033 -s "=> renegotiate" \
3034 -s "Extra-header:" \
3035 -c "HTTP/1.0 200 OK"
3036
3037needs_more_time 4
3038run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003039 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003040 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003041 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003042 debug_level=2 nbio=2" \
3043 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003044 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003045 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3046 0 \
3047 -c "=> renegotiate" \
3048 -s "=> renegotiate" \
3049 -s "Extra-header:" \
3050 -c "HTTP/1.0 200 OK"
3051
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003052needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003053run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003054 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3055 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003056 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003057 0 \
3058 -s "Extra-header:" \
3059 -c "HTTP/1.0 200 OK"
3060
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003061needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003062run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3063 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3064 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003065 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003066 0 \
3067 -s "Extra-header:" \
3068 -c "HTTP/1.0 200 OK"
3069
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003070needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003071run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3072 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3073 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003074 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003075 0 \
3076 -s "Extra-header:" \
3077 -c "HTTP/1.0 200 OK"
3078
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003079needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003080run_test "DTLS proxy: 3d, gnutls server" \
3081 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3082 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003083 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003084 0 \
3085 -s "Extra-header:" \
3086 -c "Extra-header:"
3087
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003088needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003089run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3090 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3091 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003092 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003093 0 \
3094 -s "Extra-header:" \
3095 -c "Extra-header:"
3096
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003097needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003098run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3099 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3100 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003101 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003102 0 \
3103 -s "Extra-header:" \
3104 -c "Extra-header:"
3105
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003106# Final report
3107
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003108echo "------------------------------------------------------------------------"
3109
3110if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003111 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003112else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003113 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003114fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003115PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003116echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003117
3118exit $FAILS