blob: 244c6c034e4f588daaa5a5c6bb03834e296e6666 [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é-Gonnardea0920f2015-03-24 09:50:15 +0100558 -s "SSL - The server has no ciphersuites in common"
559
560run_test "RC4: server half, client enabled" \
561 "$P_SRV arc4=1" \
562 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
563 1 \
564 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100565
566run_test "RC4: server enabled, client disabled" \
567 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
568 "$P_CLI" \
569 1 \
570 -s "SSL - The server has no ciphersuites in common"
571
572run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100573 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100574 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
575 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100576 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100577 -S "SSL - The server has no ciphersuites in common"
578
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100579# Test for SSLv2 ClientHello
580
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200581requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200582run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100583 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100584 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100585 0 \
586 -S "parse client hello v2" \
587 -S "ssl_handshake returned"
588
589# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200590requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200591run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200592 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100593 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100594 0 \
595 -s "parse client hello v2" \
596 -S "ssl_handshake returned"
597
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100598# Tests for Truncated HMAC extension
599
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100600run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200601 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100602 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100603 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100604 -s "dumping 'computed mac' (20 bytes)" \
605 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100606
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100607run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200608 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100609 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
610 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100611 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100612 -s "dumping 'computed mac' (20 bytes)" \
613 -S "dumping 'computed mac' (10 bytes)"
614
615run_test "Truncated HMAC: client enabled, server default" \
616 "$P_SRV debug_level=4" \
617 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
618 trunc_hmac=1" \
619 0 \
620 -S "dumping 'computed mac' (20 bytes)" \
621 -s "dumping 'computed mac' (10 bytes)"
622
623run_test "Truncated HMAC: client enabled, server disabled" \
624 "$P_SRV debug_level=4 trunc_hmac=0" \
625 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
626 trunc_hmac=1" \
627 0 \
628 -s "dumping 'computed mac' (20 bytes)" \
629 -S "dumping 'computed mac' (10 bytes)"
630
631run_test "Truncated HMAC: client enabled, server enabled" \
632 "$P_SRV debug_level=4 trunc_hmac=1" \
633 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
634 trunc_hmac=1" \
635 0 \
636 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100637 -s "dumping 'computed mac' (10 bytes)"
638
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100639# Tests for Encrypt-then-MAC extension
640
641run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100642 "$P_SRV debug_level=3 \
643 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100644 "$P_CLI debug_level=3" \
645 0 \
646 -c "client hello, adding encrypt_then_mac extension" \
647 -s "found encrypt then mac extension" \
648 -s "server hello, adding encrypt then mac extension" \
649 -c "found encrypt_then_mac extension" \
650 -c "using encrypt then mac" \
651 -s "using encrypt then mac"
652
653run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100654 "$P_SRV debug_level=3 etm=0 \
655 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100656 "$P_CLI debug_level=3 etm=1" \
657 0 \
658 -c "client hello, adding encrypt_then_mac extension" \
659 -s "found encrypt then mac extension" \
660 -S "server hello, adding encrypt then mac extension" \
661 -C "found encrypt_then_mac extension" \
662 -C "using encrypt then mac" \
663 -S "using encrypt then mac"
664
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100665run_test "Encrypt then MAC: client enabled, aead cipher" \
666 "$P_SRV debug_level=3 etm=1 \
667 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
668 "$P_CLI debug_level=3 etm=1" \
669 0 \
670 -c "client hello, adding encrypt_then_mac extension" \
671 -s "found encrypt then mac extension" \
672 -S "server hello, adding encrypt then mac extension" \
673 -C "found encrypt_then_mac extension" \
674 -C "using encrypt then mac" \
675 -S "using encrypt then mac"
676
677run_test "Encrypt then MAC: client enabled, stream cipher" \
678 "$P_SRV debug_level=3 etm=1 \
679 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100680 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100681 0 \
682 -c "client hello, adding encrypt_then_mac extension" \
683 -s "found encrypt then mac extension" \
684 -S "server hello, adding encrypt then mac extension" \
685 -C "found encrypt_then_mac extension" \
686 -C "using encrypt then mac" \
687 -S "using encrypt then mac"
688
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100689run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100690 "$P_SRV debug_level=3 etm=1 \
691 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100692 "$P_CLI debug_level=3 etm=0" \
693 0 \
694 -C "client hello, adding encrypt_then_mac extension" \
695 -S "found encrypt then mac extension" \
696 -S "server hello, adding encrypt then mac extension" \
697 -C "found encrypt_then_mac extension" \
698 -C "using encrypt then mac" \
699 -S "using encrypt then mac"
700
701run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100702 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100703 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100704 "$P_CLI debug_level=3 force_version=ssl3" \
705 0 \
706 -C "client hello, adding encrypt_then_mac extension" \
707 -S "found encrypt then mac extension" \
708 -S "server hello, adding encrypt then mac extension" \
709 -C "found encrypt_then_mac extension" \
710 -C "using encrypt then mac" \
711 -S "using encrypt then mac"
712
713run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100714 "$P_SRV debug_level=3 force_version=ssl3 \
715 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100716 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100717 0 \
718 -c "client hello, adding encrypt_then_mac extension" \
719 -s "found encrypt then mac extension" \
720 -S "server hello, adding encrypt then mac extension" \
721 -C "found encrypt_then_mac extension" \
722 -C "using encrypt then mac" \
723 -S "using encrypt then mac"
724
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200725# Tests for Extended Master Secret extension
726
727run_test "Extended Master Secret: default" \
728 "$P_SRV debug_level=3" \
729 "$P_CLI debug_level=3" \
730 0 \
731 -c "client hello, adding extended_master_secret extension" \
732 -s "found extended master secret extension" \
733 -s "server hello, adding extended master secret extension" \
734 -c "found extended_master_secret extension" \
735 -c "using extended master secret" \
736 -s "using extended master secret"
737
738run_test "Extended Master Secret: client enabled, server disabled" \
739 "$P_SRV debug_level=3 extended_ms=0" \
740 "$P_CLI debug_level=3 extended_ms=1" \
741 0 \
742 -c "client hello, adding extended_master_secret extension" \
743 -s "found extended master secret extension" \
744 -S "server hello, adding extended master secret extension" \
745 -C "found extended_master_secret extension" \
746 -C "using extended master secret" \
747 -S "using extended master secret"
748
749run_test "Extended Master Secret: client disabled, server enabled" \
750 "$P_SRV debug_level=3 extended_ms=1" \
751 "$P_CLI debug_level=3 extended_ms=0" \
752 0 \
753 -C "client hello, adding extended_master_secret extension" \
754 -S "found extended master secret extension" \
755 -S "server hello, adding extended master secret extension" \
756 -C "found extended_master_secret extension" \
757 -C "using extended master secret" \
758 -S "using extended master secret"
759
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200760run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100761 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200762 "$P_CLI debug_level=3 force_version=ssl3" \
763 0 \
764 -C "client hello, adding extended_master_secret extension" \
765 -S "found extended master secret extension" \
766 -S "server hello, adding extended master secret extension" \
767 -C "found extended_master_secret extension" \
768 -C "using extended master secret" \
769 -S "using extended master secret"
770
771run_test "Extended Master Secret: client enabled, server SSLv3" \
772 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100773 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200774 0 \
775 -c "client hello, adding extended_master_secret extension" \
776 -s "found extended master secret extension" \
777 -S "server hello, adding extended master secret extension" \
778 -C "found extended_master_secret extension" \
779 -C "using extended master secret" \
780 -S "using extended master secret"
781
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200782# Tests for FALLBACK_SCSV
783
784run_test "Fallback SCSV: default" \
785 "$P_SRV" \
786 "$P_CLI debug_level=3 force_version=tls1_1" \
787 0 \
788 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200789 -S "received FALLBACK_SCSV" \
790 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200791 -C "is a fatal alert message (msg 86)"
792
793run_test "Fallback SCSV: explicitly disabled" \
794 "$P_SRV" \
795 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
796 0 \
797 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200798 -S "received FALLBACK_SCSV" \
799 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200800 -C "is a fatal alert message (msg 86)"
801
802run_test "Fallback SCSV: enabled" \
803 "$P_SRV" \
804 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200805 1 \
806 -c "adding FALLBACK_SCSV" \
807 -s "received FALLBACK_SCSV" \
808 -s "inapropriate fallback" \
809 -c "is a fatal alert message (msg 86)"
810
811run_test "Fallback SCSV: enabled, max version" \
812 "$P_SRV" \
813 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200814 0 \
815 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200816 -s "received FALLBACK_SCSV" \
817 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200818 -C "is a fatal alert message (msg 86)"
819
820requires_openssl_with_fallback_scsv
821run_test "Fallback SCSV: default, openssl server" \
822 "$O_SRV" \
823 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
824 0 \
825 -C "adding FALLBACK_SCSV" \
826 -C "is a fatal alert message (msg 86)"
827
828requires_openssl_with_fallback_scsv
829run_test "Fallback SCSV: enabled, openssl server" \
830 "$O_SRV" \
831 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
832 1 \
833 -c "adding FALLBACK_SCSV" \
834 -c "is a fatal alert message (msg 86)"
835
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200836requires_openssl_with_fallback_scsv
837run_test "Fallback SCSV: disabled, openssl client" \
838 "$P_SRV" \
839 "$O_CLI -tls1_1" \
840 0 \
841 -S "received FALLBACK_SCSV" \
842 -S "inapropriate fallback"
843
844requires_openssl_with_fallback_scsv
845run_test "Fallback SCSV: enabled, openssl client" \
846 "$P_SRV" \
847 "$O_CLI -tls1_1 -fallback_scsv" \
848 1 \
849 -s "received FALLBACK_SCSV" \
850 -s "inapropriate fallback"
851
852requires_openssl_with_fallback_scsv
853run_test "Fallback SCSV: enabled, max version, openssl client" \
854 "$P_SRV" \
855 "$O_CLI -fallback_scsv" \
856 0 \
857 -s "received FALLBACK_SCSV" \
858 -S "inapropriate fallback"
859
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100860# Tests for CBC 1/n-1 record splitting
861
862run_test "CBC Record splitting: TLS 1.2, no splitting" \
863 "$P_SRV" \
864 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
865 request_size=123 force_version=tls1_2" \
866 0 \
867 -s "Read from client: 123 bytes read" \
868 -S "Read from client: 1 bytes read" \
869 -S "122 bytes read"
870
871run_test "CBC Record splitting: TLS 1.1, no splitting" \
872 "$P_SRV" \
873 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
874 request_size=123 force_version=tls1_1" \
875 0 \
876 -s "Read from client: 123 bytes read" \
877 -S "Read from client: 1 bytes read" \
878 -S "122 bytes read"
879
880run_test "CBC Record splitting: TLS 1.0, splitting" \
881 "$P_SRV" \
882 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
883 request_size=123 force_version=tls1" \
884 0 \
885 -S "Read from client: 123 bytes read" \
886 -s "Read from client: 1 bytes read" \
887 -s "122 bytes read"
888
889run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100890 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100891 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
892 request_size=123 force_version=ssl3" \
893 0 \
894 -S "Read from client: 123 bytes read" \
895 -s "Read from client: 1 bytes read" \
896 -s "122 bytes read"
897
898run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100899 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100900 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
901 request_size=123 force_version=tls1" \
902 0 \
903 -s "Read from client: 123 bytes read" \
904 -S "Read from client: 1 bytes read" \
905 -S "122 bytes read"
906
907run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
908 "$P_SRV" \
909 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
910 request_size=123 force_version=tls1 recsplit=0" \
911 0 \
912 -s "Read from client: 123 bytes read" \
913 -S "Read from client: 1 bytes read" \
914 -S "122 bytes read"
915
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100916run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
917 "$P_SRV nbio=2" \
918 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
919 request_size=123 force_version=tls1" \
920 0 \
921 -S "Read from client: 123 bytes read" \
922 -s "Read from client: 1 bytes read" \
923 -s "122 bytes read"
924
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100925# Tests for Session Tickets
926
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200927run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200928 "$P_SRV debug_level=3 tickets=1" \
929 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100930 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100931 -c "client hello, adding session ticket extension" \
932 -s "found session ticket extension" \
933 -s "server hello, adding session ticket extension" \
934 -c "found session_ticket extension" \
935 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100936 -S "session successfully restored from cache" \
937 -s "session successfully restored from ticket" \
938 -s "a session has been resumed" \
939 -c "a session has been resumed"
940
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200941run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200942 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
943 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100944 0 \
945 -c "client hello, adding session ticket extension" \
946 -s "found session ticket extension" \
947 -s "server hello, adding session ticket extension" \
948 -c "found session_ticket extension" \
949 -c "parse new session ticket" \
950 -S "session successfully restored from cache" \
951 -s "session successfully restored from ticket" \
952 -s "a session has been resumed" \
953 -c "a session has been resumed"
954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200955run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200956 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
957 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100958 0 \
959 -c "client hello, adding session ticket extension" \
960 -s "found session ticket extension" \
961 -s "server hello, adding session ticket extension" \
962 -c "found session_ticket extension" \
963 -c "parse new session ticket" \
964 -S "session successfully restored from cache" \
965 -S "session successfully restored from ticket" \
966 -S "a session has been resumed" \
967 -C "a session has been resumed"
968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200969run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100970 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200971 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100972 0 \
973 -c "client hello, adding session ticket extension" \
974 -c "found session_ticket extension" \
975 -c "parse new session ticket" \
976 -c "a session has been resumed"
977
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200978run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200979 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200980 "( $O_CLI -sess_out $SESSION; \
981 $O_CLI -sess_in $SESSION; \
982 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100983 0 \
984 -s "found session ticket extension" \
985 -s "server hello, adding session ticket extension" \
986 -S "session successfully restored from cache" \
987 -s "session successfully restored from ticket" \
988 -s "a session has been resumed"
989
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100990# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100991
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200992run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200993 "$P_SRV debug_level=3 tickets=0" \
994 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100995 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100996 -c "client hello, adding session ticket extension" \
997 -s "found session ticket extension" \
998 -S "server hello, adding session ticket extension" \
999 -C "found session_ticket extension" \
1000 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001001 -s "session successfully restored from cache" \
1002 -S "session successfully restored from ticket" \
1003 -s "a session has been resumed" \
1004 -c "a session has been resumed"
1005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001006run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001007 "$P_SRV debug_level=3 tickets=1" \
1008 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001009 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001010 -C "client hello, adding session ticket extension" \
1011 -S "found session ticket extension" \
1012 -S "server hello, adding session ticket extension" \
1013 -C "found session_ticket extension" \
1014 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001015 -s "session successfully restored from cache" \
1016 -S "session successfully restored from ticket" \
1017 -s "a session has been resumed" \
1018 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001020run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001021 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1022 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001023 0 \
1024 -S "session successfully restored from cache" \
1025 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001026 -S "a session has been resumed" \
1027 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001029run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001030 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1031 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001032 0 \
1033 -s "session successfully restored from cache" \
1034 -S "session successfully restored from ticket" \
1035 -s "a session has been resumed" \
1036 -c "a session has been resumed"
1037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001038run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001039 "$P_SRV debug_level=3 tickets=0" \
1040 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001041 0 \
1042 -s "session successfully restored from cache" \
1043 -S "session successfully restored from ticket" \
1044 -s "a session has been resumed" \
1045 -c "a session has been resumed"
1046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001047run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001048 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1049 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001050 0 \
1051 -S "session successfully restored from cache" \
1052 -S "session successfully restored from ticket" \
1053 -S "a session has been resumed" \
1054 -C "a session has been resumed"
1055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001056run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001057 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1058 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001059 0 \
1060 -s "session successfully restored from cache" \
1061 -S "session successfully restored from ticket" \
1062 -s "a session has been resumed" \
1063 -c "a session has been resumed"
1064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001065run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001066 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001067 "( $O_CLI -sess_out $SESSION; \
1068 $O_CLI -sess_in $SESSION; \
1069 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001070 0 \
1071 -s "found session ticket extension" \
1072 -S "server hello, adding session ticket extension" \
1073 -s "session successfully restored from cache" \
1074 -S "session successfully restored from ticket" \
1075 -s "a session has been resumed"
1076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001077run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001078 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001079 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001080 0 \
1081 -C "found session_ticket extension" \
1082 -C "parse new session ticket" \
1083 -c "a session has been resumed"
1084
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001085# Tests for Max Fragment Length extension
1086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001087run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001088 "$P_SRV debug_level=3" \
1089 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001090 0 \
1091 -C "client hello, adding max_fragment_length extension" \
1092 -S "found max fragment length extension" \
1093 -S "server hello, max_fragment_length extension" \
1094 -C "found max_fragment_length extension"
1095
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001096run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001097 "$P_SRV debug_level=3" \
1098 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001099 0 \
1100 -c "client hello, adding max_fragment_length extension" \
1101 -s "found max fragment length extension" \
1102 -s "server hello, max_fragment_length extension" \
1103 -c "found max_fragment_length extension"
1104
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001105run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001106 "$P_SRV debug_level=3 max_frag_len=4096" \
1107 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001108 0 \
1109 -C "client hello, adding max_fragment_length extension" \
1110 -S "found max fragment length extension" \
1111 -S "server hello, max_fragment_length extension" \
1112 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001114requires_gnutls
1115run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001116 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001117 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001118 0 \
1119 -c "client hello, adding max_fragment_length extension" \
1120 -c "found max_fragment_length extension"
1121
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001122run_test "Max fragment length: client, message just fits" \
1123 "$P_SRV debug_level=3" \
1124 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1125 0 \
1126 -c "client hello, adding max_fragment_length extension" \
1127 -s "found max fragment length extension" \
1128 -s "server hello, max_fragment_length extension" \
1129 -c "found max_fragment_length extension" \
1130 -c "2048 bytes written in 1 fragments" \
1131 -s "2048 bytes read"
1132
1133run_test "Max fragment length: client, larger message" \
1134 "$P_SRV debug_level=3" \
1135 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1136 0 \
1137 -c "client hello, adding max_fragment_length extension" \
1138 -s "found max fragment length extension" \
1139 -s "server hello, max_fragment_length extension" \
1140 -c "found max_fragment_length extension" \
1141 -c "2345 bytes written in 2 fragments" \
1142 -s "2048 bytes read" \
1143 -s "297 bytes read"
1144
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001145run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001146 "$P_SRV debug_level=3 dtls=1" \
1147 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1148 1 \
1149 -c "client hello, adding max_fragment_length extension" \
1150 -s "found max fragment length extension" \
1151 -s "server hello, max_fragment_length extension" \
1152 -c "found max_fragment_length extension" \
1153 -c "fragment larger than.*maximum"
1154
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001155# Tests for renegotiation
1156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001157run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001158 "$P_SRV debug_level=3 exchanges=2" \
1159 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001160 0 \
1161 -C "client hello, adding renegotiation extension" \
1162 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1163 -S "found renegotiation extension" \
1164 -s "server hello, secure renegotiation extension" \
1165 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001166 -C "=> renegotiate" \
1167 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001168 -S "write hello request"
1169
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001170run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001171 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
1172 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001173 0 \
1174 -c "client hello, adding renegotiation extension" \
1175 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1176 -s "found renegotiation extension" \
1177 -s "server hello, secure renegotiation extension" \
1178 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001179 -c "=> renegotiate" \
1180 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001181 -S "write hello request"
1182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001183run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001184 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1185 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001186 0 \
1187 -c "client hello, adding renegotiation extension" \
1188 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1189 -s "found renegotiation extension" \
1190 -s "server hello, secure renegotiation extension" \
1191 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001192 -c "=> renegotiate" \
1193 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001194 -s "write hello request"
1195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001196run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001197 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1198 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001199 0 \
1200 -c "client hello, adding renegotiation extension" \
1201 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1202 -s "found renegotiation extension" \
1203 -s "server hello, secure renegotiation extension" \
1204 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001205 -c "=> renegotiate" \
1206 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001207 -s "write hello request"
1208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001209run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001210 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1211 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001212 1 \
1213 -c "client hello, adding renegotiation extension" \
1214 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1215 -S "found renegotiation extension" \
1216 -s "server hello, secure renegotiation extension" \
1217 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001218 -c "=> renegotiate" \
1219 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001220 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001221 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001222 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001224run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001225 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1226 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001227 0 \
1228 -C "client hello, adding renegotiation extension" \
1229 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1230 -S "found renegotiation extension" \
1231 -s "server hello, secure renegotiation extension" \
1232 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001233 -C "=> renegotiate" \
1234 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001235 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001236 -S "SSL - An unexpected message was received from our peer" \
1237 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001238
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001239run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001240 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001241 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001242 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001243 0 \
1244 -C "client hello, adding renegotiation extension" \
1245 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1246 -S "found renegotiation extension" \
1247 -s "server hello, secure renegotiation extension" \
1248 -c "found renegotiation extension" \
1249 -C "=> renegotiate" \
1250 -S "=> renegotiate" \
1251 -s "write hello request" \
1252 -S "SSL - An unexpected message was received from our peer" \
1253 -S "failed"
1254
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001255# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001258 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001259 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001260 0 \
1261 -C "client hello, adding renegotiation extension" \
1262 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1263 -S "found renegotiation extension" \
1264 -s "server hello, secure renegotiation extension" \
1265 -c "found renegotiation extension" \
1266 -C "=> renegotiate" \
1267 -S "=> renegotiate" \
1268 -s "write hello request" \
1269 -S "SSL - An unexpected message was received from our peer" \
1270 -S "failed"
1271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001272run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001273 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001274 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001275 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001276 0 \
1277 -C "client hello, adding renegotiation extension" \
1278 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1279 -S "found renegotiation extension" \
1280 -s "server hello, secure renegotiation extension" \
1281 -c "found renegotiation extension" \
1282 -C "=> renegotiate" \
1283 -S "=> renegotiate" \
1284 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001285 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001289 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001290 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001291 0 \
1292 -c "client hello, adding renegotiation extension" \
1293 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1294 -s "found renegotiation extension" \
1295 -s "server hello, secure renegotiation extension" \
1296 -c "found renegotiation extension" \
1297 -c "=> renegotiate" \
1298 -s "=> renegotiate" \
1299 -s "write hello request" \
1300 -S "SSL - An unexpected message was received from our peer" \
1301 -S "failed"
1302
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001303run_test "Renegotiation: periodic, just below period" \
1304 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1305 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1306 0 \
1307 -C "client hello, adding renegotiation extension" \
1308 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1309 -S "found renegotiation extension" \
1310 -s "server hello, secure renegotiation extension" \
1311 -c "found renegotiation extension" \
1312 -S "record counter limit reached: renegotiate" \
1313 -C "=> renegotiate" \
1314 -S "=> renegotiate" \
1315 -S "write hello request" \
1316 -S "SSL - An unexpected message was received from our peer" \
1317 -S "failed"
1318
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001319# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001320run_test "Renegotiation: periodic, just above period" \
1321 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001322 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001323 0 \
1324 -c "client hello, adding renegotiation extension" \
1325 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1326 -s "found renegotiation extension" \
1327 -s "server hello, secure renegotiation extension" \
1328 -c "found renegotiation extension" \
1329 -s "record counter limit reached: renegotiate" \
1330 -c "=> renegotiate" \
1331 -s "=> renegotiate" \
1332 -s "write hello request" \
1333 -S "SSL - An unexpected message was received from our peer" \
1334 -S "failed"
1335
1336run_test "Renegotiation: periodic, two times period" \
1337 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001338 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001339 0 \
1340 -c "client hello, adding renegotiation extension" \
1341 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1342 -s "found renegotiation extension" \
1343 -s "server hello, secure renegotiation extension" \
1344 -c "found renegotiation extension" \
1345 -s "record counter limit reached: renegotiate" \
1346 -c "=> renegotiate" \
1347 -s "=> renegotiate" \
1348 -s "write hello request" \
1349 -S "SSL - An unexpected message was received from our peer" \
1350 -S "failed"
1351
1352run_test "Renegotiation: periodic, above period, disabled" \
1353 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1354 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1355 0 \
1356 -C "client hello, adding renegotiation extension" \
1357 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1358 -S "found renegotiation extension" \
1359 -s "server hello, secure renegotiation extension" \
1360 -c "found renegotiation extension" \
1361 -S "record counter limit reached: renegotiate" \
1362 -C "=> renegotiate" \
1363 -S "=> renegotiate" \
1364 -S "write hello request" \
1365 -S "SSL - An unexpected message was received from our peer" \
1366 -S "failed"
1367
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001368run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001369 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1370 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001371 0 \
1372 -c "client hello, adding renegotiation extension" \
1373 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1374 -s "found renegotiation extension" \
1375 -s "server hello, secure renegotiation extension" \
1376 -c "found renegotiation extension" \
1377 -c "=> renegotiate" \
1378 -s "=> renegotiate" \
1379 -S "write hello request"
1380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001381run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001382 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1383 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001384 0 \
1385 -c "client hello, adding renegotiation extension" \
1386 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1387 -s "found renegotiation extension" \
1388 -s "server hello, secure renegotiation extension" \
1389 -c "found renegotiation extension" \
1390 -c "=> renegotiate" \
1391 -s "=> renegotiate" \
1392 -s "write hello request"
1393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001394run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001395 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001396 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001397 0 \
1398 -c "client hello, adding renegotiation extension" \
1399 -c "found renegotiation extension" \
1400 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001401 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001402 -C "error" \
1403 -c "HTTP/1.0 200 [Oo][Kk]"
1404
Paul Bakker539d9722015-02-08 16:18:35 +01001405requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001406run_test "Renegotiation: gnutls server strict, client-initiated" \
1407 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001408 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001409 0 \
1410 -c "client hello, adding renegotiation extension" \
1411 -c "found renegotiation extension" \
1412 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001413 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001414 -C "error" \
1415 -c "HTTP/1.0 200 [Oo][Kk]"
1416
Paul Bakker539d9722015-02-08 16:18:35 +01001417requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001418run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1419 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1420 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1421 1 \
1422 -c "client hello, adding renegotiation extension" \
1423 -C "found renegotiation extension" \
1424 -c "=> renegotiate" \
1425 -c "ssl_handshake() returned" \
1426 -c "error" \
1427 -C "HTTP/1.0 200 [Oo][Kk]"
1428
Paul Bakker539d9722015-02-08 16:18:35 +01001429requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001430run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1431 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1432 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1433 allow_legacy=0" \
1434 1 \
1435 -c "client hello, adding renegotiation extension" \
1436 -C "found renegotiation extension" \
1437 -c "=> renegotiate" \
1438 -c "ssl_handshake() returned" \
1439 -c "error" \
1440 -C "HTTP/1.0 200 [Oo][Kk]"
1441
Paul Bakker539d9722015-02-08 16:18:35 +01001442requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001443run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1444 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1445 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1446 allow_legacy=1" \
1447 0 \
1448 -c "client hello, adding renegotiation extension" \
1449 -C "found renegotiation extension" \
1450 -c "=> renegotiate" \
1451 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001452 -C "error" \
1453 -c "HTTP/1.0 200 [Oo][Kk]"
1454
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001455run_test "Renegotiation: DTLS, client-initiated" \
1456 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1457 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1458 0 \
1459 -c "client hello, adding renegotiation extension" \
1460 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1461 -s "found renegotiation extension" \
1462 -s "server hello, secure renegotiation extension" \
1463 -c "found renegotiation extension" \
1464 -c "=> renegotiate" \
1465 -s "=> renegotiate" \
1466 -S "write hello request"
1467
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001468run_test "Renegotiation: DTLS, server-initiated" \
1469 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001470 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1471 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001472 0 \
1473 -c "client hello, adding renegotiation extension" \
1474 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1475 -s "found renegotiation extension" \
1476 -s "server hello, secure renegotiation extension" \
1477 -c "found renegotiation extension" \
1478 -c "=> renegotiate" \
1479 -s "=> renegotiate" \
1480 -s "write hello request"
1481
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001482requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001483run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1484 "$G_SRV -u --mtu 4096" \
1485 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1486 0 \
1487 -c "client hello, adding renegotiation extension" \
1488 -c "found renegotiation extension" \
1489 -c "=> renegotiate" \
1490 -C "ssl_handshake returned" \
1491 -C "error" \
1492 -s "Extra-header:"
1493
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001494# Test for the "secure renegotation" extension only (no actual renegotiation)
1495
Paul Bakker539d9722015-02-08 16:18:35 +01001496requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001497run_test "Renego ext: gnutls server strict, client default" \
1498 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1499 "$P_CLI debug_level=3" \
1500 0 \
1501 -c "found renegotiation extension" \
1502 -C "error" \
1503 -c "HTTP/1.0 200 [Oo][Kk]"
1504
Paul Bakker539d9722015-02-08 16:18:35 +01001505requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001506run_test "Renego ext: gnutls server unsafe, client default" \
1507 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1508 "$P_CLI debug_level=3" \
1509 0 \
1510 -C "found renegotiation extension" \
1511 -C "error" \
1512 -c "HTTP/1.0 200 [Oo][Kk]"
1513
Paul Bakker539d9722015-02-08 16:18:35 +01001514requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001515run_test "Renego ext: gnutls server unsafe, client break legacy" \
1516 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1517 "$P_CLI debug_level=3 allow_legacy=-1" \
1518 1 \
1519 -C "found renegotiation extension" \
1520 -c "error" \
1521 -C "HTTP/1.0 200 [Oo][Kk]"
1522
Paul Bakker539d9722015-02-08 16:18:35 +01001523requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001524run_test "Renego ext: gnutls client strict, server default" \
1525 "$P_SRV debug_level=3" \
1526 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1527 0 \
1528 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1529 -s "server hello, secure renegotiation extension"
1530
Paul Bakker539d9722015-02-08 16:18:35 +01001531requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001532run_test "Renego ext: gnutls client unsafe, server default" \
1533 "$P_SRV debug_level=3" \
1534 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1535 0 \
1536 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1537 -S "server hello, secure renegotiation extension"
1538
Paul Bakker539d9722015-02-08 16:18:35 +01001539requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001540run_test "Renego ext: gnutls client unsafe, server break legacy" \
1541 "$P_SRV debug_level=3 allow_legacy=-1" \
1542 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1543 1 \
1544 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1545 -S "server hello, secure renegotiation extension"
1546
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001547# Tests for auth_mode
1548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001549run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001550 "$P_SRV crt_file=data_files/server5-badsign.crt \
1551 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001552 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001553 1 \
1554 -c "x509_verify_cert() returned" \
1555 -c "! self-signed or not signed by a trusted CA" \
1556 -c "! ssl_handshake returned" \
1557 -c "X509 - Certificate verification failed"
1558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001559run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001560 "$P_SRV crt_file=data_files/server5-badsign.crt \
1561 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001562 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001563 0 \
1564 -c "x509_verify_cert() returned" \
1565 -c "! self-signed or not signed by a trusted CA" \
1566 -C "! ssl_handshake returned" \
1567 -C "X509 - Certificate verification failed"
1568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001569run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001570 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001571 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001572 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001573 0 \
1574 -C "x509_verify_cert() returned" \
1575 -C "! self-signed or not signed by a trusted CA" \
1576 -C "! ssl_handshake returned" \
1577 -C "X509 - Certificate verification failed"
1578
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001579run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001580 "$P_SRV debug_level=3 auth_mode=required" \
1581 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001582 key_file=data_files/server5.key" \
1583 1 \
1584 -S "skip write certificate request" \
1585 -C "skip parse certificate request" \
1586 -c "got a certificate request" \
1587 -C "skip write certificate" \
1588 -C "skip write certificate verify" \
1589 -S "skip parse certificate verify" \
1590 -s "x509_verify_cert() returned" \
1591 -S "! self-signed or not signed by a trusted CA" \
1592 -s "! ssl_handshake returned" \
1593 -c "! ssl_handshake returned" \
1594 -s "X509 - Certificate verification failed"
1595
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001596run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001597 "$P_SRV debug_level=3 auth_mode=optional" \
1598 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001599 key_file=data_files/server5.key" \
1600 0 \
1601 -S "skip write certificate request" \
1602 -C "skip parse certificate request" \
1603 -c "got a certificate request" \
1604 -C "skip write certificate" \
1605 -C "skip write certificate verify" \
1606 -S "skip parse certificate verify" \
1607 -s "x509_verify_cert() returned" \
1608 -s "! self-signed or not signed by a trusted CA" \
1609 -S "! ssl_handshake returned" \
1610 -C "! ssl_handshake returned" \
1611 -S "X509 - Certificate verification failed"
1612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001613run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001614 "$P_SRV debug_level=3 auth_mode=none" \
1615 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001616 key_file=data_files/server5.key" \
1617 0 \
1618 -s "skip write certificate request" \
1619 -C "skip parse certificate request" \
1620 -c "got no certificate request" \
1621 -c "skip write certificate" \
1622 -c "skip write certificate verify" \
1623 -s "skip parse certificate verify" \
1624 -S "x509_verify_cert() returned" \
1625 -S "! self-signed or not signed by a trusted CA" \
1626 -S "! ssl_handshake returned" \
1627 -C "! ssl_handshake returned" \
1628 -S "X509 - Certificate verification failed"
1629
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001630run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001631 "$P_SRV debug_level=3 auth_mode=optional" \
1632 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001633 0 \
1634 -S "skip write certificate request" \
1635 -C "skip parse certificate request" \
1636 -c "got a certificate request" \
1637 -C "skip write certificate$" \
1638 -C "got no certificate to send" \
1639 -S "SSLv3 client has no certificate" \
1640 -c "skip write certificate verify" \
1641 -s "skip parse certificate verify" \
1642 -s "! no client certificate sent" \
1643 -S "! ssl_handshake returned" \
1644 -C "! ssl_handshake returned" \
1645 -S "X509 - Certificate verification failed"
1646
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001647run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001648 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001649 "$O_CLI" \
1650 0 \
1651 -S "skip write certificate request" \
1652 -s "skip parse certificate verify" \
1653 -s "! no client certificate sent" \
1654 -S "! ssl_handshake returned" \
1655 -S "X509 - Certificate verification failed"
1656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001657run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001658 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001659 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001660 0 \
1661 -C "skip parse certificate request" \
1662 -c "got a certificate request" \
1663 -C "skip write certificate$" \
1664 -c "skip write certificate verify" \
1665 -C "! ssl_handshake returned"
1666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001667run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001668 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001669 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001670 0 \
1671 -S "skip write certificate request" \
1672 -C "skip parse certificate request" \
1673 -c "got a certificate request" \
1674 -C "skip write certificate$" \
1675 -c "skip write certificate verify" \
1676 -c "got no certificate to send" \
1677 -s "SSLv3 client has no certificate" \
1678 -s "skip parse certificate verify" \
1679 -s "! no client certificate sent" \
1680 -S "! ssl_handshake returned" \
1681 -C "! ssl_handshake returned" \
1682 -S "X509 - Certificate verification failed"
1683
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001684# Tests for certificate selection based on SHA verson
1685
1686run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1687 "$P_SRV crt_file=data_files/server5.crt \
1688 key_file=data_files/server5.key \
1689 crt_file2=data_files/server5-sha1.crt \
1690 key_file2=data_files/server5.key" \
1691 "$P_CLI force_version=tls1_2" \
1692 0 \
1693 -c "signed using.*ECDSA with SHA256" \
1694 -C "signed using.*ECDSA with SHA1"
1695
1696run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1697 "$P_SRV crt_file=data_files/server5.crt \
1698 key_file=data_files/server5.key \
1699 crt_file2=data_files/server5-sha1.crt \
1700 key_file2=data_files/server5.key" \
1701 "$P_CLI force_version=tls1_1" \
1702 0 \
1703 -C "signed using.*ECDSA with SHA256" \
1704 -c "signed using.*ECDSA with SHA1"
1705
1706run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1707 "$P_SRV crt_file=data_files/server5.crt \
1708 key_file=data_files/server5.key \
1709 crt_file2=data_files/server5-sha1.crt \
1710 key_file2=data_files/server5.key" \
1711 "$P_CLI force_version=tls1" \
1712 0 \
1713 -C "signed using.*ECDSA with SHA256" \
1714 -c "signed using.*ECDSA with SHA1"
1715
1716run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1717 "$P_SRV crt_file=data_files/server5.crt \
1718 key_file=data_files/server5.key \
1719 crt_file2=data_files/server6.crt \
1720 key_file2=data_files/server6.key" \
1721 "$P_CLI force_version=tls1_1" \
1722 0 \
1723 -c "serial number.*09" \
1724 -c "signed using.*ECDSA with SHA256" \
1725 -C "signed using.*ECDSA with SHA1"
1726
1727run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1728 "$P_SRV crt_file=data_files/server6.crt \
1729 key_file=data_files/server6.key \
1730 crt_file2=data_files/server5.crt \
1731 key_file2=data_files/server5.key" \
1732 "$P_CLI force_version=tls1_1" \
1733 0 \
1734 -c "serial number.*0A" \
1735 -c "signed using.*ECDSA with SHA256" \
1736 -C "signed using.*ECDSA with SHA1"
1737
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001738# tests for SNI
1739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001740run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001741 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001742 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001743 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001744 0 \
1745 -S "parse ServerName extension" \
1746 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1747 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001749run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001750 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001751 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001752 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 +02001753 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001754 0 \
1755 -s "parse ServerName extension" \
1756 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1757 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001759run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001760 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001761 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001762 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 +02001763 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001764 0 \
1765 -s "parse ServerName extension" \
1766 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001767 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001769run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001770 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001771 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001772 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 +02001773 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001774 1 \
1775 -s "parse ServerName extension" \
1776 -s "ssl_sni_wrapper() returned" \
1777 -s "ssl_handshake returned" \
1778 -c "ssl_handshake returned" \
1779 -c "SSL - A fatal alert message was received from our peer"
1780
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001781# Tests for non-blocking I/O: exercise a variety of handshake flows
1782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001783run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001784 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1785 "$P_CLI nbio=2 tickets=0" \
1786 0 \
1787 -S "ssl_handshake returned" \
1788 -C "ssl_handshake returned" \
1789 -c "Read from server: .* bytes read"
1790
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001791run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001792 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1793 "$P_CLI nbio=2 tickets=0" \
1794 0 \
1795 -S "ssl_handshake returned" \
1796 -C "ssl_handshake returned" \
1797 -c "Read from server: .* bytes read"
1798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001799run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001800 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1801 "$P_CLI nbio=2 tickets=1" \
1802 0 \
1803 -S "ssl_handshake returned" \
1804 -C "ssl_handshake returned" \
1805 -c "Read from server: .* bytes read"
1806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001807run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001808 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1809 "$P_CLI nbio=2 tickets=1" \
1810 0 \
1811 -S "ssl_handshake returned" \
1812 -C "ssl_handshake returned" \
1813 -c "Read from server: .* bytes read"
1814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001815run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001816 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1817 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1818 0 \
1819 -S "ssl_handshake returned" \
1820 -C "ssl_handshake returned" \
1821 -c "Read from server: .* bytes read"
1822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001823run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001824 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1825 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1826 0 \
1827 -S "ssl_handshake returned" \
1828 -C "ssl_handshake returned" \
1829 -c "Read from server: .* bytes read"
1830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001831run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001832 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1833 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1834 0 \
1835 -S "ssl_handshake returned" \
1836 -C "ssl_handshake returned" \
1837 -c "Read from server: .* bytes read"
1838
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001839# Tests for version negotiation
1840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001841run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001842 "$P_SRV" \
1843 "$P_CLI" \
1844 0 \
1845 -S "ssl_handshake returned" \
1846 -C "ssl_handshake returned" \
1847 -s "Protocol is TLSv1.2" \
1848 -c "Protocol is TLSv1.2"
1849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001850run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001851 "$P_SRV" \
1852 "$P_CLI max_version=tls1_1" \
1853 0 \
1854 -S "ssl_handshake returned" \
1855 -C "ssl_handshake returned" \
1856 -s "Protocol is TLSv1.1" \
1857 -c "Protocol is TLSv1.1"
1858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001859run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001860 "$P_SRV max_version=tls1_1" \
1861 "$P_CLI" \
1862 0 \
1863 -S "ssl_handshake returned" \
1864 -C "ssl_handshake returned" \
1865 -s "Protocol is TLSv1.1" \
1866 -c "Protocol is TLSv1.1"
1867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001868run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001869 "$P_SRV max_version=tls1_1" \
1870 "$P_CLI max_version=tls1_1" \
1871 0 \
1872 -S "ssl_handshake returned" \
1873 -C "ssl_handshake returned" \
1874 -s "Protocol is TLSv1.1" \
1875 -c "Protocol is TLSv1.1"
1876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001877run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001878 "$P_SRV min_version=tls1_1" \
1879 "$P_CLI max_version=tls1_1" \
1880 0 \
1881 -S "ssl_handshake returned" \
1882 -C "ssl_handshake returned" \
1883 -s "Protocol is TLSv1.1" \
1884 -c "Protocol is TLSv1.1"
1885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001886run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001887 "$P_SRV max_version=tls1_1" \
1888 "$P_CLI min_version=tls1_1" \
1889 0 \
1890 -S "ssl_handshake returned" \
1891 -C "ssl_handshake returned" \
1892 -s "Protocol is TLSv1.1" \
1893 -c "Protocol is TLSv1.1"
1894
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001895run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001896 "$P_SRV max_version=tls1_1" \
1897 "$P_CLI min_version=tls1_2" \
1898 1 \
1899 -s "ssl_handshake returned" \
1900 -c "ssl_handshake returned" \
1901 -c "SSL - Handshake protocol not within min/max boundaries"
1902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001903run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001904 "$P_SRV min_version=tls1_2" \
1905 "$P_CLI max_version=tls1_1" \
1906 1 \
1907 -s "ssl_handshake returned" \
1908 -c "ssl_handshake returned" \
1909 -s "SSL - Handshake protocol not within min/max boundaries"
1910
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001911# Tests for ALPN extension
1912
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001913if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001915run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001916 "$P_SRV debug_level=3" \
1917 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001918 0 \
1919 -C "client hello, adding alpn extension" \
1920 -S "found alpn extension" \
1921 -C "got an alert message, type: \\[2:120]" \
1922 -S "server hello, adding alpn extension" \
1923 -C "found alpn extension " \
1924 -C "Application Layer Protocol is" \
1925 -S "Application Layer Protocol is"
1926
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001927run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001928 "$P_SRV debug_level=3" \
1929 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001930 0 \
1931 -c "client hello, adding alpn extension" \
1932 -s "found alpn extension" \
1933 -C "got an alert message, type: \\[2:120]" \
1934 -S "server hello, adding alpn extension" \
1935 -C "found alpn extension " \
1936 -c "Application Layer Protocol is (none)" \
1937 -S "Application Layer Protocol is"
1938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001939run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001940 "$P_SRV debug_level=3 alpn=abc,1234" \
1941 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001942 0 \
1943 -C "client hello, adding alpn extension" \
1944 -S "found alpn extension" \
1945 -C "got an alert message, type: \\[2:120]" \
1946 -S "server hello, adding alpn extension" \
1947 -C "found alpn extension " \
1948 -C "Application Layer Protocol is" \
1949 -s "Application Layer Protocol is (none)"
1950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001951run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001952 "$P_SRV debug_level=3 alpn=abc,1234" \
1953 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001954 0 \
1955 -c "client hello, adding alpn extension" \
1956 -s "found alpn extension" \
1957 -C "got an alert message, type: \\[2:120]" \
1958 -s "server hello, adding alpn extension" \
1959 -c "found alpn extension" \
1960 -c "Application Layer Protocol is abc" \
1961 -s "Application Layer Protocol is abc"
1962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001963run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001964 "$P_SRV debug_level=3 alpn=abc,1234" \
1965 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001966 0 \
1967 -c "client hello, adding alpn extension" \
1968 -s "found alpn extension" \
1969 -C "got an alert message, type: \\[2:120]" \
1970 -s "server hello, adding alpn extension" \
1971 -c "found alpn extension" \
1972 -c "Application Layer Protocol is abc" \
1973 -s "Application Layer Protocol is abc"
1974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001975run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001976 "$P_SRV debug_level=3 alpn=abc,1234" \
1977 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001978 0 \
1979 -c "client hello, adding alpn extension" \
1980 -s "found alpn extension" \
1981 -C "got an alert message, type: \\[2:120]" \
1982 -s "server hello, adding alpn extension" \
1983 -c "found alpn extension" \
1984 -c "Application Layer Protocol is 1234" \
1985 -s "Application Layer Protocol is 1234"
1986
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001987run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001988 "$P_SRV debug_level=3 alpn=abc,123" \
1989 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001990 1 \
1991 -c "client hello, adding alpn extension" \
1992 -s "found alpn extension" \
1993 -c "got an alert message, type: \\[2:120]" \
1994 -S "server hello, adding alpn extension" \
1995 -C "found alpn extension" \
1996 -C "Application Layer Protocol is 1234" \
1997 -S "Application Layer Protocol is 1234"
1998
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001999fi
2000
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002001# Tests for keyUsage in leaf certificates, part 1:
2002# server-side certificate/suite selection
2003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002004run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002005 "$P_SRV key_file=data_files/server2.key \
2006 crt_file=data_files/server2.ku-ds.crt" \
2007 "$P_CLI" \
2008 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002009 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002010
2011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002012run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002013 "$P_SRV key_file=data_files/server2.key \
2014 crt_file=data_files/server2.ku-ke.crt" \
2015 "$P_CLI" \
2016 0 \
2017 -c "Ciphersuite is TLS-RSA-WITH-"
2018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002019run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002020 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002021 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002022 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002023 1 \
2024 -C "Ciphersuite is "
2025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002026run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002027 "$P_SRV key_file=data_files/server5.key \
2028 crt_file=data_files/server5.ku-ds.crt" \
2029 "$P_CLI" \
2030 0 \
2031 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2032
2033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002034run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002035 "$P_SRV key_file=data_files/server5.key \
2036 crt_file=data_files/server5.ku-ka.crt" \
2037 "$P_CLI" \
2038 0 \
2039 -c "Ciphersuite is TLS-ECDH-"
2040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002041run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002042 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002043 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002044 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002045 1 \
2046 -C "Ciphersuite is "
2047
2048# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002049# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002051run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002052 "$O_SRV -key data_files/server2.key \
2053 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002054 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002055 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2056 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002057 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002058 -C "Processing of the Certificate handshake message failed" \
2059 -c "Ciphersuite is TLS-"
2060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002061run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002062 "$O_SRV -key data_files/server2.key \
2063 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002064 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002065 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2066 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002067 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002068 -C "Processing of the Certificate handshake message failed" \
2069 -c "Ciphersuite is TLS-"
2070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002071run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002072 "$O_SRV -key data_files/server2.key \
2073 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002074 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002075 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2076 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002077 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002078 -C "Processing of the Certificate handshake message failed" \
2079 -c "Ciphersuite is TLS-"
2080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002081run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002082 "$O_SRV -key data_files/server2.key \
2083 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002084 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002085 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2086 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002087 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002088 -c "Processing of the Certificate handshake message failed" \
2089 -C "Ciphersuite is TLS-"
2090
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002091run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002092 "$O_SRV -key data_files/server2.key \
2093 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002094 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002095 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2096 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002097 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002098 -C "Processing of the Certificate handshake message failed" \
2099 -c "Ciphersuite is TLS-"
2100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002101run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002102 "$O_SRV -key data_files/server2.key \
2103 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002104 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002105 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2106 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002107 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002108 -c "Processing of the Certificate handshake message failed" \
2109 -C "Ciphersuite is TLS-"
2110
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002111# Tests for keyUsage in leaf certificates, part 3:
2112# server-side checking of client cert
2113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002114run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002115 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002116 "$O_CLI -key data_files/server2.key \
2117 -cert data_files/server2.ku-ds.crt" \
2118 0 \
2119 -S "bad certificate (usage extensions)" \
2120 -S "Processing of the Certificate handshake message failed"
2121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002122run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002123 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002124 "$O_CLI -key data_files/server2.key \
2125 -cert data_files/server2.ku-ke.crt" \
2126 0 \
2127 -s "bad certificate (usage extensions)" \
2128 -S "Processing of the Certificate handshake message failed"
2129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002130run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002131 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002132 "$O_CLI -key data_files/server2.key \
2133 -cert data_files/server2.ku-ke.crt" \
2134 1 \
2135 -s "bad certificate (usage extensions)" \
2136 -s "Processing of the Certificate handshake message failed"
2137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002138run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002139 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002140 "$O_CLI -key data_files/server5.key \
2141 -cert data_files/server5.ku-ds.crt" \
2142 0 \
2143 -S "bad certificate (usage extensions)" \
2144 -S "Processing of the Certificate handshake message failed"
2145
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002146run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002147 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002148 "$O_CLI -key data_files/server5.key \
2149 -cert data_files/server5.ku-ka.crt" \
2150 0 \
2151 -s "bad certificate (usage extensions)" \
2152 -S "Processing of the Certificate handshake message failed"
2153
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002154# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002156run_test "extKeyUsage srv: serverAuth -> 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: serverAuth,clientAuth -> 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-srv.crt" \
2165 "$P_CLI" \
2166 0
2167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002168run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002169 "$P_SRV key_file=data_files/server5.key \
2170 crt_file=data_files/server5.eku-cs_any.crt" \
2171 "$P_CLI" \
2172 0
2173
2174# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002175run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002176 "$P_SRV psk=abc123 key_file=data_files/server5.key \
2177 crt_file=data_files/server5.eku-cli.crt" \
2178 "$P_CLI psk=badbad" \
2179 1
2180
2181# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002183run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002184 "$O_SRV -key data_files/server5.key \
2185 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002186 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002187 0 \
2188 -C "bad certificate (usage extensions)" \
2189 -C "Processing of the Certificate handshake message failed" \
2190 -c "Ciphersuite is TLS-"
2191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002192run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002193 "$O_SRV -key data_files/server5.key \
2194 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002195 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002196 0 \
2197 -C "bad certificate (usage extensions)" \
2198 -C "Processing of the Certificate handshake message failed" \
2199 -c "Ciphersuite is TLS-"
2200
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002201run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002202 "$O_SRV -key data_files/server5.key \
2203 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002204 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002205 0 \
2206 -C "bad certificate (usage extensions)" \
2207 -C "Processing of the Certificate handshake message failed" \
2208 -c "Ciphersuite is TLS-"
2209
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002210run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002211 "$O_SRV -key data_files/server5.key \
2212 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002213 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002214 1 \
2215 -c "bad certificate (usage extensions)" \
2216 -c "Processing of the Certificate handshake message failed" \
2217 -C "Ciphersuite is TLS-"
2218
2219# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002221run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002222 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002223 "$O_CLI -key data_files/server5.key \
2224 -cert data_files/server5.eku-cli.crt" \
2225 0 \
2226 -S "bad certificate (usage extensions)" \
2227 -S "Processing of the Certificate handshake message failed"
2228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002229run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002230 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002231 "$O_CLI -key data_files/server5.key \
2232 -cert data_files/server5.eku-srv_cli.crt" \
2233 0 \
2234 -S "bad certificate (usage extensions)" \
2235 -S "Processing of the Certificate handshake message failed"
2236
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002237run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002238 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002239 "$O_CLI -key data_files/server5.key \
2240 -cert data_files/server5.eku-cs_any.crt" \
2241 0 \
2242 -S "bad certificate (usage extensions)" \
2243 -S "Processing of the Certificate handshake message failed"
2244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002245run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002246 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002247 "$O_CLI -key data_files/server5.key \
2248 -cert data_files/server5.eku-cs.crt" \
2249 0 \
2250 -s "bad certificate (usage extensions)" \
2251 -S "Processing of the Certificate handshake message failed"
2252
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002253run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002254 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002255 "$O_CLI -key data_files/server5.key \
2256 -cert data_files/server5.eku-cs.crt" \
2257 1 \
2258 -s "bad certificate (usage extensions)" \
2259 -s "Processing of the Certificate handshake message failed"
2260
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002261# Tests for DHM parameters loading
2262
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002263run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002264 "$P_SRV" \
2265 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2266 debug_level=3" \
2267 0 \
2268 -c "value of 'DHM: P ' (2048 bits)" \
2269 -c "value of 'DHM: G ' (2048 bits)"
2270
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002271run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002272 "$P_SRV dhm_file=data_files/dhparams.pem" \
2273 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2274 debug_level=3" \
2275 0 \
2276 -c "value of 'DHM: P ' (1024 bits)" \
2277 -c "value of 'DHM: G ' (2 bits)"
2278
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002279# Tests for PSK callback
2280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002281run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002282 "$P_SRV psk=abc123 psk_identity=foo" \
2283 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2284 psk_identity=foo psk=abc123" \
2285 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002286 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002287 -S "SSL - Unknown identity received" \
2288 -S "SSL - Verification of the message MAC failed"
2289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002290run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002291 "$P_SRV" \
2292 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2293 psk_identity=foo psk=abc123" \
2294 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002295 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002296 -S "SSL - Unknown identity received" \
2297 -S "SSL - Verification of the message MAC failed"
2298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002299run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002300 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2301 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2302 psk_identity=foo psk=abc123" \
2303 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002304 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002305 -s "SSL - Unknown identity received" \
2306 -S "SSL - Verification of the message MAC failed"
2307
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002308run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002309 "$P_SRV psk_list=abc,dead,def,beef" \
2310 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2311 psk_identity=abc psk=dead" \
2312 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002313 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002314 -S "SSL - Unknown identity received" \
2315 -S "SSL - Verification of the message MAC failed"
2316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002317run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002318 "$P_SRV psk_list=abc,dead,def,beef" \
2319 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2320 psk_identity=def psk=beef" \
2321 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002322 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002323 -S "SSL - Unknown identity received" \
2324 -S "SSL - Verification of the message MAC failed"
2325
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002326run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002327 "$P_SRV psk_list=abc,dead,def,beef" \
2328 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2329 psk_identity=ghi psk=beef" \
2330 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002331 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002332 -s "SSL - Unknown identity received" \
2333 -S "SSL - Verification of the message MAC failed"
2334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002335run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002336 "$P_SRV psk_list=abc,dead,def,beef" \
2337 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2338 psk_identity=abc psk=beef" \
2339 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002340 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002341 -S "SSL - Unknown identity received" \
2342 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002343
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002344# Tests for ciphersuites per version
2345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002346run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002347 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002348 "$P_CLI force_version=ssl3" \
2349 0 \
2350 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002352run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002353 "$P_SRV arc4=1 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002354 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002355 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002356 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002357
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002358run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002359 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002360 "$P_CLI force_version=tls1_1" \
2361 0 \
2362 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002364run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002365 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002366 "$P_CLI force_version=tls1_2" \
2367 0 \
2368 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2369
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002370# Tests for ssl_get_bytes_avail()
2371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002372run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002373 "$P_SRV" \
2374 "$P_CLI request_size=100" \
2375 0 \
2376 -s "Read from client: 100 bytes read$"
2377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002378run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002379 "$P_SRV" \
2380 "$P_CLI request_size=500" \
2381 0 \
2382 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002383
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002384# Tests for small packets
2385
2386run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002387 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002388 "$P_CLI request_size=1 force_version=ssl3 \
2389 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2390 0 \
2391 -s "Read from client: 1 bytes read"
2392
2393run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002394 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002395 "$P_CLI request_size=1 force_version=ssl3 \
2396 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2397 0 \
2398 -s "Read from client: 1 bytes read"
2399
2400run_test "Small packet TLS 1.0 BlockCipher" \
2401 "$P_SRV" \
2402 "$P_CLI request_size=1 force_version=tls1 \
2403 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2404 0 \
2405 -s "Read from client: 1 bytes read"
2406
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002407run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2408 "$P_SRV" \
2409 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2410 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2411 0 \
2412 -s "Read from client: 1 bytes read"
2413
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002414run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2415 "$P_SRV" \
2416 "$P_CLI request_size=1 force_version=tls1 \
2417 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2418 trunc_hmac=1" \
2419 0 \
2420 -s "Read from client: 1 bytes read"
2421
2422run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002423 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002424 "$P_CLI request_size=1 force_version=tls1 \
2425 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2426 trunc_hmac=1" \
2427 0 \
2428 -s "Read from client: 1 bytes read"
2429
2430run_test "Small packet TLS 1.1 BlockCipher" \
2431 "$P_SRV" \
2432 "$P_CLI request_size=1 force_version=tls1_1 \
2433 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2434 0 \
2435 -s "Read from client: 1 bytes read"
2436
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002437run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2438 "$P_SRV" \
2439 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2440 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2441 0 \
2442 -s "Read from client: 1 bytes read"
2443
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002444run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002445 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002446 "$P_CLI request_size=1 force_version=tls1_1 \
2447 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2448 0 \
2449 -s "Read from client: 1 bytes read"
2450
2451run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2452 "$P_SRV" \
2453 "$P_CLI request_size=1 force_version=tls1_1 \
2454 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2455 trunc_hmac=1" \
2456 0 \
2457 -s "Read from client: 1 bytes read"
2458
2459run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002460 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002461 "$P_CLI request_size=1 force_version=tls1_1 \
2462 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2463 trunc_hmac=1" \
2464 0 \
2465 -s "Read from client: 1 bytes read"
2466
2467run_test "Small packet TLS 1.2 BlockCipher" \
2468 "$P_SRV" \
2469 "$P_CLI request_size=1 force_version=tls1_2 \
2470 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2471 0 \
2472 -s "Read from client: 1 bytes read"
2473
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002474run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2475 "$P_SRV" \
2476 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2477 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2478 0 \
2479 -s "Read from client: 1 bytes read"
2480
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002481run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2482 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002483 "$P_CLI request_size=1 force_version=tls1_2 \
2484 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002485 0 \
2486 -s "Read from client: 1 bytes read"
2487
2488run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2489 "$P_SRV" \
2490 "$P_CLI request_size=1 force_version=tls1_2 \
2491 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2492 trunc_hmac=1" \
2493 0 \
2494 -s "Read from client: 1 bytes read"
2495
2496run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002497 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002498 "$P_CLI request_size=1 force_version=tls1_2 \
2499 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2500 0 \
2501 -s "Read from client: 1 bytes read"
2502
2503run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002504 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002505 "$P_CLI request_size=1 force_version=tls1_2 \
2506 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2507 trunc_hmac=1" \
2508 0 \
2509 -s "Read from client: 1 bytes read"
2510
2511run_test "Small packet TLS 1.2 AEAD" \
2512 "$P_SRV" \
2513 "$P_CLI request_size=1 force_version=tls1_2 \
2514 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2515 0 \
2516 -s "Read from client: 1 bytes read"
2517
2518run_test "Small packet TLS 1.2 AEAD shorter tag" \
2519 "$P_SRV" \
2520 "$P_CLI request_size=1 force_version=tls1_2 \
2521 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2522 0 \
2523 -s "Read from client: 1 bytes read"
2524
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002525# Test for large packets
2526
2527run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002528 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002529 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002530 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2531 0 \
2532 -s "Read from client: 16384 bytes read"
2533
2534run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002535 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002536 "$P_CLI request_size=16384 force_version=ssl3 \
2537 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2538 0 \
2539 -s "Read from client: 16384 bytes read"
2540
2541run_test "Large packet TLS 1.0 BlockCipher" \
2542 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002543 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002544 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2545 0 \
2546 -s "Read from client: 16384 bytes read"
2547
2548run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2549 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002550 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002551 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2552 trunc_hmac=1" \
2553 0 \
2554 -s "Read from client: 16384 bytes read"
2555
2556run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002557 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002558 "$P_CLI request_size=16384 force_version=tls1 \
2559 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2560 trunc_hmac=1" \
2561 0 \
2562 -s "Read from client: 16384 bytes read"
2563
2564run_test "Large packet TLS 1.1 BlockCipher" \
2565 "$P_SRV" \
2566 "$P_CLI request_size=16384 force_version=tls1_1 \
2567 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2568 0 \
2569 -s "Read from client: 16384 bytes read"
2570
2571run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002572 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002573 "$P_CLI request_size=16384 force_version=tls1_1 \
2574 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2575 0 \
2576 -s "Read from client: 16384 bytes read"
2577
2578run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2579 "$P_SRV" \
2580 "$P_CLI request_size=16384 force_version=tls1_1 \
2581 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2582 trunc_hmac=1" \
2583 0 \
2584 -s "Read from client: 16384 bytes read"
2585
2586run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002587 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002588 "$P_CLI request_size=16384 force_version=tls1_1 \
2589 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2590 trunc_hmac=1" \
2591 0 \
2592 -s "Read from client: 16384 bytes read"
2593
2594run_test "Large packet TLS 1.2 BlockCipher" \
2595 "$P_SRV" \
2596 "$P_CLI request_size=16384 force_version=tls1_2 \
2597 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2598 0 \
2599 -s "Read from client: 16384 bytes read"
2600
2601run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2602 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002603 "$P_CLI request_size=16384 force_version=tls1_2 \
2604 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002605 0 \
2606 -s "Read from client: 16384 bytes read"
2607
2608run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2609 "$P_SRV" \
2610 "$P_CLI request_size=16384 force_version=tls1_2 \
2611 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2612 trunc_hmac=1" \
2613 0 \
2614 -s "Read from client: 16384 bytes read"
2615
2616run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002617 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002618 "$P_CLI request_size=16384 force_version=tls1_2 \
2619 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2620 0 \
2621 -s "Read from client: 16384 bytes read"
2622
2623run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002624 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002625 "$P_CLI request_size=16384 force_version=tls1_2 \
2626 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2627 trunc_hmac=1" \
2628 0 \
2629 -s "Read from client: 16384 bytes read"
2630
2631run_test "Large packet TLS 1.2 AEAD" \
2632 "$P_SRV" \
2633 "$P_CLI request_size=16384 force_version=tls1_2 \
2634 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2635 0 \
2636 -s "Read from client: 16384 bytes read"
2637
2638run_test "Large packet TLS 1.2 AEAD shorter tag" \
2639 "$P_SRV" \
2640 "$P_CLI request_size=16384 force_version=tls1_2 \
2641 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2642 0 \
2643 -s "Read from client: 16384 bytes read"
2644
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002645# Tests for DTLS HelloVerifyRequest
2646
2647run_test "DTLS cookie: enabled" \
2648 "$P_SRV dtls=1 debug_level=2" \
2649 "$P_CLI dtls=1 debug_level=2" \
2650 0 \
2651 -s "cookie verification failed" \
2652 -s "cookie verification passed" \
2653 -S "cookie verification skipped" \
2654 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002655 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002656 -S "SSL - The requested feature is not available"
2657
2658run_test "DTLS cookie: disabled" \
2659 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2660 "$P_CLI dtls=1 debug_level=2" \
2661 0 \
2662 -S "cookie verification failed" \
2663 -S "cookie verification passed" \
2664 -s "cookie verification skipped" \
2665 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002666 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002667 -S "SSL - The requested feature is not available"
2668
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002669run_test "DTLS cookie: default (failing)" \
2670 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2671 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2672 1 \
2673 -s "cookie verification failed" \
2674 -S "cookie verification passed" \
2675 -S "cookie verification skipped" \
2676 -C "received hello verify request" \
2677 -S "hello verification requested" \
2678 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002679
2680requires_ipv6
2681run_test "DTLS cookie: enabled, IPv6" \
2682 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2683 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2684 0 \
2685 -s "cookie verification failed" \
2686 -s "cookie verification passed" \
2687 -S "cookie verification skipped" \
2688 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002689 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002690 -S "SSL - The requested feature is not available"
2691
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002692run_test "DTLS cookie: enabled, nbio" \
2693 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2694 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2695 0 \
2696 -s "cookie verification failed" \
2697 -s "cookie verification passed" \
2698 -S "cookie verification skipped" \
2699 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002700 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002701 -S "SSL - The requested feature is not available"
2702
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002703# Tests for various cases of client authentication with DTLS
2704# (focused on handshake flows and message parsing)
2705
2706run_test "DTLS client auth: required" \
2707 "$P_SRV dtls=1 auth_mode=required" \
2708 "$P_CLI dtls=1" \
2709 0 \
2710 -s "Verifying peer X.509 certificate... ok"
2711
2712run_test "DTLS client auth: optional, client has no cert" \
2713 "$P_SRV dtls=1 auth_mode=optional" \
2714 "$P_CLI dtls=1 crt_file=none key_file=none" \
2715 0 \
2716 -s "! no client certificate sent"
2717
2718run_test "DTLS client auth: optional, client has no cert" \
2719 "$P_SRV dtls=1 auth_mode=none" \
2720 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2721 0 \
2722 -c "skip write certificate$" \
2723 -s "! no client certificate sent"
2724
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002725# Tests for receiving fragmented handshake messages with DTLS
2726
2727requires_gnutls
2728run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2729 "$G_SRV -u --mtu 2048 -a" \
2730 "$P_CLI dtls=1 debug_level=2" \
2731 0 \
2732 -C "found fragmented DTLS handshake message" \
2733 -C "error"
2734
2735requires_gnutls
2736run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2737 "$G_SRV -u --mtu 512" \
2738 "$P_CLI dtls=1 debug_level=2" \
2739 0 \
2740 -c "found fragmented DTLS handshake message" \
2741 -C "error"
2742
2743requires_gnutls
2744run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2745 "$G_SRV -u --mtu 128" \
2746 "$P_CLI dtls=1 debug_level=2" \
2747 0 \
2748 -c "found fragmented DTLS handshake message" \
2749 -C "error"
2750
2751requires_gnutls
2752run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2753 "$G_SRV -u --mtu 128" \
2754 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2755 0 \
2756 -c "found fragmented DTLS handshake message" \
2757 -C "error"
2758
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002759requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002760run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2761 "$G_SRV -u --mtu 256" \
2762 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2763 0 \
2764 -c "found fragmented DTLS handshake message" \
2765 -c "client hello, adding renegotiation extension" \
2766 -c "found renegotiation extension" \
2767 -c "=> renegotiate" \
2768 -C "ssl_handshake returned" \
2769 -C "error" \
2770 -s "Extra-header:"
2771
2772requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002773run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2774 "$G_SRV -u --mtu 256" \
2775 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2776 0 \
2777 -c "found fragmented DTLS handshake message" \
2778 -c "client hello, adding renegotiation extension" \
2779 -c "found renegotiation extension" \
2780 -c "=> renegotiate" \
2781 -C "ssl_handshake returned" \
2782 -C "error" \
2783 -s "Extra-header:"
2784
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002785run_test "DTLS reassembly: no fragmentation (openssl server)" \
2786 "$O_SRV -dtls1 -mtu 2048" \
2787 "$P_CLI dtls=1 debug_level=2" \
2788 0 \
2789 -C "found fragmented DTLS handshake message" \
2790 -C "error"
2791
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002792run_test "DTLS reassembly: some fragmentation (openssl server)" \
2793 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002794 "$P_CLI dtls=1 debug_level=2" \
2795 0 \
2796 -c "found fragmented DTLS handshake message" \
2797 -C "error"
2798
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002799run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002800 "$O_SRV -dtls1 -mtu 256" \
2801 "$P_CLI dtls=1 debug_level=2" \
2802 0 \
2803 -c "found fragmented DTLS handshake message" \
2804 -C "error"
2805
2806run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2807 "$O_SRV -dtls1 -mtu 256" \
2808 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2809 0 \
2810 -c "found fragmented DTLS handshake message" \
2811 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002812
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002813# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002814
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002815not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002816run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002817 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002818 "$P_SRV dtls=1 debug_level=2" \
2819 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002820 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002821 -C "replayed record" \
2822 -S "replayed record" \
2823 -C "record from another epoch" \
2824 -S "record from another epoch" \
2825 -C "discarding invalid record" \
2826 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002827 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002828 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002829 -c "HTTP/1.0 200 OK"
2830
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002831not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002832run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002833 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002834 "$P_SRV dtls=1 debug_level=2" \
2835 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002836 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002837 -c "replayed record" \
2838 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002839 -c "discarding invalid record" \
2840 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002841 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002842 -s "Extra-header:" \
2843 -c "HTTP/1.0 200 OK"
2844
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002845run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2846 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002847 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2848 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002849 0 \
2850 -c "replayed record" \
2851 -S "replayed record" \
2852 -c "discarding invalid record" \
2853 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002854 -c "resend" \
2855 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002856 -s "Extra-header:" \
2857 -c "HTTP/1.0 200 OK"
2858
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002859run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002860 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002861 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002862 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002863 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002864 -c "discarding invalid record (mac)" \
2865 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002866 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002867 -c "HTTP/1.0 200 OK" \
2868 -S "too many records with bad MAC" \
2869 -S "Verification of the message MAC failed"
2870
2871run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
2872 -p "$P_PXY bad_ad=1" \
2873 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
2874 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2875 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002876 -C "discarding invalid record (mac)" \
2877 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002878 -S "Extra-header:" \
2879 -C "HTTP/1.0 200 OK" \
2880 -s "too many records with bad MAC" \
2881 -s "Verification of the message MAC failed"
2882
2883run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
2884 -p "$P_PXY bad_ad=1" \
2885 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
2886 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2887 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002888 -c "discarding invalid record (mac)" \
2889 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002890 -s "Extra-header:" \
2891 -c "HTTP/1.0 200 OK" \
2892 -S "too many records with bad MAC" \
2893 -S "Verification of the message MAC failed"
2894
2895run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
2896 -p "$P_PXY bad_ad=1" \
2897 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
2898 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
2899 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002900 -c "discarding invalid record (mac)" \
2901 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002902 -s "Extra-header:" \
2903 -c "HTTP/1.0 200 OK" \
2904 -s "too many records with bad MAC" \
2905 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002906
2907run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002908 -p "$P_PXY delay_ccs=1" \
2909 "$P_SRV dtls=1 debug_level=1" \
2910 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002911 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002912 -c "record from another epoch" \
2913 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002914 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002915 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002916 -s "Extra-header:" \
2917 -c "HTTP/1.0 200 OK"
2918
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002919# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002920
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002921needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002922run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002923 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002924 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2925 psk=abc123" \
2926 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002927 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2928 0 \
2929 -s "Extra-header:" \
2930 -c "HTTP/1.0 200 OK"
2931
2932needs_more_time 2
2933run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
2934 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002935 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2936 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002937 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2938 0 \
2939 -s "Extra-header:" \
2940 -c "HTTP/1.0 200 OK"
2941
2942needs_more_time 2
2943run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
2944 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002945 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2946 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002947 0 \
2948 -s "Extra-header:" \
2949 -c "HTTP/1.0 200 OK"
2950
2951needs_more_time 2
2952run_test "DTLS proxy: 3d, FS, client auth" \
2953 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002954 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
2955 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002956 0 \
2957 -s "Extra-header:" \
2958 -c "HTTP/1.0 200 OK"
2959
2960needs_more_time 2
2961run_test "DTLS proxy: 3d, FS, ticket" \
2962 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002963 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
2964 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002965 0 \
2966 -s "Extra-header:" \
2967 -c "HTTP/1.0 200 OK"
2968
2969needs_more_time 2
2970run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
2971 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002972 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
2973 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002974 0 \
2975 -s "Extra-header:" \
2976 -c "HTTP/1.0 200 OK"
2977
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002978needs_more_time 2
2979run_test "DTLS proxy: 3d, max handshake, nbio" \
2980 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002981 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
2982 auth_mode=required" \
2983 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002984 0 \
2985 -s "Extra-header:" \
2986 -c "HTTP/1.0 200 OK"
2987
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002988needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02002989run_test "DTLS proxy: 3d, min handshake, resumption" \
2990 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2991 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2992 psk=abc123 debug_level=3" \
2993 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2994 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2995 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2996 0 \
2997 -s "a session has been resumed" \
2998 -c "a session has been resumed" \
2999 -s "Extra-header:" \
3000 -c "HTTP/1.0 200 OK"
3001
3002needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003003run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3004 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3005 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3006 psk=abc123 debug_level=3 nbio=2" \
3007 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3008 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3009 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3010 0 \
3011 -s "a session has been resumed" \
3012 -c "a session has been resumed" \
3013 -s "Extra-header:" \
3014 -c "HTTP/1.0 200 OK"
3015
3016needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003017run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003018 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003019 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3020 psk=abc123 renegotiation=1 debug_level=2" \
3021 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3022 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003023 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3024 0 \
3025 -c "=> renegotiate" \
3026 -s "=> renegotiate" \
3027 -s "Extra-header:" \
3028 -c "HTTP/1.0 200 OK"
3029
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003030needs_more_time 4
3031run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3032 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003033 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3034 psk=abc123 renegotiation=1 debug_level=2" \
3035 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3036 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003037 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3038 0 \
3039 -c "=> renegotiate" \
3040 -s "=> renegotiate" \
3041 -s "Extra-header:" \
3042 -c "HTTP/1.0 200 OK"
3043
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003044needs_more_time 4
3045run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003046 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003047 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003048 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003049 debug_level=2" \
3050 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003051 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003052 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3053 0 \
3054 -c "=> renegotiate" \
3055 -s "=> renegotiate" \
3056 -s "Extra-header:" \
3057 -c "HTTP/1.0 200 OK"
3058
3059needs_more_time 4
3060run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003061 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003062 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003063 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003064 debug_level=2 nbio=2" \
3065 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003066 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003067 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3068 0 \
3069 -c "=> renegotiate" \
3070 -s "=> renegotiate" \
3071 -s "Extra-header:" \
3072 -c "HTTP/1.0 200 OK"
3073
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003074needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003075run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003076 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3077 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003078 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003079 0 \
3080 -s "Extra-header:" \
3081 -c "HTTP/1.0 200 OK"
3082
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003083needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003084run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3085 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3086 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003087 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003088 0 \
3089 -s "Extra-header:" \
3090 -c "HTTP/1.0 200 OK"
3091
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003092needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003093run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3094 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3095 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003096 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003097 0 \
3098 -s "Extra-header:" \
3099 -c "HTTP/1.0 200 OK"
3100
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003101requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003102needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003103run_test "DTLS proxy: 3d, gnutls server" \
3104 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3105 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003106 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003107 0 \
3108 -s "Extra-header:" \
3109 -c "Extra-header:"
3110
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003111requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003112needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003113run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3114 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3115 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003116 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003117 0 \
3118 -s "Extra-header:" \
3119 -c "Extra-header:"
3120
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003121requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003122needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003123run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3124 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3125 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003126 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003127 0 \
3128 -s "Extra-header:" \
3129 -c "Extra-header:"
3130
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003131# Final report
3132
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003133echo "------------------------------------------------------------------------"
3134
3135if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003136 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003137else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003138 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003139fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003140PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003141echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003142
3143exit $FAILS