blob: 2c0c9ffd3d4928b3bd6189e9f95f91f86f49862d [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é-Gonnard7f809972015-03-09 17:05:11 +000030CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020031
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é-Gonnard19db8ea2015-03-10 13:41:04 +0000463if cd $( dirname $0 ); then :; else
464 echo "cd $( dirname $0 ) failed" >&2
465 exit 1
466fi
467
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100468get_options "$@"
469
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100470# sanity checks, avoid an avalanche of errors
471if [ ! -x "$P_SRV" ]; then
472 echo "Command '$P_SRV' is not an executable file"
473 exit 1
474fi
475if [ ! -x "$P_CLI" ]; then
476 echo "Command '$P_CLI' is not an executable file"
477 exit 1
478fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200479if [ ! -x "$P_PXY" ]; then
480 echo "Command '$P_PXY' is not an executable file"
481 exit 1
482fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100483if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
484 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100485 exit 1
486fi
487
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200488# used by watchdog
489MAIN_PID="$$"
490
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200491# be more patient with valgrind
492if [ "$MEMCHECK" -gt 0 ]; then
493 START_DELAY=3
494 DOG_DELAY=30
495else
496 START_DELAY=1
497 DOG_DELAY=10
498fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200499CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200500
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200501# Pick a "unique" server port in the range 10000-19999, and a proxy port
502PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000503PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200504SRV_PORT="1$PORT_BASE"
505PXY_PORT="2$PORT_BASE"
506unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200507
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200508# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000509# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200510P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
511P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
512P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
513O_SRV="$O_SRV -accept $SRV_PORT"
514O_CLI="$O_CLI -connect localhost:+SRV_PORT"
515G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000516G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200517
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200518# Also pick a unique name for intermediate files
519SRV_OUT="srv_out.$$"
520CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200521PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200522SESSION="session.$$"
523
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200524SKIP_NEXT="NO"
525
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100526trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100527
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200528# Basic test
529
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200530# Checks that:
531# - things work with all ciphersuites active (used with config-full in all.sh)
532# - the expected (highest security) parameters are selected
533# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200534run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200535 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200536 "$P_CLI" \
537 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200538 -s "Protocol is TLSv1.2" \
539 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
540 -s "client hello v3, signature_algorithm ext: 6" \
541 -s "ECDHE curve: secp521r1" \
542 -S "error" \
543 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200544
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000545run_test "Default, DTLS" \
546 "$P_SRV dtls=1" \
547 "$P_CLI dtls=1" \
548 0 \
549 -s "Protocol is DTLSv1.2" \
550 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
551
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100552# Tests for rc4 option
553
554run_test "RC4: server disabled, client enabled" \
555 "$P_SRV" \
556 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
557 1 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100558 -s "SSL - None of the common ciphersuites is usable"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100559
560run_test "RC4: server enabled, client disabled" \
561 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
562 "$P_CLI" \
563 1 \
564 -s "SSL - The server has no ciphersuites in common"
565
566run_test "RC4: both enabled" \
567 "$P_SRV arc4=1" \
568 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
569 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100570 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100571 -S "SSL - The server has no ciphersuites in common"
572
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100573# Test for SSLv2 ClientHello
574
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200575requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200576run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100577 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100578 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100579 0 \
580 -S "parse client hello v2" \
581 -S "ssl_handshake returned"
582
583# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200584requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200585run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200586 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100587 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100588 0 \
589 -s "parse client hello v2" \
590 -S "ssl_handshake returned"
591
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100592# Tests for Truncated HMAC extension
593
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100594run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200595 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100596 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100597 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100598 -s "dumping 'computed mac' (20 bytes)" \
599 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100600
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100601run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200602 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100603 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
604 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100605 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100606 -s "dumping 'computed mac' (20 bytes)" \
607 -S "dumping 'computed mac' (10 bytes)"
608
609run_test "Truncated HMAC: client enabled, server default" \
610 "$P_SRV debug_level=4" \
611 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
612 trunc_hmac=1" \
613 0 \
614 -S "dumping 'computed mac' (20 bytes)" \
615 -s "dumping 'computed mac' (10 bytes)"
616
617run_test "Truncated HMAC: client enabled, server disabled" \
618 "$P_SRV debug_level=4 trunc_hmac=0" \
619 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
620 trunc_hmac=1" \
621 0 \
622 -s "dumping 'computed mac' (20 bytes)" \
623 -S "dumping 'computed mac' (10 bytes)"
624
625run_test "Truncated HMAC: client enabled, server enabled" \
626 "$P_SRV debug_level=4 trunc_hmac=1" \
627 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
628 trunc_hmac=1" \
629 0 \
630 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100631 -s "dumping 'computed mac' (10 bytes)"
632
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100633# Tests for Encrypt-then-MAC extension
634
635run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100636 "$P_SRV debug_level=3 \
637 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100638 "$P_CLI debug_level=3" \
639 0 \
640 -c "client hello, adding encrypt_then_mac extension" \
641 -s "found encrypt then mac extension" \
642 -s "server hello, adding encrypt then mac extension" \
643 -c "found encrypt_then_mac extension" \
644 -c "using encrypt then mac" \
645 -s "using encrypt then mac"
646
647run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100648 "$P_SRV debug_level=3 etm=0 \
649 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100650 "$P_CLI debug_level=3 etm=1" \
651 0 \
652 -c "client hello, adding encrypt_then_mac extension" \
653 -s "found encrypt then mac extension" \
654 -S "server hello, adding encrypt then mac extension" \
655 -C "found encrypt_then_mac extension" \
656 -C "using encrypt then mac" \
657 -S "using encrypt then mac"
658
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100659run_test "Encrypt then MAC: client enabled, aead cipher" \
660 "$P_SRV debug_level=3 etm=1 \
661 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
662 "$P_CLI debug_level=3 etm=1" \
663 0 \
664 -c "client hello, adding encrypt_then_mac extension" \
665 -s "found encrypt then mac extension" \
666 -S "server hello, adding encrypt then mac extension" \
667 -C "found encrypt_then_mac extension" \
668 -C "using encrypt then mac" \
669 -S "using encrypt then mac"
670
671run_test "Encrypt then MAC: client enabled, stream cipher" \
672 "$P_SRV debug_level=3 etm=1 \
673 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100674 "$P_CLI debug_level=3 etm=1 arc4=1" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100675 0 \
676 -c "client hello, adding encrypt_then_mac extension" \
677 -s "found encrypt then mac extension" \
678 -S "server hello, adding encrypt then mac extension" \
679 -C "found encrypt_then_mac extension" \
680 -C "using encrypt then mac" \
681 -S "using encrypt then mac"
682
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100683run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100684 "$P_SRV debug_level=3 etm=1 \
685 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100686 "$P_CLI debug_level=3 etm=0" \
687 0 \
688 -C "client hello, adding encrypt_then_mac extension" \
689 -S "found encrypt then mac extension" \
690 -S "server hello, adding encrypt then mac extension" \
691 -C "found encrypt_then_mac extension" \
692 -C "using encrypt then mac" \
693 -S "using encrypt then mac"
694
695run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100696 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100697 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100698 "$P_CLI debug_level=3 force_version=ssl3" \
699 0 \
700 -C "client hello, adding encrypt_then_mac extension" \
701 -S "found encrypt then mac extension" \
702 -S "server hello, adding encrypt then mac extension" \
703 -C "found encrypt_then_mac extension" \
704 -C "using encrypt then mac" \
705 -S "using encrypt then mac"
706
707run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100708 "$P_SRV debug_level=3 force_version=ssl3 \
709 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100710 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100711 0 \
712 -c "client hello, adding encrypt_then_mac extension" \
713 -s "found encrypt then mac extension" \
714 -S "server hello, adding encrypt then mac extension" \
715 -C "found encrypt_then_mac extension" \
716 -C "using encrypt then mac" \
717 -S "using encrypt then mac"
718
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200719# Tests for Extended Master Secret extension
720
721run_test "Extended Master Secret: default" \
722 "$P_SRV debug_level=3" \
723 "$P_CLI debug_level=3" \
724 0 \
725 -c "client hello, adding extended_master_secret extension" \
726 -s "found extended master secret extension" \
727 -s "server hello, adding extended master secret extension" \
728 -c "found extended_master_secret extension" \
729 -c "using extended master secret" \
730 -s "using extended master secret"
731
732run_test "Extended Master Secret: client enabled, server disabled" \
733 "$P_SRV debug_level=3 extended_ms=0" \
734 "$P_CLI debug_level=3 extended_ms=1" \
735 0 \
736 -c "client hello, adding extended_master_secret extension" \
737 -s "found extended master secret extension" \
738 -S "server hello, adding extended master secret extension" \
739 -C "found extended_master_secret extension" \
740 -C "using extended master secret" \
741 -S "using extended master secret"
742
743run_test "Extended Master Secret: client disabled, server enabled" \
744 "$P_SRV debug_level=3 extended_ms=1" \
745 "$P_CLI debug_level=3 extended_ms=0" \
746 0 \
747 -C "client hello, adding extended_master_secret extension" \
748 -S "found extended master secret extension" \
749 -S "server hello, adding extended master secret extension" \
750 -C "found extended_master_secret extension" \
751 -C "using extended master secret" \
752 -S "using extended master secret"
753
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200754run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100755 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200756 "$P_CLI debug_level=3 force_version=ssl3" \
757 0 \
758 -C "client hello, adding extended_master_secret extension" \
759 -S "found extended master secret extension" \
760 -S "server hello, adding extended master secret extension" \
761 -C "found extended_master_secret extension" \
762 -C "using extended master secret" \
763 -S "using extended master secret"
764
765run_test "Extended Master Secret: client enabled, server SSLv3" \
766 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100767 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200768 0 \
769 -c "client hello, adding extended_master_secret extension" \
770 -s "found extended master secret extension" \
771 -S "server hello, adding extended master secret extension" \
772 -C "found extended_master_secret extension" \
773 -C "using extended master secret" \
774 -S "using extended master secret"
775
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200776# Tests for FALLBACK_SCSV
777
778run_test "Fallback SCSV: default" \
779 "$P_SRV" \
780 "$P_CLI debug_level=3 force_version=tls1_1" \
781 0 \
782 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200783 -S "received FALLBACK_SCSV" \
784 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200785 -C "is a fatal alert message (msg 86)"
786
787run_test "Fallback SCSV: explicitly disabled" \
788 "$P_SRV" \
789 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
790 0 \
791 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200792 -S "received FALLBACK_SCSV" \
793 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200794 -C "is a fatal alert message (msg 86)"
795
796run_test "Fallback SCSV: enabled" \
797 "$P_SRV" \
798 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200799 1 \
800 -c "adding FALLBACK_SCSV" \
801 -s "received FALLBACK_SCSV" \
802 -s "inapropriate fallback" \
803 -c "is a fatal alert message (msg 86)"
804
805run_test "Fallback SCSV: enabled, max version" \
806 "$P_SRV" \
807 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200808 0 \
809 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200810 -s "received FALLBACK_SCSV" \
811 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200812 -C "is a fatal alert message (msg 86)"
813
814requires_openssl_with_fallback_scsv
815run_test "Fallback SCSV: default, openssl server" \
816 "$O_SRV" \
817 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
818 0 \
819 -C "adding FALLBACK_SCSV" \
820 -C "is a fatal alert message (msg 86)"
821
822requires_openssl_with_fallback_scsv
823run_test "Fallback SCSV: enabled, openssl server" \
824 "$O_SRV" \
825 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
826 1 \
827 -c "adding FALLBACK_SCSV" \
828 -c "is a fatal alert message (msg 86)"
829
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200830requires_openssl_with_fallback_scsv
831run_test "Fallback SCSV: disabled, openssl client" \
832 "$P_SRV" \
833 "$O_CLI -tls1_1" \
834 0 \
835 -S "received FALLBACK_SCSV" \
836 -S "inapropriate fallback"
837
838requires_openssl_with_fallback_scsv
839run_test "Fallback SCSV: enabled, openssl client" \
840 "$P_SRV" \
841 "$O_CLI -tls1_1 -fallback_scsv" \
842 1 \
843 -s "received FALLBACK_SCSV" \
844 -s "inapropriate fallback"
845
846requires_openssl_with_fallback_scsv
847run_test "Fallback SCSV: enabled, max version, openssl client" \
848 "$P_SRV" \
849 "$O_CLI -fallback_scsv" \
850 0 \
851 -s "received FALLBACK_SCSV" \
852 -S "inapropriate fallback"
853
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100854# Tests for CBC 1/n-1 record splitting
855
856run_test "CBC Record splitting: TLS 1.2, no splitting" \
857 "$P_SRV" \
858 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
859 request_size=123 force_version=tls1_2" \
860 0 \
861 -s "Read from client: 123 bytes read" \
862 -S "Read from client: 1 bytes read" \
863 -S "122 bytes read"
864
865run_test "CBC Record splitting: TLS 1.1, no splitting" \
866 "$P_SRV" \
867 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
868 request_size=123 force_version=tls1_1" \
869 0 \
870 -s "Read from client: 123 bytes read" \
871 -S "Read from client: 1 bytes read" \
872 -S "122 bytes read"
873
874run_test "CBC Record splitting: TLS 1.0, splitting" \
875 "$P_SRV" \
876 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
877 request_size=123 force_version=tls1" \
878 0 \
879 -S "Read from client: 123 bytes read" \
880 -s "Read from client: 1 bytes read" \
881 -s "122 bytes read"
882
883run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100884 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100885 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
886 request_size=123 force_version=ssl3" \
887 0 \
888 -S "Read from client: 123 bytes read" \
889 -s "Read from client: 1 bytes read" \
890 -s "122 bytes read"
891
892run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100893 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100894 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
895 request_size=123 force_version=tls1" \
896 0 \
897 -s "Read from client: 123 bytes read" \
898 -S "Read from client: 1 bytes read" \
899 -S "122 bytes read"
900
901run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
902 "$P_SRV" \
903 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
904 request_size=123 force_version=tls1 recsplit=0" \
905 0 \
906 -s "Read from client: 123 bytes read" \
907 -S "Read from client: 1 bytes read" \
908 -S "122 bytes read"
909
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100910run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
911 "$P_SRV nbio=2" \
912 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
913 request_size=123 force_version=tls1" \
914 0 \
915 -S "Read from client: 123 bytes read" \
916 -s "Read from client: 1 bytes read" \
917 -s "122 bytes read"
918
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100919# Tests for Session Tickets
920
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200921run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200922 "$P_SRV debug_level=3 tickets=1" \
923 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100924 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100925 -c "client hello, adding session ticket extension" \
926 -s "found session ticket extension" \
927 -s "server hello, adding session ticket extension" \
928 -c "found session_ticket extension" \
929 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100930 -S "session successfully restored from cache" \
931 -s "session successfully restored from ticket" \
932 -s "a session has been resumed" \
933 -c "a session has been resumed"
934
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200935run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200936 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
937 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100938 0 \
939 -c "client hello, adding session ticket extension" \
940 -s "found session ticket extension" \
941 -s "server hello, adding session ticket extension" \
942 -c "found session_ticket extension" \
943 -c "parse new session ticket" \
944 -S "session successfully restored from cache" \
945 -s "session successfully restored from ticket" \
946 -s "a session has been resumed" \
947 -c "a session has been resumed"
948
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200949run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200950 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
951 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100952 0 \
953 -c "client hello, adding session ticket extension" \
954 -s "found session ticket extension" \
955 -s "server hello, adding session ticket extension" \
956 -c "found session_ticket extension" \
957 -c "parse new session ticket" \
958 -S "session successfully restored from cache" \
959 -S "session successfully restored from ticket" \
960 -S "a session has been resumed" \
961 -C "a session has been resumed"
962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200963run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100964 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200965 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100966 0 \
967 -c "client hello, adding session ticket extension" \
968 -c "found session_ticket extension" \
969 -c "parse new session ticket" \
970 -c "a session has been resumed"
971
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200972run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200973 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200974 "( $O_CLI -sess_out $SESSION; \
975 $O_CLI -sess_in $SESSION; \
976 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100977 0 \
978 -s "found session ticket extension" \
979 -s "server hello, adding session ticket extension" \
980 -S "session successfully restored from cache" \
981 -s "session successfully restored from ticket" \
982 -s "a session has been resumed"
983
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100984# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200986run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200987 "$P_SRV debug_level=3 tickets=0" \
988 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100989 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100990 -c "client hello, adding session ticket extension" \
991 -s "found session ticket extension" \
992 -S "server hello, adding session ticket extension" \
993 -C "found session_ticket extension" \
994 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100995 -s "session successfully restored from cache" \
996 -S "session successfully restored from ticket" \
997 -s "a session has been resumed" \
998 -c "a session has been resumed"
999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001000run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001001 "$P_SRV debug_level=3 tickets=1" \
1002 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001003 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001004 -C "client hello, adding session ticket extension" \
1005 -S "found session ticket extension" \
1006 -S "server hello, adding session ticket extension" \
1007 -C "found session_ticket extension" \
1008 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001009 -s "session successfully restored from cache" \
1010 -S "session successfully restored from ticket" \
1011 -s "a session has been resumed" \
1012 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001014run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001015 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1016 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001017 0 \
1018 -S "session successfully restored from cache" \
1019 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001020 -S "a session has been resumed" \
1021 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001023run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001024 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1025 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001026 0 \
1027 -s "session successfully restored from cache" \
1028 -S "session successfully restored from ticket" \
1029 -s "a session has been resumed" \
1030 -c "a session has been resumed"
1031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001032run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001033 "$P_SRV debug_level=3 tickets=0" \
1034 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001035 0 \
1036 -s "session successfully restored from cache" \
1037 -S "session successfully restored from ticket" \
1038 -s "a session has been resumed" \
1039 -c "a session has been resumed"
1040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001041run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001042 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1043 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001044 0 \
1045 -S "session successfully restored from cache" \
1046 -S "session successfully restored from ticket" \
1047 -S "a session has been resumed" \
1048 -C "a session has been resumed"
1049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001050run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001051 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1052 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001053 0 \
1054 -s "session successfully restored from cache" \
1055 -S "session successfully restored from ticket" \
1056 -s "a session has been resumed" \
1057 -c "a session has been resumed"
1058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001059run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001060 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001061 "( $O_CLI -sess_out $SESSION; \
1062 $O_CLI -sess_in $SESSION; \
1063 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001064 0 \
1065 -s "found session ticket extension" \
1066 -S "server hello, adding session ticket extension" \
1067 -s "session successfully restored from cache" \
1068 -S "session successfully restored from ticket" \
1069 -s "a session has been resumed"
1070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001071run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001072 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001073 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001074 0 \
1075 -C "found session_ticket extension" \
1076 -C "parse new session ticket" \
1077 -c "a session has been resumed"
1078
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001079# Tests for Max Fragment Length extension
1080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001081run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001082 "$P_SRV debug_level=3" \
1083 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001084 0 \
1085 -C "client hello, adding max_fragment_length extension" \
1086 -S "found max fragment length extension" \
1087 -S "server hello, max_fragment_length extension" \
1088 -C "found max_fragment_length extension"
1089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001090run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001091 "$P_SRV debug_level=3" \
1092 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001093 0 \
1094 -c "client hello, adding max_fragment_length extension" \
1095 -s "found max fragment length extension" \
1096 -s "server hello, max_fragment_length extension" \
1097 -c "found max_fragment_length extension"
1098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001099run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001100 "$P_SRV debug_level=3 max_frag_len=4096" \
1101 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001102 0 \
1103 -C "client hello, adding max_fragment_length extension" \
1104 -S "found max fragment length extension" \
1105 -S "server hello, max_fragment_length extension" \
1106 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001108requires_gnutls
1109run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001110 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001111 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001112 0 \
1113 -c "client hello, adding max_fragment_length extension" \
1114 -c "found max_fragment_length extension"
1115
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001116run_test "Max fragment length: client, message just fits" \
1117 "$P_SRV debug_level=3" \
1118 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1119 0 \
1120 -c "client hello, adding max_fragment_length extension" \
1121 -s "found max fragment length extension" \
1122 -s "server hello, max_fragment_length extension" \
1123 -c "found max_fragment_length extension" \
1124 -c "2048 bytes written in 1 fragments" \
1125 -s "2048 bytes read"
1126
1127run_test "Max fragment length: client, larger message" \
1128 "$P_SRV debug_level=3" \
1129 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1130 0 \
1131 -c "client hello, adding max_fragment_length extension" \
1132 -s "found max fragment length extension" \
1133 -s "server hello, max_fragment_length extension" \
1134 -c "found max_fragment_length extension" \
1135 -c "2345 bytes written in 2 fragments" \
1136 -s "2048 bytes read" \
1137 -s "297 bytes read"
1138
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001139run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001140 "$P_SRV debug_level=3 dtls=1" \
1141 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1142 1 \
1143 -c "client hello, adding max_fragment_length extension" \
1144 -s "found max fragment length extension" \
1145 -s "server hello, max_fragment_length extension" \
1146 -c "found max_fragment_length extension" \
1147 -c "fragment larger than.*maximum"
1148
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001149# Tests for renegotiation
1150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001151run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001152 "$P_SRV debug_level=3 exchanges=2" \
1153 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001154 0 \
1155 -C "client hello, adding renegotiation extension" \
1156 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1157 -S "found renegotiation extension" \
1158 -s "server hello, secure renegotiation extension" \
1159 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001160 -C "=> renegotiate" \
1161 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001162 -S "write hello request"
1163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001164run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001165 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
1166 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001167 0 \
1168 -c "client hello, adding renegotiation extension" \
1169 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1170 -s "found renegotiation extension" \
1171 -s "server hello, secure renegotiation extension" \
1172 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001173 -c "=> renegotiate" \
1174 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001175 -S "write hello request"
1176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001177run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001178 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1179 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001180 0 \
1181 -c "client hello, adding renegotiation extension" \
1182 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1183 -s "found renegotiation extension" \
1184 -s "server hello, secure renegotiation extension" \
1185 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001186 -c "=> renegotiate" \
1187 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001188 -s "write hello request"
1189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001190run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001191 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1192 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001193 0 \
1194 -c "client hello, adding renegotiation extension" \
1195 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1196 -s "found renegotiation extension" \
1197 -s "server hello, secure renegotiation extension" \
1198 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001199 -c "=> renegotiate" \
1200 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001201 -s "write hello request"
1202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001203run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001204 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1205 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001206 1 \
1207 -c "client hello, adding renegotiation extension" \
1208 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1209 -S "found renegotiation extension" \
1210 -s "server hello, secure renegotiation extension" \
1211 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001212 -c "=> renegotiate" \
1213 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001214 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001215 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001216 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001218run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001219 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1220 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001221 0 \
1222 -C "client hello, adding renegotiation extension" \
1223 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1224 -S "found renegotiation extension" \
1225 -s "server hello, secure renegotiation extension" \
1226 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001227 -C "=> renegotiate" \
1228 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001229 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001230 -S "SSL - An unexpected message was received from our peer" \
1231 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001233run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001234 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001235 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001236 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001237 0 \
1238 -C "client hello, adding renegotiation extension" \
1239 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1240 -S "found renegotiation extension" \
1241 -s "server hello, secure renegotiation extension" \
1242 -c "found renegotiation extension" \
1243 -C "=> renegotiate" \
1244 -S "=> renegotiate" \
1245 -s "write hello request" \
1246 -S "SSL - An unexpected message was received from our peer" \
1247 -S "failed"
1248
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001249# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001250run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001251 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001252 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001253 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001254 0 \
1255 -C "client hello, adding renegotiation extension" \
1256 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1257 -S "found renegotiation extension" \
1258 -s "server hello, secure renegotiation extension" \
1259 -c "found renegotiation extension" \
1260 -C "=> renegotiate" \
1261 -S "=> renegotiate" \
1262 -s "write hello request" \
1263 -S "SSL - An unexpected message was received from our peer" \
1264 -S "failed"
1265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001266run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001267 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001268 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001269 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001270 0 \
1271 -C "client hello, adding renegotiation extension" \
1272 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1273 -S "found renegotiation extension" \
1274 -s "server hello, secure renegotiation extension" \
1275 -c "found renegotiation extension" \
1276 -C "=> renegotiate" \
1277 -S "=> renegotiate" \
1278 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001279 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001281run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001282 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001283 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001284 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001285 0 \
1286 -c "client hello, adding renegotiation extension" \
1287 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1288 -s "found renegotiation extension" \
1289 -s "server hello, secure renegotiation extension" \
1290 -c "found renegotiation extension" \
1291 -c "=> renegotiate" \
1292 -s "=> renegotiate" \
1293 -s "write hello request" \
1294 -S "SSL - An unexpected message was received from our peer" \
1295 -S "failed"
1296
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001297run_test "Renegotiation: periodic, just below period" \
1298 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1299 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1300 0 \
1301 -C "client hello, adding renegotiation extension" \
1302 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1303 -S "found renegotiation extension" \
1304 -s "server hello, secure renegotiation extension" \
1305 -c "found renegotiation extension" \
1306 -S "record counter limit reached: renegotiate" \
1307 -C "=> renegotiate" \
1308 -S "=> renegotiate" \
1309 -S "write hello request" \
1310 -S "SSL - An unexpected message was received from our peer" \
1311 -S "failed"
1312
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001313# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001314run_test "Renegotiation: periodic, just above period" \
1315 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001316 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001317 0 \
1318 -c "client hello, adding renegotiation extension" \
1319 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1320 -s "found renegotiation extension" \
1321 -s "server hello, secure renegotiation extension" \
1322 -c "found renegotiation extension" \
1323 -s "record counter limit reached: renegotiate" \
1324 -c "=> renegotiate" \
1325 -s "=> renegotiate" \
1326 -s "write hello request" \
1327 -S "SSL - An unexpected message was received from our peer" \
1328 -S "failed"
1329
1330run_test "Renegotiation: periodic, two times period" \
1331 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001332 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001333 0 \
1334 -c "client hello, adding renegotiation extension" \
1335 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1336 -s "found renegotiation extension" \
1337 -s "server hello, secure renegotiation extension" \
1338 -c "found renegotiation extension" \
1339 -s "record counter limit reached: renegotiate" \
1340 -c "=> renegotiate" \
1341 -s "=> renegotiate" \
1342 -s "write hello request" \
1343 -S "SSL - An unexpected message was received from our peer" \
1344 -S "failed"
1345
1346run_test "Renegotiation: periodic, above period, disabled" \
1347 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1348 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1349 0 \
1350 -C "client hello, adding renegotiation extension" \
1351 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1352 -S "found renegotiation extension" \
1353 -s "server hello, secure renegotiation extension" \
1354 -c "found renegotiation extension" \
1355 -S "record counter limit reached: renegotiate" \
1356 -C "=> renegotiate" \
1357 -S "=> renegotiate" \
1358 -S "write hello request" \
1359 -S "SSL - An unexpected message was received from our peer" \
1360 -S "failed"
1361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001362run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001363 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1364 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001365 0 \
1366 -c "client hello, adding renegotiation extension" \
1367 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1368 -s "found renegotiation extension" \
1369 -s "server hello, secure renegotiation extension" \
1370 -c "found renegotiation extension" \
1371 -c "=> renegotiate" \
1372 -s "=> renegotiate" \
1373 -S "write hello request"
1374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001375run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001376 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1377 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001378 0 \
1379 -c "client hello, adding renegotiation extension" \
1380 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1381 -s "found renegotiation extension" \
1382 -s "server hello, secure renegotiation extension" \
1383 -c "found renegotiation extension" \
1384 -c "=> renegotiate" \
1385 -s "=> renegotiate" \
1386 -s "write hello request"
1387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001388run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001389 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001390 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001391 0 \
1392 -c "client hello, adding renegotiation extension" \
1393 -c "found renegotiation extension" \
1394 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001395 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001396 -C "error" \
1397 -c "HTTP/1.0 200 [Oo][Kk]"
1398
Paul Bakker539d9722015-02-08 16:18:35 +01001399requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001400run_test "Renegotiation: gnutls server strict, client-initiated" \
1401 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001402 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001403 0 \
1404 -c "client hello, adding renegotiation extension" \
1405 -c "found renegotiation extension" \
1406 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001407 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001408 -C "error" \
1409 -c "HTTP/1.0 200 [Oo][Kk]"
1410
Paul Bakker539d9722015-02-08 16:18:35 +01001411requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001412run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1413 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1414 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1415 1 \
1416 -c "client hello, adding renegotiation extension" \
1417 -C "found renegotiation extension" \
1418 -c "=> renegotiate" \
1419 -c "ssl_handshake() returned" \
1420 -c "error" \
1421 -C "HTTP/1.0 200 [Oo][Kk]"
1422
Paul Bakker539d9722015-02-08 16:18:35 +01001423requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001424run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1425 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1426 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1427 allow_legacy=0" \
1428 1 \
1429 -c "client hello, adding renegotiation extension" \
1430 -C "found renegotiation extension" \
1431 -c "=> renegotiate" \
1432 -c "ssl_handshake() returned" \
1433 -c "error" \
1434 -C "HTTP/1.0 200 [Oo][Kk]"
1435
Paul Bakker539d9722015-02-08 16:18:35 +01001436requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001437run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1438 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1439 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1440 allow_legacy=1" \
1441 0 \
1442 -c "client hello, adding renegotiation extension" \
1443 -C "found renegotiation extension" \
1444 -c "=> renegotiate" \
1445 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001446 -C "error" \
1447 -c "HTTP/1.0 200 [Oo][Kk]"
1448
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001449run_test "Renegotiation: DTLS, client-initiated" \
1450 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1451 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1452 0 \
1453 -c "client hello, adding renegotiation extension" \
1454 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1455 -s "found renegotiation extension" \
1456 -s "server hello, secure renegotiation extension" \
1457 -c "found renegotiation extension" \
1458 -c "=> renegotiate" \
1459 -s "=> renegotiate" \
1460 -S "write hello request"
1461
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001462run_test "Renegotiation: DTLS, server-initiated" \
1463 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001464 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1465 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001466 0 \
1467 -c "client hello, adding renegotiation extension" \
1468 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1469 -s "found renegotiation extension" \
1470 -s "server hello, secure renegotiation extension" \
1471 -c "found renegotiation extension" \
1472 -c "=> renegotiate" \
1473 -s "=> renegotiate" \
1474 -s "write hello request"
1475
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001476requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001477run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1478 "$G_SRV -u --mtu 4096" \
1479 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1480 0 \
1481 -c "client hello, adding renegotiation extension" \
1482 -c "found renegotiation extension" \
1483 -c "=> renegotiate" \
1484 -C "ssl_handshake returned" \
1485 -C "error" \
1486 -s "Extra-header:"
1487
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001488# Test for the "secure renegotation" extension only (no actual renegotiation)
1489
Paul Bakker539d9722015-02-08 16:18:35 +01001490requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001491run_test "Renego ext: gnutls server strict, client default" \
1492 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1493 "$P_CLI debug_level=3" \
1494 0 \
1495 -c "found renegotiation extension" \
1496 -C "error" \
1497 -c "HTTP/1.0 200 [Oo][Kk]"
1498
Paul Bakker539d9722015-02-08 16:18:35 +01001499requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001500run_test "Renego ext: gnutls server unsafe, client default" \
1501 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1502 "$P_CLI debug_level=3" \
1503 0 \
1504 -C "found renegotiation extension" \
1505 -C "error" \
1506 -c "HTTP/1.0 200 [Oo][Kk]"
1507
Paul Bakker539d9722015-02-08 16:18:35 +01001508requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001509run_test "Renego ext: gnutls server unsafe, client break legacy" \
1510 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1511 "$P_CLI debug_level=3 allow_legacy=-1" \
1512 1 \
1513 -C "found renegotiation extension" \
1514 -c "error" \
1515 -C "HTTP/1.0 200 [Oo][Kk]"
1516
Paul Bakker539d9722015-02-08 16:18:35 +01001517requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001518run_test "Renego ext: gnutls client strict, server default" \
1519 "$P_SRV debug_level=3" \
1520 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1521 0 \
1522 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1523 -s "server hello, secure renegotiation extension"
1524
Paul Bakker539d9722015-02-08 16:18:35 +01001525requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001526run_test "Renego ext: gnutls client unsafe, server default" \
1527 "$P_SRV debug_level=3" \
1528 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1529 0 \
1530 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1531 -S "server hello, secure renegotiation extension"
1532
Paul Bakker539d9722015-02-08 16:18:35 +01001533requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001534run_test "Renego ext: gnutls client unsafe, server break legacy" \
1535 "$P_SRV debug_level=3 allow_legacy=-1" \
1536 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1537 1 \
1538 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1539 -S "server hello, secure renegotiation extension"
1540
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001541# Tests for auth_mode
1542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001543run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001544 "$P_SRV crt_file=data_files/server5-badsign.crt \
1545 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001546 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001547 1 \
1548 -c "x509_verify_cert() returned" \
1549 -c "! self-signed or not signed by a trusted CA" \
1550 -c "! ssl_handshake returned" \
1551 -c "X509 - Certificate verification failed"
1552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001553run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001554 "$P_SRV crt_file=data_files/server5-badsign.crt \
1555 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001556 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001557 0 \
1558 -c "x509_verify_cert() returned" \
1559 -c "! self-signed or not signed by a trusted CA" \
1560 -C "! ssl_handshake returned" \
1561 -C "X509 - Certificate verification failed"
1562
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001563run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001564 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001565 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001566 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001567 0 \
1568 -C "x509_verify_cert() returned" \
1569 -C "! self-signed or not signed by a trusted CA" \
1570 -C "! ssl_handshake returned" \
1571 -C "X509 - Certificate verification failed"
1572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001573run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001574 "$P_SRV debug_level=3 auth_mode=required" \
1575 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001576 key_file=data_files/server5.key" \
1577 1 \
1578 -S "skip write certificate request" \
1579 -C "skip parse certificate request" \
1580 -c "got a certificate request" \
1581 -C "skip write certificate" \
1582 -C "skip write certificate verify" \
1583 -S "skip parse certificate verify" \
1584 -s "x509_verify_cert() returned" \
1585 -S "! self-signed or not signed by a trusted CA" \
1586 -s "! ssl_handshake returned" \
1587 -c "! ssl_handshake returned" \
1588 -s "X509 - Certificate verification failed"
1589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001590run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001591 "$P_SRV debug_level=3 auth_mode=optional" \
1592 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001593 key_file=data_files/server5.key" \
1594 0 \
1595 -S "skip write certificate request" \
1596 -C "skip parse certificate request" \
1597 -c "got a certificate request" \
1598 -C "skip write certificate" \
1599 -C "skip write certificate verify" \
1600 -S "skip parse certificate verify" \
1601 -s "x509_verify_cert() returned" \
1602 -s "! self-signed or not signed by a trusted CA" \
1603 -S "! ssl_handshake returned" \
1604 -C "! ssl_handshake returned" \
1605 -S "X509 - Certificate verification failed"
1606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001607run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001608 "$P_SRV debug_level=3 auth_mode=none" \
1609 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001610 key_file=data_files/server5.key" \
1611 0 \
1612 -s "skip write certificate request" \
1613 -C "skip parse certificate request" \
1614 -c "got no certificate request" \
1615 -c "skip write certificate" \
1616 -c "skip write certificate verify" \
1617 -s "skip parse certificate verify" \
1618 -S "x509_verify_cert() returned" \
1619 -S "! self-signed or not signed by a trusted CA" \
1620 -S "! ssl_handshake returned" \
1621 -C "! ssl_handshake returned" \
1622 -S "X509 - Certificate verification failed"
1623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001624run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001625 "$P_SRV debug_level=3 auth_mode=optional" \
1626 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001627 0 \
1628 -S "skip write certificate request" \
1629 -C "skip parse certificate request" \
1630 -c "got a certificate request" \
1631 -C "skip write certificate$" \
1632 -C "got no certificate to send" \
1633 -S "SSLv3 client has no certificate" \
1634 -c "skip write certificate verify" \
1635 -s "skip parse certificate verify" \
1636 -s "! no client certificate sent" \
1637 -S "! ssl_handshake returned" \
1638 -C "! ssl_handshake returned" \
1639 -S "X509 - Certificate verification failed"
1640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001641run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001642 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001643 "$O_CLI" \
1644 0 \
1645 -S "skip write certificate request" \
1646 -s "skip parse certificate verify" \
1647 -s "! no client certificate sent" \
1648 -S "! ssl_handshake returned" \
1649 -S "X509 - Certificate verification failed"
1650
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001651run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001652 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001653 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001654 0 \
1655 -C "skip parse certificate request" \
1656 -c "got a certificate request" \
1657 -C "skip write certificate$" \
1658 -c "skip write certificate verify" \
1659 -C "! ssl_handshake returned"
1660
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001661run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001662 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001663 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001664 0 \
1665 -S "skip write certificate request" \
1666 -C "skip parse certificate request" \
1667 -c "got a certificate request" \
1668 -C "skip write certificate$" \
1669 -c "skip write certificate verify" \
1670 -c "got no certificate to send" \
1671 -s "SSLv3 client has no certificate" \
1672 -s "skip parse certificate verify" \
1673 -s "! no client certificate sent" \
1674 -S "! ssl_handshake returned" \
1675 -C "! ssl_handshake returned" \
1676 -S "X509 - Certificate verification failed"
1677
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001678# Tests for certificate selection based on SHA verson
1679
1680run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1681 "$P_SRV crt_file=data_files/server5.crt \
1682 key_file=data_files/server5.key \
1683 crt_file2=data_files/server5-sha1.crt \
1684 key_file2=data_files/server5.key" \
1685 "$P_CLI force_version=tls1_2" \
1686 0 \
1687 -c "signed using.*ECDSA with SHA256" \
1688 -C "signed using.*ECDSA with SHA1"
1689
1690run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1691 "$P_SRV crt_file=data_files/server5.crt \
1692 key_file=data_files/server5.key \
1693 crt_file2=data_files/server5-sha1.crt \
1694 key_file2=data_files/server5.key" \
1695 "$P_CLI force_version=tls1_1" \
1696 0 \
1697 -C "signed using.*ECDSA with SHA256" \
1698 -c "signed using.*ECDSA with SHA1"
1699
1700run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1701 "$P_SRV crt_file=data_files/server5.crt \
1702 key_file=data_files/server5.key \
1703 crt_file2=data_files/server5-sha1.crt \
1704 key_file2=data_files/server5.key" \
1705 "$P_CLI force_version=tls1" \
1706 0 \
1707 -C "signed using.*ECDSA with SHA256" \
1708 -c "signed using.*ECDSA with SHA1"
1709
1710run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1711 "$P_SRV crt_file=data_files/server5.crt \
1712 key_file=data_files/server5.key \
1713 crt_file2=data_files/server6.crt \
1714 key_file2=data_files/server6.key" \
1715 "$P_CLI force_version=tls1_1" \
1716 0 \
1717 -c "serial number.*09" \
1718 -c "signed using.*ECDSA with SHA256" \
1719 -C "signed using.*ECDSA with SHA1"
1720
1721run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1722 "$P_SRV crt_file=data_files/server6.crt \
1723 key_file=data_files/server6.key \
1724 crt_file2=data_files/server5.crt \
1725 key_file2=data_files/server5.key" \
1726 "$P_CLI force_version=tls1_1" \
1727 0 \
1728 -c "serial number.*0A" \
1729 -c "signed using.*ECDSA with SHA256" \
1730 -C "signed using.*ECDSA with SHA1"
1731
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001732# tests for SNI
1733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001734run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001735 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001736 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001737 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001738 0 \
1739 -S "parse ServerName extension" \
1740 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1741 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001743run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001744 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001745 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001746 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 +02001747 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001748 0 \
1749 -s "parse ServerName extension" \
1750 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1751 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001753run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001754 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001755 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001756 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 +02001757 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001758 0 \
1759 -s "parse ServerName extension" \
1760 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001761 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001763run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001764 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001765 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001766 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 +02001767 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001768 1 \
1769 -s "parse ServerName extension" \
1770 -s "ssl_sni_wrapper() returned" \
1771 -s "ssl_handshake returned" \
1772 -c "ssl_handshake returned" \
1773 -c "SSL - A fatal alert message was received from our peer"
1774
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001775# Tests for non-blocking I/O: exercise a variety of handshake flows
1776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001778 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1779 "$P_CLI nbio=2 tickets=0" \
1780 0 \
1781 -S "ssl_handshake returned" \
1782 -C "ssl_handshake returned" \
1783 -c "Read from server: .* bytes read"
1784
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001785run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001786 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1787 "$P_CLI nbio=2 tickets=0" \
1788 0 \
1789 -S "ssl_handshake returned" \
1790 -C "ssl_handshake returned" \
1791 -c "Read from server: .* bytes read"
1792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001793run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001794 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1795 "$P_CLI nbio=2 tickets=1" \
1796 0 \
1797 -S "ssl_handshake returned" \
1798 -C "ssl_handshake returned" \
1799 -c "Read from server: .* bytes read"
1800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001801run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001802 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1803 "$P_CLI nbio=2 tickets=1" \
1804 0 \
1805 -S "ssl_handshake returned" \
1806 -C "ssl_handshake returned" \
1807 -c "Read from server: .* bytes read"
1808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001809run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001810 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1811 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1812 0 \
1813 -S "ssl_handshake returned" \
1814 -C "ssl_handshake returned" \
1815 -c "Read from server: .* bytes read"
1816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001817run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001818 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1819 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1820 0 \
1821 -S "ssl_handshake returned" \
1822 -C "ssl_handshake returned" \
1823 -c "Read from server: .* bytes read"
1824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001825run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001826 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1827 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1828 0 \
1829 -S "ssl_handshake returned" \
1830 -C "ssl_handshake returned" \
1831 -c "Read from server: .* bytes read"
1832
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001833# Tests for version negotiation
1834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001835run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001836 "$P_SRV" \
1837 "$P_CLI" \
1838 0 \
1839 -S "ssl_handshake returned" \
1840 -C "ssl_handshake returned" \
1841 -s "Protocol is TLSv1.2" \
1842 -c "Protocol is TLSv1.2"
1843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001844run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001845 "$P_SRV" \
1846 "$P_CLI max_version=tls1_1" \
1847 0 \
1848 -S "ssl_handshake returned" \
1849 -C "ssl_handshake returned" \
1850 -s "Protocol is TLSv1.1" \
1851 -c "Protocol is TLSv1.1"
1852
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001853run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001854 "$P_SRV max_version=tls1_1" \
1855 "$P_CLI" \
1856 0 \
1857 -S "ssl_handshake returned" \
1858 -C "ssl_handshake returned" \
1859 -s "Protocol is TLSv1.1" \
1860 -c "Protocol is TLSv1.1"
1861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001862run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001863 "$P_SRV max_version=tls1_1" \
1864 "$P_CLI max_version=tls1_1" \
1865 0 \
1866 -S "ssl_handshake returned" \
1867 -C "ssl_handshake returned" \
1868 -s "Protocol is TLSv1.1" \
1869 -c "Protocol is TLSv1.1"
1870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001871run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001872 "$P_SRV min_version=tls1_1" \
1873 "$P_CLI max_version=tls1_1" \
1874 0 \
1875 -S "ssl_handshake returned" \
1876 -C "ssl_handshake returned" \
1877 -s "Protocol is TLSv1.1" \
1878 -c "Protocol is TLSv1.1"
1879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001880run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001881 "$P_SRV max_version=tls1_1" \
1882 "$P_CLI min_version=tls1_1" \
1883 0 \
1884 -S "ssl_handshake returned" \
1885 -C "ssl_handshake returned" \
1886 -s "Protocol is TLSv1.1" \
1887 -c "Protocol is TLSv1.1"
1888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001889run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001890 "$P_SRV max_version=tls1_1" \
1891 "$P_CLI min_version=tls1_2" \
1892 1 \
1893 -s "ssl_handshake returned" \
1894 -c "ssl_handshake returned" \
1895 -c "SSL - Handshake protocol not within min/max boundaries"
1896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001897run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001898 "$P_SRV min_version=tls1_2" \
1899 "$P_CLI max_version=tls1_1" \
1900 1 \
1901 -s "ssl_handshake returned" \
1902 -c "ssl_handshake returned" \
1903 -s "SSL - Handshake protocol not within min/max boundaries"
1904
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001905# Tests for ALPN extension
1906
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001907if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001909run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001910 "$P_SRV debug_level=3" \
1911 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001912 0 \
1913 -C "client hello, adding alpn extension" \
1914 -S "found alpn extension" \
1915 -C "got an alert message, type: \\[2:120]" \
1916 -S "server hello, adding alpn extension" \
1917 -C "found alpn extension " \
1918 -C "Application Layer Protocol is" \
1919 -S "Application Layer Protocol is"
1920
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001921run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001922 "$P_SRV debug_level=3" \
1923 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001924 0 \
1925 -c "client hello, adding alpn extension" \
1926 -s "found alpn extension" \
1927 -C "got an alert message, type: \\[2:120]" \
1928 -S "server hello, adding alpn extension" \
1929 -C "found alpn extension " \
1930 -c "Application Layer Protocol is (none)" \
1931 -S "Application Layer Protocol is"
1932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001933run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001934 "$P_SRV debug_level=3 alpn=abc,1234" \
1935 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001936 0 \
1937 -C "client hello, adding alpn extension" \
1938 -S "found alpn extension" \
1939 -C "got an alert message, type: \\[2:120]" \
1940 -S "server hello, adding alpn extension" \
1941 -C "found alpn extension " \
1942 -C "Application Layer Protocol is" \
1943 -s "Application Layer Protocol is (none)"
1944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001945run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001946 "$P_SRV debug_level=3 alpn=abc,1234" \
1947 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001948 0 \
1949 -c "client hello, adding alpn extension" \
1950 -s "found alpn extension" \
1951 -C "got an alert message, type: \\[2:120]" \
1952 -s "server hello, adding alpn extension" \
1953 -c "found alpn extension" \
1954 -c "Application Layer Protocol is abc" \
1955 -s "Application Layer Protocol is abc"
1956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001957run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001958 "$P_SRV debug_level=3 alpn=abc,1234" \
1959 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001960 0 \
1961 -c "client hello, adding alpn extension" \
1962 -s "found alpn extension" \
1963 -C "got an alert message, type: \\[2:120]" \
1964 -s "server hello, adding alpn extension" \
1965 -c "found alpn extension" \
1966 -c "Application Layer Protocol is abc" \
1967 -s "Application Layer Protocol is abc"
1968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001969run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001970 "$P_SRV debug_level=3 alpn=abc,1234" \
1971 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001972 0 \
1973 -c "client hello, adding alpn extension" \
1974 -s "found alpn extension" \
1975 -C "got an alert message, type: \\[2:120]" \
1976 -s "server hello, adding alpn extension" \
1977 -c "found alpn extension" \
1978 -c "Application Layer Protocol is 1234" \
1979 -s "Application Layer Protocol is 1234"
1980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001981run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001982 "$P_SRV debug_level=3 alpn=abc,123" \
1983 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001984 1 \
1985 -c "client hello, adding alpn extension" \
1986 -s "found alpn extension" \
1987 -c "got an alert message, type: \\[2:120]" \
1988 -S "server hello, adding alpn extension" \
1989 -C "found alpn extension" \
1990 -C "Application Layer Protocol is 1234" \
1991 -S "Application Layer Protocol is 1234"
1992
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001993fi
1994
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001995# Tests for keyUsage in leaf certificates, part 1:
1996# server-side certificate/suite selection
1997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001998run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001999 "$P_SRV key_file=data_files/server2.key \
2000 crt_file=data_files/server2.ku-ds.crt" \
2001 "$P_CLI" \
2002 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002003 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002004
2005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002006run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002007 "$P_SRV key_file=data_files/server2.key \
2008 crt_file=data_files/server2.ku-ke.crt" \
2009 "$P_CLI" \
2010 0 \
2011 -c "Ciphersuite is TLS-RSA-WITH-"
2012
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002013run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002014 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002015 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002016 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002017 1 \
2018 -C "Ciphersuite is "
2019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002020run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002021 "$P_SRV key_file=data_files/server5.key \
2022 crt_file=data_files/server5.ku-ds.crt" \
2023 "$P_CLI" \
2024 0 \
2025 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2026
2027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002028run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002029 "$P_SRV key_file=data_files/server5.key \
2030 crt_file=data_files/server5.ku-ka.crt" \
2031 "$P_CLI" \
2032 0 \
2033 -c "Ciphersuite is TLS-ECDH-"
2034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002035run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002036 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002037 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002038 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002039 1 \
2040 -C "Ciphersuite is "
2041
2042# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002043# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002045run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002046 "$O_SRV -key data_files/server2.key \
2047 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002048 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002049 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2050 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002051 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002052 -C "Processing of the Certificate handshake message failed" \
2053 -c "Ciphersuite is TLS-"
2054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002055run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002056 "$O_SRV -key data_files/server2.key \
2057 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002058 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002059 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2060 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002061 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002062 -C "Processing of the Certificate handshake message failed" \
2063 -c "Ciphersuite is TLS-"
2064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002065run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002066 "$O_SRV -key data_files/server2.key \
2067 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002068 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002069 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2070 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002071 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002072 -C "Processing of the Certificate handshake message failed" \
2073 -c "Ciphersuite is TLS-"
2074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002075run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002076 "$O_SRV -key data_files/server2.key \
2077 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002078 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002079 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2080 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002081 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002082 -c "Processing of the Certificate handshake message failed" \
2083 -C "Ciphersuite is TLS-"
2084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002085run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002086 "$O_SRV -key data_files/server2.key \
2087 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002088 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002089 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2090 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002091 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002092 -C "Processing of the Certificate handshake message failed" \
2093 -c "Ciphersuite is TLS-"
2094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002095run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002096 "$O_SRV -key data_files/server2.key \
2097 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002098 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002099 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2100 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002101 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002102 -c "Processing of the Certificate handshake message failed" \
2103 -C "Ciphersuite is TLS-"
2104
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002105# Tests for keyUsage in leaf certificates, part 3:
2106# server-side checking of client cert
2107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002108run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002109 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002110 "$O_CLI -key data_files/server2.key \
2111 -cert data_files/server2.ku-ds.crt" \
2112 0 \
2113 -S "bad certificate (usage extensions)" \
2114 -S "Processing of the Certificate handshake message failed"
2115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002116run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002117 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002118 "$O_CLI -key data_files/server2.key \
2119 -cert data_files/server2.ku-ke.crt" \
2120 0 \
2121 -s "bad certificate (usage extensions)" \
2122 -S "Processing of the Certificate handshake message failed"
2123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002124run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002125 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002126 "$O_CLI -key data_files/server2.key \
2127 -cert data_files/server2.ku-ke.crt" \
2128 1 \
2129 -s "bad certificate (usage extensions)" \
2130 -s "Processing of the Certificate handshake message failed"
2131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002132run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002133 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002134 "$O_CLI -key data_files/server5.key \
2135 -cert data_files/server5.ku-ds.crt" \
2136 0 \
2137 -S "bad certificate (usage extensions)" \
2138 -S "Processing of the Certificate handshake message failed"
2139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002140run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002141 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002142 "$O_CLI -key data_files/server5.key \
2143 -cert data_files/server5.ku-ka.crt" \
2144 0 \
2145 -s "bad certificate (usage extensions)" \
2146 -S "Processing of the Certificate handshake message failed"
2147
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002148# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2149
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002150run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002151 "$P_SRV key_file=data_files/server5.key \
2152 crt_file=data_files/server5.eku-srv.crt" \
2153 "$P_CLI" \
2154 0
2155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002156run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002157 "$P_SRV key_file=data_files/server5.key \
2158 crt_file=data_files/server5.eku-srv.crt" \
2159 "$P_CLI" \
2160 0
2161
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002162run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002163 "$P_SRV key_file=data_files/server5.key \
2164 crt_file=data_files/server5.eku-cs_any.crt" \
2165 "$P_CLI" \
2166 0
2167
2168# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002169run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002170 "$P_SRV psk=abc123 key_file=data_files/server5.key \
2171 crt_file=data_files/server5.eku-cli.crt" \
2172 "$P_CLI psk=badbad" \
2173 1
2174
2175# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002177run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002178 "$O_SRV -key data_files/server5.key \
2179 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002180 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002181 0 \
2182 -C "bad certificate (usage extensions)" \
2183 -C "Processing of the Certificate handshake message failed" \
2184 -c "Ciphersuite is TLS-"
2185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002186run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002187 "$O_SRV -key data_files/server5.key \
2188 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002189 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002190 0 \
2191 -C "bad certificate (usage extensions)" \
2192 -C "Processing of the Certificate handshake message failed" \
2193 -c "Ciphersuite is TLS-"
2194
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002195run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002196 "$O_SRV -key data_files/server5.key \
2197 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002198 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002199 0 \
2200 -C "bad certificate (usage extensions)" \
2201 -C "Processing of the Certificate handshake message failed" \
2202 -c "Ciphersuite is TLS-"
2203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002204run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002205 "$O_SRV -key data_files/server5.key \
2206 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002207 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002208 1 \
2209 -c "bad certificate (usage extensions)" \
2210 -c "Processing of the Certificate handshake message failed" \
2211 -C "Ciphersuite is TLS-"
2212
2213# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002215run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002216 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002217 "$O_CLI -key data_files/server5.key \
2218 -cert data_files/server5.eku-cli.crt" \
2219 0 \
2220 -S "bad certificate (usage extensions)" \
2221 -S "Processing of the Certificate handshake message failed"
2222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002223run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002224 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002225 "$O_CLI -key data_files/server5.key \
2226 -cert data_files/server5.eku-srv_cli.crt" \
2227 0 \
2228 -S "bad certificate (usage extensions)" \
2229 -S "Processing of the Certificate handshake message failed"
2230
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002231run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002232 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002233 "$O_CLI -key data_files/server5.key \
2234 -cert data_files/server5.eku-cs_any.crt" \
2235 0 \
2236 -S "bad certificate (usage extensions)" \
2237 -S "Processing of the Certificate handshake message failed"
2238
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002239run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002240 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002241 "$O_CLI -key data_files/server5.key \
2242 -cert data_files/server5.eku-cs.crt" \
2243 0 \
2244 -s "bad certificate (usage extensions)" \
2245 -S "Processing of the Certificate handshake message failed"
2246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002247run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002248 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002249 "$O_CLI -key data_files/server5.key \
2250 -cert data_files/server5.eku-cs.crt" \
2251 1 \
2252 -s "bad certificate (usage extensions)" \
2253 -s "Processing of the Certificate handshake message failed"
2254
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002255# Tests for DHM parameters loading
2256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002257run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002258 "$P_SRV" \
2259 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2260 debug_level=3" \
2261 0 \
2262 -c "value of 'DHM: P ' (2048 bits)" \
2263 -c "value of 'DHM: G ' (2048 bits)"
2264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002265run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002266 "$P_SRV dhm_file=data_files/dhparams.pem" \
2267 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2268 debug_level=3" \
2269 0 \
2270 -c "value of 'DHM: P ' (1024 bits)" \
2271 -c "value of 'DHM: G ' (2 bits)"
2272
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002273# Tests for PSK callback
2274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002275run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002276 "$P_SRV psk=abc123 psk_identity=foo" \
2277 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2278 psk_identity=foo psk=abc123" \
2279 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002280 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002281 -S "SSL - Unknown identity received" \
2282 -S "SSL - Verification of the message MAC failed"
2283
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002284run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002285 "$P_SRV" \
2286 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2287 psk_identity=foo psk=abc123" \
2288 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002289 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002290 -S "SSL - Unknown identity received" \
2291 -S "SSL - Verification of the message MAC failed"
2292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002293run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002294 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2295 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2296 psk_identity=foo psk=abc123" \
2297 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002298 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002299 -s "SSL - Unknown identity received" \
2300 -S "SSL - Verification of the message MAC failed"
2301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002302run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002303 "$P_SRV psk_list=abc,dead,def,beef" \
2304 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2305 psk_identity=abc psk=dead" \
2306 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002307 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002308 -S "SSL - Unknown identity received" \
2309 -S "SSL - Verification of the message MAC failed"
2310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002311run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002312 "$P_SRV psk_list=abc,dead,def,beef" \
2313 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2314 psk_identity=def psk=beef" \
2315 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002316 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002317 -S "SSL - Unknown identity received" \
2318 -S "SSL - Verification of the message MAC failed"
2319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002320run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002321 "$P_SRV psk_list=abc,dead,def,beef" \
2322 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2323 psk_identity=ghi psk=beef" \
2324 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002325 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002326 -s "SSL - Unknown identity received" \
2327 -S "SSL - Verification of the message MAC failed"
2328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002329run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002330 "$P_SRV psk_list=abc,dead,def,beef" \
2331 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2332 psk_identity=abc psk=beef" \
2333 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002334 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002335 -S "SSL - Unknown identity received" \
2336 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002337
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002338# Tests for ciphersuites per version
2339
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002340run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002341 "$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 +02002342 "$P_CLI force_version=ssl3" \
2343 0 \
2344 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002346run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002347 "$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" \
2348 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002349 0 \
2350 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002352run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002353 "$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" \
2354 "$P_CLI force_version=tls1_1" \
2355 0 \
2356 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2357
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002358run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002359 "$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" \
2360 "$P_CLI force_version=tls1_2" \
2361 0 \
2362 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2363
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002364# Tests for ssl_get_bytes_avail()
2365
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002366run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002367 "$P_SRV" \
2368 "$P_CLI request_size=100" \
2369 0 \
2370 -s "Read from client: 100 bytes read$"
2371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002372run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002373 "$P_SRV" \
2374 "$P_CLI request_size=500" \
2375 0 \
2376 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002377
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002378# Tests for small packets
2379
2380run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002381 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002382 "$P_CLI request_size=1 force_version=ssl3 \
2383 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2384 0 \
2385 -s "Read from client: 1 bytes read"
2386
2387run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002388 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002389 "$P_CLI request_size=1 force_version=ssl3 \
2390 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2391 0 \
2392 -s "Read from client: 1 bytes read"
2393
2394run_test "Small packet TLS 1.0 BlockCipher" \
2395 "$P_SRV" \
2396 "$P_CLI request_size=1 force_version=tls1 \
2397 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2398 0 \
2399 -s "Read from client: 1 bytes read"
2400
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002401run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2402 "$P_SRV" \
2403 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2404 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2405 0 \
2406 -s "Read from client: 1 bytes read"
2407
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002408run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2409 "$P_SRV" \
2410 "$P_CLI request_size=1 force_version=tls1 \
2411 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2412 trunc_hmac=1" \
2413 0 \
2414 -s "Read from client: 1 bytes read"
2415
2416run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002417 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002418 "$P_CLI request_size=1 force_version=tls1 \
2419 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2420 trunc_hmac=1" \
2421 0 \
2422 -s "Read from client: 1 bytes read"
2423
2424run_test "Small packet TLS 1.1 BlockCipher" \
2425 "$P_SRV" \
2426 "$P_CLI request_size=1 force_version=tls1_1 \
2427 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2428 0 \
2429 -s "Read from client: 1 bytes read"
2430
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002431run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2432 "$P_SRV" \
2433 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2434 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2435 0 \
2436 -s "Read from client: 1 bytes read"
2437
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002438run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002439 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002440 "$P_CLI request_size=1 force_version=tls1_1 \
2441 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2442 0 \
2443 -s "Read from client: 1 bytes read"
2444
2445run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2446 "$P_SRV" \
2447 "$P_CLI request_size=1 force_version=tls1_1 \
2448 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2449 trunc_hmac=1" \
2450 0 \
2451 -s "Read from client: 1 bytes read"
2452
2453run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002454 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002455 "$P_CLI request_size=1 force_version=tls1_1 \
2456 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2457 trunc_hmac=1" \
2458 0 \
2459 -s "Read from client: 1 bytes read"
2460
2461run_test "Small packet TLS 1.2 BlockCipher" \
2462 "$P_SRV" \
2463 "$P_CLI request_size=1 force_version=tls1_2 \
2464 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2465 0 \
2466 -s "Read from client: 1 bytes read"
2467
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002468run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2469 "$P_SRV" \
2470 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2471 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2472 0 \
2473 -s "Read from client: 1 bytes read"
2474
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002475run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2476 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002477 "$P_CLI request_size=1 force_version=tls1_2 \
2478 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002479 0 \
2480 -s "Read from client: 1 bytes read"
2481
2482run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2483 "$P_SRV" \
2484 "$P_CLI request_size=1 force_version=tls1_2 \
2485 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2486 trunc_hmac=1" \
2487 0 \
2488 -s "Read from client: 1 bytes read"
2489
2490run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002491 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002492 "$P_CLI request_size=1 force_version=tls1_2 \
2493 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2494 0 \
2495 -s "Read from client: 1 bytes read"
2496
2497run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002498 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002499 "$P_CLI request_size=1 force_version=tls1_2 \
2500 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2501 trunc_hmac=1" \
2502 0 \
2503 -s "Read from client: 1 bytes read"
2504
2505run_test "Small packet TLS 1.2 AEAD" \
2506 "$P_SRV" \
2507 "$P_CLI request_size=1 force_version=tls1_2 \
2508 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2509 0 \
2510 -s "Read from client: 1 bytes read"
2511
2512run_test "Small packet TLS 1.2 AEAD shorter tag" \
2513 "$P_SRV" \
2514 "$P_CLI request_size=1 force_version=tls1_2 \
2515 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2516 0 \
2517 -s "Read from client: 1 bytes read"
2518
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002519# Test for large packets
2520
2521run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002522 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002523 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002524 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2525 0 \
2526 -s "Read from client: 16384 bytes read"
2527
2528run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002529 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002530 "$P_CLI request_size=16384 force_version=ssl3 \
2531 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2532 0 \
2533 -s "Read from client: 16384 bytes read"
2534
2535run_test "Large packet TLS 1.0 BlockCipher" \
2536 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002537 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002538 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2539 0 \
2540 -s "Read from client: 16384 bytes read"
2541
2542run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2543 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002544 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002545 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2546 trunc_hmac=1" \
2547 0 \
2548 -s "Read from client: 16384 bytes read"
2549
2550run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002551 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002552 "$P_CLI request_size=16384 force_version=tls1 \
2553 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2554 trunc_hmac=1" \
2555 0 \
2556 -s "Read from client: 16384 bytes read"
2557
2558run_test "Large packet TLS 1.1 BlockCipher" \
2559 "$P_SRV" \
2560 "$P_CLI request_size=16384 force_version=tls1_1 \
2561 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2562 0 \
2563 -s "Read from client: 16384 bytes read"
2564
2565run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002566 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002567 "$P_CLI request_size=16384 force_version=tls1_1 \
2568 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2569 0 \
2570 -s "Read from client: 16384 bytes read"
2571
2572run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2573 "$P_SRV" \
2574 "$P_CLI request_size=16384 force_version=tls1_1 \
2575 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2576 trunc_hmac=1" \
2577 0 \
2578 -s "Read from client: 16384 bytes read"
2579
2580run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002581 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002582 "$P_CLI request_size=16384 force_version=tls1_1 \
2583 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2584 trunc_hmac=1" \
2585 0 \
2586 -s "Read from client: 16384 bytes read"
2587
2588run_test "Large packet TLS 1.2 BlockCipher" \
2589 "$P_SRV" \
2590 "$P_CLI request_size=16384 force_version=tls1_2 \
2591 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2592 0 \
2593 -s "Read from client: 16384 bytes read"
2594
2595run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2596 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002597 "$P_CLI request_size=16384 force_version=tls1_2 \
2598 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002599 0 \
2600 -s "Read from client: 16384 bytes read"
2601
2602run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2603 "$P_SRV" \
2604 "$P_CLI request_size=16384 force_version=tls1_2 \
2605 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2606 trunc_hmac=1" \
2607 0 \
2608 -s "Read from client: 16384 bytes read"
2609
2610run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002611 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002612 "$P_CLI request_size=16384 force_version=tls1_2 \
2613 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2614 0 \
2615 -s "Read from client: 16384 bytes read"
2616
2617run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002618 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002619 "$P_CLI request_size=16384 force_version=tls1_2 \
2620 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2621 trunc_hmac=1" \
2622 0 \
2623 -s "Read from client: 16384 bytes read"
2624
2625run_test "Large packet TLS 1.2 AEAD" \
2626 "$P_SRV" \
2627 "$P_CLI request_size=16384 force_version=tls1_2 \
2628 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2629 0 \
2630 -s "Read from client: 16384 bytes read"
2631
2632run_test "Large packet TLS 1.2 AEAD shorter tag" \
2633 "$P_SRV" \
2634 "$P_CLI request_size=16384 force_version=tls1_2 \
2635 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2636 0 \
2637 -s "Read from client: 16384 bytes read"
2638
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002639# Tests for DTLS HelloVerifyRequest
2640
2641run_test "DTLS cookie: enabled" \
2642 "$P_SRV dtls=1 debug_level=2" \
2643 "$P_CLI dtls=1 debug_level=2" \
2644 0 \
2645 -s "cookie verification failed" \
2646 -s "cookie verification passed" \
2647 -S "cookie verification skipped" \
2648 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002649 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002650 -S "SSL - The requested feature is not available"
2651
2652run_test "DTLS cookie: disabled" \
2653 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2654 "$P_CLI dtls=1 debug_level=2" \
2655 0 \
2656 -S "cookie verification failed" \
2657 -S "cookie verification passed" \
2658 -s "cookie verification skipped" \
2659 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002660 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002661 -S "SSL - The requested feature is not available"
2662
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002663run_test "DTLS cookie: default (failing)" \
2664 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2665 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2666 1 \
2667 -s "cookie verification failed" \
2668 -S "cookie verification passed" \
2669 -S "cookie verification skipped" \
2670 -C "received hello verify request" \
2671 -S "hello verification requested" \
2672 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002673
2674requires_ipv6
2675run_test "DTLS cookie: enabled, IPv6" \
2676 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2677 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2678 0 \
2679 -s "cookie verification failed" \
2680 -s "cookie verification passed" \
2681 -S "cookie verification skipped" \
2682 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002683 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002684 -S "SSL - The requested feature is not available"
2685
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002686run_test "DTLS cookie: enabled, nbio" \
2687 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2688 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2689 0 \
2690 -s "cookie verification failed" \
2691 -s "cookie verification passed" \
2692 -S "cookie verification skipped" \
2693 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002694 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002695 -S "SSL - The requested feature is not available"
2696
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002697# Tests for various cases of client authentication with DTLS
2698# (focused on handshake flows and message parsing)
2699
2700run_test "DTLS client auth: required" \
2701 "$P_SRV dtls=1 auth_mode=required" \
2702 "$P_CLI dtls=1" \
2703 0 \
2704 -s "Verifying peer X.509 certificate... ok"
2705
2706run_test "DTLS client auth: optional, client has no cert" \
2707 "$P_SRV dtls=1 auth_mode=optional" \
2708 "$P_CLI dtls=1 crt_file=none key_file=none" \
2709 0 \
2710 -s "! no client certificate sent"
2711
2712run_test "DTLS client auth: optional, client has no cert" \
2713 "$P_SRV dtls=1 auth_mode=none" \
2714 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2715 0 \
2716 -c "skip write certificate$" \
2717 -s "! no client certificate sent"
2718
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002719# Tests for receiving fragmented handshake messages with DTLS
2720
2721requires_gnutls
2722run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2723 "$G_SRV -u --mtu 2048 -a" \
2724 "$P_CLI dtls=1 debug_level=2" \
2725 0 \
2726 -C "found fragmented DTLS handshake message" \
2727 -C "error"
2728
2729requires_gnutls
2730run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2731 "$G_SRV -u --mtu 512" \
2732 "$P_CLI dtls=1 debug_level=2" \
2733 0 \
2734 -c "found fragmented DTLS handshake message" \
2735 -C "error"
2736
2737requires_gnutls
2738run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2739 "$G_SRV -u --mtu 128" \
2740 "$P_CLI dtls=1 debug_level=2" \
2741 0 \
2742 -c "found fragmented DTLS handshake message" \
2743 -C "error"
2744
2745requires_gnutls
2746run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2747 "$G_SRV -u --mtu 128" \
2748 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2749 0 \
2750 -c "found fragmented DTLS handshake message" \
2751 -C "error"
2752
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002753requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002754run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2755 "$G_SRV -u --mtu 256" \
2756 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2757 0 \
2758 -c "found fragmented DTLS handshake message" \
2759 -c "client hello, adding renegotiation extension" \
2760 -c "found renegotiation extension" \
2761 -c "=> renegotiate" \
2762 -C "ssl_handshake returned" \
2763 -C "error" \
2764 -s "Extra-header:"
2765
2766requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002767run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2768 "$G_SRV -u --mtu 256" \
2769 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2770 0 \
2771 -c "found fragmented DTLS handshake message" \
2772 -c "client hello, adding renegotiation extension" \
2773 -c "found renegotiation extension" \
2774 -c "=> renegotiate" \
2775 -C "ssl_handshake returned" \
2776 -C "error" \
2777 -s "Extra-header:"
2778
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002779run_test "DTLS reassembly: no fragmentation (openssl server)" \
2780 "$O_SRV -dtls1 -mtu 2048" \
2781 "$P_CLI dtls=1 debug_level=2" \
2782 0 \
2783 -C "found fragmented DTLS handshake message" \
2784 -C "error"
2785
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002786run_test "DTLS reassembly: some fragmentation (openssl server)" \
2787 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002788 "$P_CLI dtls=1 debug_level=2" \
2789 0 \
2790 -c "found fragmented DTLS handshake message" \
2791 -C "error"
2792
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002793run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002794 "$O_SRV -dtls1 -mtu 256" \
2795 "$P_CLI dtls=1 debug_level=2" \
2796 0 \
2797 -c "found fragmented DTLS handshake message" \
2798 -C "error"
2799
2800run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2801 "$O_SRV -dtls1 -mtu 256" \
2802 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2803 0 \
2804 -c "found fragmented DTLS handshake message" \
2805 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002806
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002807# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002808
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002809not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002810run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002811 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002812 "$P_SRV dtls=1 debug_level=2" \
2813 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002814 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002815 -C "replayed record" \
2816 -S "replayed record" \
2817 -C "record from another epoch" \
2818 -S "record from another epoch" \
2819 -C "discarding invalid record" \
2820 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002821 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002822 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002823 -c "HTTP/1.0 200 OK"
2824
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002825not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002826run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002827 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002828 "$P_SRV dtls=1 debug_level=2" \
2829 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002830 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002831 -c "replayed record" \
2832 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002833 -c "discarding invalid record" \
2834 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002835 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002836 -s "Extra-header:" \
2837 -c "HTTP/1.0 200 OK"
2838
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002839run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2840 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002841 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2842 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002843 0 \
2844 -c "replayed record" \
2845 -S "replayed record" \
2846 -c "discarding invalid record" \
2847 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002848 -c "resend" \
2849 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002850 -s "Extra-header:" \
2851 -c "HTTP/1.0 200 OK"
2852
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002853run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002854 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002855 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002856 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002857 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002858 -c "discarding invalid record (mac)" \
2859 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002860 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002861 -c "HTTP/1.0 200 OK" \
2862 -S "too many records with bad MAC" \
2863 -S "Verification of the message MAC failed"
2864
2865run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
2866 -p "$P_PXY bad_ad=1" \
2867 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
2868 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2869 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002870 -C "discarding invalid record (mac)" \
2871 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002872 -S "Extra-header:" \
2873 -C "HTTP/1.0 200 OK" \
2874 -s "too many records with bad MAC" \
2875 -s "Verification of the message MAC failed"
2876
2877run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
2878 -p "$P_PXY bad_ad=1" \
2879 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
2880 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2881 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002882 -c "discarding invalid record (mac)" \
2883 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002884 -s "Extra-header:" \
2885 -c "HTTP/1.0 200 OK" \
2886 -S "too many records with bad MAC" \
2887 -S "Verification of the message MAC failed"
2888
2889run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
2890 -p "$P_PXY bad_ad=1" \
2891 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
2892 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
2893 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002894 -c "discarding invalid record (mac)" \
2895 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002896 -s "Extra-header:" \
2897 -c "HTTP/1.0 200 OK" \
2898 -s "too many records with bad MAC" \
2899 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002900
2901run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002902 -p "$P_PXY delay_ccs=1" \
2903 "$P_SRV dtls=1 debug_level=1" \
2904 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002905 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002906 -c "record from another epoch" \
2907 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002908 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002909 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002910 -s "Extra-header:" \
2911 -c "HTTP/1.0 200 OK"
2912
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002913# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002914
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002915needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002916run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002917 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002918 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2919 psk=abc123" \
2920 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002921 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2922 0 \
2923 -s "Extra-header:" \
2924 -c "HTTP/1.0 200 OK"
2925
2926needs_more_time 2
2927run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
2928 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002929 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2930 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002931 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2932 0 \
2933 -s "Extra-header:" \
2934 -c "HTTP/1.0 200 OK"
2935
2936needs_more_time 2
2937run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
2938 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002939 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2940 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002941 0 \
2942 -s "Extra-header:" \
2943 -c "HTTP/1.0 200 OK"
2944
2945needs_more_time 2
2946run_test "DTLS proxy: 3d, FS, client auth" \
2947 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002948 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
2949 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002950 0 \
2951 -s "Extra-header:" \
2952 -c "HTTP/1.0 200 OK"
2953
2954needs_more_time 2
2955run_test "DTLS proxy: 3d, FS, ticket" \
2956 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002957 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
2958 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002959 0 \
2960 -s "Extra-header:" \
2961 -c "HTTP/1.0 200 OK"
2962
2963needs_more_time 2
2964run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
2965 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002966 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
2967 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002968 0 \
2969 -s "Extra-header:" \
2970 -c "HTTP/1.0 200 OK"
2971
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002972needs_more_time 2
2973run_test "DTLS proxy: 3d, max handshake, nbio" \
2974 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002975 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
2976 auth_mode=required" \
2977 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002978 0 \
2979 -s "Extra-header:" \
2980 -c "HTTP/1.0 200 OK"
2981
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002982needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02002983run_test "DTLS proxy: 3d, min handshake, resumption" \
2984 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2985 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2986 psk=abc123 debug_level=3" \
2987 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2988 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2989 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2990 0 \
2991 -s "a session has been resumed" \
2992 -c "a session has been resumed" \
2993 -s "Extra-header:" \
2994 -c "HTTP/1.0 200 OK"
2995
2996needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02002997run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
2998 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2999 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3000 psk=abc123 debug_level=3 nbio=2" \
3001 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3002 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3003 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3004 0 \
3005 -s "a session has been resumed" \
3006 -c "a session has been resumed" \
3007 -s "Extra-header:" \
3008 -c "HTTP/1.0 200 OK"
3009
3010needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003011run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003012 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003013 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3014 psk=abc123 renegotiation=1 debug_level=2" \
3015 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3016 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003017 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3018 0 \
3019 -c "=> renegotiate" \
3020 -s "=> renegotiate" \
3021 -s "Extra-header:" \
3022 -c "HTTP/1.0 200 OK"
3023
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003024needs_more_time 4
3025run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3026 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003027 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3028 psk=abc123 renegotiation=1 debug_level=2" \
3029 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3030 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003031 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3032 0 \
3033 -c "=> renegotiate" \
3034 -s "=> renegotiate" \
3035 -s "Extra-header:" \
3036 -c "HTTP/1.0 200 OK"
3037
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003038needs_more_time 4
3039run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003040 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003041 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003042 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003043 debug_level=2" \
3044 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003045 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003046 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3047 0 \
3048 -c "=> renegotiate" \
3049 -s "=> renegotiate" \
3050 -s "Extra-header:" \
3051 -c "HTTP/1.0 200 OK"
3052
3053needs_more_time 4
3054run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003055 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003056 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003057 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003058 debug_level=2 nbio=2" \
3059 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003060 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003061 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3062 0 \
3063 -c "=> renegotiate" \
3064 -s "=> renegotiate" \
3065 -s "Extra-header:" \
3066 -c "HTTP/1.0 200 OK"
3067
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003068needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003069run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003070 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3071 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003072 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003073 0 \
3074 -s "Extra-header:" \
3075 -c "HTTP/1.0 200 OK"
3076
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003077needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003078run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3079 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3080 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003081 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003082 0 \
3083 -s "Extra-header:" \
3084 -c "HTTP/1.0 200 OK"
3085
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003086needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003087run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3088 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3089 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003090 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003091 0 \
3092 -s "Extra-header:" \
3093 -c "HTTP/1.0 200 OK"
3094
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003095requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003096needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003097run_test "DTLS proxy: 3d, gnutls server" \
3098 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3099 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003100 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003101 0 \
3102 -s "Extra-header:" \
3103 -c "Extra-header:"
3104
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003105requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003106needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003107run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3108 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3109 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003110 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003111 0 \
3112 -s "Extra-header:" \
3113 -c "Extra-header:"
3114
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003115requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003116needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003117run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3118 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3119 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003120 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003121 0 \
3122 -s "Extra-header:" \
3123 -c "Extra-header:"
3124
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003125# Final report
3126
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003127echo "------------------------------------------------------------------------"
3128
3129if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003130 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003131else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003132 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003133fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003134PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003135echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003136
3137exit $FAILS