blob: 86deb2d7824f4aa08a49ab8ee773dc4a92700470 [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
Paul Bakker539d9722015-02-08 16:18:35 +01001394requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001395run_test "Renegotiation: gnutls server strict, client-initiated" \
1396 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001397 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001398 0 \
1399 -c "client hello, adding renegotiation extension" \
1400 -c "found renegotiation extension" \
1401 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001402 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001403 -C "error" \
1404 -c "HTTP/1.0 200 [Oo][Kk]"
1405
Paul Bakker539d9722015-02-08 16:18:35 +01001406requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001407run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1408 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1409 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1410 1 \
1411 -c "client hello, adding renegotiation extension" \
1412 -C "found renegotiation extension" \
1413 -c "=> renegotiate" \
1414 -c "ssl_handshake() returned" \
1415 -c "error" \
1416 -C "HTTP/1.0 200 [Oo][Kk]"
1417
Paul Bakker539d9722015-02-08 16:18:35 +01001418requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001419run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1420 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1421 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1422 allow_legacy=0" \
1423 1 \
1424 -c "client hello, adding renegotiation extension" \
1425 -C "found renegotiation extension" \
1426 -c "=> renegotiate" \
1427 -c "ssl_handshake() returned" \
1428 -c "error" \
1429 -C "HTTP/1.0 200 [Oo][Kk]"
1430
Paul Bakker539d9722015-02-08 16:18:35 +01001431requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001432run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1433 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1434 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1435 allow_legacy=1" \
1436 0 \
1437 -c "client hello, adding renegotiation extension" \
1438 -C "found renegotiation extension" \
1439 -c "=> renegotiate" \
1440 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001441 -C "error" \
1442 -c "HTTP/1.0 200 [Oo][Kk]"
1443
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001444run_test "Renegotiation: DTLS, client-initiated" \
1445 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1446 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1447 0 \
1448 -c "client hello, adding renegotiation extension" \
1449 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1450 -s "found renegotiation extension" \
1451 -s "server hello, secure renegotiation extension" \
1452 -c "found renegotiation extension" \
1453 -c "=> renegotiate" \
1454 -s "=> renegotiate" \
1455 -S "write hello request"
1456
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001457run_test "Renegotiation: DTLS, server-initiated" \
1458 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001459 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1460 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001461 0 \
1462 -c "client hello, adding renegotiation extension" \
1463 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1464 -s "found renegotiation extension" \
1465 -s "server hello, secure renegotiation extension" \
1466 -c "found renegotiation extension" \
1467 -c "=> renegotiate" \
1468 -s "=> renegotiate" \
1469 -s "write hello request"
1470
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001471requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001472run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1473 "$G_SRV -u --mtu 4096" \
1474 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1475 0 \
1476 -c "client hello, adding renegotiation extension" \
1477 -c "found renegotiation extension" \
1478 -c "=> renegotiate" \
1479 -C "ssl_handshake returned" \
1480 -C "error" \
1481 -s "Extra-header:"
1482
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001483# Test for the "secure renegotation" extension only (no actual renegotiation)
1484
Paul Bakker539d9722015-02-08 16:18:35 +01001485requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001486run_test "Renego ext: gnutls server strict, client default" \
1487 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1488 "$P_CLI debug_level=3" \
1489 0 \
1490 -c "found renegotiation extension" \
1491 -C "error" \
1492 -c "HTTP/1.0 200 [Oo][Kk]"
1493
Paul Bakker539d9722015-02-08 16:18:35 +01001494requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001495run_test "Renego ext: gnutls server unsafe, client default" \
1496 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1497 "$P_CLI debug_level=3" \
1498 0 \
1499 -C "found renegotiation extension" \
1500 -C "error" \
1501 -c "HTTP/1.0 200 [Oo][Kk]"
1502
Paul Bakker539d9722015-02-08 16:18:35 +01001503requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001504run_test "Renego ext: gnutls server unsafe, client break legacy" \
1505 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1506 "$P_CLI debug_level=3 allow_legacy=-1" \
1507 1 \
1508 -C "found renegotiation extension" \
1509 -c "error" \
1510 -C "HTTP/1.0 200 [Oo][Kk]"
1511
Paul Bakker539d9722015-02-08 16:18:35 +01001512requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001513run_test "Renego ext: gnutls client strict, server default" \
1514 "$P_SRV debug_level=3" \
1515 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1516 0 \
1517 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1518 -s "server hello, secure renegotiation extension"
1519
Paul Bakker539d9722015-02-08 16:18:35 +01001520requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001521run_test "Renego ext: gnutls client unsafe, server default" \
1522 "$P_SRV debug_level=3" \
1523 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1524 0 \
1525 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1526 -S "server hello, secure renegotiation extension"
1527
Paul Bakker539d9722015-02-08 16:18:35 +01001528requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001529run_test "Renego ext: gnutls client unsafe, server break legacy" \
1530 "$P_SRV debug_level=3 allow_legacy=-1" \
1531 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1532 1 \
1533 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1534 -S "server hello, secure renegotiation extension"
1535
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001536# Tests for auth_mode
1537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001538run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001539 "$P_SRV crt_file=data_files/server5-badsign.crt \
1540 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001541 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001542 1 \
1543 -c "x509_verify_cert() returned" \
1544 -c "! self-signed or not signed by a trusted CA" \
1545 -c "! ssl_handshake returned" \
1546 -c "X509 - Certificate verification failed"
1547
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001548run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001549 "$P_SRV crt_file=data_files/server5-badsign.crt \
1550 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001551 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001552 0 \
1553 -c "x509_verify_cert() returned" \
1554 -c "! self-signed or not signed by a trusted CA" \
1555 -C "! ssl_handshake returned" \
1556 -C "X509 - Certificate verification failed"
1557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001558run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001559 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001560 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001561 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001562 0 \
1563 -C "x509_verify_cert() returned" \
1564 -C "! self-signed or not signed by a trusted CA" \
1565 -C "! ssl_handshake returned" \
1566 -C "X509 - Certificate verification failed"
1567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001568run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001569 "$P_SRV debug_level=3 auth_mode=required" \
1570 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001571 key_file=data_files/server5.key" \
1572 1 \
1573 -S "skip write certificate request" \
1574 -C "skip parse certificate request" \
1575 -c "got a certificate request" \
1576 -C "skip write certificate" \
1577 -C "skip write certificate verify" \
1578 -S "skip parse certificate verify" \
1579 -s "x509_verify_cert() returned" \
1580 -S "! self-signed or not signed by a trusted CA" \
1581 -s "! ssl_handshake returned" \
1582 -c "! ssl_handshake returned" \
1583 -s "X509 - Certificate verification failed"
1584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001585run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001586 "$P_SRV debug_level=3 auth_mode=optional" \
1587 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001588 key_file=data_files/server5.key" \
1589 0 \
1590 -S "skip write certificate request" \
1591 -C "skip parse certificate request" \
1592 -c "got a certificate request" \
1593 -C "skip write certificate" \
1594 -C "skip write certificate verify" \
1595 -S "skip parse certificate verify" \
1596 -s "x509_verify_cert() returned" \
1597 -s "! self-signed or not signed by a trusted CA" \
1598 -S "! ssl_handshake returned" \
1599 -C "! ssl_handshake returned" \
1600 -S "X509 - Certificate verification failed"
1601
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001602run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001603 "$P_SRV debug_level=3 auth_mode=none" \
1604 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001605 key_file=data_files/server5.key" \
1606 0 \
1607 -s "skip write certificate request" \
1608 -C "skip parse certificate request" \
1609 -c "got no certificate request" \
1610 -c "skip write certificate" \
1611 -c "skip write certificate verify" \
1612 -s "skip parse certificate verify" \
1613 -S "x509_verify_cert() returned" \
1614 -S "! self-signed or not signed by a trusted CA" \
1615 -S "! ssl_handshake returned" \
1616 -C "! ssl_handshake returned" \
1617 -S "X509 - Certificate verification failed"
1618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001619run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001620 "$P_SRV debug_level=3 auth_mode=optional" \
1621 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001622 0 \
1623 -S "skip write certificate request" \
1624 -C "skip parse certificate request" \
1625 -c "got a certificate request" \
1626 -C "skip write certificate$" \
1627 -C "got no certificate to send" \
1628 -S "SSLv3 client has no certificate" \
1629 -c "skip write certificate verify" \
1630 -s "skip parse certificate verify" \
1631 -s "! no client certificate sent" \
1632 -S "! ssl_handshake returned" \
1633 -C "! ssl_handshake returned" \
1634 -S "X509 - Certificate verification failed"
1635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001636run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001637 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001638 "$O_CLI" \
1639 0 \
1640 -S "skip write certificate request" \
1641 -s "skip parse certificate verify" \
1642 -s "! no client certificate sent" \
1643 -S "! ssl_handshake returned" \
1644 -S "X509 - Certificate verification failed"
1645
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001646run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001647 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001648 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001649 0 \
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 "! ssl_handshake returned"
1655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001656run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001657 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001658 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001659 0 \
1660 -S "skip write certificate request" \
1661 -C "skip parse certificate request" \
1662 -c "got a certificate request" \
1663 -C "skip write certificate$" \
1664 -c "skip write certificate verify" \
1665 -c "got no certificate to send" \
1666 -s "SSLv3 client has no certificate" \
1667 -s "skip parse certificate verify" \
1668 -s "! no client certificate sent" \
1669 -S "! ssl_handshake returned" \
1670 -C "! ssl_handshake returned" \
1671 -S "X509 - Certificate verification failed"
1672
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001673# Tests for certificate selection based on SHA verson
1674
1675run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1676 "$P_SRV crt_file=data_files/server5.crt \
1677 key_file=data_files/server5.key \
1678 crt_file2=data_files/server5-sha1.crt \
1679 key_file2=data_files/server5.key" \
1680 "$P_CLI force_version=tls1_2" \
1681 0 \
1682 -c "signed using.*ECDSA with SHA256" \
1683 -C "signed using.*ECDSA with SHA1"
1684
1685run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1686 "$P_SRV crt_file=data_files/server5.crt \
1687 key_file=data_files/server5.key \
1688 crt_file2=data_files/server5-sha1.crt \
1689 key_file2=data_files/server5.key" \
1690 "$P_CLI force_version=tls1_1" \
1691 0 \
1692 -C "signed using.*ECDSA with SHA256" \
1693 -c "signed using.*ECDSA with SHA1"
1694
1695run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1696 "$P_SRV crt_file=data_files/server5.crt \
1697 key_file=data_files/server5.key \
1698 crt_file2=data_files/server5-sha1.crt \
1699 key_file2=data_files/server5.key" \
1700 "$P_CLI force_version=tls1" \
1701 0 \
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 1)" \
1706 "$P_SRV crt_file=data_files/server5.crt \
1707 key_file=data_files/server5.key \
1708 crt_file2=data_files/server6.crt \
1709 key_file2=data_files/server6.key" \
1710 "$P_CLI force_version=tls1_1" \
1711 0 \
1712 -c "serial number.*09" \
1713 -c "signed using.*ECDSA with SHA256" \
1714 -C "signed using.*ECDSA with SHA1"
1715
1716run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1717 "$P_SRV crt_file=data_files/server6.crt \
1718 key_file=data_files/server6.key \
1719 crt_file2=data_files/server5.crt \
1720 key_file2=data_files/server5.key" \
1721 "$P_CLI force_version=tls1_1" \
1722 0 \
1723 -c "serial number.*0A" \
1724 -c "signed using.*ECDSA with SHA256" \
1725 -C "signed using.*ECDSA with SHA1"
1726
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001727# tests for SNI
1728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001729run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001730 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001731 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001732 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001733 0 \
1734 -S "parse ServerName extension" \
1735 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1736 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1737
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001738run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001739 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001740 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001741 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 +02001742 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001743 0 \
1744 -s "parse ServerName extension" \
1745 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1746 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1747
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001748run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001749 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001750 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001751 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 +02001752 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001753 0 \
1754 -s "parse ServerName extension" \
1755 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001756 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001757
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001758run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001759 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001760 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001761 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 +02001762 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001763 1 \
1764 -s "parse ServerName extension" \
1765 -s "ssl_sni_wrapper() returned" \
1766 -s "ssl_handshake returned" \
1767 -c "ssl_handshake returned" \
1768 -c "SSL - A fatal alert message was received from our peer"
1769
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001770# Tests for non-blocking I/O: exercise a variety of handshake flows
1771
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001772run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001773 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1774 "$P_CLI nbio=2 tickets=0" \
1775 0 \
1776 -S "ssl_handshake returned" \
1777 -C "ssl_handshake returned" \
1778 -c "Read from server: .* bytes read"
1779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001780run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001781 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1782 "$P_CLI nbio=2 tickets=0" \
1783 0 \
1784 -S "ssl_handshake returned" \
1785 -C "ssl_handshake returned" \
1786 -c "Read from server: .* bytes read"
1787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001788run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001789 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1790 "$P_CLI nbio=2 tickets=1" \
1791 0 \
1792 -S "ssl_handshake returned" \
1793 -C "ssl_handshake returned" \
1794 -c "Read from server: .* bytes read"
1795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001796run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001797 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1798 "$P_CLI nbio=2 tickets=1" \
1799 0 \
1800 -S "ssl_handshake returned" \
1801 -C "ssl_handshake returned" \
1802 -c "Read from server: .* bytes read"
1803
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001804run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001805 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1806 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1807 0 \
1808 -S "ssl_handshake returned" \
1809 -C "ssl_handshake returned" \
1810 -c "Read from server: .* bytes read"
1811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001812run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001813 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1814 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1815 0 \
1816 -S "ssl_handshake returned" \
1817 -C "ssl_handshake returned" \
1818 -c "Read from server: .* bytes read"
1819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001820run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001821 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1822 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1823 0 \
1824 -S "ssl_handshake returned" \
1825 -C "ssl_handshake returned" \
1826 -c "Read from server: .* bytes read"
1827
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001828# Tests for version negotiation
1829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001830run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001831 "$P_SRV" \
1832 "$P_CLI" \
1833 0 \
1834 -S "ssl_handshake returned" \
1835 -C "ssl_handshake returned" \
1836 -s "Protocol is TLSv1.2" \
1837 -c "Protocol is TLSv1.2"
1838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001839run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001840 "$P_SRV" \
1841 "$P_CLI max_version=tls1_1" \
1842 0 \
1843 -S "ssl_handshake returned" \
1844 -C "ssl_handshake returned" \
1845 -s "Protocol is TLSv1.1" \
1846 -c "Protocol is TLSv1.1"
1847
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001848run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001849 "$P_SRV max_version=tls1_1" \
1850 "$P_CLI" \
1851 0 \
1852 -S "ssl_handshake returned" \
1853 -C "ssl_handshake returned" \
1854 -s "Protocol is TLSv1.1" \
1855 -c "Protocol is TLSv1.1"
1856
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001857run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001858 "$P_SRV max_version=tls1_1" \
1859 "$P_CLI max_version=tls1_1" \
1860 0 \
1861 -S "ssl_handshake returned" \
1862 -C "ssl_handshake returned" \
1863 -s "Protocol is TLSv1.1" \
1864 -c "Protocol is TLSv1.1"
1865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001866run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001867 "$P_SRV min_version=tls1_1" \
1868 "$P_CLI max_version=tls1_1" \
1869 0 \
1870 -S "ssl_handshake returned" \
1871 -C "ssl_handshake returned" \
1872 -s "Protocol is TLSv1.1" \
1873 -c "Protocol is TLSv1.1"
1874
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001875run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001876 "$P_SRV max_version=tls1_1" \
1877 "$P_CLI min_version=tls1_1" \
1878 0 \
1879 -S "ssl_handshake returned" \
1880 -C "ssl_handshake returned" \
1881 -s "Protocol is TLSv1.1" \
1882 -c "Protocol is TLSv1.1"
1883
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001884run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001885 "$P_SRV max_version=tls1_1" \
1886 "$P_CLI min_version=tls1_2" \
1887 1 \
1888 -s "ssl_handshake returned" \
1889 -c "ssl_handshake returned" \
1890 -c "SSL - Handshake protocol not within min/max boundaries"
1891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001892run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001893 "$P_SRV min_version=tls1_2" \
1894 "$P_CLI max_version=tls1_1" \
1895 1 \
1896 -s "ssl_handshake returned" \
1897 -c "ssl_handshake returned" \
1898 -s "SSL - Handshake protocol not within min/max boundaries"
1899
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001900# Tests for ALPN extension
1901
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001902if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1903
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001904run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001905 "$P_SRV debug_level=3" \
1906 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001907 0 \
1908 -C "client hello, adding alpn extension" \
1909 -S "found alpn extension" \
1910 -C "got an alert message, type: \\[2:120]" \
1911 -S "server hello, adding alpn extension" \
1912 -C "found alpn extension " \
1913 -C "Application Layer Protocol is" \
1914 -S "Application Layer Protocol is"
1915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001916run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001917 "$P_SRV debug_level=3" \
1918 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001919 0 \
1920 -c "client hello, adding alpn extension" \
1921 -s "found alpn extension" \
1922 -C "got an alert message, type: \\[2:120]" \
1923 -S "server hello, adding alpn extension" \
1924 -C "found alpn extension " \
1925 -c "Application Layer Protocol is (none)" \
1926 -S "Application Layer Protocol is"
1927
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001928run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001929 "$P_SRV debug_level=3 alpn=abc,1234" \
1930 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001931 0 \
1932 -C "client hello, adding alpn extension" \
1933 -S "found alpn extension" \
1934 -C "got an alert message, type: \\[2:120]" \
1935 -S "server hello, adding alpn extension" \
1936 -C "found alpn extension " \
1937 -C "Application Layer Protocol is" \
1938 -s "Application Layer Protocol is (none)"
1939
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001940run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001941 "$P_SRV debug_level=3 alpn=abc,1234" \
1942 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001943 0 \
1944 -c "client hello, adding alpn extension" \
1945 -s "found alpn extension" \
1946 -C "got an alert message, type: \\[2:120]" \
1947 -s "server hello, adding alpn extension" \
1948 -c "found alpn extension" \
1949 -c "Application Layer Protocol is abc" \
1950 -s "Application Layer Protocol is abc"
1951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001952run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001953 "$P_SRV debug_level=3 alpn=abc,1234" \
1954 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001955 0 \
1956 -c "client hello, adding alpn extension" \
1957 -s "found alpn extension" \
1958 -C "got an alert message, type: \\[2:120]" \
1959 -s "server hello, adding alpn extension" \
1960 -c "found alpn extension" \
1961 -c "Application Layer Protocol is abc" \
1962 -s "Application Layer Protocol is abc"
1963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001964run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001965 "$P_SRV debug_level=3 alpn=abc,1234" \
1966 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001967 0 \
1968 -c "client hello, adding alpn extension" \
1969 -s "found alpn extension" \
1970 -C "got an alert message, type: \\[2:120]" \
1971 -s "server hello, adding alpn extension" \
1972 -c "found alpn extension" \
1973 -c "Application Layer Protocol is 1234" \
1974 -s "Application Layer Protocol is 1234"
1975
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001976run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001977 "$P_SRV debug_level=3 alpn=abc,123" \
1978 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001979 1 \
1980 -c "client hello, adding alpn extension" \
1981 -s "found alpn extension" \
1982 -c "got an alert message, type: \\[2:120]" \
1983 -S "server hello, adding alpn extension" \
1984 -C "found alpn extension" \
1985 -C "Application Layer Protocol is 1234" \
1986 -S "Application Layer Protocol is 1234"
1987
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001988fi
1989
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001990# Tests for keyUsage in leaf certificates, part 1:
1991# server-side certificate/suite selection
1992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001993run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001994 "$P_SRV key_file=data_files/server2.key \
1995 crt_file=data_files/server2.ku-ds.crt" \
1996 "$P_CLI" \
1997 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001998 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001999
2000
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002001run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002002 "$P_SRV key_file=data_files/server2.key \
2003 crt_file=data_files/server2.ku-ke.crt" \
2004 "$P_CLI" \
2005 0 \
2006 -c "Ciphersuite is TLS-RSA-WITH-"
2007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002008run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002009 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002010 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002011 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002012 1 \
2013 -C "Ciphersuite is "
2014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002015run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002016 "$P_SRV key_file=data_files/server5.key \
2017 crt_file=data_files/server5.ku-ds.crt" \
2018 "$P_CLI" \
2019 0 \
2020 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2021
2022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002023run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002024 "$P_SRV key_file=data_files/server5.key \
2025 crt_file=data_files/server5.ku-ka.crt" \
2026 "$P_CLI" \
2027 0 \
2028 -c "Ciphersuite is TLS-ECDH-"
2029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002030run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002031 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002032 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002033 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002034 1 \
2035 -C "Ciphersuite is "
2036
2037# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002038# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002040run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002041 "$O_SRV -key data_files/server2.key \
2042 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002043 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002044 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2045 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002046 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002047 -C "Processing of the Certificate handshake message failed" \
2048 -c "Ciphersuite is TLS-"
2049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002050run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002051 "$O_SRV -key data_files/server2.key \
2052 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002053 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002054 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2055 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002056 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002057 -C "Processing of the Certificate handshake message failed" \
2058 -c "Ciphersuite is TLS-"
2059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002060run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002061 "$O_SRV -key data_files/server2.key \
2062 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002063 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002064 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2065 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002066 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002067 -C "Processing of the Certificate handshake message failed" \
2068 -c "Ciphersuite is TLS-"
2069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002070run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002071 "$O_SRV -key data_files/server2.key \
2072 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002073 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002074 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2075 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002076 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002077 -c "Processing of the Certificate handshake message failed" \
2078 -C "Ciphersuite is TLS-"
2079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002080run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002081 "$O_SRV -key data_files/server2.key \
2082 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002083 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002084 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2085 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002086 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002087 -C "Processing of the Certificate handshake message failed" \
2088 -c "Ciphersuite is TLS-"
2089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002090run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002091 "$O_SRV -key data_files/server2.key \
2092 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002093 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002094 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2095 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002096 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002097 -c "Processing of the Certificate handshake message failed" \
2098 -C "Ciphersuite is TLS-"
2099
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002100# Tests for keyUsage in leaf certificates, part 3:
2101# server-side checking of client cert
2102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002103run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002104 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002105 "$O_CLI -key data_files/server2.key \
2106 -cert data_files/server2.ku-ds.crt" \
2107 0 \
2108 -S "bad certificate (usage extensions)" \
2109 -S "Processing of the Certificate handshake message failed"
2110
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002111run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002112 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002113 "$O_CLI -key data_files/server2.key \
2114 -cert data_files/server2.ku-ke.crt" \
2115 0 \
2116 -s "bad certificate (usage extensions)" \
2117 -S "Processing of the Certificate handshake message failed"
2118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002119run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002120 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002121 "$O_CLI -key data_files/server2.key \
2122 -cert data_files/server2.ku-ke.crt" \
2123 1 \
2124 -s "bad certificate (usage extensions)" \
2125 -s "Processing of the Certificate handshake message failed"
2126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002127run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002128 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002129 "$O_CLI -key data_files/server5.key \
2130 -cert data_files/server5.ku-ds.crt" \
2131 0 \
2132 -S "bad certificate (usage extensions)" \
2133 -S "Processing of the Certificate handshake message failed"
2134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002135run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002136 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002137 "$O_CLI -key data_files/server5.key \
2138 -cert data_files/server5.ku-ka.crt" \
2139 0 \
2140 -s "bad certificate (usage extensions)" \
2141 -S "Processing of the Certificate handshake message failed"
2142
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002143# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2144
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002145run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002146 "$P_SRV key_file=data_files/server5.key \
2147 crt_file=data_files/server5.eku-srv.crt" \
2148 "$P_CLI" \
2149 0
2150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002151run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002152 "$P_SRV key_file=data_files/server5.key \
2153 crt_file=data_files/server5.eku-srv.crt" \
2154 "$P_CLI" \
2155 0
2156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002157run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002158 "$P_SRV key_file=data_files/server5.key \
2159 crt_file=data_files/server5.eku-cs_any.crt" \
2160 "$P_CLI" \
2161 0
2162
2163# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002164run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002165 "$P_SRV psk=abc123 key_file=data_files/server5.key \
2166 crt_file=data_files/server5.eku-cli.crt" \
2167 "$P_CLI psk=badbad" \
2168 1
2169
2170# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002172run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002173 "$O_SRV -key data_files/server5.key \
2174 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002175 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002176 0 \
2177 -C "bad certificate (usage extensions)" \
2178 -C "Processing of the Certificate handshake message failed" \
2179 -c "Ciphersuite is TLS-"
2180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002181run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002182 "$O_SRV -key data_files/server5.key \
2183 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002184 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002185 0 \
2186 -C "bad certificate (usage extensions)" \
2187 -C "Processing of the Certificate handshake message failed" \
2188 -c "Ciphersuite is TLS-"
2189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002190run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002191 "$O_SRV -key data_files/server5.key \
2192 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002193 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002194 0 \
2195 -C "bad certificate (usage extensions)" \
2196 -C "Processing of the Certificate handshake message failed" \
2197 -c "Ciphersuite is TLS-"
2198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002199run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002200 "$O_SRV -key data_files/server5.key \
2201 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002202 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002203 1 \
2204 -c "bad certificate (usage extensions)" \
2205 -c "Processing of the Certificate handshake message failed" \
2206 -C "Ciphersuite is TLS-"
2207
2208# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2209
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002210run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002211 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002212 "$O_CLI -key data_files/server5.key \
2213 -cert data_files/server5.eku-cli.crt" \
2214 0 \
2215 -S "bad certificate (usage extensions)" \
2216 -S "Processing of the Certificate handshake message failed"
2217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002218run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002219 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002220 "$O_CLI -key data_files/server5.key \
2221 -cert data_files/server5.eku-srv_cli.crt" \
2222 0 \
2223 -S "bad certificate (usage extensions)" \
2224 -S "Processing of the Certificate handshake message failed"
2225
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002226run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002227 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002228 "$O_CLI -key data_files/server5.key \
2229 -cert data_files/server5.eku-cs_any.crt" \
2230 0 \
2231 -S "bad certificate (usage extensions)" \
2232 -S "Processing of the Certificate handshake message failed"
2233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002234run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002235 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002236 "$O_CLI -key data_files/server5.key \
2237 -cert data_files/server5.eku-cs.crt" \
2238 0 \
2239 -s "bad certificate (usage extensions)" \
2240 -S "Processing of the Certificate handshake message failed"
2241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002242run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002243 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002244 "$O_CLI -key data_files/server5.key \
2245 -cert data_files/server5.eku-cs.crt" \
2246 1 \
2247 -s "bad certificate (usage extensions)" \
2248 -s "Processing of the Certificate handshake message failed"
2249
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002250# Tests for DHM parameters loading
2251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002252run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002253 "$P_SRV" \
2254 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2255 debug_level=3" \
2256 0 \
2257 -c "value of 'DHM: P ' (2048 bits)" \
2258 -c "value of 'DHM: G ' (2048 bits)"
2259
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002260run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002261 "$P_SRV dhm_file=data_files/dhparams.pem" \
2262 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2263 debug_level=3" \
2264 0 \
2265 -c "value of 'DHM: P ' (1024 bits)" \
2266 -c "value of 'DHM: G ' (2 bits)"
2267
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002268# Tests for PSK callback
2269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002270run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002271 "$P_SRV psk=abc123 psk_identity=foo" \
2272 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2273 psk_identity=foo psk=abc123" \
2274 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002275 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002276 -S "SSL - Unknown identity received" \
2277 -S "SSL - Verification of the message MAC failed"
2278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002279run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002280 "$P_SRV" \
2281 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2282 psk_identity=foo psk=abc123" \
2283 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002284 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002285 -S "SSL - Unknown identity received" \
2286 -S "SSL - Verification of the message MAC failed"
2287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002288run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002289 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2290 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2291 psk_identity=foo psk=abc123" \
2292 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002293 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002294 -s "SSL - Unknown identity received" \
2295 -S "SSL - Verification of the message MAC failed"
2296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002297run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002298 "$P_SRV psk_list=abc,dead,def,beef" \
2299 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2300 psk_identity=abc psk=dead" \
2301 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002302 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002303 -S "SSL - Unknown identity received" \
2304 -S "SSL - Verification of the message MAC failed"
2305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002306run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002307 "$P_SRV psk_list=abc,dead,def,beef" \
2308 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2309 psk_identity=def psk=beef" \
2310 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002311 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002312 -S "SSL - Unknown identity received" \
2313 -S "SSL - Verification of the message MAC failed"
2314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002315run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002316 "$P_SRV psk_list=abc,dead,def,beef" \
2317 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2318 psk_identity=ghi psk=beef" \
2319 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002320 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002321 -s "SSL - Unknown identity received" \
2322 -S "SSL - Verification of the message MAC failed"
2323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002324run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002325 "$P_SRV psk_list=abc,dead,def,beef" \
2326 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2327 psk_identity=abc psk=beef" \
2328 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002329 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002330 -S "SSL - Unknown identity received" \
2331 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002332
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002333# Tests for ciphersuites per version
2334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002335run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002336 "$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 +02002337 "$P_CLI force_version=ssl3" \
2338 0 \
2339 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002341run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002342 "$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" \
2343 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002344 0 \
2345 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2346
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002347run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002348 "$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" \
2349 "$P_CLI force_version=tls1_1" \
2350 0 \
2351 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2352
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002353run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002354 "$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" \
2355 "$P_CLI force_version=tls1_2" \
2356 0 \
2357 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2358
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002359# Tests for ssl_get_bytes_avail()
2360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002361run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002362 "$P_SRV" \
2363 "$P_CLI request_size=100" \
2364 0 \
2365 -s "Read from client: 100 bytes read$"
2366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002367run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002368 "$P_SRV" \
2369 "$P_CLI request_size=500" \
2370 0 \
2371 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002372
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002373# Tests for small packets
2374
2375run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002376 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002377 "$P_CLI request_size=1 force_version=ssl3 \
2378 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2379 0 \
2380 -s "Read from client: 1 bytes read"
2381
2382run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002383 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002384 "$P_CLI request_size=1 force_version=ssl3 \
2385 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2386 0 \
2387 -s "Read from client: 1 bytes read"
2388
2389run_test "Small packet TLS 1.0 BlockCipher" \
2390 "$P_SRV" \
2391 "$P_CLI request_size=1 force_version=tls1 \
2392 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2393 0 \
2394 -s "Read from client: 1 bytes read"
2395
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002396run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2397 "$P_SRV" \
2398 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2399 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2400 0 \
2401 -s "Read from client: 1 bytes read"
2402
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002403run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2404 "$P_SRV" \
2405 "$P_CLI request_size=1 force_version=tls1 \
2406 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2407 trunc_hmac=1" \
2408 0 \
2409 -s "Read from client: 1 bytes read"
2410
2411run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002412 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002413 "$P_CLI request_size=1 force_version=tls1 \
2414 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2415 trunc_hmac=1" \
2416 0 \
2417 -s "Read from client: 1 bytes read"
2418
2419run_test "Small packet TLS 1.1 BlockCipher" \
2420 "$P_SRV" \
2421 "$P_CLI request_size=1 force_version=tls1_1 \
2422 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2423 0 \
2424 -s "Read from client: 1 bytes read"
2425
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002426run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2427 "$P_SRV" \
2428 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2429 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2430 0 \
2431 -s "Read from client: 1 bytes read"
2432
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002433run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002434 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002435 "$P_CLI request_size=1 force_version=tls1_1 \
2436 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2437 0 \
2438 -s "Read from client: 1 bytes read"
2439
2440run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2441 "$P_SRV" \
2442 "$P_CLI request_size=1 force_version=tls1_1 \
2443 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2444 trunc_hmac=1" \
2445 0 \
2446 -s "Read from client: 1 bytes read"
2447
2448run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002449 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002450 "$P_CLI request_size=1 force_version=tls1_1 \
2451 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2452 trunc_hmac=1" \
2453 0 \
2454 -s "Read from client: 1 bytes read"
2455
2456run_test "Small packet TLS 1.2 BlockCipher" \
2457 "$P_SRV" \
2458 "$P_CLI request_size=1 force_version=tls1_2 \
2459 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2460 0 \
2461 -s "Read from client: 1 bytes read"
2462
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002463run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2464 "$P_SRV" \
2465 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2466 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2467 0 \
2468 -s "Read from client: 1 bytes read"
2469
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002470run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2471 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002472 "$P_CLI request_size=1 force_version=tls1_2 \
2473 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002474 0 \
2475 -s "Read from client: 1 bytes read"
2476
2477run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2478 "$P_SRV" \
2479 "$P_CLI request_size=1 force_version=tls1_2 \
2480 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2481 trunc_hmac=1" \
2482 0 \
2483 -s "Read from client: 1 bytes read"
2484
2485run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002486 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002487 "$P_CLI request_size=1 force_version=tls1_2 \
2488 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2489 0 \
2490 -s "Read from client: 1 bytes read"
2491
2492run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002493 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002494 "$P_CLI request_size=1 force_version=tls1_2 \
2495 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2496 trunc_hmac=1" \
2497 0 \
2498 -s "Read from client: 1 bytes read"
2499
2500run_test "Small packet TLS 1.2 AEAD" \
2501 "$P_SRV" \
2502 "$P_CLI request_size=1 force_version=tls1_2 \
2503 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2504 0 \
2505 -s "Read from client: 1 bytes read"
2506
2507run_test "Small packet TLS 1.2 AEAD shorter tag" \
2508 "$P_SRV" \
2509 "$P_CLI request_size=1 force_version=tls1_2 \
2510 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2511 0 \
2512 -s "Read from client: 1 bytes read"
2513
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002514# Test for large packets
2515
2516run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002517 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002518 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002519 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2520 0 \
2521 -s "Read from client: 16384 bytes read"
2522
2523run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002524 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002525 "$P_CLI request_size=16384 force_version=ssl3 \
2526 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2527 0 \
2528 -s "Read from client: 16384 bytes read"
2529
2530run_test "Large packet TLS 1.0 BlockCipher" \
2531 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002532 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002533 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2534 0 \
2535 -s "Read from client: 16384 bytes read"
2536
2537run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2538 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002539 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002540 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2541 trunc_hmac=1" \
2542 0 \
2543 -s "Read from client: 16384 bytes read"
2544
2545run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002546 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002547 "$P_CLI request_size=16384 force_version=tls1 \
2548 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2549 trunc_hmac=1" \
2550 0 \
2551 -s "Read from client: 16384 bytes read"
2552
2553run_test "Large packet TLS 1.1 BlockCipher" \
2554 "$P_SRV" \
2555 "$P_CLI request_size=16384 force_version=tls1_1 \
2556 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2557 0 \
2558 -s "Read from client: 16384 bytes read"
2559
2560run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002561 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002562 "$P_CLI request_size=16384 force_version=tls1_1 \
2563 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2564 0 \
2565 -s "Read from client: 16384 bytes read"
2566
2567run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2568 "$P_SRV" \
2569 "$P_CLI request_size=16384 force_version=tls1_1 \
2570 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2571 trunc_hmac=1" \
2572 0 \
2573 -s "Read from client: 16384 bytes read"
2574
2575run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002576 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002577 "$P_CLI request_size=16384 force_version=tls1_1 \
2578 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2579 trunc_hmac=1" \
2580 0 \
2581 -s "Read from client: 16384 bytes read"
2582
2583run_test "Large packet TLS 1.2 BlockCipher" \
2584 "$P_SRV" \
2585 "$P_CLI request_size=16384 force_version=tls1_2 \
2586 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2587 0 \
2588 -s "Read from client: 16384 bytes read"
2589
2590run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2591 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002592 "$P_CLI request_size=16384 force_version=tls1_2 \
2593 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002594 0 \
2595 -s "Read from client: 16384 bytes read"
2596
2597run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2598 "$P_SRV" \
2599 "$P_CLI request_size=16384 force_version=tls1_2 \
2600 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2601 trunc_hmac=1" \
2602 0 \
2603 -s "Read from client: 16384 bytes read"
2604
2605run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002606 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002607 "$P_CLI request_size=16384 force_version=tls1_2 \
2608 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2609 0 \
2610 -s "Read from client: 16384 bytes read"
2611
2612run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002613 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002614 "$P_CLI request_size=16384 force_version=tls1_2 \
2615 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2616 trunc_hmac=1" \
2617 0 \
2618 -s "Read from client: 16384 bytes read"
2619
2620run_test "Large packet TLS 1.2 AEAD" \
2621 "$P_SRV" \
2622 "$P_CLI request_size=16384 force_version=tls1_2 \
2623 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2624 0 \
2625 -s "Read from client: 16384 bytes read"
2626
2627run_test "Large packet TLS 1.2 AEAD shorter tag" \
2628 "$P_SRV" \
2629 "$P_CLI request_size=16384 force_version=tls1_2 \
2630 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2631 0 \
2632 -s "Read from client: 16384 bytes read"
2633
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002634# Tests for DTLS HelloVerifyRequest
2635
2636run_test "DTLS cookie: enabled" \
2637 "$P_SRV dtls=1 debug_level=2" \
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
2647run_test "DTLS cookie: disabled" \
2648 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2649 "$P_CLI dtls=1 debug_level=2" \
2650 0 \
2651 -S "cookie verification failed" \
2652 -S "cookie verification passed" \
2653 -s "cookie verification skipped" \
2654 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002655 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002656 -S "SSL - The requested feature is not available"
2657
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002658run_test "DTLS cookie: default (failing)" \
2659 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2660 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2661 1 \
2662 -s "cookie verification failed" \
2663 -S "cookie verification passed" \
2664 -S "cookie verification skipped" \
2665 -C "received hello verify request" \
2666 -S "hello verification requested" \
2667 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002668
2669requires_ipv6
2670run_test "DTLS cookie: enabled, IPv6" \
2671 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2672 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
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é-Gonnard0eb6cab2014-07-23 20:17:47 +02002679 -S "SSL - The requested feature is not available"
2680
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002681run_test "DTLS cookie: enabled, nbio" \
2682 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2683 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2684 0 \
2685 -s "cookie verification failed" \
2686 -s "cookie verification passed" \
2687 -S "cookie verification skipped" \
2688 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002689 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002690 -S "SSL - The requested feature is not available"
2691
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002692# Tests for various cases of client authentication with DTLS
2693# (focused on handshake flows and message parsing)
2694
2695run_test "DTLS client auth: required" \
2696 "$P_SRV dtls=1 auth_mode=required" \
2697 "$P_CLI dtls=1" \
2698 0 \
2699 -s "Verifying peer X.509 certificate... ok"
2700
2701run_test "DTLS client auth: optional, client has no cert" \
2702 "$P_SRV dtls=1 auth_mode=optional" \
2703 "$P_CLI dtls=1 crt_file=none key_file=none" \
2704 0 \
2705 -s "! no client certificate sent"
2706
2707run_test "DTLS client auth: optional, client has no cert" \
2708 "$P_SRV dtls=1 auth_mode=none" \
2709 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2710 0 \
2711 -c "skip write certificate$" \
2712 -s "! no client certificate sent"
2713
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002714# Tests for receiving fragmented handshake messages with DTLS
2715
2716requires_gnutls
2717run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2718 "$G_SRV -u --mtu 2048 -a" \
2719 "$P_CLI dtls=1 debug_level=2" \
2720 0 \
2721 -C "found fragmented DTLS handshake message" \
2722 -C "error"
2723
2724requires_gnutls
2725run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2726 "$G_SRV -u --mtu 512" \
2727 "$P_CLI dtls=1 debug_level=2" \
2728 0 \
2729 -c "found fragmented DTLS handshake message" \
2730 -C "error"
2731
2732requires_gnutls
2733run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2734 "$G_SRV -u --mtu 128" \
2735 "$P_CLI dtls=1 debug_level=2" \
2736 0 \
2737 -c "found fragmented DTLS handshake message" \
2738 -C "error"
2739
2740requires_gnutls
2741run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2742 "$G_SRV -u --mtu 128" \
2743 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2744 0 \
2745 -c "found fragmented DTLS handshake message" \
2746 -C "error"
2747
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002748requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002749run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2750 "$G_SRV -u --mtu 256" \
2751 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2752 0 \
2753 -c "found fragmented DTLS handshake message" \
2754 -c "client hello, adding renegotiation extension" \
2755 -c "found renegotiation extension" \
2756 -c "=> renegotiate" \
2757 -C "ssl_handshake returned" \
2758 -C "error" \
2759 -s "Extra-header:"
2760
2761requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002762run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2763 "$G_SRV -u --mtu 256" \
2764 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2765 0 \
2766 -c "found fragmented DTLS handshake message" \
2767 -c "client hello, adding renegotiation extension" \
2768 -c "found renegotiation extension" \
2769 -c "=> renegotiate" \
2770 -C "ssl_handshake returned" \
2771 -C "error" \
2772 -s "Extra-header:"
2773
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002774run_test "DTLS reassembly: no fragmentation (openssl server)" \
2775 "$O_SRV -dtls1 -mtu 2048" \
2776 "$P_CLI dtls=1 debug_level=2" \
2777 0 \
2778 -C "found fragmented DTLS handshake message" \
2779 -C "error"
2780
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002781run_test "DTLS reassembly: some fragmentation (openssl server)" \
2782 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002783 "$P_CLI dtls=1 debug_level=2" \
2784 0 \
2785 -c "found fragmented DTLS handshake message" \
2786 -C "error"
2787
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002788run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002789 "$O_SRV -dtls1 -mtu 256" \
2790 "$P_CLI dtls=1 debug_level=2" \
2791 0 \
2792 -c "found fragmented DTLS handshake message" \
2793 -C "error"
2794
2795run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2796 "$O_SRV -dtls1 -mtu 256" \
2797 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2798 0 \
2799 -c "found fragmented DTLS handshake message" \
2800 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002801
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002802# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002803
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002804not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002805run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002806 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002807 "$P_SRV dtls=1 debug_level=2" \
2808 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002809 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002810 -C "replayed record" \
2811 -S "replayed record" \
2812 -C "record from another epoch" \
2813 -S "record from another epoch" \
2814 -C "discarding invalid record" \
2815 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002816 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002817 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002818 -c "HTTP/1.0 200 OK"
2819
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002820not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002821run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002822 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002823 "$P_SRV dtls=1 debug_level=2" \
2824 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002825 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002826 -c "replayed record" \
2827 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002828 -c "discarding invalid record" \
2829 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002830 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002831 -s "Extra-header:" \
2832 -c "HTTP/1.0 200 OK"
2833
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002834run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2835 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002836 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2837 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002838 0 \
2839 -c "replayed record" \
2840 -S "replayed record" \
2841 -c "discarding invalid record" \
2842 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002843 -c "resend" \
2844 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002845 -s "Extra-header:" \
2846 -c "HTTP/1.0 200 OK"
2847
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002848run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002849 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002850 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002851 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002852 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002853 -c "discarding invalid record (mac)" \
2854 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002855 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002856 -c "HTTP/1.0 200 OK" \
2857 -S "too many records with bad MAC" \
2858 -S "Verification of the message MAC failed"
2859
2860run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
2861 -p "$P_PXY bad_ad=1" \
2862 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
2863 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2864 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002865 -C "discarding invalid record (mac)" \
2866 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002867 -S "Extra-header:" \
2868 -C "HTTP/1.0 200 OK" \
2869 -s "too many records with bad MAC" \
2870 -s "Verification of the message MAC failed"
2871
2872run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
2873 -p "$P_PXY bad_ad=1" \
2874 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
2875 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2876 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002877 -c "discarding invalid record (mac)" \
2878 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002879 -s "Extra-header:" \
2880 -c "HTTP/1.0 200 OK" \
2881 -S "too many records with bad MAC" \
2882 -S "Verification of the message MAC failed"
2883
2884run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
2885 -p "$P_PXY bad_ad=1" \
2886 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
2887 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
2888 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002889 -c "discarding invalid record (mac)" \
2890 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002891 -s "Extra-header:" \
2892 -c "HTTP/1.0 200 OK" \
2893 -s "too many records with bad MAC" \
2894 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002895
2896run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002897 -p "$P_PXY delay_ccs=1" \
2898 "$P_SRV dtls=1 debug_level=1" \
2899 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002900 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002901 -c "record from another epoch" \
2902 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002903 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002904 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002905 -s "Extra-header:" \
2906 -c "HTTP/1.0 200 OK"
2907
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002908# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002909
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002910needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002911run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002912 -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 psk=abc123" \
2915 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002916 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2917 0 \
2918 -s "Extra-header:" \
2919 -c "HTTP/1.0 200 OK"
2920
2921needs_more_time 2
2922run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
2923 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002924 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2925 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002926 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2927 0 \
2928 -s "Extra-header:" \
2929 -c "HTTP/1.0 200 OK"
2930
2931needs_more_time 2
2932run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
2933 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002934 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2935 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002936 0 \
2937 -s "Extra-header:" \
2938 -c "HTTP/1.0 200 OK"
2939
2940needs_more_time 2
2941run_test "DTLS proxy: 3d, FS, client auth" \
2942 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002943 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
2944 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002945 0 \
2946 -s "Extra-header:" \
2947 -c "HTTP/1.0 200 OK"
2948
2949needs_more_time 2
2950run_test "DTLS proxy: 3d, FS, ticket" \
2951 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002952 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
2953 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002954 0 \
2955 -s "Extra-header:" \
2956 -c "HTTP/1.0 200 OK"
2957
2958needs_more_time 2
2959run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
2960 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002961 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
2962 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002963 0 \
2964 -s "Extra-header:" \
2965 -c "HTTP/1.0 200 OK"
2966
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002967needs_more_time 2
2968run_test "DTLS proxy: 3d, max handshake, nbio" \
2969 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002970 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
2971 auth_mode=required" \
2972 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002973 0 \
2974 -s "Extra-header:" \
2975 -c "HTTP/1.0 200 OK"
2976
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002977needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02002978run_test "DTLS proxy: 3d, min handshake, resumption" \
2979 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2980 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2981 psk=abc123 debug_level=3" \
2982 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2983 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2984 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2985 0 \
2986 -s "a session has been resumed" \
2987 -c "a session has been resumed" \
2988 -s "Extra-header:" \
2989 -c "HTTP/1.0 200 OK"
2990
2991needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02002992run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
2993 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2994 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2995 psk=abc123 debug_level=3 nbio=2" \
2996 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2997 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2998 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
2999 0 \
3000 -s "a session has been resumed" \
3001 -c "a session has been resumed" \
3002 -s "Extra-header:" \
3003 -c "HTTP/1.0 200 OK"
3004
3005needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003006run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003007 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003008 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3009 psk=abc123 renegotiation=1 debug_level=2" \
3010 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3011 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003012 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3013 0 \
3014 -c "=> renegotiate" \
3015 -s "=> renegotiate" \
3016 -s "Extra-header:" \
3017 -c "HTTP/1.0 200 OK"
3018
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003019needs_more_time 4
3020run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3021 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003022 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3023 psk=abc123 renegotiation=1 debug_level=2" \
3024 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3025 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003026 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3027 0 \
3028 -c "=> renegotiate" \
3029 -s "=> renegotiate" \
3030 -s "Extra-header:" \
3031 -c "HTTP/1.0 200 OK"
3032
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003033needs_more_time 4
3034run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003035 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003036 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003037 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003038 debug_level=2" \
3039 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003040 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003041 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3042 0 \
3043 -c "=> renegotiate" \
3044 -s "=> renegotiate" \
3045 -s "Extra-header:" \
3046 -c "HTTP/1.0 200 OK"
3047
3048needs_more_time 4
3049run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003050 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003051 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003052 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003053 debug_level=2 nbio=2" \
3054 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003055 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003056 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3057 0 \
3058 -c "=> renegotiate" \
3059 -s "=> renegotiate" \
3060 -s "Extra-header:" \
3061 -c "HTTP/1.0 200 OK"
3062
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003063needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003064run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003065 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3066 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003067 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003068 0 \
3069 -s "Extra-header:" \
3070 -c "HTTP/1.0 200 OK"
3071
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003072needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003073run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3074 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3075 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003076 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003077 0 \
3078 -s "Extra-header:" \
3079 -c "HTTP/1.0 200 OK"
3080
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003081needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003082run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3083 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3084 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003085 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003086 0 \
3087 -s "Extra-header:" \
3088 -c "HTTP/1.0 200 OK"
3089
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003090requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003091needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003092run_test "DTLS proxy: 3d, gnutls server" \
3093 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3094 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003095 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003096 0 \
3097 -s "Extra-header:" \
3098 -c "Extra-header:"
3099
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003100requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003101needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003102run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3103 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3104 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003105 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003106 0 \
3107 -s "Extra-header:" \
3108 -c "Extra-header:"
3109
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003110requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003111needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003112run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3113 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3114 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003115 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003116 0 \
3117 -s "Extra-header:" \
3118 -c "Extra-header:"
3119
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003120# Final report
3121
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003122echo "------------------------------------------------------------------------"
3123
3124if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003125 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003126else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003127 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003128fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003129PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003130echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003131
3132exit $FAILS