blob: 82d1238947ae9812eff9b510845e612f6dd2245e [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é-Gonnard988209f2015-03-24 10:43:55 +010070# skip next test if the flag is not enabled in config.h
71requires_config_enabled() {
72 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
73 SKIP_NEXT="YES"
74 fi
75}
76
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020077# skip next test if OpenSSL can't send SSLv2 ClientHello
78requires_openssl_with_sslv2() {
79 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020080 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020081 OPENSSL_HAS_SSL2="YES"
82 else
83 OPENSSL_HAS_SSL2="NO"
84 fi
85 fi
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +020086
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020087 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
88 SKIP_NEXT="YES"
89 fi
90}
91
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020092# skip next test if OpenSSL doesn't support FALLBACK_SCSV
93requires_openssl_with_fallback_scsv() {
94 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
95 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
96 then
97 OPENSSL_HAS_FBSCSV="YES"
98 else
99 OPENSSL_HAS_FBSCSV="NO"
100 fi
101 fi
102 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
103 SKIP_NEXT="YES"
104 fi
105}
106
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200107# skip next test if GnuTLS isn't available
108requires_gnutls() {
109 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
110 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
111 GNUTLS_AVAILABLE="YES"
112 else
113 GNUTLS_AVAILABLE="NO"
114 fi
115 fi
116 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
117 SKIP_NEXT="YES"
118 fi
119}
120
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200121# skip next test if IPv6 isn't available on this host
122requires_ipv6() {
123 if [ -z "${HAS_IPV6:-}" ]; then
124 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
125 SRV_PID=$!
126 sleep 1
127 kill $SRV_PID >/dev/null 2>&1
128 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
129 HAS_IPV6="NO"
130 else
131 HAS_IPV6="YES"
132 fi
133 rm -r $SRV_OUT
134 fi
135
136 if [ "$HAS_IPV6" = "NO" ]; then
137 SKIP_NEXT="YES"
138 fi
139}
140
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200141# skip the next test if valgrind is in use
142not_with_valgrind() {
143 if [ "$MEMCHECK" -gt 0 ]; then
144 SKIP_NEXT="YES"
145 fi
146}
147
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200148# multiply the client timeout delay by the given factor for the next test
149needs_more_time() {
150 CLI_DELAY_FACTOR=$1
151}
152
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100153# print_name <name>
154print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100155 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200156 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100157 for i in `seq 1 $LEN`; do printf '.'; done
158 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100159
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200160 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100161}
162
163# fail <message>
164fail() {
165 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100166 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100167
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200168 mv $SRV_OUT o-srv-${TESTS}.log
169 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200170 if [ -n "$PXY_CMD" ]; then
171 mv $PXY_OUT o-pxy-${TESTS}.log
172 fi
173 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100174
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200175 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
176 echo " ! server output:"
177 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200178 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200179 echo " ! client output:"
180 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200181 if [ -n "$PXY_CMD" ]; then
182 echo " ! ========================================================"
183 echo " ! proxy output:"
184 cat o-pxy-${TESTS}.log
185 fi
186 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200187 fi
188
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200189 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100190}
191
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100192# is_polar <cmd_line>
193is_polar() {
194 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
195}
196
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200197# openssl s_server doesn't have -www with DTLS
198check_osrv_dtls() {
199 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
200 NEEDS_INPUT=1
201 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
202 else
203 NEEDS_INPUT=0
204 fi
205}
206
207# provide input to commands that need it
208provide_input() {
209 if [ $NEEDS_INPUT -eq 0 ]; then
210 return
211 fi
212
213 while true; do
214 echo "HTTP/1.0 200 OK"
215 sleep 1
216 done
217}
218
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100219# has_mem_err <log_file_name>
220has_mem_err() {
221 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
222 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
223 then
224 return 1 # false: does not have errors
225 else
226 return 0 # true: has errors
227 fi
228}
229
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200230# wait for server to start: two versions depending on lsof availability
231wait_server_start() {
232 if which lsof >/dev/null; then
233 # make sure we don't loop forever
234 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200235 DOG_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200236
237 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200238 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnarda65d5082015-01-12 14:54:55 +0100239 until lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null;
240 do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200241 else
Manuel Pégourié-Gonnarda65d5082015-01-12 14:54:55 +0100242 until lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null;
243 do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200244 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200245
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200246 kill $DOG_PID >/dev/null 2>&1
247 wait $DOG_PID
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200248 else
249 sleep "$START_DELAY"
250 fi
251}
252
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200253# wait for client to terminate and set CLI_EXIT
254# must be called right after starting the client
255wait_client_done() {
256 CLI_PID=$!
257
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200258 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
259 CLI_DELAY_FACTOR=1
260
261 ( sleep $CLI_DELAY; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200262 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200263
264 wait $CLI_PID
265 CLI_EXIT=$?
266
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200267 kill $DOG_PID >/dev/null 2>&1
268 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200269
270 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
271}
272
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200273# check if the given command uses dtls and sets global variable DTLS
274detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200275 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200276 DTLS=1
277 else
278 DTLS=0
279 fi
280}
281
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200282# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100283# Options: -s pattern pattern that must be present in server output
284# -c pattern pattern that must be present in client output
285# -S pattern pattern that must be absent in server output
286# -C pattern pattern that must be absent in client output
287run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100288 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200289 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100290
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100291 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
292 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200293 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100294 return
295 fi
296
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100297 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100298
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200299 # should we skip?
300 if [ "X$SKIP_NEXT" = "XYES" ]; then
301 SKIP_NEXT="NO"
302 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200303 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200304 return
305 fi
306
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200307 # does this test use a proxy?
308 if [ "X$1" = "X-p" ]; then
309 PXY_CMD="$2"
310 shift 2
311 else
312 PXY_CMD=""
313 fi
314
315 # get commands and client output
316 SRV_CMD="$1"
317 CLI_CMD="$2"
318 CLI_EXPECT="$3"
319 shift 3
320
321 # fix client port
322 if [ -n "$PXY_CMD" ]; then
323 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
324 else
325 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
326 fi
327
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200328 # update DTLS variable
329 detect_dtls "$SRV_CMD"
330
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100331 # prepend valgrind to our commands if active
332 if [ "$MEMCHECK" -gt 0 ]; then
333 if is_polar "$SRV_CMD"; then
334 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
335 fi
336 if is_polar "$CLI_CMD"; then
337 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
338 fi
339 fi
340
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100341 # run the commands
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200342 if [ -n "$PXY_CMD" ]; then
343 echo "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200344 $PXY_CMD >> $PXY_OUT 2>&1 &
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200345 PXY_PID=$!
346 # assume proxy starts faster than server
347 fi
348
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200349 check_osrv_dtls
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200350 echo "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200351 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100352 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200353 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200354
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200355 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200356 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
357 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100358
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200359 # terminate the server (and the proxy)
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200360 kill $SRV_PID
361 wait $SRV_PID
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200362 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200363 kill $PXY_PID >/dev/null 2>&1
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200364 wait $PXY_PID
365 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100366
367 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200368 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100369 # expected client exit to incorrectly succeed in case of catastrophic
370 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100371 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200372 if grep "Performing the SSL/TLS handshake" $SRV_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
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100378 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200379 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100380 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100381 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100382 return
383 fi
384 fi
385
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100386 # check server exit code
387 if [ $? != 0 ]; then
388 fail "server fail"
389 return
390 fi
391
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100392 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100393 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
394 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100395 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200396 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100397 return
398 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100399
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100400 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200401 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100402 while [ $# -gt 0 ]
403 do
404 case $1 in
405 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200406 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100407 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100408 return
409 fi
410 ;;
411
412 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200413 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100414 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100415 return
416 fi
417 ;;
418
419 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200420 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100421 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100422 return
423 fi
424 ;;
425
426 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200427 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100428 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100429 return
430 fi
431 ;;
432
433 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200434 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100435 exit 1
436 esac
437 shift 2
438 done
439
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100440 # check valgrind's results
441 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200442 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100443 fail "Server has memory errors"
444 return
445 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200446 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100447 fail "Client has memory errors"
448 return
449 fi
450 fi
451
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100452 # if we're here, everything is ok
453 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200454 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100455}
456
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100457cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200458 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200459 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
460 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
461 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
462 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100463 exit 1
464}
465
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100466#
467# MAIN
468#
469
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000470if cd $( dirname $0 ); then :; else
471 echo "cd $( dirname $0 ) failed" >&2
472 exit 1
473fi
474
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100475get_options "$@"
476
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100477# sanity checks, avoid an avalanche of errors
478if [ ! -x "$P_SRV" ]; then
479 echo "Command '$P_SRV' is not an executable file"
480 exit 1
481fi
482if [ ! -x "$P_CLI" ]; then
483 echo "Command '$P_CLI' is not an executable file"
484 exit 1
485fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200486if [ ! -x "$P_PXY" ]; then
487 echo "Command '$P_PXY' is not an executable file"
488 exit 1
489fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100490if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
491 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100492 exit 1
493fi
494
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200495# used by watchdog
496MAIN_PID="$$"
497
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200498# be more patient with valgrind
499if [ "$MEMCHECK" -gt 0 ]; then
500 START_DELAY=3
501 DOG_DELAY=30
502else
503 START_DELAY=1
504 DOG_DELAY=10
505fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200506CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200507
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200508# Pick a "unique" server port in the range 10000-19999, and a proxy port
509PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000510PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200511SRV_PORT="1$PORT_BASE"
512PXY_PORT="2$PORT_BASE"
513unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200514
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200515# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000516# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200517P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
518P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
519P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
520O_SRV="$O_SRV -accept $SRV_PORT"
521O_CLI="$O_CLI -connect localhost:+SRV_PORT"
522G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000523G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200524
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200525# Also pick a unique name for intermediate files
526SRV_OUT="srv_out.$$"
527CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200528PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200529SESSION="session.$$"
530
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200531SKIP_NEXT="NO"
532
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100533trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100534
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200535# Basic test
536
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200537# Checks that:
538# - things work with all ciphersuites active (used with config-full in all.sh)
539# - the expected (highest security) parameters are selected
540# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200541run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200542 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200543 "$P_CLI" \
544 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200545 -s "Protocol is TLSv1.2" \
546 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
547 -s "client hello v3, signature_algorithm ext: 6" \
548 -s "ECDHE curve: secp521r1" \
549 -S "error" \
550 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200551
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000552run_test "Default, DTLS" \
553 "$P_SRV dtls=1" \
554 "$P_CLI dtls=1" \
555 0 \
556 -s "Protocol is DTLSv1.2" \
557 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
558
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100559# Tests for rc4 option
560
561run_test "RC4: server disabled, client enabled" \
562 "$P_SRV" \
563 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
564 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100565 -s "SSL - The server has no ciphersuites in common"
566
567run_test "RC4: server half, client enabled" \
568 "$P_SRV arc4=1" \
569 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
570 1 \
571 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100572
573run_test "RC4: server enabled, client disabled" \
574 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
575 "$P_CLI" \
576 1 \
577 -s "SSL - The server has no ciphersuites in common"
578
579run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100580 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100581 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
582 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100583 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100584 -S "SSL - The server has no ciphersuites in common"
585
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100586# Test for SSLv2 ClientHello
587
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200588requires_openssl_with_sslv2
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100589requires_config_enabled POLARSSL_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200590run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100591 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100592 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100593 0 \
594 -S "parse client hello v2" \
595 -S "ssl_handshake returned"
596
597# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200598requires_openssl_with_sslv2
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100599requires_config_enabled POLARSSL_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200600run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200601 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100602 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100603 0 \
604 -s "parse client hello v2" \
605 -S "ssl_handshake returned"
606
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100607# Tests for Truncated HMAC extension
608
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100609run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200610 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100611 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100612 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100613 -s "dumping 'computed mac' (20 bytes)" \
614 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100615
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100616run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200617 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100618 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
619 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100620 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100621 -s "dumping 'computed mac' (20 bytes)" \
622 -S "dumping 'computed mac' (10 bytes)"
623
624run_test "Truncated HMAC: client enabled, server default" \
625 "$P_SRV debug_level=4" \
626 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
627 trunc_hmac=1" \
628 0 \
629 -S "dumping 'computed mac' (20 bytes)" \
630 -s "dumping 'computed mac' (10 bytes)"
631
632run_test "Truncated HMAC: client enabled, server disabled" \
633 "$P_SRV debug_level=4 trunc_hmac=0" \
634 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
635 trunc_hmac=1" \
636 0 \
637 -s "dumping 'computed mac' (20 bytes)" \
638 -S "dumping 'computed mac' (10 bytes)"
639
640run_test "Truncated HMAC: client enabled, server enabled" \
641 "$P_SRV debug_level=4 trunc_hmac=1" \
642 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
643 trunc_hmac=1" \
644 0 \
645 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100646 -s "dumping 'computed mac' (10 bytes)"
647
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100648# Tests for Encrypt-then-MAC extension
649
650run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100651 "$P_SRV debug_level=3 \
652 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100653 "$P_CLI debug_level=3" \
654 0 \
655 -c "client hello, adding encrypt_then_mac extension" \
656 -s "found encrypt then mac extension" \
657 -s "server hello, adding encrypt then mac extension" \
658 -c "found encrypt_then_mac extension" \
659 -c "using encrypt then mac" \
660 -s "using encrypt then mac"
661
662run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100663 "$P_SRV debug_level=3 etm=0 \
664 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100665 "$P_CLI debug_level=3 etm=1" \
666 0 \
667 -c "client hello, adding encrypt_then_mac extension" \
668 -s "found encrypt then mac extension" \
669 -S "server hello, adding encrypt then mac extension" \
670 -C "found encrypt_then_mac extension" \
671 -C "using encrypt then mac" \
672 -S "using encrypt then mac"
673
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100674run_test "Encrypt then MAC: client enabled, aead cipher" \
675 "$P_SRV debug_level=3 etm=1 \
676 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
677 "$P_CLI debug_level=3 etm=1" \
678 0 \
679 -c "client hello, adding encrypt_then_mac extension" \
680 -s "found encrypt then mac extension" \
681 -S "server hello, adding encrypt then mac extension" \
682 -C "found encrypt_then_mac extension" \
683 -C "using encrypt then mac" \
684 -S "using encrypt then mac"
685
686run_test "Encrypt then MAC: client enabled, stream cipher" \
687 "$P_SRV debug_level=3 etm=1 \
688 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100689 "$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 +0100690 0 \
691 -c "client hello, adding encrypt_then_mac extension" \
692 -s "found encrypt then mac extension" \
693 -S "server hello, adding encrypt then mac extension" \
694 -C "found encrypt_then_mac extension" \
695 -C "using encrypt then mac" \
696 -S "using encrypt then mac"
697
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100698run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100699 "$P_SRV debug_level=3 etm=1 \
700 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100701 "$P_CLI debug_level=3 etm=0" \
702 0 \
703 -C "client hello, adding encrypt_then_mac extension" \
704 -S "found encrypt then mac extension" \
705 -S "server hello, adding encrypt then mac extension" \
706 -C "found encrypt_then_mac extension" \
707 -C "using encrypt then mac" \
708 -S "using encrypt then mac"
709
710run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100711 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100712 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100713 "$P_CLI debug_level=3 force_version=ssl3" \
714 0 \
715 -C "client hello, adding encrypt_then_mac extension" \
716 -S "found encrypt then mac extension" \
717 -S "server hello, adding encrypt then mac extension" \
718 -C "found encrypt_then_mac extension" \
719 -C "using encrypt then mac" \
720 -S "using encrypt then mac"
721
722run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100723 "$P_SRV debug_level=3 force_version=ssl3 \
724 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100725 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100726 0 \
727 -c "client hello, adding encrypt_then_mac extension" \
728 -s "found encrypt then mac extension" \
729 -S "server hello, adding encrypt then mac extension" \
730 -C "found encrypt_then_mac extension" \
731 -C "using encrypt then mac" \
732 -S "using encrypt then mac"
733
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200734# Tests for Extended Master Secret extension
735
736run_test "Extended Master Secret: default" \
737 "$P_SRV debug_level=3" \
738 "$P_CLI debug_level=3" \
739 0 \
740 -c "client hello, adding extended_master_secret extension" \
741 -s "found extended master secret extension" \
742 -s "server hello, adding extended master secret extension" \
743 -c "found extended_master_secret extension" \
744 -c "using extended master secret" \
745 -s "using extended master secret"
746
747run_test "Extended Master Secret: client enabled, server disabled" \
748 "$P_SRV debug_level=3 extended_ms=0" \
749 "$P_CLI debug_level=3 extended_ms=1" \
750 0 \
751 -c "client hello, adding extended_master_secret extension" \
752 -s "found extended master secret extension" \
753 -S "server hello, adding extended master secret extension" \
754 -C "found extended_master_secret extension" \
755 -C "using extended master secret" \
756 -S "using extended master secret"
757
758run_test "Extended Master Secret: client disabled, server enabled" \
759 "$P_SRV debug_level=3 extended_ms=1" \
760 "$P_CLI debug_level=3 extended_ms=0" \
761 0 \
762 -C "client hello, adding extended_master_secret extension" \
763 -S "found extended master secret extension" \
764 -S "server hello, adding extended master secret extension" \
765 -C "found extended_master_secret extension" \
766 -C "using extended master secret" \
767 -S "using extended master secret"
768
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200769run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100770 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200771 "$P_CLI debug_level=3 force_version=ssl3" \
772 0 \
773 -C "client hello, adding extended_master_secret extension" \
774 -S "found extended master secret extension" \
775 -S "server hello, adding extended master secret extension" \
776 -C "found extended_master_secret extension" \
777 -C "using extended master secret" \
778 -S "using extended master secret"
779
780run_test "Extended Master Secret: client enabled, server SSLv3" \
781 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100782 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200783 0 \
784 -c "client hello, adding extended_master_secret extension" \
785 -s "found extended master secret extension" \
786 -S "server hello, adding extended master secret extension" \
787 -C "found extended_master_secret extension" \
788 -C "using extended master secret" \
789 -S "using extended master secret"
790
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200791# Tests for FALLBACK_SCSV
792
793run_test "Fallback SCSV: default" \
794 "$P_SRV" \
795 "$P_CLI debug_level=3 force_version=tls1_1" \
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: explicitly disabled" \
803 "$P_SRV" \
804 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
805 0 \
806 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200807 -S "received FALLBACK_SCSV" \
808 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200809 -C "is a fatal alert message (msg 86)"
810
811run_test "Fallback SCSV: enabled" \
812 "$P_SRV" \
813 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200814 1 \
815 -c "adding FALLBACK_SCSV" \
816 -s "received FALLBACK_SCSV" \
817 -s "inapropriate fallback" \
818 -c "is a fatal alert message (msg 86)"
819
820run_test "Fallback SCSV: enabled, max version" \
821 "$P_SRV" \
822 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200823 0 \
824 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200825 -s "received FALLBACK_SCSV" \
826 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200827 -C "is a fatal alert message (msg 86)"
828
829requires_openssl_with_fallback_scsv
830run_test "Fallback SCSV: default, openssl server" \
831 "$O_SRV" \
832 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
833 0 \
834 -C "adding FALLBACK_SCSV" \
835 -C "is a fatal alert message (msg 86)"
836
837requires_openssl_with_fallback_scsv
838run_test "Fallback SCSV: enabled, openssl server" \
839 "$O_SRV" \
840 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
841 1 \
842 -c "adding FALLBACK_SCSV" \
843 -c "is a fatal alert message (msg 86)"
844
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200845requires_openssl_with_fallback_scsv
846run_test "Fallback SCSV: disabled, openssl client" \
847 "$P_SRV" \
848 "$O_CLI -tls1_1" \
849 0 \
850 -S "received FALLBACK_SCSV" \
851 -S "inapropriate fallback"
852
853requires_openssl_with_fallback_scsv
854run_test "Fallback SCSV: enabled, openssl client" \
855 "$P_SRV" \
856 "$O_CLI -tls1_1 -fallback_scsv" \
857 1 \
858 -s "received FALLBACK_SCSV" \
859 -s "inapropriate fallback"
860
861requires_openssl_with_fallback_scsv
862run_test "Fallback SCSV: enabled, max version, openssl client" \
863 "$P_SRV" \
864 "$O_CLI -fallback_scsv" \
865 0 \
866 -s "received FALLBACK_SCSV" \
867 -S "inapropriate fallback"
868
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100869# Tests for CBC 1/n-1 record splitting
870
871run_test "CBC Record splitting: TLS 1.2, no splitting" \
872 "$P_SRV" \
873 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
874 request_size=123 force_version=tls1_2" \
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.1, no splitting" \
881 "$P_SRV" \
882 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
883 request_size=123 force_version=tls1_1" \
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: TLS 1.0, splitting" \
890 "$P_SRV" \
891 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
892 request_size=123 force_version=tls1" \
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: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100899 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100900 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
901 request_size=123 force_version=ssl3" \
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 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100908 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100909 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
910 request_size=123 force_version=tls1" \
911 0 \
912 -s "Read from client: 123 bytes read" \
913 -S "Read from client: 1 bytes read" \
914 -S "122 bytes read"
915
916run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
917 "$P_SRV" \
918 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
919 request_size=123 force_version=tls1 recsplit=0" \
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é-Gonnarda852cf42015-01-13 20:56:15 +0100925run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
926 "$P_SRV nbio=2" \
927 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
928 request_size=123 force_version=tls1" \
929 0 \
930 -S "Read from client: 123 bytes read" \
931 -s "Read from client: 1 bytes read" \
932 -s "122 bytes read"
933
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100934# Tests for Session Tickets
935
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200936run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200937 "$P_SRV debug_level=3 tickets=1" \
938 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100939 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100940 -c "client hello, adding session ticket extension" \
941 -s "found session ticket extension" \
942 -s "server hello, adding session ticket extension" \
943 -c "found session_ticket extension" \
944 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100945 -S "session successfully restored from cache" \
946 -s "session successfully restored from ticket" \
947 -s "a session has been resumed" \
948 -c "a session has been resumed"
949
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200950run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200951 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
952 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100953 0 \
954 -c "client hello, adding session ticket extension" \
955 -s "found session ticket extension" \
956 -s "server hello, adding session ticket extension" \
957 -c "found session_ticket extension" \
958 -c "parse new session ticket" \
959 -S "session successfully restored from cache" \
960 -s "session successfully restored from ticket" \
961 -s "a session has been resumed" \
962 -c "a session has been resumed"
963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200964run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200965 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
966 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100967 0 \
968 -c "client hello, adding session ticket extension" \
969 -s "found session ticket extension" \
970 -s "server hello, adding session ticket extension" \
971 -c "found session_ticket extension" \
972 -c "parse new session ticket" \
973 -S "session successfully restored from cache" \
974 -S "session successfully restored from ticket" \
975 -S "a session has been resumed" \
976 -C "a session has been resumed"
977
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200978run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100979 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200980 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100981 0 \
982 -c "client hello, adding session ticket extension" \
983 -c "found session_ticket extension" \
984 -c "parse new session ticket" \
985 -c "a session has been resumed"
986
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200987run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200988 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200989 "( $O_CLI -sess_out $SESSION; \
990 $O_CLI -sess_in $SESSION; \
991 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100992 0 \
993 -s "found session ticket extension" \
994 -s "server hello, adding session ticket extension" \
995 -S "session successfully restored from cache" \
996 -s "session successfully restored from ticket" \
997 -s "a session has been resumed"
998
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100999# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001000
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001001run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001002 "$P_SRV debug_level=3 tickets=0" \
1003 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001004 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001005 -c "client hello, adding session ticket extension" \
1006 -s "found session ticket extension" \
1007 -S "server hello, adding session ticket extension" \
1008 -C "found session_ticket extension" \
1009 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001010 -s "session successfully restored from cache" \
1011 -S "session successfully restored from ticket" \
1012 -s "a session has been resumed" \
1013 -c "a session has been resumed"
1014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001015run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001016 "$P_SRV debug_level=3 tickets=1" \
1017 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001018 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001019 -C "client hello, adding session ticket extension" \
1020 -S "found session ticket extension" \
1021 -S "server hello, adding session ticket extension" \
1022 -C "found session_ticket extension" \
1023 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001024 -s "session successfully restored from cache" \
1025 -S "session successfully restored from ticket" \
1026 -s "a session has been resumed" \
1027 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001029run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001030 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1031 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001032 0 \
1033 -S "session successfully restored from cache" \
1034 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001035 -S "a session has been resumed" \
1036 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001038run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001039 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1040 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
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: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001048 "$P_SRV debug_level=3 tickets=0" \
1049 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
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: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001057 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1058 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +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: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001066 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1067 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001068 0 \
1069 -s "session successfully restored from cache" \
1070 -S "session successfully restored from ticket" \
1071 -s "a session has been resumed" \
1072 -c "a session has been resumed"
1073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001074run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001075 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001076 "( $O_CLI -sess_out $SESSION; \
1077 $O_CLI -sess_in $SESSION; \
1078 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001079 0 \
1080 -s "found session ticket extension" \
1081 -S "server hello, adding session ticket extension" \
1082 -s "session successfully restored from cache" \
1083 -S "session successfully restored from ticket" \
1084 -s "a session has been resumed"
1085
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001086run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001087 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001088 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001089 0 \
1090 -C "found session_ticket extension" \
1091 -C "parse new session ticket" \
1092 -c "a session has been resumed"
1093
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001094# Tests for Max Fragment Length extension
1095
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001096run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001097 "$P_SRV debug_level=3" \
1098 "$P_CLI debug_level=3" \
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 client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001106 "$P_SRV debug_level=3" \
1107 "$P_CLI debug_level=3 max_frag_len=4096" \
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"
1113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001114run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001115 "$P_SRV debug_level=3 max_frag_len=4096" \
1116 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001117 0 \
1118 -C "client hello, adding max_fragment_length extension" \
1119 -S "found max fragment length extension" \
1120 -S "server hello, max_fragment_length extension" \
1121 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001122
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001123requires_gnutls
1124run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001125 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001126 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001127 0 \
1128 -c "client hello, adding max_fragment_length extension" \
1129 -c "found max_fragment_length extension"
1130
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001131run_test "Max fragment length: client, message just fits" \
1132 "$P_SRV debug_level=3" \
1133 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1134 0 \
1135 -c "client hello, adding max_fragment_length extension" \
1136 -s "found max fragment length extension" \
1137 -s "server hello, max_fragment_length extension" \
1138 -c "found max_fragment_length extension" \
1139 -c "2048 bytes written in 1 fragments" \
1140 -s "2048 bytes read"
1141
1142run_test "Max fragment length: client, larger message" \
1143 "$P_SRV debug_level=3" \
1144 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1145 0 \
1146 -c "client hello, adding max_fragment_length extension" \
1147 -s "found max fragment length extension" \
1148 -s "server hello, max_fragment_length extension" \
1149 -c "found max_fragment_length extension" \
1150 -c "2345 bytes written in 2 fragments" \
1151 -s "2048 bytes read" \
1152 -s "297 bytes read"
1153
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001154run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001155 "$P_SRV debug_level=3 dtls=1" \
1156 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1157 1 \
1158 -c "client hello, adding max_fragment_length extension" \
1159 -s "found max fragment length extension" \
1160 -s "server hello, max_fragment_length extension" \
1161 -c "found max_fragment_length extension" \
1162 -c "fragment larger than.*maximum"
1163
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001164# Tests for renegotiation
1165
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001166run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001167 "$P_SRV debug_level=3 exchanges=2" \
1168 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001169 0 \
1170 -C "client hello, adding renegotiation extension" \
1171 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1172 -S "found renegotiation extension" \
1173 -s "server hello, secure renegotiation extension" \
1174 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001175 -C "=> renegotiate" \
1176 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001177 -S "write hello request"
1178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001179run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001180 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
1181 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001182 0 \
1183 -c "client hello, adding renegotiation extension" \
1184 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1185 -s "found renegotiation extension" \
1186 -s "server hello, secure renegotiation extension" \
1187 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001188 -c "=> renegotiate" \
1189 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001190 -S "write hello request"
1191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001192run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001193 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1194 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001195 0 \
1196 -c "client hello, adding renegotiation extension" \
1197 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1198 -s "found renegotiation extension" \
1199 -s "server hello, secure renegotiation extension" \
1200 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001201 -c "=> renegotiate" \
1202 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001203 -s "write hello request"
1204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001205run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001206 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1207 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001208 0 \
1209 -c "client hello, adding renegotiation extension" \
1210 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1211 -s "found renegotiation extension" \
1212 -s "server hello, secure renegotiation extension" \
1213 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001214 -c "=> renegotiate" \
1215 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001216 -s "write hello request"
1217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001218run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001219 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1220 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001221 1 \
1222 -c "client hello, adding renegotiation extension" \
1223 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1224 -S "found renegotiation extension" \
1225 -s "server hello, secure renegotiation extension" \
1226 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001227 -c "=> renegotiate" \
1228 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001229 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001230 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001231 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001233run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001234 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1235 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001236 0 \
1237 -C "client hello, adding renegotiation extension" \
1238 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1239 -S "found renegotiation extension" \
1240 -s "server hello, secure renegotiation extension" \
1241 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001242 -C "=> renegotiate" \
1243 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001244 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001245 -S "SSL - An unexpected message was received from our peer" \
1246 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001247
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001248run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001249 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001250 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001251 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001252 0 \
1253 -C "client hello, adding renegotiation extension" \
1254 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1255 -S "found renegotiation extension" \
1256 -s "server hello, secure renegotiation extension" \
1257 -c "found renegotiation extension" \
1258 -C "=> renegotiate" \
1259 -S "=> renegotiate" \
1260 -s "write hello request" \
1261 -S "SSL - An unexpected message was received from our peer" \
1262 -S "failed"
1263
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001264# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001265run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001266 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001267 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001268 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001269 0 \
1270 -C "client hello, adding renegotiation extension" \
1271 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1272 -S "found renegotiation extension" \
1273 -s "server hello, secure renegotiation extension" \
1274 -c "found renegotiation extension" \
1275 -C "=> renegotiate" \
1276 -S "=> renegotiate" \
1277 -s "write hello request" \
1278 -S "SSL - An unexpected message was received from our peer" \
1279 -S "failed"
1280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001281run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001282 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001283 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001284 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001285 0 \
1286 -C "client hello, adding renegotiation extension" \
1287 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1288 -S "found renegotiation extension" \
1289 -s "server hello, secure renegotiation extension" \
1290 -c "found renegotiation extension" \
1291 -C "=> renegotiate" \
1292 -S "=> renegotiate" \
1293 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001294 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001296run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001297 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001298 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001299 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001300 0 \
1301 -c "client hello, adding renegotiation extension" \
1302 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1303 -s "found renegotiation extension" \
1304 -s "server hello, secure renegotiation extension" \
1305 -c "found renegotiation extension" \
1306 -c "=> renegotiate" \
1307 -s "=> renegotiate" \
1308 -s "write hello request" \
1309 -S "SSL - An unexpected message was received from our peer" \
1310 -S "failed"
1311
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001312run_test "Renegotiation: periodic, just below period" \
1313 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1314 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1315 0 \
1316 -C "client hello, adding renegotiation extension" \
1317 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1318 -S "found renegotiation extension" \
1319 -s "server hello, secure renegotiation extension" \
1320 -c "found renegotiation extension" \
1321 -S "record counter limit reached: renegotiate" \
1322 -C "=> renegotiate" \
1323 -S "=> renegotiate" \
1324 -S "write hello request" \
1325 -S "SSL - An unexpected message was received from our peer" \
1326 -S "failed"
1327
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001328# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001329run_test "Renegotiation: periodic, just above period" \
1330 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001331 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001332 0 \
1333 -c "client hello, adding renegotiation extension" \
1334 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1335 -s "found renegotiation extension" \
1336 -s "server hello, secure renegotiation extension" \
1337 -c "found renegotiation extension" \
1338 -s "record counter limit reached: renegotiate" \
1339 -c "=> renegotiate" \
1340 -s "=> renegotiate" \
1341 -s "write hello request" \
1342 -S "SSL - An unexpected message was received from our peer" \
1343 -S "failed"
1344
1345run_test "Renegotiation: periodic, two times period" \
1346 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001347 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001348 0 \
1349 -c "client hello, adding renegotiation extension" \
1350 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1351 -s "found renegotiation extension" \
1352 -s "server hello, secure renegotiation extension" \
1353 -c "found renegotiation extension" \
1354 -s "record counter limit reached: renegotiate" \
1355 -c "=> renegotiate" \
1356 -s "=> renegotiate" \
1357 -s "write hello request" \
1358 -S "SSL - An unexpected message was received from our peer" \
1359 -S "failed"
1360
1361run_test "Renegotiation: periodic, above period, disabled" \
1362 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1363 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1364 0 \
1365 -C "client hello, adding renegotiation extension" \
1366 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1367 -S "found renegotiation extension" \
1368 -s "server hello, secure renegotiation extension" \
1369 -c "found renegotiation extension" \
1370 -S "record counter limit reached: renegotiate" \
1371 -C "=> renegotiate" \
1372 -S "=> renegotiate" \
1373 -S "write hello request" \
1374 -S "SSL - An unexpected message was received from our peer" \
1375 -S "failed"
1376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001377run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001378 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1379 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001380 0 \
1381 -c "client hello, adding renegotiation extension" \
1382 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1383 -s "found renegotiation extension" \
1384 -s "server hello, secure renegotiation extension" \
1385 -c "found renegotiation extension" \
1386 -c "=> renegotiate" \
1387 -s "=> renegotiate" \
1388 -S "write hello request"
1389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001390run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001391 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1392 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001393 0 \
1394 -c "client hello, adding renegotiation extension" \
1395 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1396 -s "found renegotiation extension" \
1397 -s "server hello, secure renegotiation extension" \
1398 -c "found renegotiation extension" \
1399 -c "=> renegotiate" \
1400 -s "=> renegotiate" \
1401 -s "write hello request"
1402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001403run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001404 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001405 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001406 0 \
1407 -c "client hello, adding renegotiation extension" \
1408 -c "found renegotiation extension" \
1409 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001410 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001411 -C "error" \
1412 -c "HTTP/1.0 200 [Oo][Kk]"
1413
Paul Bakker539d9722015-02-08 16:18:35 +01001414requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001415run_test "Renegotiation: gnutls server strict, client-initiated" \
1416 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001417 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001418 0 \
1419 -c "client hello, adding renegotiation extension" \
1420 -c "found renegotiation extension" \
1421 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001422 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001423 -C "error" \
1424 -c "HTTP/1.0 200 [Oo][Kk]"
1425
Paul Bakker539d9722015-02-08 16:18:35 +01001426requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001427run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1428 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1429 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1430 1 \
1431 -c "client hello, adding renegotiation extension" \
1432 -C "found renegotiation extension" \
1433 -c "=> renegotiate" \
1434 -c "ssl_handshake() returned" \
1435 -c "error" \
1436 -C "HTTP/1.0 200 [Oo][Kk]"
1437
Paul Bakker539d9722015-02-08 16:18:35 +01001438requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001439run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1440 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1441 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1442 allow_legacy=0" \
1443 1 \
1444 -c "client hello, adding renegotiation extension" \
1445 -C "found renegotiation extension" \
1446 -c "=> renegotiate" \
1447 -c "ssl_handshake() returned" \
1448 -c "error" \
1449 -C "HTTP/1.0 200 [Oo][Kk]"
1450
Paul Bakker539d9722015-02-08 16:18:35 +01001451requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001452run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1453 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1454 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1455 allow_legacy=1" \
1456 0 \
1457 -c "client hello, adding renegotiation extension" \
1458 -C "found renegotiation extension" \
1459 -c "=> renegotiate" \
1460 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001461 -C "error" \
1462 -c "HTTP/1.0 200 [Oo][Kk]"
1463
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001464run_test "Renegotiation: DTLS, client-initiated" \
1465 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1466 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1467 0 \
1468 -c "client hello, adding renegotiation extension" \
1469 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1470 -s "found renegotiation extension" \
1471 -s "server hello, secure renegotiation extension" \
1472 -c "found renegotiation extension" \
1473 -c "=> renegotiate" \
1474 -s "=> renegotiate" \
1475 -S "write hello request"
1476
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001477run_test "Renegotiation: DTLS, server-initiated" \
1478 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001479 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1480 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001481 0 \
1482 -c "client hello, adding renegotiation extension" \
1483 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1484 -s "found renegotiation extension" \
1485 -s "server hello, secure renegotiation extension" \
1486 -c "found renegotiation extension" \
1487 -c "=> renegotiate" \
1488 -s "=> renegotiate" \
1489 -s "write hello request"
1490
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001491requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001492run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1493 "$G_SRV -u --mtu 4096" \
1494 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1495 0 \
1496 -c "client hello, adding renegotiation extension" \
1497 -c "found renegotiation extension" \
1498 -c "=> renegotiate" \
1499 -C "ssl_handshake returned" \
1500 -C "error" \
1501 -s "Extra-header:"
1502
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001503# Test for the "secure renegotation" extension only (no actual renegotiation)
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 strict, client default" \
1507 "$G_SRV --priority=NORMAL:%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 default" \
1516 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1517 "$P_CLI debug_level=3" \
1518 0 \
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 server unsafe, client break legacy" \
1525 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1526 "$P_CLI debug_level=3 allow_legacy=-1" \
1527 1 \
1528 -C "found renegotiation extension" \
1529 -c "error" \
1530 -C "HTTP/1.0 200 [Oo][Kk]"
1531
Paul Bakker539d9722015-02-08 16:18:35 +01001532requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001533run_test "Renego ext: gnutls client strict, server default" \
1534 "$P_SRV debug_level=3" \
1535 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1536 0 \
1537 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1538 -s "server hello, secure renegotiation extension"
1539
Paul Bakker539d9722015-02-08 16:18:35 +01001540requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001541run_test "Renego ext: gnutls client unsafe, server default" \
1542 "$P_SRV debug_level=3" \
1543 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1544 0 \
1545 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1546 -S "server hello, secure renegotiation extension"
1547
Paul Bakker539d9722015-02-08 16:18:35 +01001548requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001549run_test "Renego ext: gnutls client unsafe, server break legacy" \
1550 "$P_SRV debug_level=3 allow_legacy=-1" \
1551 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1552 1 \
1553 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1554 -S "server hello, secure renegotiation extension"
1555
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001556# Tests for auth_mode
1557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001558run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001559 "$P_SRV crt_file=data_files/server5-badsign.crt \
1560 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001561 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001562 1 \
1563 -c "x509_verify_cert() returned" \
1564 -c "! self-signed or not signed by a trusted CA" \
1565 -c "! ssl_handshake returned" \
1566 -c "X509 - Certificate verification failed"
1567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001568run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001569 "$P_SRV crt_file=data_files/server5-badsign.crt \
1570 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001571 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001572 0 \
1573 -c "x509_verify_cert() returned" \
1574 -c "! self-signed or not signed by a trusted CA" \
1575 -C "! ssl_handshake returned" \
1576 -C "X509 - Certificate verification failed"
1577
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001578run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001579 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001580 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001581 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001582 0 \
1583 -C "x509_verify_cert() returned" \
1584 -C "! self-signed or not signed by a trusted CA" \
1585 -C "! ssl_handshake returned" \
1586 -C "X509 - Certificate verification failed"
1587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001588run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001589 "$P_SRV debug_level=3 auth_mode=required" \
1590 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001591 key_file=data_files/server5.key" \
1592 1 \
1593 -S "skip write certificate request" \
1594 -C "skip parse certificate request" \
1595 -c "got a certificate request" \
1596 -C "skip write certificate" \
1597 -C "skip write certificate verify" \
1598 -S "skip parse certificate verify" \
1599 -s "x509_verify_cert() returned" \
1600 -S "! self-signed or not signed by a trusted CA" \
1601 -s "! ssl_handshake returned" \
1602 -c "! ssl_handshake returned" \
1603 -s "X509 - Certificate verification failed"
1604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001605run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001606 "$P_SRV debug_level=3 auth_mode=optional" \
1607 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001608 key_file=data_files/server5.key" \
1609 0 \
1610 -S "skip write certificate request" \
1611 -C "skip parse certificate request" \
1612 -c "got a certificate request" \
1613 -C "skip write certificate" \
1614 -C "skip write certificate verify" \
1615 -S "skip parse certificate verify" \
1616 -s "x509_verify_cert() returned" \
1617 -s "! self-signed or not signed by a trusted CA" \
1618 -S "! ssl_handshake returned" \
1619 -C "! ssl_handshake returned" \
1620 -S "X509 - Certificate verification failed"
1621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001622run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001623 "$P_SRV debug_level=3 auth_mode=none" \
1624 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001625 key_file=data_files/server5.key" \
1626 0 \
1627 -s "skip write certificate request" \
1628 -C "skip parse certificate request" \
1629 -c "got no certificate request" \
1630 -c "skip write certificate" \
1631 -c "skip write certificate verify" \
1632 -s "skip parse certificate verify" \
1633 -S "x509_verify_cert() returned" \
1634 -S "! self-signed or not signed by a trusted CA" \
1635 -S "! ssl_handshake returned" \
1636 -C "! ssl_handshake returned" \
1637 -S "X509 - Certificate verification failed"
1638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001639run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001640 "$P_SRV debug_level=3 auth_mode=optional" \
1641 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001642 0 \
1643 -S "skip write certificate request" \
1644 -C "skip parse certificate request" \
1645 -c "got a certificate request" \
1646 -C "skip write certificate$" \
1647 -C "got no certificate to send" \
1648 -S "SSLv3 client has no certificate" \
1649 -c "skip write certificate verify" \
1650 -s "skip parse certificate verify" \
1651 -s "! no client certificate sent" \
1652 -S "! ssl_handshake returned" \
1653 -C "! ssl_handshake returned" \
1654 -S "X509 - Certificate verification failed"
1655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001656run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001657 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001658 "$O_CLI" \
1659 0 \
1660 -S "skip write certificate request" \
1661 -s "skip parse certificate verify" \
1662 -s "! no client certificate sent" \
1663 -S "! ssl_handshake returned" \
1664 -S "X509 - Certificate verification failed"
1665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001666run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001667 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001668 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001669 0 \
1670 -C "skip parse certificate request" \
1671 -c "got a certificate request" \
1672 -C "skip write certificate$" \
1673 -c "skip write certificate verify" \
1674 -C "! ssl_handshake returned"
1675
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001676run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001677 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001678 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001679 0 \
1680 -S "skip write certificate request" \
1681 -C "skip parse certificate request" \
1682 -c "got a certificate request" \
1683 -C "skip write certificate$" \
1684 -c "skip write certificate verify" \
1685 -c "got no certificate to send" \
1686 -s "SSLv3 client has no certificate" \
1687 -s "skip parse certificate verify" \
1688 -s "! no client certificate sent" \
1689 -S "! ssl_handshake returned" \
1690 -C "! ssl_handshake returned" \
1691 -S "X509 - Certificate verification failed"
1692
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001693# Tests for certificate selection based on SHA verson
1694
1695run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1696 "$P_SRV crt_file=data_files/server5.crt \
1697 key_file=data_files/server5.key \
1698 crt_file2=data_files/server5-sha1.crt \
1699 key_file2=data_files/server5.key" \
1700 "$P_CLI force_version=tls1_2" \
1701 0 \
1702 -c "signed using.*ECDSA with SHA256" \
1703 -C "signed using.*ECDSA with SHA1"
1704
1705run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1706 "$P_SRV crt_file=data_files/server5.crt \
1707 key_file=data_files/server5.key \
1708 crt_file2=data_files/server5-sha1.crt \
1709 key_file2=data_files/server5.key" \
1710 "$P_CLI force_version=tls1_1" \
1711 0 \
1712 -C "signed using.*ECDSA with SHA256" \
1713 -c "signed using.*ECDSA with SHA1"
1714
1715run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1716 "$P_SRV crt_file=data_files/server5.crt \
1717 key_file=data_files/server5.key \
1718 crt_file2=data_files/server5-sha1.crt \
1719 key_file2=data_files/server5.key" \
1720 "$P_CLI force_version=tls1" \
1721 0 \
1722 -C "signed using.*ECDSA with SHA256" \
1723 -c "signed using.*ECDSA with SHA1"
1724
1725run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1726 "$P_SRV crt_file=data_files/server5.crt \
1727 key_file=data_files/server5.key \
1728 crt_file2=data_files/server6.crt \
1729 key_file2=data_files/server6.key" \
1730 "$P_CLI force_version=tls1_1" \
1731 0 \
1732 -c "serial number.*09" \
1733 -c "signed using.*ECDSA with SHA256" \
1734 -C "signed using.*ECDSA with SHA1"
1735
1736run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1737 "$P_SRV crt_file=data_files/server6.crt \
1738 key_file=data_files/server6.key \
1739 crt_file2=data_files/server5.crt \
1740 key_file2=data_files/server5.key" \
1741 "$P_CLI force_version=tls1_1" \
1742 0 \
1743 -c "serial number.*0A" \
1744 -c "signed using.*ECDSA with SHA256" \
1745 -C "signed using.*ECDSA with SHA1"
1746
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001747# tests for SNI
1748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001749run_test "SNI: no SNI callback" \
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é-Gonnard0eb6cab2014-07-23 20:17:47 +02001752 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001753 0 \
1754 -S "parse ServerName extension" \
1755 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1756 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1757
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001758run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001759 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001760 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001761 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001762 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001763 0 \
1764 -s "parse ServerName extension" \
1765 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1766 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1767
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001768run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001769 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001770 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001771 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 +02001772 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001773 0 \
1774 -s "parse ServerName extension" \
1775 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001776 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001777
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001778run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001779 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001780 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001781 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 +02001782 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001783 1 \
1784 -s "parse ServerName extension" \
1785 -s "ssl_sni_wrapper() returned" \
1786 -s "ssl_handshake returned" \
1787 -c "ssl_handshake returned" \
1788 -c "SSL - A fatal alert message was received from our peer"
1789
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001790# Tests for non-blocking I/O: exercise a variety of handshake flows
1791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001792run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001793 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1794 "$P_CLI nbio=2 tickets=0" \
1795 0 \
1796 -S "ssl_handshake returned" \
1797 -C "ssl_handshake returned" \
1798 -c "Read from server: .* bytes read"
1799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001800run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001801 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1802 "$P_CLI nbio=2 tickets=0" \
1803 0 \
1804 -S "ssl_handshake returned" \
1805 -C "ssl_handshake returned" \
1806 -c "Read from server: .* bytes read"
1807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001808run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001809 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1810 "$P_CLI nbio=2 tickets=1" \
1811 0 \
1812 -S "ssl_handshake returned" \
1813 -C "ssl_handshake returned" \
1814 -c "Read from server: .* bytes read"
1815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001816run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001817 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1818 "$P_CLI nbio=2 tickets=1" \
1819 0 \
1820 -S "ssl_handshake returned" \
1821 -C "ssl_handshake returned" \
1822 -c "Read from server: .* bytes read"
1823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001824run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001825 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1826 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1827 0 \
1828 -S "ssl_handshake returned" \
1829 -C "ssl_handshake returned" \
1830 -c "Read from server: .* bytes read"
1831
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001832run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001833 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1834 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1835 0 \
1836 -S "ssl_handshake returned" \
1837 -C "ssl_handshake returned" \
1838 -c "Read from server: .* bytes read"
1839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001840run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001841 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1842 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1843 0 \
1844 -S "ssl_handshake returned" \
1845 -C "ssl_handshake returned" \
1846 -c "Read from server: .* bytes read"
1847
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001848# Tests for version negotiation
1849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001850run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001851 "$P_SRV" \
1852 "$P_CLI" \
1853 0 \
1854 -S "ssl_handshake returned" \
1855 -C "ssl_handshake returned" \
1856 -s "Protocol is TLSv1.2" \
1857 -c "Protocol is TLSv1.2"
1858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001859run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001860 "$P_SRV" \
1861 "$P_CLI max_version=tls1_1" \
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: 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" \
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+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001878 "$P_SRV max_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 max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001887 "$P_SRV min_version=tls1_1" \
1888 "$P_CLI max_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.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001896 "$P_SRV max_version=tls1_1" \
1897 "$P_CLI min_version=tls1_1" \
1898 0 \
1899 -S "ssl_handshake returned" \
1900 -C "ssl_handshake returned" \
1901 -s "Protocol is TLSv1.1" \
1902 -c "Protocol is TLSv1.1"
1903
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001904run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001905 "$P_SRV max_version=tls1_1" \
1906 "$P_CLI min_version=tls1_2" \
1907 1 \
1908 -s "ssl_handshake returned" \
1909 -c "ssl_handshake returned" \
1910 -c "SSL - Handshake protocol not within min/max boundaries"
1911
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001912run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001913 "$P_SRV min_version=tls1_2" \
1914 "$P_CLI max_version=tls1_1" \
1915 1 \
1916 -s "ssl_handshake returned" \
1917 -c "ssl_handshake returned" \
1918 -s "SSL - Handshake protocol not within min/max boundaries"
1919
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001920# Tests for ALPN extension
1921
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001922run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001923 "$P_SRV debug_level=3" \
1924 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001925 0 \
1926 -C "client hello, adding alpn extension" \
1927 -S "found alpn extension" \
1928 -C "got an alert message, type: \\[2:120]" \
1929 -S "server hello, adding alpn extension" \
1930 -C "found alpn extension " \
1931 -C "Application Layer Protocol is" \
1932 -S "Application Layer Protocol is"
1933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001934run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001935 "$P_SRV debug_level=3" \
1936 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001937 0 \
1938 -c "client hello, adding alpn extension" \
1939 -s "found alpn extension" \
1940 -C "got an alert message, type: \\[2:120]" \
1941 -S "server hello, adding alpn extension" \
1942 -C "found alpn extension " \
1943 -c "Application Layer Protocol is (none)" \
1944 -S "Application Layer Protocol is"
1945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001946run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001947 "$P_SRV debug_level=3 alpn=abc,1234" \
1948 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001949 0 \
1950 -C "client hello, adding alpn extension" \
1951 -S "found alpn extension" \
1952 -C "got an alert message, type: \\[2:120]" \
1953 -S "server hello, adding alpn extension" \
1954 -C "found alpn extension " \
1955 -C "Application Layer Protocol is" \
1956 -s "Application Layer Protocol is (none)"
1957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001958run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001959 "$P_SRV debug_level=3 alpn=abc,1234" \
1960 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001961 0 \
1962 -c "client hello, adding alpn extension" \
1963 -s "found alpn extension" \
1964 -C "got an alert message, type: \\[2:120]" \
1965 -s "server hello, adding alpn extension" \
1966 -c "found alpn extension" \
1967 -c "Application Layer Protocol is abc" \
1968 -s "Application Layer Protocol is abc"
1969
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001970run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001971 "$P_SRV debug_level=3 alpn=abc,1234" \
1972 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001973 0 \
1974 -c "client hello, adding alpn extension" \
1975 -s "found alpn extension" \
1976 -C "got an alert message, type: \\[2:120]" \
1977 -s "server hello, adding alpn extension" \
1978 -c "found alpn extension" \
1979 -c "Application Layer Protocol is abc" \
1980 -s "Application Layer Protocol is abc"
1981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001982run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001983 "$P_SRV debug_level=3 alpn=abc,1234" \
1984 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001985 0 \
1986 -c "client hello, adding alpn extension" \
1987 -s "found alpn extension" \
1988 -C "got an alert message, type: \\[2:120]" \
1989 -s "server hello, adding alpn extension" \
1990 -c "found alpn extension" \
1991 -c "Application Layer Protocol is 1234" \
1992 -s "Application Layer Protocol is 1234"
1993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001994run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001995 "$P_SRV debug_level=3 alpn=abc,123" \
1996 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001997 1 \
1998 -c "client hello, adding alpn extension" \
1999 -s "found alpn extension" \
2000 -c "got an alert message, type: \\[2:120]" \
2001 -S "server hello, adding alpn extension" \
2002 -C "found alpn extension" \
2003 -C "Application Layer Protocol is 1234" \
2004 -S "Application Layer Protocol is 1234"
2005
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002006
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002007# Tests for keyUsage in leaf certificates, part 1:
2008# server-side certificate/suite selection
2009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002010run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002011 "$P_SRV key_file=data_files/server2.key \
2012 crt_file=data_files/server2.ku-ds.crt" \
2013 "$P_CLI" \
2014 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002015 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002016
2017
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002018run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002019 "$P_SRV key_file=data_files/server2.key \
2020 crt_file=data_files/server2.ku-ke.crt" \
2021 "$P_CLI" \
2022 0 \
2023 -c "Ciphersuite is TLS-RSA-WITH-"
2024
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002025run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002026 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002027 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002028 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002029 1 \
2030 -C "Ciphersuite is "
2031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002032run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002033 "$P_SRV key_file=data_files/server5.key \
2034 crt_file=data_files/server5.ku-ds.crt" \
2035 "$P_CLI" \
2036 0 \
2037 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2038
2039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002040run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002041 "$P_SRV key_file=data_files/server5.key \
2042 crt_file=data_files/server5.ku-ka.crt" \
2043 "$P_CLI" \
2044 0 \
2045 -c "Ciphersuite is TLS-ECDH-"
2046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002047run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002048 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002049 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002050 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002051 1 \
2052 -C "Ciphersuite is "
2053
2054# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002055# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002057run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002058 "$O_SRV -key data_files/server2.key \
2059 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002060 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002061 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2062 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002063 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002064 -C "Processing of the Certificate handshake message failed" \
2065 -c "Ciphersuite is TLS-"
2066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002067run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002068 "$O_SRV -key data_files/server2.key \
2069 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002070 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002071 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2072 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002073 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002074 -C "Processing of the Certificate handshake message failed" \
2075 -c "Ciphersuite is TLS-"
2076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002077run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002078 "$O_SRV -key data_files/server2.key \
2079 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002080 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002081 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2082 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002083 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002084 -C "Processing of the Certificate handshake message failed" \
2085 -c "Ciphersuite is TLS-"
2086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002087run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002088 "$O_SRV -key data_files/server2.key \
2089 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002090 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002091 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2092 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002093 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002094 -c "Processing of the Certificate handshake message failed" \
2095 -C "Ciphersuite is TLS-"
2096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002097run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002098 "$O_SRV -key data_files/server2.key \
2099 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002100 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002101 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2102 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002103 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002104 -C "Processing of the Certificate handshake message failed" \
2105 -c "Ciphersuite is TLS-"
2106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002107run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002108 "$O_SRV -key data_files/server2.key \
2109 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002110 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002111 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2112 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002113 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002114 -c "Processing of the Certificate handshake message failed" \
2115 -C "Ciphersuite is TLS-"
2116
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002117# Tests for keyUsage in leaf certificates, part 3:
2118# server-side checking of client cert
2119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002120run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002121 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002122 "$O_CLI -key data_files/server2.key \
2123 -cert data_files/server2.ku-ds.crt" \
2124 0 \
2125 -S "bad certificate (usage extensions)" \
2126 -S "Processing of the Certificate handshake message failed"
2127
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002128run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002129 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002130 "$O_CLI -key data_files/server2.key \
2131 -cert data_files/server2.ku-ke.crt" \
2132 0 \
2133 -s "bad certificate (usage extensions)" \
2134 -S "Processing of the Certificate handshake message failed"
2135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002136run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002137 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002138 "$O_CLI -key data_files/server2.key \
2139 -cert data_files/server2.ku-ke.crt" \
2140 1 \
2141 -s "bad certificate (usage extensions)" \
2142 -s "Processing of the Certificate handshake message failed"
2143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002144run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002145 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002146 "$O_CLI -key data_files/server5.key \
2147 -cert data_files/server5.ku-ds.crt" \
2148 0 \
2149 -S "bad certificate (usage extensions)" \
2150 -S "Processing of the Certificate handshake message failed"
2151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002152run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002153 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002154 "$O_CLI -key data_files/server5.key \
2155 -cert data_files/server5.ku-ka.crt" \
2156 0 \
2157 -s "bad certificate (usage extensions)" \
2158 -S "Processing of the Certificate handshake message failed"
2159
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002160# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2161
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002162run_test "extKeyUsage srv: serverAuth -> 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: serverAuth,clientAuth -> 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-srv.crt" \
2171 "$P_CLI" \
2172 0
2173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002174run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002175 "$P_SRV key_file=data_files/server5.key \
2176 crt_file=data_files/server5.eku-cs_any.crt" \
2177 "$P_CLI" \
2178 0
2179
2180# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002181run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002182 "$P_SRV psk=abc123 key_file=data_files/server5.key \
2183 crt_file=data_files/server5.eku-cli.crt" \
2184 "$P_CLI psk=badbad" \
2185 1
2186
2187# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002189run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002190 "$O_SRV -key data_files/server5.key \
2191 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002192 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002193 0 \
2194 -C "bad certificate (usage extensions)" \
2195 -C "Processing of the Certificate handshake message failed" \
2196 -c "Ciphersuite is TLS-"
2197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002198run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002199 "$O_SRV -key data_files/server5.key \
2200 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002201 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002202 0 \
2203 -C "bad certificate (usage extensions)" \
2204 -C "Processing of the Certificate handshake message failed" \
2205 -c "Ciphersuite is TLS-"
2206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002207run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002208 "$O_SRV -key data_files/server5.key \
2209 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002210 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002211 0 \
2212 -C "bad certificate (usage extensions)" \
2213 -C "Processing of the Certificate handshake message failed" \
2214 -c "Ciphersuite is TLS-"
2215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002216run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002217 "$O_SRV -key data_files/server5.key \
2218 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002219 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002220 1 \
2221 -c "bad certificate (usage extensions)" \
2222 -c "Processing of the Certificate handshake message failed" \
2223 -C "Ciphersuite is TLS-"
2224
2225# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002227run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002228 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002229 "$O_CLI -key data_files/server5.key \
2230 -cert data_files/server5.eku-cli.crt" \
2231 0 \
2232 -S "bad certificate (usage extensions)" \
2233 -S "Processing of the Certificate handshake message failed"
2234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002235run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002236 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002237 "$O_CLI -key data_files/server5.key \
2238 -cert data_files/server5.eku-srv_cli.crt" \
2239 0 \
2240 -S "bad certificate (usage extensions)" \
2241 -S "Processing of the Certificate handshake message failed"
2242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002243run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002244 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002245 "$O_CLI -key data_files/server5.key \
2246 -cert data_files/server5.eku-cs_any.crt" \
2247 0 \
2248 -S "bad certificate (usage extensions)" \
2249 -S "Processing of the Certificate handshake message failed"
2250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002251run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002252 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002253 "$O_CLI -key data_files/server5.key \
2254 -cert data_files/server5.eku-cs.crt" \
2255 0 \
2256 -s "bad certificate (usage extensions)" \
2257 -S "Processing of the Certificate handshake message failed"
2258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002259run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002260 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002261 "$O_CLI -key data_files/server5.key \
2262 -cert data_files/server5.eku-cs.crt" \
2263 1 \
2264 -s "bad certificate (usage extensions)" \
2265 -s "Processing of the Certificate handshake message failed"
2266
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002267# Tests for DHM parameters loading
2268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002269run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002270 "$P_SRV" \
2271 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2272 debug_level=3" \
2273 0 \
2274 -c "value of 'DHM: P ' (2048 bits)" \
2275 -c "value of 'DHM: G ' (2048 bits)"
2276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002277run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002278 "$P_SRV dhm_file=data_files/dhparams.pem" \
2279 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2280 debug_level=3" \
2281 0 \
2282 -c "value of 'DHM: P ' (1024 bits)" \
2283 -c "value of 'DHM: G ' (2 bits)"
2284
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002285# Tests for PSK callback
2286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002287run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002288 "$P_SRV psk=abc123 psk_identity=foo" \
2289 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2290 psk_identity=foo psk=abc123" \
2291 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002292 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002293 -S "SSL - Unknown identity received" \
2294 -S "SSL - Verification of the message MAC failed"
2295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002296run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002297 "$P_SRV" \
2298 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2299 psk_identity=foo psk=abc123" \
2300 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002301 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002302 -S "SSL - Unknown identity received" \
2303 -S "SSL - Verification of the message MAC failed"
2304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002305run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002306 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2307 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2308 psk_identity=foo psk=abc123" \
2309 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002310 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002311 -s "SSL - Unknown identity received" \
2312 -S "SSL - Verification of the message MAC failed"
2313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002314run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002315 "$P_SRV psk_list=abc,dead,def,beef" \
2316 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2317 psk_identity=abc psk=dead" \
2318 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002319 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002320 -S "SSL - Unknown identity received" \
2321 -S "SSL - Verification of the message MAC failed"
2322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002323run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002324 "$P_SRV psk_list=abc,dead,def,beef" \
2325 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2326 psk_identity=def psk=beef" \
2327 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002328 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002329 -S "SSL - Unknown identity received" \
2330 -S "SSL - Verification of the message MAC failed"
2331
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002332run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002333 "$P_SRV psk_list=abc,dead,def,beef" \
2334 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2335 psk_identity=ghi psk=beef" \
2336 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002337 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002338 -s "SSL - Unknown identity received" \
2339 -S "SSL - Verification of the message MAC failed"
2340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002341run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002342 "$P_SRV psk_list=abc,dead,def,beef" \
2343 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2344 psk_identity=abc psk=beef" \
2345 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002346 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002347 -S "SSL - Unknown identity received" \
2348 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002349
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002350# Tests for ciphersuites per version
2351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002352run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002353 "$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 +02002354 "$P_CLI force_version=ssl3" \
2355 0 \
2356 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2357
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002358run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002359 "$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 +01002360 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002361 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002362 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002364run_test "Per-version suites: TLS 1.1" \
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_1" \
2367 0 \
2368 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002370run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002371 "$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 +02002372 "$P_CLI force_version=tls1_2" \
2373 0 \
2374 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2375
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002376# Tests for ssl_get_bytes_avail()
2377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002378run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002379 "$P_SRV" \
2380 "$P_CLI request_size=100" \
2381 0 \
2382 -s "Read from client: 100 bytes read$"
2383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002384run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002385 "$P_SRV" \
2386 "$P_CLI request_size=500" \
2387 0 \
2388 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002389
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002390# Tests for small packets
2391
2392run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002393 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002394 "$P_CLI request_size=1 force_version=ssl3 \
2395 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2396 0 \
2397 -s "Read from client: 1 bytes read"
2398
2399run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002400 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002401 "$P_CLI request_size=1 force_version=ssl3 \
2402 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2403 0 \
2404 -s "Read from client: 1 bytes read"
2405
2406run_test "Small packet TLS 1.0 BlockCipher" \
2407 "$P_SRV" \
2408 "$P_CLI request_size=1 force_version=tls1 \
2409 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2410 0 \
2411 -s "Read from client: 1 bytes read"
2412
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002413run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2414 "$P_SRV" \
2415 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2416 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2417 0 \
2418 -s "Read from client: 1 bytes read"
2419
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002420run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2421 "$P_SRV" \
2422 "$P_CLI request_size=1 force_version=tls1 \
2423 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2424 trunc_hmac=1" \
2425 0 \
2426 -s "Read from client: 1 bytes read"
2427
2428run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002429 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002430 "$P_CLI request_size=1 force_version=tls1 \
2431 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2432 trunc_hmac=1" \
2433 0 \
2434 -s "Read from client: 1 bytes read"
2435
2436run_test "Small packet TLS 1.1 BlockCipher" \
2437 "$P_SRV" \
2438 "$P_CLI request_size=1 force_version=tls1_1 \
2439 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2440 0 \
2441 -s "Read from client: 1 bytes read"
2442
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002443run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2444 "$P_SRV" \
2445 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2446 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2447 0 \
2448 -s "Read from client: 1 bytes read"
2449
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002450run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002451 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002452 "$P_CLI request_size=1 force_version=tls1_1 \
2453 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2454 0 \
2455 -s "Read from client: 1 bytes read"
2456
2457run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2458 "$P_SRV" \
2459 "$P_CLI request_size=1 force_version=tls1_1 \
2460 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2461 trunc_hmac=1" \
2462 0 \
2463 -s "Read from client: 1 bytes read"
2464
2465run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002466 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002467 "$P_CLI request_size=1 force_version=tls1_1 \
2468 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2469 trunc_hmac=1" \
2470 0 \
2471 -s "Read from client: 1 bytes read"
2472
2473run_test "Small packet TLS 1.2 BlockCipher" \
2474 "$P_SRV" \
2475 "$P_CLI request_size=1 force_version=tls1_2 \
2476 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2477 0 \
2478 -s "Read from client: 1 bytes read"
2479
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002480run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2481 "$P_SRV" \
2482 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2483 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2484 0 \
2485 -s "Read from client: 1 bytes read"
2486
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002487run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2488 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002489 "$P_CLI request_size=1 force_version=tls1_2 \
2490 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002491 0 \
2492 -s "Read from client: 1 bytes read"
2493
2494run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2495 "$P_SRV" \
2496 "$P_CLI request_size=1 force_version=tls1_2 \
2497 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2498 trunc_hmac=1" \
2499 0 \
2500 -s "Read from client: 1 bytes read"
2501
2502run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002503 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002504 "$P_CLI request_size=1 force_version=tls1_2 \
2505 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2506 0 \
2507 -s "Read from client: 1 bytes read"
2508
2509run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002510 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002511 "$P_CLI request_size=1 force_version=tls1_2 \
2512 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2513 trunc_hmac=1" \
2514 0 \
2515 -s "Read from client: 1 bytes read"
2516
2517run_test "Small packet TLS 1.2 AEAD" \
2518 "$P_SRV" \
2519 "$P_CLI request_size=1 force_version=tls1_2 \
2520 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2521 0 \
2522 -s "Read from client: 1 bytes read"
2523
2524run_test "Small packet TLS 1.2 AEAD shorter tag" \
2525 "$P_SRV" \
2526 "$P_CLI request_size=1 force_version=tls1_2 \
2527 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2528 0 \
2529 -s "Read from client: 1 bytes read"
2530
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002531# Test for large packets
2532
2533run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002534 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002535 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002536 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2537 0 \
2538 -s "Read from client: 16384 bytes read"
2539
2540run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002541 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002542 "$P_CLI request_size=16384 force_version=ssl3 \
2543 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2544 0 \
2545 -s "Read from client: 16384 bytes read"
2546
2547run_test "Large packet TLS 1.0 BlockCipher" \
2548 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002549 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002550 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2551 0 \
2552 -s "Read from client: 16384 bytes read"
2553
2554run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2555 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002556 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002557 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2558 trunc_hmac=1" \
2559 0 \
2560 -s "Read from client: 16384 bytes read"
2561
2562run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002563 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002564 "$P_CLI request_size=16384 force_version=tls1 \
2565 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2566 trunc_hmac=1" \
2567 0 \
2568 -s "Read from client: 16384 bytes read"
2569
2570run_test "Large packet TLS 1.1 BlockCipher" \
2571 "$P_SRV" \
2572 "$P_CLI request_size=16384 force_version=tls1_1 \
2573 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2574 0 \
2575 -s "Read from client: 16384 bytes read"
2576
2577run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002578 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002579 "$P_CLI request_size=16384 force_version=tls1_1 \
2580 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2581 0 \
2582 -s "Read from client: 16384 bytes read"
2583
2584run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2585 "$P_SRV" \
2586 "$P_CLI request_size=16384 force_version=tls1_1 \
2587 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2588 trunc_hmac=1" \
2589 0 \
2590 -s "Read from client: 16384 bytes read"
2591
2592run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002593 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002594 "$P_CLI request_size=16384 force_version=tls1_1 \
2595 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2596 trunc_hmac=1" \
2597 0 \
2598 -s "Read from client: 16384 bytes read"
2599
2600run_test "Large packet TLS 1.2 BlockCipher" \
2601 "$P_SRV" \
2602 "$P_CLI request_size=16384 force_version=tls1_2 \
2603 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2604 0 \
2605 -s "Read from client: 16384 bytes read"
2606
2607run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2608 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002609 "$P_CLI request_size=16384 force_version=tls1_2 \
2610 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002611 0 \
2612 -s "Read from client: 16384 bytes read"
2613
2614run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2615 "$P_SRV" \
2616 "$P_CLI request_size=16384 force_version=tls1_2 \
2617 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2618 trunc_hmac=1" \
2619 0 \
2620 -s "Read from client: 16384 bytes read"
2621
2622run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002623 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002624 "$P_CLI request_size=16384 force_version=tls1_2 \
2625 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2626 0 \
2627 -s "Read from client: 16384 bytes read"
2628
2629run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002630 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002631 "$P_CLI request_size=16384 force_version=tls1_2 \
2632 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2633 trunc_hmac=1" \
2634 0 \
2635 -s "Read from client: 16384 bytes read"
2636
2637run_test "Large packet TLS 1.2 AEAD" \
2638 "$P_SRV" \
2639 "$P_CLI request_size=16384 force_version=tls1_2 \
2640 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2641 0 \
2642 -s "Read from client: 16384 bytes read"
2643
2644run_test "Large packet TLS 1.2 AEAD shorter tag" \
2645 "$P_SRV" \
2646 "$P_CLI request_size=16384 force_version=tls1_2 \
2647 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2648 0 \
2649 -s "Read from client: 16384 bytes read"
2650
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002651# Tests for DTLS HelloVerifyRequest
2652
2653run_test "DTLS cookie: enabled" \
2654 "$P_SRV dtls=1 debug_level=2" \
2655 "$P_CLI dtls=1 debug_level=2" \
2656 0 \
2657 -s "cookie verification failed" \
2658 -s "cookie verification passed" \
2659 -S "cookie verification skipped" \
2660 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002661 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002662 -S "SSL - The requested feature is not available"
2663
2664run_test "DTLS cookie: disabled" \
2665 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2666 "$P_CLI dtls=1 debug_level=2" \
2667 0 \
2668 -S "cookie verification failed" \
2669 -S "cookie verification passed" \
2670 -s "cookie verification skipped" \
2671 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002672 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002673 -S "SSL - The requested feature is not available"
2674
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002675run_test "DTLS cookie: default (failing)" \
2676 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2677 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2678 1 \
2679 -s "cookie verification failed" \
2680 -S "cookie verification passed" \
2681 -S "cookie verification skipped" \
2682 -C "received hello verify request" \
2683 -S "hello verification requested" \
2684 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002685
2686requires_ipv6
2687run_test "DTLS cookie: enabled, IPv6" \
2688 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2689 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2690 0 \
2691 -s "cookie verification failed" \
2692 -s "cookie verification passed" \
2693 -S "cookie verification skipped" \
2694 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002695 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002696 -S "SSL - The requested feature is not available"
2697
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002698run_test "DTLS cookie: enabled, nbio" \
2699 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2700 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2701 0 \
2702 -s "cookie verification failed" \
2703 -s "cookie verification passed" \
2704 -S "cookie verification skipped" \
2705 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002706 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002707 -S "SSL - The requested feature is not available"
2708
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002709# Tests for various cases of client authentication with DTLS
2710# (focused on handshake flows and message parsing)
2711
2712run_test "DTLS client auth: required" \
2713 "$P_SRV dtls=1 auth_mode=required" \
2714 "$P_CLI dtls=1" \
2715 0 \
2716 -s "Verifying peer X.509 certificate... ok"
2717
2718run_test "DTLS client auth: optional, client has no cert" \
2719 "$P_SRV dtls=1 auth_mode=optional" \
2720 "$P_CLI dtls=1 crt_file=none key_file=none" \
2721 0 \
2722 -s "! no client certificate sent"
2723
2724run_test "DTLS client auth: optional, client has no cert" \
2725 "$P_SRV dtls=1 auth_mode=none" \
2726 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2727 0 \
2728 -c "skip write certificate$" \
2729 -s "! no client certificate sent"
2730
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002731# Tests for receiving fragmented handshake messages with DTLS
2732
2733requires_gnutls
2734run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2735 "$G_SRV -u --mtu 2048 -a" \
2736 "$P_CLI dtls=1 debug_level=2" \
2737 0 \
2738 -C "found fragmented DTLS handshake message" \
2739 -C "error"
2740
2741requires_gnutls
2742run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2743 "$G_SRV -u --mtu 512" \
2744 "$P_CLI dtls=1 debug_level=2" \
2745 0 \
2746 -c "found fragmented DTLS handshake message" \
2747 -C "error"
2748
2749requires_gnutls
2750run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2751 "$G_SRV -u --mtu 128" \
2752 "$P_CLI dtls=1 debug_level=2" \
2753 0 \
2754 -c "found fragmented DTLS handshake message" \
2755 -C "error"
2756
2757requires_gnutls
2758run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2759 "$G_SRV -u --mtu 128" \
2760 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2761 0 \
2762 -c "found fragmented DTLS handshake message" \
2763 -C "error"
2764
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002765requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002766run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2767 "$G_SRV -u --mtu 256" \
2768 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2769 0 \
2770 -c "found fragmented DTLS handshake message" \
2771 -c "client hello, adding renegotiation extension" \
2772 -c "found renegotiation extension" \
2773 -c "=> renegotiate" \
2774 -C "ssl_handshake returned" \
2775 -C "error" \
2776 -s "Extra-header:"
2777
2778requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002779run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2780 "$G_SRV -u --mtu 256" \
2781 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2782 0 \
2783 -c "found fragmented DTLS handshake message" \
2784 -c "client hello, adding renegotiation extension" \
2785 -c "found renegotiation extension" \
2786 -c "=> renegotiate" \
2787 -C "ssl_handshake returned" \
2788 -C "error" \
2789 -s "Extra-header:"
2790
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002791run_test "DTLS reassembly: no fragmentation (openssl server)" \
2792 "$O_SRV -dtls1 -mtu 2048" \
2793 "$P_CLI dtls=1 debug_level=2" \
2794 0 \
2795 -C "found fragmented DTLS handshake message" \
2796 -C "error"
2797
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002798run_test "DTLS reassembly: some fragmentation (openssl server)" \
2799 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002800 "$P_CLI dtls=1 debug_level=2" \
2801 0 \
2802 -c "found fragmented DTLS handshake message" \
2803 -C "error"
2804
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002805run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002806 "$O_SRV -dtls1 -mtu 256" \
2807 "$P_CLI dtls=1 debug_level=2" \
2808 0 \
2809 -c "found fragmented DTLS handshake message" \
2810 -C "error"
2811
2812run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2813 "$O_SRV -dtls1 -mtu 256" \
2814 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2815 0 \
2816 -c "found fragmented DTLS handshake message" \
2817 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002818
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002819# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002820
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002821not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002822run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002823 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002824 "$P_SRV dtls=1 debug_level=2" \
2825 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002826 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002827 -C "replayed record" \
2828 -S "replayed record" \
2829 -C "record from another epoch" \
2830 -S "record from another epoch" \
2831 -C "discarding invalid record" \
2832 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002833 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002834 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002835 -c "HTTP/1.0 200 OK"
2836
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002837not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002838run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002839 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002840 "$P_SRV dtls=1 debug_level=2" \
2841 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002842 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002843 -c "replayed record" \
2844 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002845 -c "discarding invalid record" \
2846 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002847 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002848 -s "Extra-header:" \
2849 -c "HTTP/1.0 200 OK"
2850
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002851run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2852 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002853 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2854 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002855 0 \
2856 -c "replayed record" \
2857 -S "replayed record" \
2858 -c "discarding invalid record" \
2859 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002860 -c "resend" \
2861 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002862 -s "Extra-header:" \
2863 -c "HTTP/1.0 200 OK"
2864
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002865run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002866 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002867 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002868 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002869 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002870 -c "discarding invalid record (mac)" \
2871 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002872 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002873 -c "HTTP/1.0 200 OK" \
2874 -S "too many records with bad MAC" \
2875 -S "Verification of the message MAC failed"
2876
2877run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
2878 -p "$P_PXY bad_ad=1" \
2879 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
2880 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2881 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002882 -C "discarding invalid record (mac)" \
2883 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002884 -S "Extra-header:" \
2885 -C "HTTP/1.0 200 OK" \
2886 -s "too many records with bad MAC" \
2887 -s "Verification of the message MAC failed"
2888
2889run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
2890 -p "$P_PXY bad_ad=1" \
2891 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
2892 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2893 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002894 -c "discarding invalid record (mac)" \
2895 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002896 -s "Extra-header:" \
2897 -c "HTTP/1.0 200 OK" \
2898 -S "too many records with bad MAC" \
2899 -S "Verification of the message MAC failed"
2900
2901run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
2902 -p "$P_PXY bad_ad=1" \
2903 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
2904 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
2905 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002906 -c "discarding invalid record (mac)" \
2907 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002908 -s "Extra-header:" \
2909 -c "HTTP/1.0 200 OK" \
2910 -s "too many records with bad MAC" \
2911 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002912
2913run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002914 -p "$P_PXY delay_ccs=1" \
2915 "$P_SRV dtls=1 debug_level=1" \
2916 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002917 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002918 -c "record from another epoch" \
2919 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002920 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002921 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002922 -s "Extra-header:" \
2923 -c "HTTP/1.0 200 OK"
2924
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002925# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002926
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002927needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002928run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002929 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002930 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2931 psk=abc123" \
2932 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002933 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2934 0 \
2935 -s "Extra-header:" \
2936 -c "HTTP/1.0 200 OK"
2937
2938needs_more_time 2
2939run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
2940 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002941 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2942 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002943 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2944 0 \
2945 -s "Extra-header:" \
2946 -c "HTTP/1.0 200 OK"
2947
2948needs_more_time 2
2949run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
2950 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002951 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2952 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002953 0 \
2954 -s "Extra-header:" \
2955 -c "HTTP/1.0 200 OK"
2956
2957needs_more_time 2
2958run_test "DTLS proxy: 3d, FS, client auth" \
2959 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002960 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
2961 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002962 0 \
2963 -s "Extra-header:" \
2964 -c "HTTP/1.0 200 OK"
2965
2966needs_more_time 2
2967run_test "DTLS proxy: 3d, FS, ticket" \
2968 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002969 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
2970 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002971 0 \
2972 -s "Extra-header:" \
2973 -c "HTTP/1.0 200 OK"
2974
2975needs_more_time 2
2976run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
2977 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002978 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
2979 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002980 0 \
2981 -s "Extra-header:" \
2982 -c "HTTP/1.0 200 OK"
2983
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002984needs_more_time 2
2985run_test "DTLS proxy: 3d, max handshake, nbio" \
2986 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002987 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
2988 auth_mode=required" \
2989 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002990 0 \
2991 -s "Extra-header:" \
2992 -c "HTTP/1.0 200 OK"
2993
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002994needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02002995run_test "DTLS proxy: 3d, min handshake, resumption" \
2996 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2997 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2998 psk=abc123 debug_level=3" \
2999 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3000 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3001 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3002 0 \
3003 -s "a session has been resumed" \
3004 -c "a session has been resumed" \
3005 -s "Extra-header:" \
3006 -c "HTTP/1.0 200 OK"
3007
3008needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003009run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3010 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3011 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3012 psk=abc123 debug_level=3 nbio=2" \
3013 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3014 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3015 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3016 0 \
3017 -s "a session has been resumed" \
3018 -c "a session has been resumed" \
3019 -s "Extra-header:" \
3020 -c "HTTP/1.0 200 OK"
3021
3022needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003023run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003024 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003025 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3026 psk=abc123 renegotiation=1 debug_level=2" \
3027 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3028 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003029 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3030 0 \
3031 -c "=> renegotiate" \
3032 -s "=> renegotiate" \
3033 -s "Extra-header:" \
3034 -c "HTTP/1.0 200 OK"
3035
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003036needs_more_time 4
3037run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3038 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003039 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3040 psk=abc123 renegotiation=1 debug_level=2" \
3041 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3042 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003043 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3044 0 \
3045 -c "=> renegotiate" \
3046 -s "=> renegotiate" \
3047 -s "Extra-header:" \
3048 -c "HTTP/1.0 200 OK"
3049
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003050needs_more_time 4
3051run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003052 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003053 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003054 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003055 debug_level=2" \
3056 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003057 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003058 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3059 0 \
3060 -c "=> renegotiate" \
3061 -s "=> renegotiate" \
3062 -s "Extra-header:" \
3063 -c "HTTP/1.0 200 OK"
3064
3065needs_more_time 4
3066run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003067 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003068 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003069 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003070 debug_level=2 nbio=2" \
3071 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003072 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003073 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3074 0 \
3075 -c "=> renegotiate" \
3076 -s "=> renegotiate" \
3077 -s "Extra-header:" \
3078 -c "HTTP/1.0 200 OK"
3079
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003080needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003081run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003082 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3083 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003084 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003085 0 \
3086 -s "Extra-header:" \
3087 -c "HTTP/1.0 200 OK"
3088
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003089needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003090run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3091 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3092 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003093 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003094 0 \
3095 -s "Extra-header:" \
3096 -c "HTTP/1.0 200 OK"
3097
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003098needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003099run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3100 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3101 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003102 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003103 0 \
3104 -s "Extra-header:" \
3105 -c "HTTP/1.0 200 OK"
3106
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003107requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003108needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003109run_test "DTLS proxy: 3d, gnutls server" \
3110 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3111 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003112 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003113 0 \
3114 -s "Extra-header:" \
3115 -c "Extra-header:"
3116
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003117requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003118needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003119run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3120 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3121 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003122 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003123 0 \
3124 -s "Extra-header:" \
3125 -c "Extra-header:"
3126
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003127requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003128needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003129run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3130 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3131 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003132 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003133 0 \
3134 -s "Extra-header:" \
3135 -c "Extra-header:"
3136
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003137# Final report
3138
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003139echo "------------------------------------------------------------------------"
3140
3141if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003142 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003143else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003144 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003145fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003146PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003147echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003148
3149exit $FAILS