blob: 103809bd1d3c36faebe4ac8cbe0d3cb05a2d24ca [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é-Gonnard1cbd39d2014-10-20 13:34:59 +020077# skip next test if OpenSSL doesn't support FALLBACK_SCSV
78requires_openssl_with_fallback_scsv() {
79 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
80 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
81 then
82 OPENSSL_HAS_FBSCSV="YES"
83 else
84 OPENSSL_HAS_FBSCSV="NO"
85 fi
86 fi
87 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
88 SKIP_NEXT="YES"
89 fi
90}
91
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020092# skip next test if GnuTLS isn't available
93requires_gnutls() {
94 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +020095 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020096 GNUTLS_AVAILABLE="YES"
97 else
98 GNUTLS_AVAILABLE="NO"
99 fi
100 fi
101 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
102 SKIP_NEXT="YES"
103 fi
104}
105
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200106# skip next test if IPv6 isn't available on this host
107requires_ipv6() {
108 if [ -z "${HAS_IPV6:-}" ]; then
109 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
110 SRV_PID=$!
111 sleep 1
112 kill $SRV_PID >/dev/null 2>&1
113 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
114 HAS_IPV6="NO"
115 else
116 HAS_IPV6="YES"
117 fi
118 rm -r $SRV_OUT
119 fi
120
121 if [ "$HAS_IPV6" = "NO" ]; then
122 SKIP_NEXT="YES"
123 fi
124}
125
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200126# skip the next test if valgrind is in use
127not_with_valgrind() {
128 if [ "$MEMCHECK" -gt 0 ]; then
129 SKIP_NEXT="YES"
130 fi
131}
132
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200133# multiply the client timeout delay by the given factor for the next test
134needs_more_time() {
135 CLI_DELAY_FACTOR=$1
136}
137
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100138# print_name <name>
139print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100140 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200141 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100142 for i in `seq 1 $LEN`; do printf '.'; done
143 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100144
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200145 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100146}
147
148# fail <message>
149fail() {
150 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100151 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100152
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200153 mv $SRV_OUT o-srv-${TESTS}.log
154 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200155 if [ -n "$PXY_CMD" ]; then
156 mv $PXY_OUT o-pxy-${TESTS}.log
157 fi
158 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100159
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200160 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
161 echo " ! server output:"
162 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200163 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200164 echo " ! client output:"
165 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200166 if [ -n "$PXY_CMD" ]; then
167 echo " ! ========================================================"
168 echo " ! proxy output:"
169 cat o-pxy-${TESTS}.log
170 fi
171 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200172 fi
173
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200174 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100175}
176
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100177# is_polar <cmd_line>
178is_polar() {
179 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
180}
181
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200182# openssl s_server doesn't have -www with DTLS
183check_osrv_dtls() {
184 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
185 NEEDS_INPUT=1
186 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
187 else
188 NEEDS_INPUT=0
189 fi
190}
191
192# provide input to commands that need it
193provide_input() {
194 if [ $NEEDS_INPUT -eq 0 ]; then
195 return
196 fi
197
198 while true; do
199 echo "HTTP/1.0 200 OK"
200 sleep 1
201 done
202}
203
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100204# has_mem_err <log_file_name>
205has_mem_err() {
206 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
207 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
208 then
209 return 1 # false: does not have errors
210 else
211 return 0 # true: has errors
212 fi
213}
214
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200215# wait for server to start: two versions depending on lsof availability
216wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200217 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200218 START_TIME=$( date +%s )
219 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200220
221 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200222 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200223 while [ $DONE -eq 0 ]; do
224 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
225 then
226 DONE=1
227 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
228 echo "SERVERSTART TIMEOUT"
229 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
230 DONE=1
231 fi
232 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200233 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200234 while [ $DONE -eq 0 ]; do
235 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
236 then
237 DONE=1
238 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
239 echo "SERVERSTART TIMEOUT"
240 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
241 DONE=1
242 fi
243 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200244 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200245 else
246 sleep "$START_DELAY"
247 fi
248}
249
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200250# wait for client to terminate and set CLI_EXIT
251# must be called right after starting the client
252wait_client_done() {
253 CLI_PID=$!
254
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200255 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
256 CLI_DELAY_FACTOR=1
257
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200258 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200259 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200260
261 wait $CLI_PID
262 CLI_EXIT=$?
263
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200264 kill $DOG_PID >/dev/null 2>&1
265 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200266
267 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
268}
269
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200270# check if the given command uses dtls and sets global variable DTLS
271detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200272 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200273 DTLS=1
274 else
275 DTLS=0
276 fi
277}
278
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200279# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100280# Options: -s pattern pattern that must be present in server output
281# -c pattern pattern that must be present in client output
282# -S pattern pattern that must be absent in server output
283# -C pattern pattern that must be absent in client output
284run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100285 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200286 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100287
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100288 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
289 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200290 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100291 return
292 fi
293
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100294 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100295
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200296 # should we skip?
297 if [ "X$SKIP_NEXT" = "XYES" ]; then
298 SKIP_NEXT="NO"
299 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200300 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200301 return
302 fi
303
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200304 # does this test use a proxy?
305 if [ "X$1" = "X-p" ]; then
306 PXY_CMD="$2"
307 shift 2
308 else
309 PXY_CMD=""
310 fi
311
312 # get commands and client output
313 SRV_CMD="$1"
314 CLI_CMD="$2"
315 CLI_EXPECT="$3"
316 shift 3
317
318 # fix client port
319 if [ -n "$PXY_CMD" ]; then
320 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
321 else
322 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
323 fi
324
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200325 # update DTLS variable
326 detect_dtls "$SRV_CMD"
327
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100328 # prepend valgrind to our commands if active
329 if [ "$MEMCHECK" -gt 0 ]; then
330 if is_polar "$SRV_CMD"; then
331 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
332 fi
333 if is_polar "$CLI_CMD"; then
334 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
335 fi
336 fi
337
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200338 TIMES_LEFT=2
339 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200340 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200341
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200342 # run the commands
343 if [ -n "$PXY_CMD" ]; then
344 echo "$PXY_CMD" > $PXY_OUT
345 $PXY_CMD >> $PXY_OUT 2>&1 &
346 PXY_PID=$!
347 # assume proxy starts faster than server
348 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200349
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200350 check_osrv_dtls
351 echo "$SRV_CMD" > $SRV_OUT
352 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
353 SRV_PID=$!
354 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200355
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200356 echo "$CLI_CMD" > $CLI_OUT
357 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
358 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100359
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200360 # terminate the server (and the proxy)
361 kill $SRV_PID
362 wait $SRV_PID
363 if [ -n "$PXY_CMD" ]; then
364 kill $PXY_PID >/dev/null 2>&1
365 wait $PXY_PID
366 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100367
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200368 # retry only on timeouts
369 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
370 printf "RETRY "
371 else
372 TIMES_LEFT=0
373 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200374 done
375
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100376 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200377 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100378 # expected client exit to incorrectly succeed in case of catastrophic
379 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100380 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200381 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100382 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100383 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100384 return
385 fi
386 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100387 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200388 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100389 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100390 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100391 return
392 fi
393 fi
394
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100395 # check server exit code
396 if [ $? != 0 ]; then
397 fail "server fail"
398 return
399 fi
400
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100401 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100402 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
403 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100404 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200405 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100406 return
407 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100408
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100409 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200410 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100411 while [ $# -gt 0 ]
412 do
413 case $1 in
414 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200415 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100416 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100417 return
418 fi
419 ;;
420
421 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200422 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100423 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100424 return
425 fi
426 ;;
427
428 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200429 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100430 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100431 return
432 fi
433 ;;
434
435 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200436 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100437 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100438 return
439 fi
440 ;;
441
442 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200443 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100444 exit 1
445 esac
446 shift 2
447 done
448
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100449 # check valgrind's results
450 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200451 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100452 fail "Server has memory errors"
453 return
454 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200455 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100456 fail "Client has memory errors"
457 return
458 fi
459 fi
460
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100461 # if we're here, everything is ok
462 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200463 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100464}
465
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100466cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200467 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200468 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
469 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
470 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
471 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100472 exit 1
473}
474
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100475#
476# MAIN
477#
478
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000479if cd $( dirname $0 ); then :; else
480 echo "cd $( dirname $0 ) failed" >&2
481 exit 1
482fi
483
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100484get_options "$@"
485
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100486# sanity checks, avoid an avalanche of errors
487if [ ! -x "$P_SRV" ]; then
488 echo "Command '$P_SRV' is not an executable file"
489 exit 1
490fi
491if [ ! -x "$P_CLI" ]; then
492 echo "Command '$P_CLI' is not an executable file"
493 exit 1
494fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200495if [ ! -x "$P_PXY" ]; then
496 echo "Command '$P_PXY' is not an executable file"
497 exit 1
498fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100499if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
500 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100501 exit 1
502fi
503
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200504# used by watchdog
505MAIN_PID="$$"
506
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200507# be more patient with valgrind
508if [ "$MEMCHECK" -gt 0 ]; then
509 START_DELAY=3
510 DOG_DELAY=30
511else
512 START_DELAY=1
513 DOG_DELAY=10
514fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200515CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200516
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200517# Pick a "unique" server port in the range 10000-19999, and a proxy port
518PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000519PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200520SRV_PORT="1$PORT_BASE"
521PXY_PORT="2$PORT_BASE"
522unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200523
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200524# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000525# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200526P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
527P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
528P_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 +0200529O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200530O_CLI="$O_CLI -connect localhost:+SRV_PORT"
531G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000532G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200533
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200534# Also pick a unique name for intermediate files
535SRV_OUT="srv_out.$$"
536CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200537PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200538SESSION="session.$$"
539
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200540SKIP_NEXT="NO"
541
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100542trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100543
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200544# Basic test
545
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200546# Checks that:
547# - things work with all ciphersuites active (used with config-full in all.sh)
548# - the expected (highest security) parameters are selected
549# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200550run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200551 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200552 "$P_CLI" \
553 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200554 -s "Protocol is TLSv1.2" \
555 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
556 -s "client hello v3, signature_algorithm ext: 6" \
557 -s "ECDHE curve: secp521r1" \
558 -S "error" \
559 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200560
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000561run_test "Default, DTLS" \
562 "$P_SRV dtls=1" \
563 "$P_CLI dtls=1" \
564 0 \
565 -s "Protocol is DTLSv1.2" \
566 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
567
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100568# Tests for rc4 option
569
Simon Butcher6eb066e2016-05-19 22:12:18 +0100570requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100571run_test "RC4: server disabled, client enabled" \
572 "$P_SRV" \
573 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
574 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100575 -s "SSL - The server has no ciphersuites in common"
576
Simon Butcher6eb066e2016-05-19 22:12:18 +0100577requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100578run_test "RC4: server half, client enabled" \
579 "$P_SRV arc4=1" \
580 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
581 1 \
582 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100583
584run_test "RC4: server enabled, client disabled" \
585 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
586 "$P_CLI" \
587 1 \
588 -s "SSL - The server has no ciphersuites in common"
589
590run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100591 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100592 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
593 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100594 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100595 -S "SSL - The server has no ciphersuites in common"
596
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100597# Tests for Truncated HMAC extension
598
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100599run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200600 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100601 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100602 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100603 -s "dumping 'computed mac' (20 bytes)" \
604 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100605
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100606run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200607 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100608 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
609 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100610 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100611 -s "dumping 'computed mac' (20 bytes)" \
612 -S "dumping 'computed mac' (10 bytes)"
613
614run_test "Truncated HMAC: client enabled, server default" \
615 "$P_SRV debug_level=4" \
616 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
617 trunc_hmac=1" \
618 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100619 -s "dumping 'computed mac' (20 bytes)" \
620 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100621
622run_test "Truncated HMAC: client enabled, server disabled" \
623 "$P_SRV debug_level=4 trunc_hmac=0" \
624 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
625 trunc_hmac=1" \
626 0 \
627 -s "dumping 'computed mac' (20 bytes)" \
628 -S "dumping 'computed mac' (10 bytes)"
629
630run_test "Truncated HMAC: client enabled, server enabled" \
631 "$P_SRV debug_level=4 trunc_hmac=1" \
632 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
633 trunc_hmac=1" \
634 0 \
635 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100636 -s "dumping 'computed mac' (10 bytes)"
637
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100638# Tests for Encrypt-then-MAC extension
639
640run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100641 "$P_SRV debug_level=3 \
642 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100643 "$P_CLI debug_level=3" \
644 0 \
645 -c "client hello, adding encrypt_then_mac extension" \
646 -s "found encrypt then mac extension" \
647 -s "server hello, adding encrypt then mac extension" \
648 -c "found encrypt_then_mac extension" \
649 -c "using encrypt then mac" \
650 -s "using encrypt then mac"
651
652run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100653 "$P_SRV debug_level=3 etm=0 \
654 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100655 "$P_CLI debug_level=3 etm=1" \
656 0 \
657 -c "client hello, adding encrypt_then_mac extension" \
658 -s "found encrypt then mac extension" \
659 -S "server hello, adding encrypt then mac extension" \
660 -C "found encrypt_then_mac extension" \
661 -C "using encrypt then mac" \
662 -S "using encrypt then mac"
663
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100664run_test "Encrypt then MAC: client enabled, aead cipher" \
665 "$P_SRV debug_level=3 etm=1 \
666 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
667 "$P_CLI debug_level=3 etm=1" \
668 0 \
669 -c "client hello, adding encrypt_then_mac extension" \
670 -s "found encrypt then mac extension" \
671 -S "server hello, adding encrypt then mac extension" \
672 -C "found encrypt_then_mac extension" \
673 -C "using encrypt then mac" \
674 -S "using encrypt then mac"
675
676run_test "Encrypt then MAC: client enabled, stream cipher" \
677 "$P_SRV debug_level=3 etm=1 \
678 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100679 "$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 +0100680 0 \
681 -c "client hello, adding encrypt_then_mac extension" \
682 -s "found encrypt then mac extension" \
683 -S "server hello, adding encrypt then mac extension" \
684 -C "found encrypt_then_mac extension" \
685 -C "using encrypt then mac" \
686 -S "using encrypt then mac"
687
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100688run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100689 "$P_SRV debug_level=3 etm=1 \
690 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100691 "$P_CLI debug_level=3 etm=0" \
692 0 \
693 -C "client hello, adding encrypt_then_mac extension" \
694 -S "found encrypt then mac extension" \
695 -S "server hello, adding encrypt then mac extension" \
696 -C "found encrypt_then_mac extension" \
697 -C "using encrypt then mac" \
698 -S "using encrypt then mac"
699
Janos Follath542ee5d2016-03-07 15:57:05 +0000700requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100701run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100702 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100703 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100704 "$P_CLI debug_level=3 force_version=ssl3" \
705 0 \
706 -C "client hello, adding encrypt_then_mac extension" \
707 -S "found encrypt then mac extension" \
708 -S "server hello, adding encrypt then mac extension" \
709 -C "found encrypt_then_mac extension" \
710 -C "using encrypt then mac" \
711 -S "using encrypt then mac"
712
Janos Follath542ee5d2016-03-07 15:57:05 +0000713requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100714run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100715 "$P_SRV debug_level=3 force_version=ssl3 \
716 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100717 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100718 0 \
719 -c "client hello, adding encrypt_then_mac extension" \
720 -s "found encrypt then mac extension" \
721 -S "server hello, adding encrypt then mac extension" \
722 -C "found encrypt_then_mac extension" \
723 -C "using encrypt then mac" \
724 -S "using encrypt then mac"
725
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200726# Tests for Extended Master Secret extension
727
728run_test "Extended Master Secret: default" \
729 "$P_SRV debug_level=3" \
730 "$P_CLI debug_level=3" \
731 0 \
732 -c "client hello, adding extended_master_secret extension" \
733 -s "found extended master secret extension" \
734 -s "server hello, adding extended master secret extension" \
735 -c "found extended_master_secret extension" \
736 -c "using extended master secret" \
737 -s "using extended master secret"
738
739run_test "Extended Master Secret: client enabled, server disabled" \
740 "$P_SRV debug_level=3 extended_ms=0" \
741 "$P_CLI debug_level=3 extended_ms=1" \
742 0 \
743 -c "client hello, adding extended_master_secret extension" \
744 -s "found extended master secret extension" \
745 -S "server hello, adding extended master secret extension" \
746 -C "found extended_master_secret extension" \
747 -C "using extended master secret" \
748 -S "using extended master secret"
749
750run_test "Extended Master Secret: client disabled, server enabled" \
751 "$P_SRV debug_level=3 extended_ms=1" \
752 "$P_CLI debug_level=3 extended_ms=0" \
753 0 \
754 -C "client hello, adding extended_master_secret extension" \
755 -S "found extended master secret extension" \
756 -S "server hello, adding extended master secret extension" \
757 -C "found extended_master_secret extension" \
758 -C "using extended master secret" \
759 -S "using extended master secret"
760
Janos Follath542ee5d2016-03-07 15:57:05 +0000761requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200762run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100763 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200764 "$P_CLI debug_level=3 force_version=ssl3" \
765 0 \
766 -C "client hello, adding extended_master_secret extension" \
767 -S "found extended master secret extension" \
768 -S "server hello, adding extended master secret extension" \
769 -C "found extended_master_secret extension" \
770 -C "using extended master secret" \
771 -S "using extended master secret"
772
Janos Follath542ee5d2016-03-07 15:57:05 +0000773requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200774run_test "Extended Master Secret: client enabled, server SSLv3" \
775 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100776 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200777 0 \
778 -c "client hello, adding extended_master_secret extension" \
779 -s "found extended master secret extension" \
780 -S "server hello, adding extended master secret extension" \
781 -C "found extended_master_secret extension" \
782 -C "using extended master secret" \
783 -S "using extended master secret"
784
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200785# Tests for FALLBACK_SCSV
786
787run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200788 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200789 "$P_CLI debug_level=3 force_version=tls1_1" \
790 0 \
791 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200792 -S "received FALLBACK_SCSV" \
793 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200794 -C "is a fatal alert message (msg 86)"
795
796run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200797 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200798 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
799 0 \
800 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200801 -S "received FALLBACK_SCSV" \
802 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200803 -C "is a fatal alert message (msg 86)"
804
805run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200806 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200807 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200808 1 \
809 -c "adding FALLBACK_SCSV" \
810 -s "received FALLBACK_SCSV" \
811 -s "inapropriate fallback" \
812 -c "is a fatal alert message (msg 86)"
813
814run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200815 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200816 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200817 0 \
818 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200819 -s "received FALLBACK_SCSV" \
820 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200821 -C "is a fatal alert message (msg 86)"
822
823requires_openssl_with_fallback_scsv
824run_test "Fallback SCSV: default, openssl server" \
825 "$O_SRV" \
826 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
827 0 \
828 -C "adding FALLBACK_SCSV" \
829 -C "is a fatal alert message (msg 86)"
830
831requires_openssl_with_fallback_scsv
832run_test "Fallback SCSV: enabled, openssl server" \
833 "$O_SRV" \
834 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
835 1 \
836 -c "adding FALLBACK_SCSV" \
837 -c "is a fatal alert message (msg 86)"
838
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200839requires_openssl_with_fallback_scsv
840run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200841 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200842 "$O_CLI -tls1_1" \
843 0 \
844 -S "received FALLBACK_SCSV" \
845 -S "inapropriate fallback"
846
847requires_openssl_with_fallback_scsv
848run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200849 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200850 "$O_CLI -tls1_1 -fallback_scsv" \
851 1 \
852 -s "received FALLBACK_SCSV" \
853 -s "inapropriate fallback"
854
855requires_openssl_with_fallback_scsv
856run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200857 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200858 "$O_CLI -fallback_scsv" \
859 0 \
860 -s "received FALLBACK_SCSV" \
861 -S "inapropriate fallback"
862
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100863# Tests for CBC 1/n-1 record splitting
864
865run_test "CBC Record splitting: TLS 1.2, no splitting" \
866 "$P_SRV" \
867 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
868 request_size=123 force_version=tls1_2" \
869 0 \
870 -s "Read from client: 123 bytes read" \
871 -S "Read from client: 1 bytes read" \
872 -S "122 bytes read"
873
874run_test "CBC Record splitting: TLS 1.1, no splitting" \
875 "$P_SRV" \
876 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
877 request_size=123 force_version=tls1_1" \
878 0 \
879 -s "Read from client: 123 bytes read" \
880 -S "Read from client: 1 bytes read" \
881 -S "122 bytes read"
882
883run_test "CBC Record splitting: TLS 1.0, splitting" \
884 "$P_SRV" \
885 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
886 request_size=123 force_version=tls1" \
887 0 \
888 -S "Read from client: 123 bytes read" \
889 -s "Read from client: 1 bytes read" \
890 -s "122 bytes read"
891
Janos Follath542ee5d2016-03-07 15:57:05 +0000892requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100893run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100894 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100895 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
896 request_size=123 force_version=ssl3" \
897 0 \
898 -S "Read from client: 123 bytes read" \
899 -s "Read from client: 1 bytes read" \
900 -s "122 bytes read"
901
902run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100903 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100904 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
905 request_size=123 force_version=tls1" \
906 0 \
907 -s "Read from client: 123 bytes read" \
908 -S "Read from client: 1 bytes read" \
909 -S "122 bytes read"
910
911run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
912 "$P_SRV" \
913 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
914 request_size=123 force_version=tls1 recsplit=0" \
915 0 \
916 -s "Read from client: 123 bytes read" \
917 -S "Read from client: 1 bytes read" \
918 -S "122 bytes read"
919
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100920run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
921 "$P_SRV nbio=2" \
922 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
923 request_size=123 force_version=tls1" \
924 0 \
925 -S "Read from client: 123 bytes read" \
926 -s "Read from client: 1 bytes read" \
927 -s "122 bytes read"
928
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100929# Tests for Session Tickets
930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200931run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200932 "$P_SRV debug_level=3 tickets=1" \
933 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100934 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100935 -c "client hello, adding session ticket extension" \
936 -s "found session ticket extension" \
937 -s "server hello, adding session ticket extension" \
938 -c "found session_ticket extension" \
939 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100940 -S "session successfully restored from cache" \
941 -s "session successfully restored from ticket" \
942 -s "a session has been resumed" \
943 -c "a session has been resumed"
944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200945run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200946 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
947 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100948 0 \
949 -c "client hello, adding session ticket extension" \
950 -s "found session ticket extension" \
951 -s "server hello, adding session ticket extension" \
952 -c "found session_ticket extension" \
953 -c "parse new session ticket" \
954 -S "session successfully restored from cache" \
955 -s "session successfully restored from ticket" \
956 -s "a session has been resumed" \
957 -c "a session has been resumed"
958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200959run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200960 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
961 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100962 0 \
963 -c "client hello, adding session ticket extension" \
964 -s "found session ticket extension" \
965 -s "server hello, adding session ticket extension" \
966 -c "found session_ticket extension" \
967 -c "parse new session ticket" \
968 -S "session successfully restored from cache" \
969 -S "session successfully restored from ticket" \
970 -S "a session has been resumed" \
971 -C "a session has been resumed"
972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200973run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100974 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200975 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100976 0 \
977 -c "client hello, adding session ticket extension" \
978 -c "found session_ticket extension" \
979 -c "parse new session ticket" \
980 -c "a session has been resumed"
981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200982run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200983 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200984 "( $O_CLI -sess_out $SESSION; \
985 $O_CLI -sess_in $SESSION; \
986 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100987 0 \
988 -s "found session ticket extension" \
989 -s "server hello, adding session ticket extension" \
990 -S "session successfully restored from cache" \
991 -s "session successfully restored from ticket" \
992 -s "a session has been resumed"
993
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100994# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100995
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200996run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200997 "$P_SRV debug_level=3 tickets=0" \
998 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100999 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001000 -c "client hello, adding session ticket extension" \
1001 -s "found session ticket extension" \
1002 -S "server hello, adding session ticket extension" \
1003 -C "found session_ticket extension" \
1004 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001005 -s "session successfully restored from cache" \
1006 -S "session successfully restored from ticket" \
1007 -s "a session has been resumed" \
1008 -c "a session has been resumed"
1009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001010run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001011 "$P_SRV debug_level=3 tickets=1" \
1012 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001013 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001014 -C "client hello, adding session ticket extension" \
1015 -S "found session ticket extension" \
1016 -S "server hello, adding session ticket extension" \
1017 -C "found session_ticket extension" \
1018 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001019 -s "session successfully restored from cache" \
1020 -S "session successfully restored from ticket" \
1021 -s "a session has been resumed" \
1022 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001024run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001025 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1026 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001027 0 \
1028 -S "session successfully restored from cache" \
1029 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001030 -S "a session has been resumed" \
1031 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001033run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001034 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1035 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001036 0 \
1037 -s "session successfully restored from cache" \
1038 -S "session successfully restored from ticket" \
1039 -s "a session has been resumed" \
1040 -c "a session has been resumed"
1041
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001042run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001043 "$P_SRV debug_level=3 tickets=0" \
1044 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001045 0 \
1046 -s "session successfully restored from cache" \
1047 -S "session successfully restored from ticket" \
1048 -s "a session has been resumed" \
1049 -c "a session has been resumed"
1050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001051run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001052 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1053 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001054 0 \
1055 -S "session successfully restored from cache" \
1056 -S "session successfully restored from ticket" \
1057 -S "a session has been resumed" \
1058 -C "a session has been resumed"
1059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001060run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001061 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1062 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001063 0 \
1064 -s "session successfully restored from cache" \
1065 -S "session successfully restored from ticket" \
1066 -s "a session has been resumed" \
1067 -c "a session has been resumed"
1068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001069run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001070 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001071 "( $O_CLI -sess_out $SESSION; \
1072 $O_CLI -sess_in $SESSION; \
1073 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001074 0 \
1075 -s "found session ticket extension" \
1076 -S "server hello, adding session ticket extension" \
1077 -s "session successfully restored from cache" \
1078 -S "session successfully restored from ticket" \
1079 -s "a session has been resumed"
1080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001081run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001082 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001083 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001084 0 \
1085 -C "found session_ticket extension" \
1086 -C "parse new session ticket" \
1087 -c "a session has been resumed"
1088
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001089# Tests for Max Fragment Length extension
1090
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001091run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001092 "$P_SRV debug_level=3" \
1093 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001094 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001095 -c "Maximum fragment length is 16384" \
1096 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001097 -C "client hello, adding max_fragment_length extension" \
1098 -S "found max fragment length extension" \
1099 -S "server hello, max_fragment_length extension" \
1100 -C "found max_fragment_length extension"
1101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001102run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001103 "$P_SRV debug_level=3" \
1104 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001105 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001106 -c "Maximum fragment length is 4096" \
1107 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001108 -c "client hello, adding max_fragment_length extension" \
1109 -s "found max fragment length extension" \
1110 -s "server hello, max_fragment_length extension" \
1111 -c "found max_fragment_length extension"
1112
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001113run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001114 "$P_SRV debug_level=3 max_frag_len=4096" \
1115 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001116 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001117 -c "Maximum fragment length is 16384" \
1118 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001119 -C "client hello, adding max_fragment_length extension" \
1120 -S "found max fragment length extension" \
1121 -S "server hello, max_fragment_length extension" \
1122 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001124requires_gnutls
1125run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001126 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001127 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001128 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001129 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001130 -c "client hello, adding max_fragment_length extension" \
1131 -c "found max_fragment_length extension"
1132
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001133run_test "Max fragment length: client, message just fits" \
1134 "$P_SRV debug_level=3" \
1135 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1136 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001137 -c "Maximum fragment length is 2048" \
1138 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001139 -c "client hello, adding max_fragment_length extension" \
1140 -s "found max fragment length extension" \
1141 -s "server hello, max_fragment_length extension" \
1142 -c "found max_fragment_length extension" \
1143 -c "2048 bytes written in 1 fragments" \
1144 -s "2048 bytes read"
1145
1146run_test "Max fragment length: client, larger message" \
1147 "$P_SRV debug_level=3" \
1148 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1149 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001150 -c "Maximum fragment length is 2048" \
1151 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001152 -c "client hello, adding max_fragment_length extension" \
1153 -s "found max fragment length extension" \
1154 -s "server hello, max_fragment_length extension" \
1155 -c "found max_fragment_length extension" \
1156 -c "2345 bytes written in 2 fragments" \
1157 -s "2048 bytes read" \
1158 -s "297 bytes read"
1159
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001160run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001161 "$P_SRV debug_level=3 dtls=1" \
1162 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1163 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001164 -c "Maximum fragment length is 2048" \
1165 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001166 -c "client hello, adding max_fragment_length extension" \
1167 -s "found max fragment length extension" \
1168 -s "server hello, max_fragment_length extension" \
1169 -c "found max_fragment_length extension" \
1170 -c "fragment larger than.*maximum"
1171
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001172# Tests for renegotiation
1173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001174run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001175 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001176 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001177 0 \
1178 -C "client hello, adding renegotiation extension" \
1179 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1180 -S "found renegotiation extension" \
1181 -s "server hello, secure renegotiation extension" \
1182 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001183 -C "=> renegotiate" \
1184 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001185 -S "write hello request"
1186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001187run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001188 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001189 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001190 0 \
1191 -c "client hello, adding renegotiation extension" \
1192 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1193 -s "found renegotiation extension" \
1194 -s "server hello, secure renegotiation extension" \
1195 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001196 -c "=> renegotiate" \
1197 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001198 -S "write hello request"
1199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001200run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001201 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001202 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001203 0 \
1204 -c "client hello, adding renegotiation extension" \
1205 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1206 -s "found renegotiation extension" \
1207 -s "server hello, secure renegotiation extension" \
1208 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001209 -c "=> renegotiate" \
1210 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001211 -s "write hello request"
1212
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001213run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001214 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001215 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001216 0 \
1217 -c "client hello, adding renegotiation extension" \
1218 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1219 -s "found renegotiation extension" \
1220 -s "server hello, secure renegotiation extension" \
1221 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001222 -c "=> renegotiate" \
1223 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001224 -s "write hello request"
1225
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001226run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001227 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001228 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001229 1 \
1230 -c "client hello, adding renegotiation extension" \
1231 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1232 -S "found renegotiation extension" \
1233 -s "server hello, secure renegotiation extension" \
1234 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001235 -c "=> renegotiate" \
1236 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001237 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001238 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001239 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001240
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001241run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001242 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001243 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001244 0 \
1245 -C "client hello, adding renegotiation extension" \
1246 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1247 -S "found renegotiation extension" \
1248 -s "server hello, secure renegotiation extension" \
1249 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001250 -C "=> renegotiate" \
1251 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001252 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001253 -S "SSL - An unexpected message was received from our peer" \
1254 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001258 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001259 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001260 0 \
1261 -C "client hello, adding renegotiation extension" \
1262 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1263 -S "found renegotiation extension" \
1264 -s "server hello, secure renegotiation extension" \
1265 -c "found renegotiation extension" \
1266 -C "=> renegotiate" \
1267 -S "=> renegotiate" \
1268 -s "write hello request" \
1269 -S "SSL - An unexpected message was received from our peer" \
1270 -S "failed"
1271
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001272# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001273run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001274 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001275 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001276 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001277 0 \
1278 -C "client hello, adding renegotiation extension" \
1279 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1280 -S "found renegotiation extension" \
1281 -s "server hello, secure renegotiation extension" \
1282 -c "found renegotiation extension" \
1283 -C "=> renegotiate" \
1284 -S "=> renegotiate" \
1285 -s "write hello request" \
1286 -S "SSL - An unexpected message was received from our peer" \
1287 -S "failed"
1288
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001289run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001290 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001291 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001292 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001293 0 \
1294 -C "client hello, adding renegotiation extension" \
1295 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1296 -S "found renegotiation extension" \
1297 -s "server hello, secure renegotiation extension" \
1298 -c "found renegotiation extension" \
1299 -C "=> renegotiate" \
1300 -S "=> renegotiate" \
1301 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001302 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001305 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001306 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001307 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001308 0 \
1309 -c "client hello, adding renegotiation extension" \
1310 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1311 -s "found renegotiation extension" \
1312 -s "server hello, secure renegotiation extension" \
1313 -c "found renegotiation extension" \
1314 -c "=> renegotiate" \
1315 -s "=> renegotiate" \
1316 -s "write hello request" \
1317 -S "SSL - An unexpected message was received from our peer" \
1318 -S "failed"
1319
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001320run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001321 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001322 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1323 0 \
1324 -C "client hello, adding renegotiation extension" \
1325 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1326 -S "found renegotiation extension" \
1327 -s "server hello, secure renegotiation extension" \
1328 -c "found renegotiation extension" \
1329 -S "record counter limit reached: renegotiate" \
1330 -C "=> renegotiate" \
1331 -S "=> renegotiate" \
1332 -S "write hello request" \
1333 -S "SSL - An unexpected message was received from our peer" \
1334 -S "failed"
1335
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001336# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001337run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001338 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001339 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001340 0 \
1341 -c "client hello, adding renegotiation extension" \
1342 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1343 -s "found renegotiation extension" \
1344 -s "server hello, secure renegotiation extension" \
1345 -c "found renegotiation extension" \
1346 -s "record counter limit reached: renegotiate" \
1347 -c "=> renegotiate" \
1348 -s "=> renegotiate" \
1349 -s "write hello request" \
1350 -S "SSL - An unexpected message was received from our peer" \
1351 -S "failed"
1352
1353run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001354 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001355 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001356 0 \
1357 -c "client hello, adding renegotiation extension" \
1358 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1359 -s "found renegotiation extension" \
1360 -s "server hello, secure renegotiation extension" \
1361 -c "found renegotiation extension" \
1362 -s "record counter limit reached: renegotiate" \
1363 -c "=> renegotiate" \
1364 -s "=> renegotiate" \
1365 -s "write hello request" \
1366 -S "SSL - An unexpected message was received from our peer" \
1367 -S "failed"
1368
1369run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001370 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001371 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1372 0 \
1373 -C "client hello, adding renegotiation extension" \
1374 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1375 -S "found renegotiation extension" \
1376 -s "server hello, secure renegotiation extension" \
1377 -c "found renegotiation extension" \
1378 -S "record counter limit reached: renegotiate" \
1379 -C "=> renegotiate" \
1380 -S "=> renegotiate" \
1381 -S "write hello request" \
1382 -S "SSL - An unexpected message was received from our peer" \
1383 -S "failed"
1384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001385run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001386 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001387 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001388 0 \
1389 -c "client hello, adding renegotiation extension" \
1390 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1391 -s "found renegotiation extension" \
1392 -s "server hello, secure renegotiation extension" \
1393 -c "found renegotiation extension" \
1394 -c "=> renegotiate" \
1395 -s "=> renegotiate" \
1396 -S "write hello request"
1397
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001398run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001399 "$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 +02001400 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001401 0 \
1402 -c "client hello, adding renegotiation extension" \
1403 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1404 -s "found renegotiation extension" \
1405 -s "server hello, secure renegotiation extension" \
1406 -c "found renegotiation extension" \
1407 -c "=> renegotiate" \
1408 -s "=> renegotiate" \
1409 -s "write hello request"
1410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001411run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001412 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001413 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001414 0 \
1415 -c "client hello, adding renegotiation extension" \
1416 -c "found renegotiation extension" \
1417 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001418 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001419 -C "error" \
1420 -c "HTTP/1.0 200 [Oo][Kk]"
1421
Paul Bakker539d9722015-02-08 16:18:35 +01001422requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001423run_test "Renegotiation: gnutls server strict, client-initiated" \
1424 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001425 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001426 0 \
1427 -c "client hello, adding renegotiation extension" \
1428 -c "found renegotiation extension" \
1429 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001430 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001431 -C "error" \
1432 -c "HTTP/1.0 200 [Oo][Kk]"
1433
Paul Bakker539d9722015-02-08 16:18:35 +01001434requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001435run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1436 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1437 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1438 1 \
1439 -c "client hello, adding renegotiation extension" \
1440 -C "found renegotiation extension" \
1441 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001442 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001443 -c "error" \
1444 -C "HTTP/1.0 200 [Oo][Kk]"
1445
Paul Bakker539d9722015-02-08 16:18:35 +01001446requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001447run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1448 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1449 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1450 allow_legacy=0" \
1451 1 \
1452 -c "client hello, adding renegotiation extension" \
1453 -C "found renegotiation extension" \
1454 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001455 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001456 -c "error" \
1457 -C "HTTP/1.0 200 [Oo][Kk]"
1458
Paul Bakker539d9722015-02-08 16:18:35 +01001459requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001460run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1461 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1462 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1463 allow_legacy=1" \
1464 0 \
1465 -c "client hello, adding renegotiation extension" \
1466 -C "found renegotiation extension" \
1467 -c "=> renegotiate" \
1468 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001469 -C "error" \
1470 -c "HTTP/1.0 200 [Oo][Kk]"
1471
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001472run_test "Renegotiation: DTLS, client-initiated" \
1473 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1474 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1475 0 \
1476 -c "client hello, adding renegotiation extension" \
1477 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1478 -s "found renegotiation extension" \
1479 -s "server hello, secure renegotiation extension" \
1480 -c "found renegotiation extension" \
1481 -c "=> renegotiate" \
1482 -s "=> renegotiate" \
1483 -S "write hello request"
1484
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001485run_test "Renegotiation: DTLS, server-initiated" \
1486 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001487 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1488 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001489 0 \
1490 -c "client hello, adding renegotiation extension" \
1491 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1492 -s "found renegotiation extension" \
1493 -s "server hello, secure renegotiation extension" \
1494 -c "found renegotiation extension" \
1495 -c "=> renegotiate" \
1496 -s "=> renegotiate" \
1497 -s "write hello request"
1498
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001499requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001500run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1501 "$G_SRV -u --mtu 4096" \
1502 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1503 0 \
1504 -c "client hello, adding renegotiation extension" \
1505 -c "found renegotiation extension" \
1506 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001507 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001508 -C "error" \
1509 -s "Extra-header:"
1510
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001511# Test for the "secure renegotation" extension only (no actual renegotiation)
1512
Paul Bakker539d9722015-02-08 16:18:35 +01001513requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001514run_test "Renego ext: gnutls server strict, client default" \
1515 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1516 "$P_CLI debug_level=3" \
1517 0 \
1518 -c "found renegotiation extension" \
1519 -C "error" \
1520 -c "HTTP/1.0 200 [Oo][Kk]"
1521
Paul Bakker539d9722015-02-08 16:18:35 +01001522requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001523run_test "Renego ext: gnutls server unsafe, client default" \
1524 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1525 "$P_CLI debug_level=3" \
1526 0 \
1527 -C "found renegotiation extension" \
1528 -C "error" \
1529 -c "HTTP/1.0 200 [Oo][Kk]"
1530
Paul Bakker539d9722015-02-08 16:18:35 +01001531requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001532run_test "Renego ext: gnutls server unsafe, client break legacy" \
1533 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1534 "$P_CLI debug_level=3 allow_legacy=-1" \
1535 1 \
1536 -C "found renegotiation extension" \
1537 -c "error" \
1538 -C "HTTP/1.0 200 [Oo][Kk]"
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 strict, server default" \
1542 "$P_SRV debug_level=3" \
1543 "$G_CLI --priority=NORMAL:%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 default" \
1550 "$P_SRV debug_level=3" \
1551 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1552 0 \
1553 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1554 -S "server hello, secure renegotiation extension"
1555
Paul Bakker539d9722015-02-08 16:18:35 +01001556requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001557run_test "Renego ext: gnutls client unsafe, server break legacy" \
1558 "$P_SRV debug_level=3 allow_legacy=-1" \
1559 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1560 1 \
1561 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1562 -S "server hello, secure renegotiation extension"
1563
Janos Follath365b2262016-02-17 10:11:21 +00001564# Tests for silently dropping trailing extra bytes in .der certificates
1565
1566requires_gnutls
1567run_test "DER format: no trailing bytes" \
1568 "$P_SRV crt_file=data_files/server5-der0.crt \
1569 key_file=data_files/server5.key" \
1570 "$G_CLI " \
1571 0 \
1572 -c "Handshake was completed" \
1573
1574requires_gnutls
1575run_test "DER format: with a trailing zero byte" \
1576 "$P_SRV crt_file=data_files/server5-der1a.crt \
1577 key_file=data_files/server5.key" \
1578 "$G_CLI " \
1579 0 \
1580 -c "Handshake was completed" \
1581
1582requires_gnutls
1583run_test "DER format: with a trailing random byte" \
1584 "$P_SRV crt_file=data_files/server5-der1b.crt \
1585 key_file=data_files/server5.key" \
1586 "$G_CLI " \
1587 0 \
1588 -c "Handshake was completed" \
1589
1590requires_gnutls
1591run_test "DER format: with 2 trailing random bytes" \
1592 "$P_SRV crt_file=data_files/server5-der2.crt \
1593 key_file=data_files/server5.key" \
1594 "$G_CLI " \
1595 0 \
1596 -c "Handshake was completed" \
1597
1598requires_gnutls
1599run_test "DER format: with 4 trailing random bytes" \
1600 "$P_SRV crt_file=data_files/server5-der4.crt \
1601 key_file=data_files/server5.key" \
1602 "$G_CLI " \
1603 0 \
1604 -c "Handshake was completed" \
1605
1606requires_gnutls
1607run_test "DER format: with 8 trailing random bytes" \
1608 "$P_SRV crt_file=data_files/server5-der8.crt \
1609 key_file=data_files/server5.key" \
1610 "$G_CLI " \
1611 0 \
1612 -c "Handshake was completed" \
1613
1614requires_gnutls
1615run_test "DER format: with 9 trailing random bytes" \
1616 "$P_SRV crt_file=data_files/server5-der9.crt \
1617 key_file=data_files/server5.key" \
1618 "$G_CLI " \
1619 0 \
1620 -c "Handshake was completed" \
1621
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001622# Tests for auth_mode
1623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001624run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001625 "$P_SRV crt_file=data_files/server5-badsign.crt \
1626 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001627 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001628 1 \
1629 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001630 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001631 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001632 -c "X509 - Certificate verification failed"
1633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001634run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001635 "$P_SRV crt_file=data_files/server5-badsign.crt \
1636 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001637 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001638 0 \
1639 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001640 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001641 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001642 -C "X509 - Certificate verification failed"
1643
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001644run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001645 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001646 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001647 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001648 0 \
1649 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001650 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001651 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001652 -C "X509 - Certificate verification failed"
1653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001654run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001655 "$P_SRV debug_level=3 auth_mode=required" \
1656 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001657 key_file=data_files/server5.key" \
1658 1 \
1659 -S "skip write certificate request" \
1660 -C "skip parse certificate request" \
1661 -c "got a certificate request" \
1662 -C "skip write certificate" \
1663 -C "skip write certificate verify" \
1664 -S "skip parse certificate verify" \
1665 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001666 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001667 -s "! mbedtls_ssl_handshake returned" \
1668 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001669 -s "X509 - Certificate verification failed"
1670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001671run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001672 "$P_SRV debug_level=3 auth_mode=optional" \
1673 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001674 key_file=data_files/server5.key" \
1675 0 \
1676 -S "skip write certificate request" \
1677 -C "skip parse certificate request" \
1678 -c "got a certificate request" \
1679 -C "skip write certificate" \
1680 -C "skip write certificate verify" \
1681 -S "skip parse certificate verify" \
1682 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001683 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001684 -S "! mbedtls_ssl_handshake returned" \
1685 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001686 -S "X509 - Certificate verification failed"
1687
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001688run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001689 "$P_SRV debug_level=3 auth_mode=none" \
1690 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001691 key_file=data_files/server5.key" \
1692 0 \
1693 -s "skip write certificate request" \
1694 -C "skip parse certificate request" \
1695 -c "got no certificate request" \
1696 -c "skip write certificate" \
1697 -c "skip write certificate verify" \
1698 -s "skip parse certificate verify" \
1699 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001700 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001701 -S "! mbedtls_ssl_handshake returned" \
1702 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001703 -S "X509 - Certificate verification failed"
1704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001705run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001706 "$P_SRV debug_level=3 auth_mode=optional" \
1707 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001708 0 \
1709 -S "skip write certificate request" \
1710 -C "skip parse certificate request" \
1711 -c "got a certificate request" \
1712 -C "skip write certificate$" \
1713 -C "got no certificate to send" \
1714 -S "SSLv3 client has no certificate" \
1715 -c "skip write certificate verify" \
1716 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001717 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001718 -S "! mbedtls_ssl_handshake returned" \
1719 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001720 -S "X509 - Certificate verification failed"
1721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001722run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001723 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001724 "$O_CLI" \
1725 0 \
1726 -S "skip write certificate request" \
1727 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001728 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001729 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001730 -S "X509 - Certificate verification failed"
1731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001732run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001733 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001734 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001735 0 \
1736 -C "skip parse certificate request" \
1737 -c "got a certificate request" \
1738 -C "skip write certificate$" \
1739 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001740 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001741
Janos Follath542ee5d2016-03-07 15:57:05 +00001742requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001743run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001744 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001745 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001746 0 \
1747 -S "skip write certificate request" \
1748 -C "skip parse certificate request" \
1749 -c "got a certificate request" \
1750 -C "skip write certificate$" \
1751 -c "skip write certificate verify" \
1752 -c "got no certificate to send" \
1753 -s "SSLv3 client has no certificate" \
1754 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001755 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001756 -S "! mbedtls_ssl_handshake returned" \
1757 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001758 -S "X509 - Certificate verification failed"
1759
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001760# Tests for certificate selection based on SHA verson
1761
1762run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1763 "$P_SRV crt_file=data_files/server5.crt \
1764 key_file=data_files/server5.key \
1765 crt_file2=data_files/server5-sha1.crt \
1766 key_file2=data_files/server5.key" \
1767 "$P_CLI force_version=tls1_2" \
1768 0 \
1769 -c "signed using.*ECDSA with SHA256" \
1770 -C "signed using.*ECDSA with SHA1"
1771
1772run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1773 "$P_SRV crt_file=data_files/server5.crt \
1774 key_file=data_files/server5.key \
1775 crt_file2=data_files/server5-sha1.crt \
1776 key_file2=data_files/server5.key" \
1777 "$P_CLI force_version=tls1_1" \
1778 0 \
1779 -C "signed using.*ECDSA with SHA256" \
1780 -c "signed using.*ECDSA with SHA1"
1781
1782run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1783 "$P_SRV crt_file=data_files/server5.crt \
1784 key_file=data_files/server5.key \
1785 crt_file2=data_files/server5-sha1.crt \
1786 key_file2=data_files/server5.key" \
1787 "$P_CLI force_version=tls1" \
1788 0 \
1789 -C "signed using.*ECDSA with SHA256" \
1790 -c "signed using.*ECDSA with SHA1"
1791
1792run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1793 "$P_SRV crt_file=data_files/server5.crt \
1794 key_file=data_files/server5.key \
1795 crt_file2=data_files/server6.crt \
1796 key_file2=data_files/server6.key" \
1797 "$P_CLI force_version=tls1_1" \
1798 0 \
1799 -c "serial number.*09" \
1800 -c "signed using.*ECDSA with SHA256" \
1801 -C "signed using.*ECDSA with SHA1"
1802
1803run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1804 "$P_SRV crt_file=data_files/server6.crt \
1805 key_file=data_files/server6.key \
1806 crt_file2=data_files/server5.crt \
1807 key_file2=data_files/server5.key" \
1808 "$P_CLI force_version=tls1_1" \
1809 0 \
1810 -c "serial number.*0A" \
1811 -c "signed using.*ECDSA with SHA256" \
1812 -C "signed using.*ECDSA with SHA1"
1813
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001814# tests for SNI
1815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001816run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001817 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001818 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001819 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001820 0 \
1821 -S "parse ServerName extension" \
1822 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1823 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001825run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001826 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001827 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001828 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 +02001829 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001830 0 \
1831 -s "parse ServerName extension" \
1832 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1833 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001835run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001836 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001837 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001838 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 +02001839 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001840 0 \
1841 -s "parse ServerName extension" \
1842 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1843 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001845run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001846 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001847 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001848 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 +02001849 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001850 1 \
1851 -s "parse ServerName extension" \
1852 -s "ssl_sni_wrapper() returned" \
1853 -s "mbedtls_ssl_handshake returned" \
1854 -c "mbedtls_ssl_handshake returned" \
1855 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001856
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001857run_test "SNI: client auth no override: optional" \
1858 "$P_SRV debug_level=3 auth_mode=optional \
1859 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1860 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1861 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001862 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001863 -S "skip write certificate request" \
1864 -C "skip parse certificate request" \
1865 -c "got a certificate request" \
1866 -C "skip write certificate" \
1867 -C "skip write certificate verify" \
1868 -S "skip parse certificate verify"
1869
1870run_test "SNI: client auth override: none -> optional" \
1871 "$P_SRV debug_level=3 auth_mode=none \
1872 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1873 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1874 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001875 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001876 -S "skip write certificate request" \
1877 -C "skip parse certificate request" \
1878 -c "got a certificate request" \
1879 -C "skip write certificate" \
1880 -C "skip write certificate verify" \
1881 -S "skip parse certificate verify"
1882
1883run_test "SNI: client auth override: optional -> none" \
1884 "$P_SRV debug_level=3 auth_mode=optional \
1885 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1886 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1887 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001888 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001889 -s "skip write certificate request" \
1890 -C "skip parse certificate request" \
1891 -c "got no certificate request" \
1892 -c "skip write certificate" \
1893 -c "skip write certificate verify" \
1894 -s "skip parse certificate verify"
1895
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001896run_test "SNI: CA no override" \
1897 "$P_SRV debug_level=3 auth_mode=optional \
1898 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1899 ca_file=data_files/test-ca.crt \
1900 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1901 "$P_CLI debug_level=3 server_name=localhost \
1902 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1903 1 \
1904 -S "skip write certificate request" \
1905 -C "skip parse certificate request" \
1906 -c "got a certificate request" \
1907 -C "skip write certificate" \
1908 -C "skip write certificate verify" \
1909 -S "skip parse certificate verify" \
1910 -s "x509_verify_cert() returned" \
1911 -s "! The certificate is not correctly signed by the trusted CA" \
1912 -S "The certificate has been revoked (is on a CRL)"
1913
1914run_test "SNI: CA override" \
1915 "$P_SRV debug_level=3 auth_mode=optional \
1916 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1917 ca_file=data_files/test-ca.crt \
1918 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1919 "$P_CLI debug_level=3 server_name=localhost \
1920 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1921 0 \
1922 -S "skip write certificate request" \
1923 -C "skip parse certificate request" \
1924 -c "got a certificate request" \
1925 -C "skip write certificate" \
1926 -C "skip write certificate verify" \
1927 -S "skip parse certificate verify" \
1928 -S "x509_verify_cert() returned" \
1929 -S "! The certificate is not correctly signed by the trusted CA" \
1930 -S "The certificate has been revoked (is on a CRL)"
1931
1932run_test "SNI: CA override with CRL" \
1933 "$P_SRV debug_level=3 auth_mode=optional \
1934 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1935 ca_file=data_files/test-ca.crt \
1936 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1937 "$P_CLI debug_level=3 server_name=localhost \
1938 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1939 1 \
1940 -S "skip write certificate request" \
1941 -C "skip parse certificate request" \
1942 -c "got a certificate request" \
1943 -C "skip write certificate" \
1944 -C "skip write certificate verify" \
1945 -S "skip parse certificate verify" \
1946 -s "x509_verify_cert() returned" \
1947 -S "! The certificate is not correctly signed by the trusted CA" \
1948 -s "The certificate has been revoked (is on a CRL)"
1949
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001950# Tests for non-blocking I/O: exercise a variety of handshake flows
1951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001952run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001953 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1954 "$P_CLI nbio=2 tickets=0" \
1955 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001956 -S "mbedtls_ssl_handshake returned" \
1957 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001958 -c "Read from server: .* bytes read"
1959
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001960run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001961 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1962 "$P_CLI nbio=2 tickets=0" \
1963 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001964 -S "mbedtls_ssl_handshake returned" \
1965 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001966 -c "Read from server: .* bytes read"
1967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001968run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001969 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1970 "$P_CLI nbio=2 tickets=1" \
1971 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001972 -S "mbedtls_ssl_handshake returned" \
1973 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001974 -c "Read from server: .* bytes read"
1975
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001976run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001977 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1978 "$P_CLI nbio=2 tickets=1" \
1979 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001980 -S "mbedtls_ssl_handshake returned" \
1981 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001982 -c "Read from server: .* bytes read"
1983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001984run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001985 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1986 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1987 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001988 -S "mbedtls_ssl_handshake returned" \
1989 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001990 -c "Read from server: .* bytes read"
1991
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001992run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001993 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1994 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1995 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001996 -S "mbedtls_ssl_handshake returned" \
1997 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001998 -c "Read from server: .* bytes read"
1999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002000run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002001 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2002 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2003 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002004 -S "mbedtls_ssl_handshake returned" \
2005 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002006 -c "Read from server: .* bytes read"
2007
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002008# Tests for version negotiation
2009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002010run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002011 "$P_SRV" \
2012 "$P_CLI" \
2013 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002014 -S "mbedtls_ssl_handshake returned" \
2015 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002016 -s "Protocol is TLSv1.2" \
2017 -c "Protocol is TLSv1.2"
2018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002019run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002020 "$P_SRV" \
2021 "$P_CLI max_version=tls1_1" \
2022 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002023 -S "mbedtls_ssl_handshake returned" \
2024 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002025 -s "Protocol is TLSv1.1" \
2026 -c "Protocol is TLSv1.1"
2027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002028run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002029 "$P_SRV max_version=tls1_1" \
2030 "$P_CLI" \
2031 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002032 -S "mbedtls_ssl_handshake returned" \
2033 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002034 -s "Protocol is TLSv1.1" \
2035 -c "Protocol is TLSv1.1"
2036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002037run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002038 "$P_SRV max_version=tls1_1" \
2039 "$P_CLI max_version=tls1_1" \
2040 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002041 -S "mbedtls_ssl_handshake returned" \
2042 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002043 -s "Protocol is TLSv1.1" \
2044 -c "Protocol is TLSv1.1"
2045
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002046run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002047 "$P_SRV min_version=tls1_1" \
2048 "$P_CLI max_version=tls1_1" \
2049 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002050 -S "mbedtls_ssl_handshake returned" \
2051 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002052 -s "Protocol is TLSv1.1" \
2053 -c "Protocol is TLSv1.1"
2054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002055run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002056 "$P_SRV max_version=tls1_1" \
2057 "$P_CLI min_version=tls1_1" \
2058 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002059 -S "mbedtls_ssl_handshake returned" \
2060 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002061 -s "Protocol is TLSv1.1" \
2062 -c "Protocol is TLSv1.1"
2063
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002064run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002065 "$P_SRV max_version=tls1_1" \
2066 "$P_CLI min_version=tls1_2" \
2067 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002068 -s "mbedtls_ssl_handshake returned" \
2069 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002070 -c "SSL - Handshake protocol not within min/max boundaries"
2071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002072run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002073 "$P_SRV min_version=tls1_2" \
2074 "$P_CLI max_version=tls1_1" \
2075 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002076 -s "mbedtls_ssl_handshake returned" \
2077 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002078 -s "SSL - Handshake protocol not within min/max boundaries"
2079
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002080# Tests for ALPN extension
2081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002082run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002083 "$P_SRV debug_level=3" \
2084 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002085 0 \
2086 -C "client hello, adding alpn extension" \
2087 -S "found alpn extension" \
2088 -C "got an alert message, type: \\[2:120]" \
2089 -S "server hello, adding alpn extension" \
2090 -C "found alpn extension " \
2091 -C "Application Layer Protocol is" \
2092 -S "Application Layer Protocol is"
2093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002094run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002095 "$P_SRV debug_level=3" \
2096 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002097 0 \
2098 -c "client hello, adding alpn extension" \
2099 -s "found alpn extension" \
2100 -C "got an alert message, type: \\[2:120]" \
2101 -S "server hello, adding alpn extension" \
2102 -C "found alpn extension " \
2103 -c "Application Layer Protocol is (none)" \
2104 -S "Application Layer Protocol is"
2105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002106run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002107 "$P_SRV debug_level=3 alpn=abc,1234" \
2108 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002109 0 \
2110 -C "client hello, adding alpn extension" \
2111 -S "found alpn extension" \
2112 -C "got an alert message, type: \\[2:120]" \
2113 -S "server hello, adding alpn extension" \
2114 -C "found alpn extension " \
2115 -C "Application Layer Protocol is" \
2116 -s "Application Layer Protocol is (none)"
2117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002118run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002119 "$P_SRV debug_level=3 alpn=abc,1234" \
2120 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002121 0 \
2122 -c "client hello, adding alpn extension" \
2123 -s "found alpn extension" \
2124 -C "got an alert message, type: \\[2:120]" \
2125 -s "server hello, adding alpn extension" \
2126 -c "found alpn extension" \
2127 -c "Application Layer Protocol is abc" \
2128 -s "Application Layer Protocol is abc"
2129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002130run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002131 "$P_SRV debug_level=3 alpn=abc,1234" \
2132 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002133 0 \
2134 -c "client hello, adding alpn extension" \
2135 -s "found alpn extension" \
2136 -C "got an alert message, type: \\[2:120]" \
2137 -s "server hello, adding alpn extension" \
2138 -c "found alpn extension" \
2139 -c "Application Layer Protocol is abc" \
2140 -s "Application Layer Protocol is abc"
2141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002142run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002143 "$P_SRV debug_level=3 alpn=abc,1234" \
2144 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002145 0 \
2146 -c "client hello, adding alpn extension" \
2147 -s "found alpn extension" \
2148 -C "got an alert message, type: \\[2:120]" \
2149 -s "server hello, adding alpn extension" \
2150 -c "found alpn extension" \
2151 -c "Application Layer Protocol is 1234" \
2152 -s "Application Layer Protocol is 1234"
2153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002154run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002155 "$P_SRV debug_level=3 alpn=abc,123" \
2156 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002157 1 \
2158 -c "client hello, adding alpn extension" \
2159 -s "found alpn extension" \
2160 -c "got an alert message, type: \\[2:120]" \
2161 -S "server hello, adding alpn extension" \
2162 -C "found alpn extension" \
2163 -C "Application Layer Protocol is 1234" \
2164 -S "Application Layer Protocol is 1234"
2165
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002166
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002167# Tests for keyUsage in leaf certificates, part 1:
2168# server-side certificate/suite selection
2169
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002170run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002171 "$P_SRV key_file=data_files/server2.key \
2172 crt_file=data_files/server2.ku-ds.crt" \
2173 "$P_CLI" \
2174 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002175 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002176
2177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002178run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002179 "$P_SRV key_file=data_files/server2.key \
2180 crt_file=data_files/server2.ku-ke.crt" \
2181 "$P_CLI" \
2182 0 \
2183 -c "Ciphersuite is TLS-RSA-WITH-"
2184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002185run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002186 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002187 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002188 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002189 1 \
2190 -C "Ciphersuite is "
2191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002192run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002193 "$P_SRV key_file=data_files/server5.key \
2194 crt_file=data_files/server5.ku-ds.crt" \
2195 "$P_CLI" \
2196 0 \
2197 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2198
2199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002200run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002201 "$P_SRV key_file=data_files/server5.key \
2202 crt_file=data_files/server5.ku-ka.crt" \
2203 "$P_CLI" \
2204 0 \
2205 -c "Ciphersuite is TLS-ECDH-"
2206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002207run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002208 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002209 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002210 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002211 1 \
2212 -C "Ciphersuite is "
2213
2214# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002215# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002216
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002217run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002218 "$O_SRV -key data_files/server2.key \
2219 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002220 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002221 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2222 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002223 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002224 -C "Processing of the Certificate handshake message failed" \
2225 -c "Ciphersuite is TLS-"
2226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002227run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002228 "$O_SRV -key data_files/server2.key \
2229 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002230 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002231 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2232 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002233 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002234 -C "Processing of the Certificate handshake message failed" \
2235 -c "Ciphersuite is TLS-"
2236
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002237run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002238 "$O_SRV -key data_files/server2.key \
2239 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002240 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002241 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2242 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002243 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002244 -C "Processing of the Certificate handshake message failed" \
2245 -c "Ciphersuite is TLS-"
2246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002247run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002248 "$O_SRV -key data_files/server2.key \
2249 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002250 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002251 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2252 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002253 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002254 -c "Processing of the Certificate handshake message failed" \
2255 -C "Ciphersuite is TLS-"
2256
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002257run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2258 "$O_SRV -key data_files/server2.key \
2259 -cert data_files/server2.ku-ke.crt" \
2260 "$P_CLI debug_level=1 auth_mode=optional \
2261 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2262 0 \
2263 -c "bad certificate (usage extensions)" \
2264 -C "Processing of the Certificate handshake message failed" \
2265 -c "Ciphersuite is TLS-" \
2266 -c "! Usage does not match the keyUsage extension"
2267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002268run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002269 "$O_SRV -key data_files/server2.key \
2270 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002271 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002272 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2273 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002274 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002275 -C "Processing of the Certificate handshake message failed" \
2276 -c "Ciphersuite is TLS-"
2277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002278run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002279 "$O_SRV -key data_files/server2.key \
2280 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002281 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002282 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2283 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002284 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002285 -c "Processing of the Certificate handshake message failed" \
2286 -C "Ciphersuite is TLS-"
2287
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002288run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2289 "$O_SRV -key data_files/server2.key \
2290 -cert data_files/server2.ku-ds.crt" \
2291 "$P_CLI debug_level=1 auth_mode=optional \
2292 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2293 0 \
2294 -c "bad certificate (usage extensions)" \
2295 -C "Processing of the Certificate handshake message failed" \
2296 -c "Ciphersuite is TLS-" \
2297 -c "! Usage does not match the keyUsage extension"
2298
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002299# Tests for keyUsage in leaf certificates, part 3:
2300# server-side checking of client cert
2301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002302run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002303 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002304 "$O_CLI -key data_files/server2.key \
2305 -cert data_files/server2.ku-ds.crt" \
2306 0 \
2307 -S "bad certificate (usage extensions)" \
2308 -S "Processing of the Certificate handshake message failed"
2309
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002310run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002311 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002312 "$O_CLI -key data_files/server2.key \
2313 -cert data_files/server2.ku-ke.crt" \
2314 0 \
2315 -s "bad certificate (usage extensions)" \
2316 -S "Processing of the Certificate handshake message failed"
2317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002318run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002319 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002320 "$O_CLI -key data_files/server2.key \
2321 -cert data_files/server2.ku-ke.crt" \
2322 1 \
2323 -s "bad certificate (usage extensions)" \
2324 -s "Processing of the Certificate handshake message failed"
2325
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002326run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002327 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002328 "$O_CLI -key data_files/server5.key \
2329 -cert data_files/server5.ku-ds.crt" \
2330 0 \
2331 -S "bad certificate (usage extensions)" \
2332 -S "Processing of the Certificate handshake message failed"
2333
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002334run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002335 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002336 "$O_CLI -key data_files/server5.key \
2337 -cert data_files/server5.ku-ka.crt" \
2338 0 \
2339 -s "bad certificate (usage extensions)" \
2340 -S "Processing of the Certificate handshake message failed"
2341
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002342# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2343
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002344run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002345 "$P_SRV key_file=data_files/server5.key \
2346 crt_file=data_files/server5.eku-srv.crt" \
2347 "$P_CLI" \
2348 0
2349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002350run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002351 "$P_SRV key_file=data_files/server5.key \
2352 crt_file=data_files/server5.eku-srv.crt" \
2353 "$P_CLI" \
2354 0
2355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002356run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002357 "$P_SRV key_file=data_files/server5.key \
2358 crt_file=data_files/server5.eku-cs_any.crt" \
2359 "$P_CLI" \
2360 0
2361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002362run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002363 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002364 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002365 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002366 1
2367
2368# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002370run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002371 "$O_SRV -key data_files/server5.key \
2372 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002373 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002374 0 \
2375 -C "bad certificate (usage extensions)" \
2376 -C "Processing of the Certificate handshake message failed" \
2377 -c "Ciphersuite is TLS-"
2378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002379run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002380 "$O_SRV -key data_files/server5.key \
2381 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002382 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002383 0 \
2384 -C "bad certificate (usage extensions)" \
2385 -C "Processing of the Certificate handshake message failed" \
2386 -c "Ciphersuite is TLS-"
2387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002388run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002389 "$O_SRV -key data_files/server5.key \
2390 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002391 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002392 0 \
2393 -C "bad certificate (usage extensions)" \
2394 -C "Processing of the Certificate handshake message failed" \
2395 -c "Ciphersuite is TLS-"
2396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002397run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002398 "$O_SRV -key data_files/server5.key \
2399 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002400 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002401 1 \
2402 -c "bad certificate (usage extensions)" \
2403 -c "Processing of the Certificate handshake message failed" \
2404 -C "Ciphersuite is TLS-"
2405
2406# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002408run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002409 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002410 "$O_CLI -key data_files/server5.key \
2411 -cert data_files/server5.eku-cli.crt" \
2412 0 \
2413 -S "bad certificate (usage extensions)" \
2414 -S "Processing of the Certificate handshake message failed"
2415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002416run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002417 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002418 "$O_CLI -key data_files/server5.key \
2419 -cert data_files/server5.eku-srv_cli.crt" \
2420 0 \
2421 -S "bad certificate (usage extensions)" \
2422 -S "Processing of the Certificate handshake message failed"
2423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002424run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002425 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002426 "$O_CLI -key data_files/server5.key \
2427 -cert data_files/server5.eku-cs_any.crt" \
2428 0 \
2429 -S "bad certificate (usage extensions)" \
2430 -S "Processing of the Certificate handshake message failed"
2431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002432run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002433 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002434 "$O_CLI -key data_files/server5.key \
2435 -cert data_files/server5.eku-cs.crt" \
2436 0 \
2437 -s "bad certificate (usage extensions)" \
2438 -S "Processing of the Certificate handshake message failed"
2439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002440run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002441 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002442 "$O_CLI -key data_files/server5.key \
2443 -cert data_files/server5.eku-cs.crt" \
2444 1 \
2445 -s "bad certificate (usage extensions)" \
2446 -s "Processing of the Certificate handshake message failed"
2447
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002448# Tests for DHM parameters loading
2449
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002450run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002451 "$P_SRV" \
2452 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2453 debug_level=3" \
2454 0 \
2455 -c "value of 'DHM: P ' (2048 bits)" \
2456 -c "value of 'DHM: G ' (2048 bits)"
2457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002458run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002459 "$P_SRV dhm_file=data_files/dhparams.pem" \
2460 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2461 debug_level=3" \
2462 0 \
2463 -c "value of 'DHM: P ' (1024 bits)" \
2464 -c "value of 'DHM: G ' (2 bits)"
2465
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002466# Tests for DHM client-side size checking
2467
2468run_test "DHM size: server default, client default, OK" \
2469 "$P_SRV" \
2470 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2471 debug_level=1" \
2472 0 \
2473 -C "DHM prime too short:"
2474
2475run_test "DHM size: server default, client 2048, OK" \
2476 "$P_SRV" \
2477 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2478 debug_level=1 dhmlen=2048" \
2479 0 \
2480 -C "DHM prime too short:"
2481
2482run_test "DHM size: server 1024, client default, OK" \
2483 "$P_SRV dhm_file=data_files/dhparams.pem" \
2484 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2485 debug_level=1" \
2486 0 \
2487 -C "DHM prime too short:"
2488
2489run_test "DHM size: server 1000, client default, rejected" \
2490 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2491 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2492 debug_level=1" \
2493 1 \
2494 -c "DHM prime too short:"
2495
2496run_test "DHM size: server default, client 2049, rejected" \
2497 "$P_SRV" \
2498 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2499 debug_level=1 dhmlen=2049" \
2500 1 \
2501 -c "DHM prime too short:"
2502
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002503# Tests for PSK callback
2504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002505run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002506 "$P_SRV psk=abc123 psk_identity=foo" \
2507 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2508 psk_identity=foo psk=abc123" \
2509 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002510 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002511 -S "SSL - Unknown identity received" \
2512 -S "SSL - Verification of the message MAC failed"
2513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002514run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002515 "$P_SRV" \
2516 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2517 psk_identity=foo psk=abc123" \
2518 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002519 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002520 -S "SSL - Unknown identity received" \
2521 -S "SSL - Verification of the message MAC failed"
2522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002523run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002524 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2525 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2526 psk_identity=foo psk=abc123" \
2527 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002528 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002529 -s "SSL - Unknown identity received" \
2530 -S "SSL - Verification of the message MAC failed"
2531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002532run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002533 "$P_SRV psk_list=abc,dead,def,beef" \
2534 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2535 psk_identity=abc psk=dead" \
2536 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002537 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002538 -S "SSL - Unknown identity received" \
2539 -S "SSL - Verification of the message MAC failed"
2540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002541run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002542 "$P_SRV psk_list=abc,dead,def,beef" \
2543 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2544 psk_identity=def psk=beef" \
2545 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002546 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002547 -S "SSL - Unknown identity received" \
2548 -S "SSL - Verification of the message MAC failed"
2549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002550run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002551 "$P_SRV psk_list=abc,dead,def,beef" \
2552 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2553 psk_identity=ghi psk=beef" \
2554 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002555 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002556 -s "SSL - Unknown identity received" \
2557 -S "SSL - Verification of the message MAC failed"
2558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002559run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002560 "$P_SRV psk_list=abc,dead,def,beef" \
2561 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2562 psk_identity=abc psk=beef" \
2563 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002564 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002565 -S "SSL - Unknown identity received" \
2566 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002567
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002568# Tests for ciphersuites per version
2569
Janos Follath542ee5d2016-03-07 15:57:05 +00002570requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002571run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002572 "$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 +02002573 "$P_CLI force_version=ssl3" \
2574 0 \
2575 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002577run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002578 "$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 +01002579 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002580 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002581 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002583run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002584 "$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 +02002585 "$P_CLI force_version=tls1_1" \
2586 0 \
2587 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002589run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002590 "$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 +02002591 "$P_CLI force_version=tls1_2" \
2592 0 \
2593 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2594
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002595# Test for ClientHello without extensions
2596
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002597requires_gnutls
2598run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002599 "$P_SRV debug_level=3" \
2600 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2601 0 \
2602 -s "dumping 'client hello extensions' (0 bytes)"
2603
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002604# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002605
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002606run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002607 "$P_SRV" \
2608 "$P_CLI request_size=100" \
2609 0 \
2610 -s "Read from client: 100 bytes read$"
2611
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002612run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002613 "$P_SRV" \
2614 "$P_CLI request_size=500" \
2615 0 \
2616 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002617
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002618# Tests for small packets
2619
Janos Follath542ee5d2016-03-07 15:57:05 +00002620requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002621run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002622 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002623 "$P_CLI request_size=1 force_version=ssl3 \
2624 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2625 0 \
2626 -s "Read from client: 1 bytes read"
2627
Janos Follath542ee5d2016-03-07 15:57:05 +00002628requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002629run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002630 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002631 "$P_CLI request_size=1 force_version=ssl3 \
2632 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2633 0 \
2634 -s "Read from client: 1 bytes read"
2635
2636run_test "Small packet TLS 1.0 BlockCipher" \
2637 "$P_SRV" \
2638 "$P_CLI request_size=1 force_version=tls1 \
2639 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2640 0 \
2641 -s "Read from client: 1 bytes read"
2642
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002643run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2644 "$P_SRV" \
2645 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2646 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2647 0 \
2648 -s "Read from client: 1 bytes read"
2649
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002650run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2651 "$P_SRV" \
2652 "$P_CLI request_size=1 force_version=tls1 \
2653 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2654 trunc_hmac=1" \
2655 0 \
2656 -s "Read from client: 1 bytes read"
2657
2658run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002659 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002660 "$P_CLI request_size=1 force_version=tls1 \
2661 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2662 trunc_hmac=1" \
2663 0 \
2664 -s "Read from client: 1 bytes read"
2665
2666run_test "Small packet TLS 1.1 BlockCipher" \
2667 "$P_SRV" \
2668 "$P_CLI request_size=1 force_version=tls1_1 \
2669 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2670 0 \
2671 -s "Read from client: 1 bytes read"
2672
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002673run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2674 "$P_SRV" \
2675 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2676 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2677 0 \
2678 -s "Read from client: 1 bytes read"
2679
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002680run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002681 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002682 "$P_CLI request_size=1 force_version=tls1_1 \
2683 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2684 0 \
2685 -s "Read from client: 1 bytes read"
2686
2687run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2688 "$P_SRV" \
2689 "$P_CLI request_size=1 force_version=tls1_1 \
2690 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2691 trunc_hmac=1" \
2692 0 \
2693 -s "Read from client: 1 bytes read"
2694
2695run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002696 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002697 "$P_CLI request_size=1 force_version=tls1_1 \
2698 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2699 trunc_hmac=1" \
2700 0 \
2701 -s "Read from client: 1 bytes read"
2702
2703run_test "Small packet TLS 1.2 BlockCipher" \
2704 "$P_SRV" \
2705 "$P_CLI request_size=1 force_version=tls1_2 \
2706 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2707 0 \
2708 -s "Read from client: 1 bytes read"
2709
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002710run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2711 "$P_SRV" \
2712 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2713 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2714 0 \
2715 -s "Read from client: 1 bytes read"
2716
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002717run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2718 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002719 "$P_CLI request_size=1 force_version=tls1_2 \
2720 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002721 0 \
2722 -s "Read from client: 1 bytes read"
2723
2724run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2725 "$P_SRV" \
2726 "$P_CLI request_size=1 force_version=tls1_2 \
2727 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2728 trunc_hmac=1" \
2729 0 \
2730 -s "Read from client: 1 bytes read"
2731
2732run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002733 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002734 "$P_CLI request_size=1 force_version=tls1_2 \
2735 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2736 0 \
2737 -s "Read from client: 1 bytes read"
2738
2739run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002740 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002741 "$P_CLI request_size=1 force_version=tls1_2 \
2742 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2743 trunc_hmac=1" \
2744 0 \
2745 -s "Read from client: 1 bytes read"
2746
2747run_test "Small packet TLS 1.2 AEAD" \
2748 "$P_SRV" \
2749 "$P_CLI request_size=1 force_version=tls1_2 \
2750 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2751 0 \
2752 -s "Read from client: 1 bytes read"
2753
2754run_test "Small packet TLS 1.2 AEAD shorter tag" \
2755 "$P_SRV" \
2756 "$P_CLI request_size=1 force_version=tls1_2 \
2757 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2758 0 \
2759 -s "Read from client: 1 bytes read"
2760
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002761# Test for large packets
2762
Janos Follath542ee5d2016-03-07 15:57:05 +00002763requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002764run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002765 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002766 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002767 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2768 0 \
2769 -s "Read from client: 16384 bytes read"
2770
Janos Follath542ee5d2016-03-07 15:57:05 +00002771requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002772run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002773 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002774 "$P_CLI request_size=16384 force_version=ssl3 \
2775 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2776 0 \
2777 -s "Read from client: 16384 bytes read"
2778
2779run_test "Large packet TLS 1.0 BlockCipher" \
2780 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002781 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002782 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2783 0 \
2784 -s "Read from client: 16384 bytes read"
2785
2786run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2787 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002788 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002789 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2790 trunc_hmac=1" \
2791 0 \
2792 -s "Read from client: 16384 bytes read"
2793
2794run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002795 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002796 "$P_CLI request_size=16384 force_version=tls1 \
2797 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2798 trunc_hmac=1" \
2799 0 \
2800 -s "Read from client: 16384 bytes read"
2801
2802run_test "Large packet TLS 1.1 BlockCipher" \
2803 "$P_SRV" \
2804 "$P_CLI request_size=16384 force_version=tls1_1 \
2805 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2806 0 \
2807 -s "Read from client: 16384 bytes read"
2808
2809run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002810 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002811 "$P_CLI request_size=16384 force_version=tls1_1 \
2812 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2813 0 \
2814 -s "Read from client: 16384 bytes read"
2815
2816run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2817 "$P_SRV" \
2818 "$P_CLI request_size=16384 force_version=tls1_1 \
2819 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2820 trunc_hmac=1" \
2821 0 \
2822 -s "Read from client: 16384 bytes read"
2823
2824run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002825 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002826 "$P_CLI request_size=16384 force_version=tls1_1 \
2827 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2828 trunc_hmac=1" \
2829 0 \
2830 -s "Read from client: 16384 bytes read"
2831
2832run_test "Large packet TLS 1.2 BlockCipher" \
2833 "$P_SRV" \
2834 "$P_CLI request_size=16384 force_version=tls1_2 \
2835 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2836 0 \
2837 -s "Read from client: 16384 bytes read"
2838
2839run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2840 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002841 "$P_CLI request_size=16384 force_version=tls1_2 \
2842 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002843 0 \
2844 -s "Read from client: 16384 bytes read"
2845
2846run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2847 "$P_SRV" \
2848 "$P_CLI request_size=16384 force_version=tls1_2 \
2849 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2850 trunc_hmac=1" \
2851 0 \
2852 -s "Read from client: 16384 bytes read"
2853
2854run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002855 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002856 "$P_CLI request_size=16384 force_version=tls1_2 \
2857 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2858 0 \
2859 -s "Read from client: 16384 bytes read"
2860
2861run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002862 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002863 "$P_CLI request_size=16384 force_version=tls1_2 \
2864 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2865 trunc_hmac=1" \
2866 0 \
2867 -s "Read from client: 16384 bytes read"
2868
2869run_test "Large packet TLS 1.2 AEAD" \
2870 "$P_SRV" \
2871 "$P_CLI request_size=16384 force_version=tls1_2 \
2872 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2873 0 \
2874 -s "Read from client: 16384 bytes read"
2875
2876run_test "Large packet TLS 1.2 AEAD shorter tag" \
2877 "$P_SRV" \
2878 "$P_CLI request_size=16384 force_version=tls1_2 \
2879 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2880 0 \
2881 -s "Read from client: 16384 bytes read"
2882
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002883# Tests for DTLS HelloVerifyRequest
2884
2885run_test "DTLS cookie: enabled" \
2886 "$P_SRV dtls=1 debug_level=2" \
2887 "$P_CLI dtls=1 debug_level=2" \
2888 0 \
2889 -s "cookie verification failed" \
2890 -s "cookie verification passed" \
2891 -S "cookie verification skipped" \
2892 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002893 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002894 -S "SSL - The requested feature is not available"
2895
2896run_test "DTLS cookie: disabled" \
2897 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2898 "$P_CLI dtls=1 debug_level=2" \
2899 0 \
2900 -S "cookie verification failed" \
2901 -S "cookie verification passed" \
2902 -s "cookie verification skipped" \
2903 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002904 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002905 -S "SSL - The requested feature is not available"
2906
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002907run_test "DTLS cookie: default (failing)" \
2908 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2909 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2910 1 \
2911 -s "cookie verification failed" \
2912 -S "cookie verification passed" \
2913 -S "cookie verification skipped" \
2914 -C "received hello verify request" \
2915 -S "hello verification requested" \
2916 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002917
2918requires_ipv6
2919run_test "DTLS cookie: enabled, IPv6" \
2920 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2921 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2922 0 \
2923 -s "cookie verification failed" \
2924 -s "cookie verification passed" \
2925 -S "cookie verification skipped" \
2926 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002927 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002928 -S "SSL - The requested feature is not available"
2929
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002930run_test "DTLS cookie: enabled, nbio" \
2931 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2932 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2933 0 \
2934 -s "cookie verification failed" \
2935 -s "cookie verification passed" \
2936 -S "cookie verification skipped" \
2937 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002938 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002939 -S "SSL - The requested feature is not available"
2940
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002941# Tests for client reconnecting from the same port with DTLS
2942
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002943not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002944run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002945 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
2946 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002947 0 \
2948 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002949 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002950 -S "Client initiated reconnection from same port"
2951
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002952not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002953run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002954 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
2955 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002956 0 \
2957 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002958 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002959 -s "Client initiated reconnection from same port"
2960
2961run_test "DTLS client reconnect from same port: reconnect, nbio" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002962 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
2963 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002964 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002965 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002966 -s "Client initiated reconnection from same port"
2967
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002968run_test "DTLS client reconnect from same port: no cookies" \
2969 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02002970 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
2971 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002972 -s "The operation timed out" \
2973 -S "Client initiated reconnection from same port"
2974
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002975# Tests for various cases of client authentication with DTLS
2976# (focused on handshake flows and message parsing)
2977
2978run_test "DTLS client auth: required" \
2979 "$P_SRV dtls=1 auth_mode=required" \
2980 "$P_CLI dtls=1" \
2981 0 \
2982 -s "Verifying peer X.509 certificate... ok"
2983
2984run_test "DTLS client auth: optional, client has no cert" \
2985 "$P_SRV dtls=1 auth_mode=optional" \
2986 "$P_CLI dtls=1 crt_file=none key_file=none" \
2987 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002988 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002989
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002990run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002991 "$P_SRV dtls=1 auth_mode=none" \
2992 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2993 0 \
2994 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002995 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002996
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02002997run_test "DTLS wrong PSK: badmac alert" \
2998 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
2999 "$P_CLI dtls=1 psk=abc124" \
3000 1 \
3001 -s "SSL - Verification of the message MAC failed" \
3002 -c "SSL - A fatal alert message was received from our peer"
3003
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003004# Tests for receiving fragmented handshake messages with DTLS
3005
3006requires_gnutls
3007run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3008 "$G_SRV -u --mtu 2048 -a" \
3009 "$P_CLI dtls=1 debug_level=2" \
3010 0 \
3011 -C "found fragmented DTLS handshake message" \
3012 -C "error"
3013
3014requires_gnutls
3015run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3016 "$G_SRV -u --mtu 512" \
3017 "$P_CLI dtls=1 debug_level=2" \
3018 0 \
3019 -c "found fragmented DTLS handshake message" \
3020 -C "error"
3021
3022requires_gnutls
3023run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3024 "$G_SRV -u --mtu 128" \
3025 "$P_CLI dtls=1 debug_level=2" \
3026 0 \
3027 -c "found fragmented DTLS handshake message" \
3028 -C "error"
3029
3030requires_gnutls
3031run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3032 "$G_SRV -u --mtu 128" \
3033 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3034 0 \
3035 -c "found fragmented DTLS handshake message" \
3036 -C "error"
3037
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003038requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003039run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3040 "$G_SRV -u --mtu 256" \
3041 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3042 0 \
3043 -c "found fragmented DTLS handshake message" \
3044 -c "client hello, adding renegotiation extension" \
3045 -c "found renegotiation extension" \
3046 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003047 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003048 -C "error" \
3049 -s "Extra-header:"
3050
3051requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003052run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3053 "$G_SRV -u --mtu 256" \
3054 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3055 0 \
3056 -c "found fragmented DTLS handshake message" \
3057 -c "client hello, adding renegotiation extension" \
3058 -c "found renegotiation extension" \
3059 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003060 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003061 -C "error" \
3062 -s "Extra-header:"
3063
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003064run_test "DTLS reassembly: no fragmentation (openssl server)" \
3065 "$O_SRV -dtls1 -mtu 2048" \
3066 "$P_CLI dtls=1 debug_level=2" \
3067 0 \
3068 -C "found fragmented DTLS handshake message" \
3069 -C "error"
3070
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003071run_test "DTLS reassembly: some fragmentation (openssl server)" \
3072 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003073 "$P_CLI dtls=1 debug_level=2" \
3074 0 \
3075 -c "found fragmented DTLS handshake message" \
3076 -C "error"
3077
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003078run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003079 "$O_SRV -dtls1 -mtu 256" \
3080 "$P_CLI dtls=1 debug_level=2" \
3081 0 \
3082 -c "found fragmented DTLS handshake message" \
3083 -C "error"
3084
3085run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3086 "$O_SRV -dtls1 -mtu 256" \
3087 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3088 0 \
3089 -c "found fragmented DTLS handshake message" \
3090 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003091
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003092# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003093
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003094not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003095run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003096 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003097 "$P_SRV dtls=1 debug_level=2" \
3098 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003099 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003100 -C "replayed record" \
3101 -S "replayed record" \
3102 -C "record from another epoch" \
3103 -S "record from another epoch" \
3104 -C "discarding invalid record" \
3105 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003106 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003107 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003108 -c "HTTP/1.0 200 OK"
3109
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003110not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003111run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003112 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003113 "$P_SRV dtls=1 debug_level=2" \
3114 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003115 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003116 -c "replayed record" \
3117 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003118 -c "discarding invalid record" \
3119 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003120 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003121 -s "Extra-header:" \
3122 -c "HTTP/1.0 200 OK"
3123
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003124run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3125 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003126 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3127 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003128 0 \
3129 -c "replayed record" \
3130 -S "replayed record" \
3131 -c "discarding invalid record" \
3132 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003133 -c "resend" \
3134 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003135 -s "Extra-header:" \
3136 -c "HTTP/1.0 200 OK"
3137
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003138run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003139 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003140 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003141 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003142 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003143 -c "discarding invalid record (mac)" \
3144 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003145 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003146 -c "HTTP/1.0 200 OK" \
3147 -S "too many records with bad MAC" \
3148 -S "Verification of the message MAC failed"
3149
3150run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3151 -p "$P_PXY bad_ad=1" \
3152 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3153 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3154 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003155 -C "discarding invalid record (mac)" \
3156 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003157 -S "Extra-header:" \
3158 -C "HTTP/1.0 200 OK" \
3159 -s "too many records with bad MAC" \
3160 -s "Verification of the message MAC failed"
3161
3162run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3163 -p "$P_PXY bad_ad=1" \
3164 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3165 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3166 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003167 -c "discarding invalid record (mac)" \
3168 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003169 -s "Extra-header:" \
3170 -c "HTTP/1.0 200 OK" \
3171 -S "too many records with bad MAC" \
3172 -S "Verification of the message MAC failed"
3173
3174run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3175 -p "$P_PXY bad_ad=1" \
3176 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3177 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3178 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003179 -c "discarding invalid record (mac)" \
3180 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003181 -s "Extra-header:" \
3182 -c "HTTP/1.0 200 OK" \
3183 -s "too many records with bad MAC" \
3184 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003185
3186run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003187 -p "$P_PXY delay_ccs=1" \
3188 "$P_SRV dtls=1 debug_level=1" \
3189 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003190 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003191 -c "record from another epoch" \
3192 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003193 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003194 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003195 -s "Extra-header:" \
3196 -c "HTTP/1.0 200 OK"
3197
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003198# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003199
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003200needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003201run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003202 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003203 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3204 psk=abc123" \
3205 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003206 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3207 0 \
3208 -s "Extra-header:" \
3209 -c "HTTP/1.0 200 OK"
3210
3211needs_more_time 2
3212run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3213 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003214 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3215 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003216 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3217 0 \
3218 -s "Extra-header:" \
3219 -c "HTTP/1.0 200 OK"
3220
3221needs_more_time 2
3222run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3223 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003224 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3225 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003226 0 \
3227 -s "Extra-header:" \
3228 -c "HTTP/1.0 200 OK"
3229
3230needs_more_time 2
3231run_test "DTLS proxy: 3d, FS, client auth" \
3232 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003233 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3234 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003235 0 \
3236 -s "Extra-header:" \
3237 -c "HTTP/1.0 200 OK"
3238
3239needs_more_time 2
3240run_test "DTLS proxy: 3d, FS, ticket" \
3241 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003242 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3243 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003244 0 \
3245 -s "Extra-header:" \
3246 -c "HTTP/1.0 200 OK"
3247
3248needs_more_time 2
3249run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3250 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003251 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3252 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003253 0 \
3254 -s "Extra-header:" \
3255 -c "HTTP/1.0 200 OK"
3256
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003257needs_more_time 2
3258run_test "DTLS proxy: 3d, max handshake, nbio" \
3259 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003260 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3261 auth_mode=required" \
3262 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003263 0 \
3264 -s "Extra-header:" \
3265 -c "HTTP/1.0 200 OK"
3266
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003267needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003268run_test "DTLS proxy: 3d, min handshake, resumption" \
3269 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3270 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3271 psk=abc123 debug_level=3" \
3272 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3273 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3274 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3275 0 \
3276 -s "a session has been resumed" \
3277 -c "a session has been resumed" \
3278 -s "Extra-header:" \
3279 -c "HTTP/1.0 200 OK"
3280
3281needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003282run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3283 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3284 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3285 psk=abc123 debug_level=3 nbio=2" \
3286 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3287 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3288 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3289 0 \
3290 -s "a session has been resumed" \
3291 -c "a session has been resumed" \
3292 -s "Extra-header:" \
3293 -c "HTTP/1.0 200 OK"
3294
3295needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003296run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003297 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003298 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3299 psk=abc123 renegotiation=1 debug_level=2" \
3300 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3301 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003302 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3303 0 \
3304 -c "=> renegotiate" \
3305 -s "=> renegotiate" \
3306 -s "Extra-header:" \
3307 -c "HTTP/1.0 200 OK"
3308
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003309needs_more_time 4
3310run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3311 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003312 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3313 psk=abc123 renegotiation=1 debug_level=2" \
3314 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3315 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003316 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3317 0 \
3318 -c "=> renegotiate" \
3319 -s "=> renegotiate" \
3320 -s "Extra-header:" \
3321 -c "HTTP/1.0 200 OK"
3322
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003323needs_more_time 4
3324run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003325 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003326 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003327 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003328 debug_level=2" \
3329 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003330 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003331 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3332 0 \
3333 -c "=> renegotiate" \
3334 -s "=> renegotiate" \
3335 -s "Extra-header:" \
3336 -c "HTTP/1.0 200 OK"
3337
3338needs_more_time 4
3339run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003340 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003341 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003342 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003343 debug_level=2 nbio=2" \
3344 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003345 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003346 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3347 0 \
3348 -c "=> renegotiate" \
3349 -s "=> renegotiate" \
3350 -s "Extra-header:" \
3351 -c "HTTP/1.0 200 OK"
3352
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003353needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003354not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003355run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003356 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3357 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003358 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003359 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003360 -c "HTTP/1.0 200 OK"
3361
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003362needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003363not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003364run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3365 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3366 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003367 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003368 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003369 -c "HTTP/1.0 200 OK"
3370
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003371needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003372not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003373run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3374 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3375 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003376 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003377 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003378 -c "HTTP/1.0 200 OK"
3379
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003380requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003381needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003382not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003383run_test "DTLS proxy: 3d, gnutls server" \
3384 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3385 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003386 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003387 0 \
3388 -s "Extra-header:" \
3389 -c "Extra-header:"
3390
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003391requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003392needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003393not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003394run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3395 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3396 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003397 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003398 0 \
3399 -s "Extra-header:" \
3400 -c "Extra-header:"
3401
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003402requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003403needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003404not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003405run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3406 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3407 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003408 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003409 0 \
3410 -s "Extra-header:" \
3411 -c "Extra-header:"
3412
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003413# Final report
3414
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003415echo "------------------------------------------------------------------------"
3416
3417if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003418 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003419else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003420 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003421fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003422PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003423echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003424
3425exit $FAILS