blob: 6b0df56531f891360f0e42cb559abed533c772f7 [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"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200520O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200521O_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é-Gonnard2cf5a7c2015-04-08 12:49:31 +0200589requires_config_enabled MBEDTLS_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" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200595 -S "mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100596
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é-Gonnard2cf5a7c2015-04-08 12:49:31 +0200599requires_config_enabled MBEDTLS_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" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200605 -S "mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100606
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 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100629 -s "dumping 'computed mac' (20 bytes)" \
630 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100631
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é-Gonnard6df31962015-05-04 10:55:47 +02001047run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001048 "$P_SRV debug_level=3 tickets=0" \
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é-Gonnardfa44f202015-03-27 17:52:25 +01001167 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001168 "$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é-Gonnardfa44f202015-03-27 17:52:25 +01001180 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001181 "$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é-Gonnardfa44f202015-03-27 17:52:25 +01001193 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001194 "$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é-Gonnardfa44f202015-03-27 17:52:25 +01001206 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001207 "$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é-Gonnardfa44f202015-03-27 17:52:25 +01001219 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001220 "$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é-Gonnardfa44f202015-03-27 17:52:25 +01001234 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001235 "$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é-Gonnardfa44f202015-03-27 17:52:25 +01001250 renego_delay=-1 auth_mode=optional" \
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é-Gonnardfa44f202015-03-27 17:52:25 +01001267 renego_delay=2 auth_mode=optional" \
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é-Gonnardfa44f202015-03-27 17:52:25 +01001283 renego_delay=0 auth_mode=optional" \
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é-Gonnardfa44f202015-03-27 17:52:25 +01001298 renego_delay=0 auth_mode=optional" \
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" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001313 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001314 "$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" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001330 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
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" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001346 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
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" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001362 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001363 "$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é-Gonnardfa44f202015-03-27 17:52:25 +01001378 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001379 "$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é-Gonnardfa44f202015-03-27 17:52:25 +01001391 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001392 "$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" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001434 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001435 -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" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001447 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001448 -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" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001499 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001500 -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" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001564 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001565 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001566 -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" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001574 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001575 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001576 -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" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001584 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001585 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001586 -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" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001600 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001601 -s "! mbedtls_ssl_handshake returned" \
1602 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001603 -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" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001617 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001618 -S "! mbedtls_ssl_handshake returned" \
1619 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001620 -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" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001634 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001635 -S "! mbedtls_ssl_handshake returned" \
1636 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001637 -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" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001651 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001652 -S "! mbedtls_ssl_handshake returned" \
1653 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001654 -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" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001662 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001663 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001664 -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" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001674 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001675
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" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001688 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001689 -S "! mbedtls_ssl_handshake returned" \
1690 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001691 -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" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001786 -s "mbedtls_ssl_handshake returned" \
1787 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001788 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001796 -S "mbedtls_ssl_handshake returned" \
1797 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001798 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001804 -S "mbedtls_ssl_handshake returned" \
1805 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001806 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001812 -S "mbedtls_ssl_handshake returned" \
1813 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001814 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001820 -S "mbedtls_ssl_handshake returned" \
1821 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001822 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001828 -S "mbedtls_ssl_handshake returned" \
1829 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001830 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001836 -S "mbedtls_ssl_handshake returned" \
1837 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001838 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001844 -S "mbedtls_ssl_handshake returned" \
1845 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001846 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001854 -S "mbedtls_ssl_handshake returned" \
1855 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001856 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001863 -S "mbedtls_ssl_handshake returned" \
1864 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001865 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001872 -S "mbedtls_ssl_handshake returned" \
1873 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001874 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001881 -S "mbedtls_ssl_handshake returned" \
1882 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001883 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001890 -S "mbedtls_ssl_handshake returned" \
1891 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001892 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001899 -S "mbedtls_ssl_handshake returned" \
1900 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001901 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001908 -s "mbedtls_ssl_handshake returned" \
1909 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001910 -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 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001916 -s "mbedtls_ssl_handshake returned" \
1917 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001918 -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é-Gonnarde6efa6f2015-04-20 11:01:48 +01002097run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2098 "$O_SRV -key data_files/server2.key \
2099 -cert data_files/server2.ku-ke.crt" \
2100 "$P_CLI debug_level=1 auth_mode=optional \
2101 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2102 0 \
2103 -c "bad certificate (usage extensions)" \
2104 -C "Processing of the Certificate handshake message failed" \
2105 -c "Ciphersuite is TLS-" \
2106 -c "! Usage does not match the keyUsage extension"
2107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002108run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002109 "$O_SRV -key data_files/server2.key \
2110 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002111 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002112 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2113 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002114 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002115 -C "Processing of the Certificate handshake message failed" \
2116 -c "Ciphersuite is TLS-"
2117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002118run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002119 "$O_SRV -key data_files/server2.key \
2120 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002121 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002122 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2123 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002124 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002125 -c "Processing of the Certificate handshake message failed" \
2126 -C "Ciphersuite is TLS-"
2127
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002128run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2129 "$O_SRV -key data_files/server2.key \
2130 -cert data_files/server2.ku-ds.crt" \
2131 "$P_CLI debug_level=1 auth_mode=optional \
2132 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2133 0 \
2134 -c "bad certificate (usage extensions)" \
2135 -C "Processing of the Certificate handshake message failed" \
2136 -c "Ciphersuite is TLS-" \
2137 -c "! Usage does not match the keyUsage extension"
2138
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002139# Tests for keyUsage in leaf certificates, part 3:
2140# server-side checking of client cert
2141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002142run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002143 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002144 "$O_CLI -key data_files/server2.key \
2145 -cert data_files/server2.ku-ds.crt" \
2146 0 \
2147 -S "bad certificate (usage extensions)" \
2148 -S "Processing of the Certificate handshake message failed"
2149
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002150run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002151 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002152 "$O_CLI -key data_files/server2.key \
2153 -cert data_files/server2.ku-ke.crt" \
2154 0 \
2155 -s "bad certificate (usage extensions)" \
2156 -S "Processing of the Certificate handshake message failed"
2157
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002158run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002159 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002160 "$O_CLI -key data_files/server2.key \
2161 -cert data_files/server2.ku-ke.crt" \
2162 1 \
2163 -s "bad certificate (usage extensions)" \
2164 -s "Processing of the Certificate handshake message failed"
2165
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002166run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002167 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002168 "$O_CLI -key data_files/server5.key \
2169 -cert data_files/server5.ku-ds.crt" \
2170 0 \
2171 -S "bad certificate (usage extensions)" \
2172 -S "Processing of the Certificate handshake message failed"
2173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002174run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002175 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002176 "$O_CLI -key data_files/server5.key \
2177 -cert data_files/server5.ku-ka.crt" \
2178 0 \
2179 -s "bad certificate (usage extensions)" \
2180 -S "Processing of the Certificate handshake message failed"
2181
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002182# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2183
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002184run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002185 "$P_SRV key_file=data_files/server5.key \
2186 crt_file=data_files/server5.eku-srv.crt" \
2187 "$P_CLI" \
2188 0
2189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002190run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002191 "$P_SRV key_file=data_files/server5.key \
2192 crt_file=data_files/server5.eku-srv.crt" \
2193 "$P_CLI" \
2194 0
2195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002196run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002197 "$P_SRV key_file=data_files/server5.key \
2198 crt_file=data_files/server5.eku-cs_any.crt" \
2199 "$P_CLI" \
2200 0
2201
2202# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002203run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002204 "$P_SRV psk=abc123 key_file=data_files/server5.key \
2205 crt_file=data_files/server5.eku-cli.crt" \
2206 "$P_CLI psk=badbad" \
2207 1
2208
2209# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002211run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002212 "$O_SRV -key data_files/server5.key \
2213 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002214 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002215 0 \
2216 -C "bad certificate (usage extensions)" \
2217 -C "Processing of the Certificate handshake message failed" \
2218 -c "Ciphersuite is TLS-"
2219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002220run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002221 "$O_SRV -key data_files/server5.key \
2222 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002223 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002224 0 \
2225 -C "bad certificate (usage extensions)" \
2226 -C "Processing of the Certificate handshake message failed" \
2227 -c "Ciphersuite is TLS-"
2228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002229run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002230 "$O_SRV -key data_files/server5.key \
2231 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002232 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002233 0 \
2234 -C "bad certificate (usage extensions)" \
2235 -C "Processing of the Certificate handshake message failed" \
2236 -c "Ciphersuite is TLS-"
2237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002238run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002239 "$O_SRV -key data_files/server5.key \
2240 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002241 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002242 1 \
2243 -c "bad certificate (usage extensions)" \
2244 -c "Processing of the Certificate handshake message failed" \
2245 -C "Ciphersuite is TLS-"
2246
2247# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002249run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002250 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002251 "$O_CLI -key data_files/server5.key \
2252 -cert data_files/server5.eku-cli.crt" \
2253 0 \
2254 -S "bad certificate (usage extensions)" \
2255 -S "Processing of the Certificate handshake message failed"
2256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002257run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002258 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002259 "$O_CLI -key data_files/server5.key \
2260 -cert data_files/server5.eku-srv_cli.crt" \
2261 0 \
2262 -S "bad certificate (usage extensions)" \
2263 -S "Processing of the Certificate handshake message failed"
2264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002265run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002266 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002267 "$O_CLI -key data_files/server5.key \
2268 -cert data_files/server5.eku-cs_any.crt" \
2269 0 \
2270 -S "bad certificate (usage extensions)" \
2271 -S "Processing of the Certificate handshake message failed"
2272
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002273run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002274 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002275 "$O_CLI -key data_files/server5.key \
2276 -cert data_files/server5.eku-cs.crt" \
2277 0 \
2278 -s "bad certificate (usage extensions)" \
2279 -S "Processing of the Certificate handshake message failed"
2280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002281run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002282 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002283 "$O_CLI -key data_files/server5.key \
2284 -cert data_files/server5.eku-cs.crt" \
2285 1 \
2286 -s "bad certificate (usage extensions)" \
2287 -s "Processing of the Certificate handshake message failed"
2288
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002289# Tests for DHM parameters loading
2290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002291run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002292 "$P_SRV" \
2293 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2294 debug_level=3" \
2295 0 \
2296 -c "value of 'DHM: P ' (2048 bits)" \
2297 -c "value of 'DHM: G ' (2048 bits)"
2298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002299run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002300 "$P_SRV dhm_file=data_files/dhparams.pem" \
2301 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2302 debug_level=3" \
2303 0 \
2304 -c "value of 'DHM: P ' (1024 bits)" \
2305 -c "value of 'DHM: G ' (2 bits)"
2306
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002307# Tests for DHM client-side size checking
2308
2309run_test "DHM size: server default, client default, OK" \
2310 "$P_SRV" \
2311 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2312 debug_level=1" \
2313 0 \
2314 -C "DHM prime too short:"
2315
2316run_test "DHM size: server default, client 2048, OK" \
2317 "$P_SRV" \
2318 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2319 debug_level=1 dhmlen=2048" \
2320 0 \
2321 -C "DHM prime too short:"
2322
2323run_test "DHM size: server 1024, client default, OK" \
2324 "$P_SRV dhm_file=data_files/dhparams.pem" \
2325 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2326 debug_level=1" \
2327 0 \
2328 -C "DHM prime too short:"
2329
2330run_test "DHM size: server 1000, client default, rejected" \
2331 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2332 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2333 debug_level=1" \
2334 1 \
2335 -c "DHM prime too short:"
2336
2337run_test "DHM size: server default, client 2049, rejected" \
2338 "$P_SRV" \
2339 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2340 debug_level=1 dhmlen=2049" \
2341 1 \
2342 -c "DHM prime too short:"
2343
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002344# Tests for PSK callback
2345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002346run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002347 "$P_SRV psk=abc123 psk_identity=foo" \
2348 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2349 psk_identity=foo psk=abc123" \
2350 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002351 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002352 -S "SSL - Unknown identity received" \
2353 -S "SSL - Verification of the message MAC failed"
2354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002355run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002356 "$P_SRV" \
2357 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2358 psk_identity=foo psk=abc123" \
2359 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002360 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002361 -S "SSL - Unknown identity received" \
2362 -S "SSL - Verification of the message MAC failed"
2363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002364run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002365 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2366 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2367 psk_identity=foo psk=abc123" \
2368 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002369 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002370 -s "SSL - Unknown identity received" \
2371 -S "SSL - Verification of the message MAC failed"
2372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002373run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002374 "$P_SRV psk_list=abc,dead,def,beef" \
2375 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2376 psk_identity=abc psk=dead" \
2377 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002378 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002379 -S "SSL - Unknown identity received" \
2380 -S "SSL - Verification of the message MAC failed"
2381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002382run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002383 "$P_SRV psk_list=abc,dead,def,beef" \
2384 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2385 psk_identity=def psk=beef" \
2386 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002387 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002388 -S "SSL - Unknown identity received" \
2389 -S "SSL - Verification of the message MAC failed"
2390
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002391run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002392 "$P_SRV psk_list=abc,dead,def,beef" \
2393 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2394 psk_identity=ghi psk=beef" \
2395 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002396 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002397 -s "SSL - Unknown identity received" \
2398 -S "SSL - Verification of the message MAC failed"
2399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002400run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002401 "$P_SRV psk_list=abc,dead,def,beef" \
2402 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2403 psk_identity=abc psk=beef" \
2404 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002405 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002406 -S "SSL - Unknown identity received" \
2407 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002408
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002409# Tests for ciphersuites per version
2410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002411run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002412 "$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 +02002413 "$P_CLI force_version=ssl3" \
2414 0 \
2415 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002417run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002418 "$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 +01002419 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002420 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002421 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002423run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002424 "$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 +02002425 "$P_CLI force_version=tls1_1" \
2426 0 \
2427 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002429run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002430 "$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 +02002431 "$P_CLI force_version=tls1_2" \
2432 0 \
2433 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2434
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002435# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002436
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002437run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002438 "$P_SRV" \
2439 "$P_CLI request_size=100" \
2440 0 \
2441 -s "Read from client: 100 bytes read$"
2442
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002443run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002444 "$P_SRV" \
2445 "$P_CLI request_size=500" \
2446 0 \
2447 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002448
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002449# Tests for small packets
2450
2451run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002452 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002453 "$P_CLI request_size=1 force_version=ssl3 \
2454 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2455 0 \
2456 -s "Read from client: 1 bytes read"
2457
2458run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002459 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002460 "$P_CLI request_size=1 force_version=ssl3 \
2461 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2462 0 \
2463 -s "Read from client: 1 bytes read"
2464
2465run_test "Small packet TLS 1.0 BlockCipher" \
2466 "$P_SRV" \
2467 "$P_CLI request_size=1 force_version=tls1 \
2468 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2469 0 \
2470 -s "Read from client: 1 bytes read"
2471
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002472run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2473 "$P_SRV" \
2474 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2475 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2476 0 \
2477 -s "Read from client: 1 bytes read"
2478
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002479run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2480 "$P_SRV" \
2481 "$P_CLI request_size=1 force_version=tls1 \
2482 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2483 trunc_hmac=1" \
2484 0 \
2485 -s "Read from client: 1 bytes read"
2486
2487run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002488 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002489 "$P_CLI request_size=1 force_version=tls1 \
2490 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2491 trunc_hmac=1" \
2492 0 \
2493 -s "Read from client: 1 bytes read"
2494
2495run_test "Small packet TLS 1.1 BlockCipher" \
2496 "$P_SRV" \
2497 "$P_CLI request_size=1 force_version=tls1_1 \
2498 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2499 0 \
2500 -s "Read from client: 1 bytes read"
2501
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002502run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2503 "$P_SRV" \
2504 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2505 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2506 0 \
2507 -s "Read from client: 1 bytes read"
2508
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002509run_test "Small packet TLS 1.1 StreamCipher" \
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_1 \
2512 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2513 0 \
2514 -s "Read from client: 1 bytes read"
2515
2516run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2517 "$P_SRV" \
2518 "$P_CLI request_size=1 force_version=tls1_1 \
2519 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2520 trunc_hmac=1" \
2521 0 \
2522 -s "Read from client: 1 bytes read"
2523
2524run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002525 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002526 "$P_CLI request_size=1 force_version=tls1_1 \
2527 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2528 trunc_hmac=1" \
2529 0 \
2530 -s "Read from client: 1 bytes read"
2531
2532run_test "Small packet TLS 1.2 BlockCipher" \
2533 "$P_SRV" \
2534 "$P_CLI request_size=1 force_version=tls1_2 \
2535 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2536 0 \
2537 -s "Read from client: 1 bytes read"
2538
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002539run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2540 "$P_SRV" \
2541 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2542 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2543 0 \
2544 -s "Read from client: 1 bytes read"
2545
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002546run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2547 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002548 "$P_CLI request_size=1 force_version=tls1_2 \
2549 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002550 0 \
2551 -s "Read from client: 1 bytes read"
2552
2553run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2554 "$P_SRV" \
2555 "$P_CLI request_size=1 force_version=tls1_2 \
2556 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2557 trunc_hmac=1" \
2558 0 \
2559 -s "Read from client: 1 bytes read"
2560
2561run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002562 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002563 "$P_CLI request_size=1 force_version=tls1_2 \
2564 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2565 0 \
2566 -s "Read from client: 1 bytes read"
2567
2568run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002569 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002570 "$P_CLI request_size=1 force_version=tls1_2 \
2571 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2572 trunc_hmac=1" \
2573 0 \
2574 -s "Read from client: 1 bytes read"
2575
2576run_test "Small packet TLS 1.2 AEAD" \
2577 "$P_SRV" \
2578 "$P_CLI request_size=1 force_version=tls1_2 \
2579 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2580 0 \
2581 -s "Read from client: 1 bytes read"
2582
2583run_test "Small packet TLS 1.2 AEAD shorter tag" \
2584 "$P_SRV" \
2585 "$P_CLI request_size=1 force_version=tls1_2 \
2586 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2587 0 \
2588 -s "Read from client: 1 bytes read"
2589
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002590# Test for large packets
2591
2592run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002593 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002594 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002595 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2596 0 \
2597 -s "Read from client: 16384 bytes read"
2598
2599run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002600 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002601 "$P_CLI request_size=16384 force_version=ssl3 \
2602 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2603 0 \
2604 -s "Read from client: 16384 bytes read"
2605
2606run_test "Large packet TLS 1.0 BlockCipher" \
2607 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002608 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002609 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2610 0 \
2611 -s "Read from client: 16384 bytes read"
2612
2613run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2614 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002615 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002616 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2617 trunc_hmac=1" \
2618 0 \
2619 -s "Read from client: 16384 bytes read"
2620
2621run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002622 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002623 "$P_CLI request_size=16384 force_version=tls1 \
2624 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2625 trunc_hmac=1" \
2626 0 \
2627 -s "Read from client: 16384 bytes read"
2628
2629run_test "Large packet TLS 1.1 BlockCipher" \
2630 "$P_SRV" \
2631 "$P_CLI request_size=16384 force_version=tls1_1 \
2632 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2633 0 \
2634 -s "Read from client: 16384 bytes read"
2635
2636run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002637 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002638 "$P_CLI request_size=16384 force_version=tls1_1 \
2639 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2640 0 \
2641 -s "Read from client: 16384 bytes read"
2642
2643run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2644 "$P_SRV" \
2645 "$P_CLI request_size=16384 force_version=tls1_1 \
2646 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2647 trunc_hmac=1" \
2648 0 \
2649 -s "Read from client: 16384 bytes read"
2650
2651run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002652 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002653 "$P_CLI request_size=16384 force_version=tls1_1 \
2654 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2655 trunc_hmac=1" \
2656 0 \
2657 -s "Read from client: 16384 bytes read"
2658
2659run_test "Large packet TLS 1.2 BlockCipher" \
2660 "$P_SRV" \
2661 "$P_CLI request_size=16384 force_version=tls1_2 \
2662 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2663 0 \
2664 -s "Read from client: 16384 bytes read"
2665
2666run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2667 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002668 "$P_CLI request_size=16384 force_version=tls1_2 \
2669 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002670 0 \
2671 -s "Read from client: 16384 bytes read"
2672
2673run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2674 "$P_SRV" \
2675 "$P_CLI request_size=16384 force_version=tls1_2 \
2676 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2677 trunc_hmac=1" \
2678 0 \
2679 -s "Read from client: 16384 bytes read"
2680
2681run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002682 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002683 "$P_CLI request_size=16384 force_version=tls1_2 \
2684 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2685 0 \
2686 -s "Read from client: 16384 bytes read"
2687
2688run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002689 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002690 "$P_CLI request_size=16384 force_version=tls1_2 \
2691 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2692 trunc_hmac=1" \
2693 0 \
2694 -s "Read from client: 16384 bytes read"
2695
2696run_test "Large packet TLS 1.2 AEAD" \
2697 "$P_SRV" \
2698 "$P_CLI request_size=16384 force_version=tls1_2 \
2699 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2700 0 \
2701 -s "Read from client: 16384 bytes read"
2702
2703run_test "Large packet TLS 1.2 AEAD shorter tag" \
2704 "$P_SRV" \
2705 "$P_CLI request_size=16384 force_version=tls1_2 \
2706 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2707 0 \
2708 -s "Read from client: 16384 bytes read"
2709
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002710# Tests for DTLS HelloVerifyRequest
2711
2712run_test "DTLS cookie: enabled" \
2713 "$P_SRV dtls=1 debug_level=2" \
2714 "$P_CLI dtls=1 debug_level=2" \
2715 0 \
2716 -s "cookie verification failed" \
2717 -s "cookie verification passed" \
2718 -S "cookie verification skipped" \
2719 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002720 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002721 -S "SSL - The requested feature is not available"
2722
2723run_test "DTLS cookie: disabled" \
2724 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2725 "$P_CLI dtls=1 debug_level=2" \
2726 0 \
2727 -S "cookie verification failed" \
2728 -S "cookie verification passed" \
2729 -s "cookie verification skipped" \
2730 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002731 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002732 -S "SSL - The requested feature is not available"
2733
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002734run_test "DTLS cookie: default (failing)" \
2735 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2736 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2737 1 \
2738 -s "cookie verification failed" \
2739 -S "cookie verification passed" \
2740 -S "cookie verification skipped" \
2741 -C "received hello verify request" \
2742 -S "hello verification requested" \
2743 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002744
2745requires_ipv6
2746run_test "DTLS cookie: enabled, IPv6" \
2747 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2748 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2749 0 \
2750 -s "cookie verification failed" \
2751 -s "cookie verification passed" \
2752 -S "cookie verification skipped" \
2753 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002754 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002755 -S "SSL - The requested feature is not available"
2756
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002757run_test "DTLS cookie: enabled, nbio" \
2758 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2759 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2760 0 \
2761 -s "cookie verification failed" \
2762 -s "cookie verification passed" \
2763 -S "cookie verification skipped" \
2764 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002765 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002766 -S "SSL - The requested feature is not available"
2767
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002768# Tests for various cases of client authentication with DTLS
2769# (focused on handshake flows and message parsing)
2770
2771run_test "DTLS client auth: required" \
2772 "$P_SRV dtls=1 auth_mode=required" \
2773 "$P_CLI dtls=1" \
2774 0 \
2775 -s "Verifying peer X.509 certificate... ok"
2776
2777run_test "DTLS client auth: optional, client has no cert" \
2778 "$P_SRV dtls=1 auth_mode=optional" \
2779 "$P_CLI dtls=1 crt_file=none key_file=none" \
2780 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002781 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002782
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002783run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002784 "$P_SRV dtls=1 auth_mode=none" \
2785 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2786 0 \
2787 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002788 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002789
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002790# Tests for receiving fragmented handshake messages with DTLS
2791
2792requires_gnutls
2793run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2794 "$G_SRV -u --mtu 2048 -a" \
2795 "$P_CLI dtls=1 debug_level=2" \
2796 0 \
2797 -C "found fragmented DTLS handshake message" \
2798 -C "error"
2799
2800requires_gnutls
2801run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2802 "$G_SRV -u --mtu 512" \
2803 "$P_CLI dtls=1 debug_level=2" \
2804 0 \
2805 -c "found fragmented DTLS handshake message" \
2806 -C "error"
2807
2808requires_gnutls
2809run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2810 "$G_SRV -u --mtu 128" \
2811 "$P_CLI dtls=1 debug_level=2" \
2812 0 \
2813 -c "found fragmented DTLS handshake message" \
2814 -C "error"
2815
2816requires_gnutls
2817run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2818 "$G_SRV -u --mtu 128" \
2819 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2820 0 \
2821 -c "found fragmented DTLS handshake message" \
2822 -C "error"
2823
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002824requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002825run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2826 "$G_SRV -u --mtu 256" \
2827 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2828 0 \
2829 -c "found fragmented DTLS handshake message" \
2830 -c "client hello, adding renegotiation extension" \
2831 -c "found renegotiation extension" \
2832 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002833 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002834 -C "error" \
2835 -s "Extra-header:"
2836
2837requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002838run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2839 "$G_SRV -u --mtu 256" \
2840 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2841 0 \
2842 -c "found fragmented DTLS handshake message" \
2843 -c "client hello, adding renegotiation extension" \
2844 -c "found renegotiation extension" \
2845 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002846 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002847 -C "error" \
2848 -s "Extra-header:"
2849
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002850run_test "DTLS reassembly: no fragmentation (openssl server)" \
2851 "$O_SRV -dtls1 -mtu 2048" \
2852 "$P_CLI dtls=1 debug_level=2" \
2853 0 \
2854 -C "found fragmented DTLS handshake message" \
2855 -C "error"
2856
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002857run_test "DTLS reassembly: some fragmentation (openssl server)" \
2858 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002859 "$P_CLI dtls=1 debug_level=2" \
2860 0 \
2861 -c "found fragmented DTLS handshake message" \
2862 -C "error"
2863
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002864run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002865 "$O_SRV -dtls1 -mtu 256" \
2866 "$P_CLI dtls=1 debug_level=2" \
2867 0 \
2868 -c "found fragmented DTLS handshake message" \
2869 -C "error"
2870
2871run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2872 "$O_SRV -dtls1 -mtu 256" \
2873 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2874 0 \
2875 -c "found fragmented DTLS handshake message" \
2876 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002877
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002878# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002879
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002880not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002881run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002882 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002883 "$P_SRV dtls=1 debug_level=2" \
2884 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002885 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002886 -C "replayed record" \
2887 -S "replayed record" \
2888 -C "record from another epoch" \
2889 -S "record from another epoch" \
2890 -C "discarding invalid record" \
2891 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002892 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002893 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002894 -c "HTTP/1.0 200 OK"
2895
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002896not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002897run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002898 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002899 "$P_SRV dtls=1 debug_level=2" \
2900 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002901 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002902 -c "replayed record" \
2903 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002904 -c "discarding invalid record" \
2905 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002906 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002907 -s "Extra-header:" \
2908 -c "HTTP/1.0 200 OK"
2909
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002910run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2911 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002912 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2913 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002914 0 \
2915 -c "replayed record" \
2916 -S "replayed record" \
2917 -c "discarding invalid record" \
2918 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002919 -c "resend" \
2920 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002921 -s "Extra-header:" \
2922 -c "HTTP/1.0 200 OK"
2923
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002924run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002925 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002926 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002927 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002928 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002929 -c "discarding invalid record (mac)" \
2930 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002931 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002932 -c "HTTP/1.0 200 OK" \
2933 -S "too many records with bad MAC" \
2934 -S "Verification of the message MAC failed"
2935
2936run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
2937 -p "$P_PXY bad_ad=1" \
2938 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
2939 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2940 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002941 -C "discarding invalid record (mac)" \
2942 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002943 -S "Extra-header:" \
2944 -C "HTTP/1.0 200 OK" \
2945 -s "too many records with bad MAC" \
2946 -s "Verification of the message MAC failed"
2947
2948run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
2949 -p "$P_PXY bad_ad=1" \
2950 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
2951 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2952 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002953 -c "discarding invalid record (mac)" \
2954 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002955 -s "Extra-header:" \
2956 -c "HTTP/1.0 200 OK" \
2957 -S "too many records with bad MAC" \
2958 -S "Verification of the message MAC failed"
2959
2960run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
2961 -p "$P_PXY bad_ad=1" \
2962 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
2963 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
2964 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002965 -c "discarding invalid record (mac)" \
2966 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002967 -s "Extra-header:" \
2968 -c "HTTP/1.0 200 OK" \
2969 -s "too many records with bad MAC" \
2970 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002971
2972run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002973 -p "$P_PXY delay_ccs=1" \
2974 "$P_SRV dtls=1 debug_level=1" \
2975 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002976 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002977 -c "record from another epoch" \
2978 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002979 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002980 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002981 -s "Extra-header:" \
2982 -c "HTTP/1.0 200 OK"
2983
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002984# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002985
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002986needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002987run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002988 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002989 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2990 psk=abc123" \
2991 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002992 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2993 0 \
2994 -s "Extra-header:" \
2995 -c "HTTP/1.0 200 OK"
2996
2997needs_more_time 2
2998run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
2999 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003000 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3001 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003002 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3003 0 \
3004 -s "Extra-header:" \
3005 -c "HTTP/1.0 200 OK"
3006
3007needs_more_time 2
3008run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3009 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003010 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3011 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003012 0 \
3013 -s "Extra-header:" \
3014 -c "HTTP/1.0 200 OK"
3015
3016needs_more_time 2
3017run_test "DTLS proxy: 3d, FS, client auth" \
3018 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003019 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3020 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003021 0 \
3022 -s "Extra-header:" \
3023 -c "HTTP/1.0 200 OK"
3024
3025needs_more_time 2
3026run_test "DTLS proxy: 3d, FS, ticket" \
3027 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003028 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3029 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003030 0 \
3031 -s "Extra-header:" \
3032 -c "HTTP/1.0 200 OK"
3033
3034needs_more_time 2
3035run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3036 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003037 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3038 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003039 0 \
3040 -s "Extra-header:" \
3041 -c "HTTP/1.0 200 OK"
3042
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003043needs_more_time 2
3044run_test "DTLS proxy: 3d, max handshake, nbio" \
3045 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003046 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3047 auth_mode=required" \
3048 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003049 0 \
3050 -s "Extra-header:" \
3051 -c "HTTP/1.0 200 OK"
3052
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003053needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003054run_test "DTLS proxy: 3d, min handshake, resumption" \
3055 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3056 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3057 psk=abc123 debug_level=3" \
3058 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3059 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3060 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3061 0 \
3062 -s "a session has been resumed" \
3063 -c "a session has been resumed" \
3064 -s "Extra-header:" \
3065 -c "HTTP/1.0 200 OK"
3066
3067needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003068run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3069 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3070 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3071 psk=abc123 debug_level=3 nbio=2" \
3072 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3073 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3074 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3075 0 \
3076 -s "a session has been resumed" \
3077 -c "a session has been resumed" \
3078 -s "Extra-header:" \
3079 -c "HTTP/1.0 200 OK"
3080
3081needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003082run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003083 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003084 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3085 psk=abc123 renegotiation=1 debug_level=2" \
3086 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3087 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003088 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3089 0 \
3090 -c "=> renegotiate" \
3091 -s "=> renegotiate" \
3092 -s "Extra-header:" \
3093 -c "HTTP/1.0 200 OK"
3094
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003095needs_more_time 4
3096run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3097 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003098 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3099 psk=abc123 renegotiation=1 debug_level=2" \
3100 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3101 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003102 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3103 0 \
3104 -c "=> renegotiate" \
3105 -s "=> renegotiate" \
3106 -s "Extra-header:" \
3107 -c "HTTP/1.0 200 OK"
3108
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003109needs_more_time 4
3110run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003111 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003112 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003113 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003114 debug_level=2" \
3115 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003116 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003117 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3118 0 \
3119 -c "=> renegotiate" \
3120 -s "=> renegotiate" \
3121 -s "Extra-header:" \
3122 -c "HTTP/1.0 200 OK"
3123
3124needs_more_time 4
3125run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003126 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003127 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003128 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003129 debug_level=2 nbio=2" \
3130 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003131 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003132 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3133 0 \
3134 -c "=> renegotiate" \
3135 -s "=> renegotiate" \
3136 -s "Extra-header:" \
3137 -c "HTTP/1.0 200 OK"
3138
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003139needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003140run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003141 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3142 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003143 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003144 0 \
3145 -s "Extra-header:" \
3146 -c "HTTP/1.0 200 OK"
3147
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003148needs_more_time 8
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003149run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3150 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3151 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003152 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003153 0 \
3154 -s "Extra-header:" \
3155 -c "HTTP/1.0 200 OK"
3156
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003157needs_more_time 8
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003158run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3159 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3160 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003161 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003162 0 \
3163 -s "Extra-header:" \
3164 -c "HTTP/1.0 200 OK"
3165
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003166requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003167needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003168run_test "DTLS proxy: 3d, gnutls server" \
3169 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3170 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003171 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003172 0 \
3173 -s "Extra-header:" \
3174 -c "Extra-header:"
3175
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003176requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003177needs_more_time 8
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003178run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3179 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3180 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003181 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003182 0 \
3183 -s "Extra-header:" \
3184 -c "Extra-header:"
3185
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003186requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003187needs_more_time 8
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003188run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3189 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3190 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003191 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003192 0 \
3193 -s "Extra-header:" \
3194 -c "Extra-header:"
3195
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003196# Final report
3197
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003198echo "------------------------------------------------------------------------"
3199
3200if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003201 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003202else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003203 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003204fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003205PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003206echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003207
3208exit $FAILS