blob: 9f3cbf0ce8ef0c187a943d9eb1d4f84728052554 [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}
Gilles Peskine39e29812017-05-16 17:53:03 +020020: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020022O_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 +010023O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020024G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010025G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskine39e29812017-05-16 17:53:03 +020026TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010027
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028TESTS=0
29FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020030SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010031
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000032CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020033
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010035FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020036EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010037
38print_usage() {
39 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010040 printf " -h|--help\tPrint this help.\n"
41 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
42 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
43 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010044}
45
46get_options() {
47 while [ $# -gt 0 ]; do
48 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010049 -f|--filter)
50 shift; FILTER=$1
51 ;;
52 -e|--exclude)
53 shift; EXCLUDE=$1
54 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010055 -m|--memcheck)
56 MEMCHECK=1
57 ;;
58 -h|--help)
59 print_usage
60 exit 0
61 ;;
62 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020063 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010064 print_usage
65 exit 1
66 ;;
67 esac
68 shift
69 done
70}
71
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010072# skip next test if the flag is not enabled in config.h
73requires_config_enabled() {
74 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
75 SKIP_NEXT="YES"
76 fi
77}
78
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +020079# skip next test if the flag is enabled in config.h
80requires_config_disabled() {
81 if grep "^#define $1" $CONFIG_H > /dev/null; then
82 SKIP_NEXT="YES"
83 fi
84}
85
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020086# skip next test if OpenSSL doesn't support FALLBACK_SCSV
87requires_openssl_with_fallback_scsv() {
88 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
89 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
90 then
91 OPENSSL_HAS_FBSCSV="YES"
92 else
93 OPENSSL_HAS_FBSCSV="NO"
94 fi
95 fi
96 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
97 SKIP_NEXT="YES"
98 fi
99}
100
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200101# skip next test if GnuTLS isn't available
102requires_gnutls() {
103 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200104 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200105 GNUTLS_AVAILABLE="YES"
106 else
107 GNUTLS_AVAILABLE="NO"
108 fi
109 fi
110 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
111 SKIP_NEXT="YES"
112 fi
113}
114
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200115# skip next test if IPv6 isn't available on this host
116requires_ipv6() {
117 if [ -z "${HAS_IPV6:-}" ]; then
118 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
119 SRV_PID=$!
120 sleep 1
121 kill $SRV_PID >/dev/null 2>&1
122 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
123 HAS_IPV6="NO"
124 else
125 HAS_IPV6="YES"
126 fi
127 rm -r $SRV_OUT
128 fi
129
130 if [ "$HAS_IPV6" = "NO" ]; then
131 SKIP_NEXT="YES"
132 fi
133}
134
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200135# skip the next test if valgrind is in use
136not_with_valgrind() {
137 if [ "$MEMCHECK" -gt 0 ]; then
138 SKIP_NEXT="YES"
139 fi
140}
141
Paul Bakker3b224ff2016-05-13 10:33:25 +0100142# skip the next test if valgrind is NOT in use
143only_with_valgrind() {
144 if [ "$MEMCHECK" -eq 0 ]; then
145 SKIP_NEXT="YES"
146 fi
147}
148
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200149# multiply the client timeout delay by the given factor for the next test
150needs_more_time() {
151 CLI_DELAY_FACTOR=$1
152}
153
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100154# print_name <name>
155print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100156 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200157 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100158 for i in `seq 1 $LEN`; do printf '.'; done
159 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100160
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200161 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100162}
163
164# fail <message>
165fail() {
166 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100167 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100168
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200169 mv $SRV_OUT o-srv-${TESTS}.log
170 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200171 if [ -n "$PXY_CMD" ]; then
172 mv $PXY_OUT o-pxy-${TESTS}.log
173 fi
174 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100175
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200176 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
177 echo " ! server output:"
178 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200179 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200180 echo " ! client output:"
181 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200182 if [ -n "$PXY_CMD" ]; then
183 echo " ! ========================================================"
184 echo " ! proxy output:"
185 cat o-pxy-${TESTS}.log
186 fi
187 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200188 fi
189
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200190 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100191}
192
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100193# is_polar <cmd_line>
194is_polar() {
195 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
196}
197
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200198# openssl s_server doesn't have -www with DTLS
199check_osrv_dtls() {
200 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
201 NEEDS_INPUT=1
202 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
203 else
204 NEEDS_INPUT=0
205 fi
206}
207
208# provide input to commands that need it
209provide_input() {
210 if [ $NEEDS_INPUT -eq 0 ]; then
211 return
212 fi
213
214 while true; do
215 echo "HTTP/1.0 200 OK"
216 sleep 1
217 done
218}
219
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100220# has_mem_err <log_file_name>
221has_mem_err() {
222 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
223 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
224 then
225 return 1 # false: does not have errors
226 else
227 return 0 # true: has errors
228 fi
229}
230
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200231# wait for server to start: two versions depending on lsof availability
232wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200233 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200234 START_TIME=$( date +%s )
235 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200236
237 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200238 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200239 while [ $DONE -eq 0 ]; do
240 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
241 then
242 DONE=1
243 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
244 echo "SERVERSTART TIMEOUT"
245 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
246 DONE=1
247 fi
248 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200249 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200250 while [ $DONE -eq 0 ]; do
251 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
252 then
253 DONE=1
254 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
255 echo "SERVERSTART TIMEOUT"
256 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
257 DONE=1
258 fi
259 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200260 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200261 else
262 sleep "$START_DELAY"
263 fi
264}
265
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200266# wait for client to terminate and set CLI_EXIT
267# must be called right after starting the client
268wait_client_done() {
269 CLI_PID=$!
270
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200271 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
272 CLI_DELAY_FACTOR=1
273
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200274 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200275 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200276
277 wait $CLI_PID
278 CLI_EXIT=$?
279
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200280 kill $DOG_PID >/dev/null 2>&1
281 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200282
283 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
284}
285
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200286# check if the given command uses dtls and sets global variable DTLS
287detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200288 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200289 DTLS=1
290 else
291 DTLS=0
292 fi
293}
294
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200295# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100296# Options: -s pattern pattern that must be present in server output
297# -c pattern pattern that must be present in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100298# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299# -S pattern pattern that must be absent in server output
300# -C pattern pattern that must be absent in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100301# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100302run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100303 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200304 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100305
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100306 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
307 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200308 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100309 return
310 fi
311
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100312 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100313
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200314 # should we skip?
315 if [ "X$SKIP_NEXT" = "XYES" ]; then
316 SKIP_NEXT="NO"
317 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200318 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200319 return
320 fi
321
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200322 # does this test use a proxy?
323 if [ "X$1" = "X-p" ]; then
324 PXY_CMD="$2"
325 shift 2
326 else
327 PXY_CMD=""
328 fi
329
330 # get commands and client output
331 SRV_CMD="$1"
332 CLI_CMD="$2"
333 CLI_EXPECT="$3"
334 shift 3
335
336 # fix client port
337 if [ -n "$PXY_CMD" ]; then
338 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
339 else
340 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
341 fi
342
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200343 # update DTLS variable
344 detect_dtls "$SRV_CMD"
345
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100346 # prepend valgrind to our commands if active
347 if [ "$MEMCHECK" -gt 0 ]; then
348 if is_polar "$SRV_CMD"; then
349 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
350 fi
351 if is_polar "$CLI_CMD"; then
352 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
353 fi
354 fi
355
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200356 TIMES_LEFT=2
357 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200358 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200359
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200360 # run the commands
361 if [ -n "$PXY_CMD" ]; then
362 echo "$PXY_CMD" > $PXY_OUT
363 $PXY_CMD >> $PXY_OUT 2>&1 &
364 PXY_PID=$!
365 # assume proxy starts faster than server
366 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200367
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200368 check_osrv_dtls
369 echo "$SRV_CMD" > $SRV_OUT
370 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
371 SRV_PID=$!
372 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200373
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200374 echo "$CLI_CMD" > $CLI_OUT
375 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
376 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100377
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200378 # terminate the server (and the proxy)
379 kill $SRV_PID
380 wait $SRV_PID
381 if [ -n "$PXY_CMD" ]; then
382 kill $PXY_PID >/dev/null 2>&1
383 wait $PXY_PID
384 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100385
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200386 # retry only on timeouts
387 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
388 printf "RETRY "
389 else
390 TIMES_LEFT=0
391 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200392 done
393
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100394 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200395 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100396 # expected client exit to incorrectly succeed in case of catastrophic
397 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100398 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200399 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100400 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100401 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100402 return
403 fi
404 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100405 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200406 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100407 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100408 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100409 return
410 fi
411 fi
412
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100413 # check server exit code
414 if [ $? != 0 ]; then
415 fail "server fail"
416 return
417 fi
418
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100419 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100420 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
421 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100422 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200423 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100424 return
425 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100427 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200428 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100429 while [ $# -gt 0 ]
430 do
431 case $1 in
432 "-s")
Janos Follath6d3e3382016-09-07 15:48:48 +0100433 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
434 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100435 return
436 fi
437 ;;
438
439 "-c")
Janos Follath6d3e3382016-09-07 15:48:48 +0100440 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
441 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100442 return
443 fi
444 ;;
445
446 "-S")
Janos Follath6d3e3382016-09-07 15:48:48 +0100447 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
448 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100449 return
450 fi
451 ;;
452
453 "-C")
Janos Follath6d3e3382016-09-07 15:48:48 +0100454 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
455 fail "pattern '$2' MUST NOT be present in the Client output"
456 return
457 fi
458 ;;
459
460 # The filtering in the following two options (-u and -U) do the following
461 # - ignore valgrind output
462 # - filter out everything but lines right after the pattern occurances
463 # - keep one of each non-unique line
464 # - count how many lines remain
465 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
466 # if there were no duplicates.
467 "-U")
468 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
469 fail "lines following pattern '$2' must be unique in Server output"
470 return
471 fi
472 ;;
473
474 "-u")
475 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
476 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100477 return
478 fi
479 ;;
480
481 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200482 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100483 exit 1
484 esac
485 shift 2
486 done
487
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100488 # check valgrind's results
489 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200490 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100491 fail "Server has memory errors"
492 return
493 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200494 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100495 fail "Client has memory errors"
496 return
497 fi
498 fi
499
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100500 # if we're here, everything is ok
501 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200502 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100503}
504
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100505cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200506 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200507 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
508 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
509 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
510 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100511 exit 1
512}
513
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100514#
515# MAIN
516#
517
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000518if cd $( dirname $0 ); then :; else
519 echo "cd $( dirname $0 ) failed" >&2
520 exit 1
521fi
522
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100523get_options "$@"
524
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100525# sanity checks, avoid an avalanche of errors
526if [ ! -x "$P_SRV" ]; then
527 echo "Command '$P_SRV' is not an executable file"
528 exit 1
529fi
530if [ ! -x "$P_CLI" ]; then
531 echo "Command '$P_CLI' is not an executable file"
532 exit 1
533fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200534if [ ! -x "$P_PXY" ]; then
535 echo "Command '$P_PXY' is not an executable file"
536 exit 1
537fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100538if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
539 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100540 exit 1
541fi
542
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200543# used by watchdog
544MAIN_PID="$$"
545
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200546# be more patient with valgrind
547if [ "$MEMCHECK" -gt 0 ]; then
548 START_DELAY=3
549 DOG_DELAY=30
550else
551 START_DELAY=1
552 DOG_DELAY=10
553fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200554CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200555
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200556# Pick a "unique" server port in the range 10000-19999, and a proxy port
557PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000558PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200559SRV_PORT="1$PORT_BASE"
560PXY_PORT="2$PORT_BASE"
561unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200562
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200563# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000564# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200565P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
566P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
567P_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 +0200568O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200569O_CLI="$O_CLI -connect localhost:+SRV_PORT"
570G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000571G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200572
Gilles Peskine35db5ba2017-05-10 10:13:59 +0200573# Allow SHA-1, because many of our test certificates use it
574P_SRV="$P_SRV allow_sha1=1"
575P_CLI="$P_CLI allow_sha1=1"
576
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200577# Also pick a unique name for intermediate files
578SRV_OUT="srv_out.$$"
579CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200580PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200581SESSION="session.$$"
582
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200583SKIP_NEXT="NO"
584
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100585trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100586
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200587# Basic test
588
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200589# Checks that:
590# - things work with all ciphersuites active (used with config-full in all.sh)
591# - the expected (highest security) parameters are selected
592# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200593run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200594 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200595 "$P_CLI" \
596 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200597 -s "Protocol is TLSv1.2" \
598 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
599 -s "client hello v3, signature_algorithm ext: 6" \
600 -s "ECDHE curve: secp521r1" \
601 -S "error" \
602 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200603
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000604run_test "Default, DTLS" \
605 "$P_SRV dtls=1" \
606 "$P_CLI dtls=1" \
607 0 \
608 -s "Protocol is DTLSv1.2" \
609 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
610
Janos Follath6d3e3382016-09-07 15:48:48 +0100611# Test for uniqueness of IVs in AEAD ciphersuites
612run_test "Unique IV in GCM" \
613 "$P_SRV exchanges=20 debug_level=4" \
614 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
615 0 \
616 -u "IV used" \
617 -U "IV used"
618
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100619# Tests for rc4 option
620
Simon Butcher6eb066e2016-05-19 22:12:18 +0100621requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100622run_test "RC4: server disabled, client enabled" \
623 "$P_SRV" \
624 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
625 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100626 -s "SSL - The server has no ciphersuites in common"
627
Simon Butcher6eb066e2016-05-19 22:12:18 +0100628requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100629run_test "RC4: server half, client enabled" \
630 "$P_SRV arc4=1" \
631 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
632 1 \
633 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100634
635run_test "RC4: server enabled, client disabled" \
636 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
637 "$P_CLI" \
638 1 \
639 -s "SSL - The server has no ciphersuites in common"
640
641run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100642 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100643 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
644 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100645 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100646 -S "SSL - The server has no ciphersuites in common"
647
Gilles Peskineae765992017-05-09 15:59:24 +0200648# Tests for SHA-1 support
649
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200650requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200651run_test "SHA-1 forbidden by default in server certificate" \
652 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
653 "$P_CLI debug_level=2 allow_sha1=0" \
654 1 \
655 -c "The certificate is signed with an unacceptable hash"
656
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200657requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
658run_test "SHA-1 forbidden by default in server certificate" \
659 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
660 "$P_CLI debug_level=2 allow_sha1=0" \
661 0
662
Gilles Peskineae765992017-05-09 15:59:24 +0200663run_test "SHA-1 explicitly allowed in server certificate" \
664 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
665 "$P_CLI allow_sha1=1" \
666 0
667
668run_test "SHA-256 allowed by default in server certificate" \
669 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
670 "$P_CLI allow_sha1=0" \
671 0
672
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200673requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200674run_test "SHA-1 forbidden by default in client certificate" \
675 "$P_SRV auth_mode=required allow_sha1=0" \
676 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
677 1 \
678 -s "The certificate is signed with an unacceptable hash"
679
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200680requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
681run_test "SHA-1 forbidden by default in client certificate" \
682 "$P_SRV auth_mode=required allow_sha1=0" \
683 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
684 0
685
Gilles Peskineae765992017-05-09 15:59:24 +0200686run_test "SHA-1 explicitly allowed in client certificate" \
687 "$P_SRV auth_mode=required allow_sha1=1" \
688 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
689 0
690
691run_test "SHA-256 allowed by default in client certificate" \
692 "$P_SRV auth_mode=required allow_sha1=0" \
693 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
694 0
695
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100696# Tests for Truncated HMAC extension
697
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100698run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200699 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100700 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100701 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100702 -s "dumping 'computed mac' (20 bytes)" \
703 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100704
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100705run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200706 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100707 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
708 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100709 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100710 -s "dumping 'computed mac' (20 bytes)" \
711 -S "dumping 'computed mac' (10 bytes)"
712
713run_test "Truncated HMAC: client enabled, server default" \
714 "$P_SRV debug_level=4" \
715 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
716 trunc_hmac=1" \
717 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100718 -s "dumping 'computed mac' (20 bytes)" \
719 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100720
721run_test "Truncated HMAC: client enabled, server disabled" \
722 "$P_SRV debug_level=4 trunc_hmac=0" \
723 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
724 trunc_hmac=1" \
725 0 \
726 -s "dumping 'computed mac' (20 bytes)" \
727 -S "dumping 'computed mac' (10 bytes)"
728
729run_test "Truncated HMAC: client enabled, server enabled" \
730 "$P_SRV debug_level=4 trunc_hmac=1" \
731 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
732 trunc_hmac=1" \
733 0 \
734 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100735 -s "dumping 'computed mac' (10 bytes)"
736
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100737# Tests for Encrypt-then-MAC extension
738
739run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100740 "$P_SRV debug_level=3 \
741 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100742 "$P_CLI debug_level=3" \
743 0 \
744 -c "client hello, adding encrypt_then_mac extension" \
745 -s "found encrypt then mac extension" \
746 -s "server hello, adding encrypt then mac extension" \
747 -c "found encrypt_then_mac extension" \
748 -c "using encrypt then mac" \
749 -s "using encrypt then mac"
750
751run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100752 "$P_SRV debug_level=3 etm=0 \
753 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100754 "$P_CLI debug_level=3 etm=1" \
755 0 \
756 -c "client hello, adding encrypt_then_mac extension" \
757 -s "found encrypt then mac extension" \
758 -S "server hello, adding encrypt then mac extension" \
759 -C "found encrypt_then_mac extension" \
760 -C "using encrypt then mac" \
761 -S "using encrypt then mac"
762
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100763run_test "Encrypt then MAC: client enabled, aead cipher" \
764 "$P_SRV debug_level=3 etm=1 \
765 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
766 "$P_CLI debug_level=3 etm=1" \
767 0 \
768 -c "client hello, adding encrypt_then_mac extension" \
769 -s "found encrypt then mac extension" \
770 -S "server hello, adding encrypt then mac extension" \
771 -C "found encrypt_then_mac extension" \
772 -C "using encrypt then mac" \
773 -S "using encrypt then mac"
774
775run_test "Encrypt then MAC: client enabled, stream cipher" \
776 "$P_SRV debug_level=3 etm=1 \
777 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100778 "$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 +0100779 0 \
780 -c "client hello, adding encrypt_then_mac extension" \
781 -s "found encrypt then mac extension" \
782 -S "server hello, adding encrypt then mac extension" \
783 -C "found encrypt_then_mac extension" \
784 -C "using encrypt then mac" \
785 -S "using encrypt then mac"
786
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100787run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100788 "$P_SRV debug_level=3 etm=1 \
789 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100790 "$P_CLI debug_level=3 etm=0" \
791 0 \
792 -C "client hello, adding encrypt_then_mac extension" \
793 -S "found encrypt then mac extension" \
794 -S "server hello, adding encrypt then mac extension" \
795 -C "found encrypt_then_mac extension" \
796 -C "using encrypt then mac" \
797 -S "using encrypt then mac"
798
Janos Follath542ee5d2016-03-07 15:57:05 +0000799requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100800run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100801 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100802 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100803 "$P_CLI debug_level=3 force_version=ssl3" \
804 0 \
805 -C "client hello, adding encrypt_then_mac extension" \
806 -S "found encrypt then mac extension" \
807 -S "server hello, adding encrypt then mac extension" \
808 -C "found encrypt_then_mac extension" \
809 -C "using encrypt then mac" \
810 -S "using encrypt then mac"
811
Janos Follath542ee5d2016-03-07 15:57:05 +0000812requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100813run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100814 "$P_SRV debug_level=3 force_version=ssl3 \
815 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100816 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100817 0 \
818 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100819 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100820 -S "server hello, adding encrypt then mac extension" \
821 -C "found encrypt_then_mac extension" \
822 -C "using encrypt then mac" \
823 -S "using encrypt then mac"
824
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200825# Tests for Extended Master Secret extension
826
827run_test "Extended Master Secret: default" \
828 "$P_SRV debug_level=3" \
829 "$P_CLI debug_level=3" \
830 0 \
831 -c "client hello, adding extended_master_secret extension" \
832 -s "found extended master secret extension" \
833 -s "server hello, adding extended master secret extension" \
834 -c "found extended_master_secret extension" \
835 -c "using extended master secret" \
836 -s "using extended master secret"
837
838run_test "Extended Master Secret: client enabled, server disabled" \
839 "$P_SRV debug_level=3 extended_ms=0" \
840 "$P_CLI debug_level=3 extended_ms=1" \
841 0 \
842 -c "client hello, adding extended_master_secret extension" \
843 -s "found extended master secret extension" \
844 -S "server hello, adding extended master secret extension" \
845 -C "found extended_master_secret extension" \
846 -C "using extended master secret" \
847 -S "using extended master secret"
848
849run_test "Extended Master Secret: client disabled, server enabled" \
850 "$P_SRV debug_level=3 extended_ms=1" \
851 "$P_CLI debug_level=3 extended_ms=0" \
852 0 \
853 -C "client hello, adding extended_master_secret extension" \
854 -S "found extended master secret extension" \
855 -S "server hello, adding extended master secret extension" \
856 -C "found extended_master_secret extension" \
857 -C "using extended master secret" \
858 -S "using extended master secret"
859
Janos Follath542ee5d2016-03-07 15:57:05 +0000860requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200861run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100862 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200863 "$P_CLI debug_level=3 force_version=ssl3" \
864 0 \
865 -C "client hello, adding extended_master_secret extension" \
866 -S "found extended master secret extension" \
867 -S "server hello, adding extended master secret extension" \
868 -C "found extended_master_secret extension" \
869 -C "using extended master secret" \
870 -S "using extended master secret"
871
Janos Follath542ee5d2016-03-07 15:57:05 +0000872requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200873run_test "Extended Master Secret: client enabled, server SSLv3" \
874 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100875 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200876 0 \
877 -c "client hello, adding extended_master_secret extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100878 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200879 -S "server hello, adding extended master secret extension" \
880 -C "found extended_master_secret extension" \
881 -C "using extended master secret" \
882 -S "using extended master secret"
883
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200884# Tests for FALLBACK_SCSV
885
886run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200887 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200888 "$P_CLI debug_level=3 force_version=tls1_1" \
889 0 \
890 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200891 -S "received FALLBACK_SCSV" \
892 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200893 -C "is a fatal alert message (msg 86)"
894
895run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200896 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200897 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
898 0 \
899 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200900 -S "received FALLBACK_SCSV" \
901 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200902 -C "is a fatal alert message (msg 86)"
903
904run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200905 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200906 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200907 1 \
908 -c "adding FALLBACK_SCSV" \
909 -s "received FALLBACK_SCSV" \
910 -s "inapropriate fallback" \
911 -c "is a fatal alert message (msg 86)"
912
913run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200914 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200915 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200916 0 \
917 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200918 -s "received FALLBACK_SCSV" \
919 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200920 -C "is a fatal alert message (msg 86)"
921
922requires_openssl_with_fallback_scsv
923run_test "Fallback SCSV: default, openssl server" \
924 "$O_SRV" \
925 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
926 0 \
927 -C "adding FALLBACK_SCSV" \
928 -C "is a fatal alert message (msg 86)"
929
930requires_openssl_with_fallback_scsv
931run_test "Fallback SCSV: enabled, openssl server" \
932 "$O_SRV" \
933 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
934 1 \
935 -c "adding FALLBACK_SCSV" \
936 -c "is a fatal alert message (msg 86)"
937
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200938requires_openssl_with_fallback_scsv
939run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200940 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200941 "$O_CLI -tls1_1" \
942 0 \
943 -S "received FALLBACK_SCSV" \
944 -S "inapropriate fallback"
945
946requires_openssl_with_fallback_scsv
947run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200948 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200949 "$O_CLI -tls1_1 -fallback_scsv" \
950 1 \
951 -s "received FALLBACK_SCSV" \
952 -s "inapropriate fallback"
953
954requires_openssl_with_fallback_scsv
955run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200956 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200957 "$O_CLI -fallback_scsv" \
958 0 \
959 -s "received FALLBACK_SCSV" \
960 -S "inapropriate fallback"
961
Gilles Peskine39e29812017-05-16 17:53:03 +0200962## ClientHello generated with
963## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
964## then manually twiddling the ciphersuite list.
965## The ClientHello content is spelled out below as a hex string as
966## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
967## The expected response is an inappropriate_fallback alert.
968requires_openssl_with_fallback_scsv
969run_test "Fallback SCSV: beginning of list" \
970 "$P_SRV debug_level=2" \
971 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
972 0 \
973 -s "received FALLBACK_SCSV" \
974 -s "inapropriate fallback"
975
976requires_openssl_with_fallback_scsv
977run_test "Fallback SCSV: end of list" \
978 "$P_SRV debug_level=2" \
979 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
980 0 \
981 -s "received FALLBACK_SCSV" \
982 -s "inapropriate fallback"
983
984## Here the expected response is a valid ServerHello prefix, up to the random.
985requires_openssl_with_fallback_scsv
986run_test "Fallback SCSV: not in list" \
987 "$P_SRV debug_level=2" \
988 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
989 0 \
990 -S "received FALLBACK_SCSV" \
991 -S "inapropriate fallback"
992
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100993# Tests for CBC 1/n-1 record splitting
994
995run_test "CBC Record splitting: TLS 1.2, no splitting" \
996 "$P_SRV" \
997 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
998 request_size=123 force_version=tls1_2" \
999 0 \
1000 -s "Read from client: 123 bytes read" \
1001 -S "Read from client: 1 bytes read" \
1002 -S "122 bytes read"
1003
1004run_test "CBC Record splitting: TLS 1.1, no splitting" \
1005 "$P_SRV" \
1006 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1007 request_size=123 force_version=tls1_1" \
1008 0 \
1009 -s "Read from client: 123 bytes read" \
1010 -S "Read from client: 1 bytes read" \
1011 -S "122 bytes read"
1012
1013run_test "CBC Record splitting: TLS 1.0, splitting" \
1014 "$P_SRV" \
1015 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1016 request_size=123 force_version=tls1" \
1017 0 \
1018 -S "Read from client: 123 bytes read" \
1019 -s "Read from client: 1 bytes read" \
1020 -s "122 bytes read"
1021
Janos Follath542ee5d2016-03-07 15:57:05 +00001022requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001023run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001024 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001025 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1026 request_size=123 force_version=ssl3" \
1027 0 \
1028 -S "Read from client: 123 bytes read" \
1029 -s "Read from client: 1 bytes read" \
1030 -s "122 bytes read"
1031
1032run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001033 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001034 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1035 request_size=123 force_version=tls1" \
1036 0 \
1037 -s "Read from client: 123 bytes read" \
1038 -S "Read from client: 1 bytes read" \
1039 -S "122 bytes read"
1040
1041run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1042 "$P_SRV" \
1043 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1044 request_size=123 force_version=tls1 recsplit=0" \
1045 0 \
1046 -s "Read from client: 123 bytes read" \
1047 -S "Read from client: 1 bytes read" \
1048 -S "122 bytes read"
1049
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001050run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1051 "$P_SRV nbio=2" \
1052 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1053 request_size=123 force_version=tls1" \
1054 0 \
1055 -S "Read from client: 123 bytes read" \
1056 -s "Read from client: 1 bytes read" \
1057 -s "122 bytes read"
1058
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001059# Tests for Session Tickets
1060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001061run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001062 "$P_SRV debug_level=3 tickets=1" \
1063 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001064 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001065 -c "client hello, adding session ticket extension" \
1066 -s "found session ticket extension" \
1067 -s "server hello, adding session ticket extension" \
1068 -c "found session_ticket extension" \
1069 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001070 -S "session successfully restored from cache" \
1071 -s "session successfully restored from ticket" \
1072 -s "a session has been resumed" \
1073 -c "a session has been resumed"
1074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001075run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001076 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1077 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001078 0 \
1079 -c "client hello, adding session ticket extension" \
1080 -s "found session ticket extension" \
1081 -s "server hello, adding session ticket extension" \
1082 -c "found session_ticket extension" \
1083 -c "parse new session ticket" \
1084 -S "session successfully restored from cache" \
1085 -s "session successfully restored from ticket" \
1086 -s "a session has been resumed" \
1087 -c "a session has been resumed"
1088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001089run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001090 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1091 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001092 0 \
1093 -c "client hello, adding session ticket extension" \
1094 -s "found session ticket extension" \
1095 -s "server hello, adding session ticket extension" \
1096 -c "found session_ticket extension" \
1097 -c "parse new session ticket" \
1098 -S "session successfully restored from cache" \
1099 -S "session successfully restored from ticket" \
1100 -S "a session has been resumed" \
1101 -C "a session has been resumed"
1102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001103run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001104 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001105 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001106 0 \
1107 -c "client hello, adding session ticket extension" \
1108 -c "found session_ticket extension" \
1109 -c "parse new session ticket" \
1110 -c "a session has been resumed"
1111
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001112run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001113 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001114 "( $O_CLI -sess_out $SESSION; \
1115 $O_CLI -sess_in $SESSION; \
1116 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001117 0 \
1118 -s "found session ticket extension" \
1119 -s "server hello, adding session ticket extension" \
1120 -S "session successfully restored from cache" \
1121 -s "session successfully restored from ticket" \
1122 -s "a session has been resumed"
1123
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001124# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001126run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001127 "$P_SRV debug_level=3 tickets=0" \
1128 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001129 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001130 -c "client hello, adding session ticket extension" \
1131 -s "found session ticket extension" \
1132 -S "server hello, adding session ticket extension" \
1133 -C "found session_ticket extension" \
1134 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001135 -s "session successfully restored from cache" \
1136 -S "session successfully restored from ticket" \
1137 -s "a session has been resumed" \
1138 -c "a session has been resumed"
1139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001140run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001141 "$P_SRV debug_level=3 tickets=1" \
1142 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001143 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001144 -C "client hello, adding session ticket extension" \
1145 -S "found session ticket extension" \
1146 -S "server hello, adding session ticket extension" \
1147 -C "found session_ticket extension" \
1148 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001149 -s "session successfully restored from cache" \
1150 -S "session successfully restored from ticket" \
1151 -s "a session has been resumed" \
1152 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001154run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001155 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1156 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001157 0 \
1158 -S "session successfully restored from cache" \
1159 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001160 -S "a session has been resumed" \
1161 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001163run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001164 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1165 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001166 0 \
1167 -s "session successfully restored from cache" \
1168 -S "session successfully restored from ticket" \
1169 -s "a session has been resumed" \
1170 -c "a session has been resumed"
1171
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001172run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001173 "$P_SRV debug_level=3 tickets=0" \
1174 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001175 0 \
1176 -s "session successfully restored from cache" \
1177 -S "session successfully restored from ticket" \
1178 -s "a session has been resumed" \
1179 -c "a session has been resumed"
1180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001181run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001182 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1183 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001184 0 \
1185 -S "session successfully restored from cache" \
1186 -S "session successfully restored from ticket" \
1187 -S "a session has been resumed" \
1188 -C "a session has been resumed"
1189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001190run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001191 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1192 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001193 0 \
1194 -s "session successfully restored from cache" \
1195 -S "session successfully restored from ticket" \
1196 -s "a session has been resumed" \
1197 -c "a session has been resumed"
1198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001199run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001200 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001201 "( $O_CLI -sess_out $SESSION; \
1202 $O_CLI -sess_in $SESSION; \
1203 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001204 0 \
1205 -s "found session ticket extension" \
1206 -S "server hello, adding session ticket extension" \
1207 -s "session successfully restored from cache" \
1208 -S "session successfully restored from ticket" \
1209 -s "a session has been resumed"
1210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001211run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001212 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001213 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001214 0 \
1215 -C "found session_ticket extension" \
1216 -C "parse new session ticket" \
1217 -c "a session has been resumed"
1218
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001219# Tests for Max Fragment Length extension
1220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001221run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001222 "$P_SRV debug_level=3" \
1223 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001224 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001225 -c "Maximum fragment length is 16384" \
1226 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001227 -C "client hello, adding max_fragment_length extension" \
1228 -S "found max fragment length extension" \
1229 -S "server hello, max_fragment_length extension" \
1230 -C "found max_fragment_length extension"
1231
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001232run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001233 "$P_SRV debug_level=3" \
1234 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001235 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001236 -c "Maximum fragment length is 4096" \
1237 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001238 -c "client hello, adding max_fragment_length extension" \
1239 -s "found max fragment length extension" \
1240 -s "server hello, max_fragment_length extension" \
1241 -c "found max_fragment_length extension"
1242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001243run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001244 "$P_SRV debug_level=3 max_frag_len=4096" \
1245 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001246 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001247 -c "Maximum fragment length is 16384" \
1248 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001249 -C "client hello, adding max_fragment_length extension" \
1250 -S "found max fragment length extension" \
1251 -S "server hello, max_fragment_length extension" \
1252 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001253
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001254requires_gnutls
1255run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001256 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001258 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001259 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001260 -c "client hello, adding max_fragment_length extension" \
1261 -c "found max_fragment_length extension"
1262
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001263run_test "Max fragment length: client, message just fits" \
1264 "$P_SRV debug_level=3" \
1265 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1266 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001267 -c "Maximum fragment length is 2048" \
1268 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001269 -c "client hello, adding max_fragment_length extension" \
1270 -s "found max fragment length extension" \
1271 -s "server hello, max_fragment_length extension" \
1272 -c "found max_fragment_length extension" \
1273 -c "2048 bytes written in 1 fragments" \
1274 -s "2048 bytes read"
1275
1276run_test "Max fragment length: client, larger message" \
1277 "$P_SRV debug_level=3" \
1278 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1279 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001280 -c "Maximum fragment length is 2048" \
1281 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001282 -c "client hello, adding max_fragment_length extension" \
1283 -s "found max fragment length extension" \
1284 -s "server hello, max_fragment_length extension" \
1285 -c "found max_fragment_length extension" \
1286 -c "2345 bytes written in 2 fragments" \
1287 -s "2048 bytes read" \
1288 -s "297 bytes read"
1289
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001290run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001291 "$P_SRV debug_level=3 dtls=1" \
1292 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1293 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001294 -c "Maximum fragment length is 2048" \
1295 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001296 -c "client hello, adding max_fragment_length extension" \
1297 -s "found max fragment length extension" \
1298 -s "server hello, max_fragment_length extension" \
1299 -c "found max_fragment_length extension" \
1300 -c "fragment larger than.*maximum"
1301
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001302# Tests for renegotiation
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001305 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001306 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001307 0 \
1308 -C "client hello, adding renegotiation extension" \
1309 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1310 -S "found renegotiation extension" \
1311 -s "server hello, secure renegotiation extension" \
1312 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001313 -C "=> renegotiate" \
1314 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001315 -S "write hello request"
1316
Hanno Becker78891132017-10-24 11:54:55 +01001317requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001318run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001319 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001320 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001321 0 \
1322 -c "client hello, adding renegotiation extension" \
1323 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1324 -s "found renegotiation extension" \
1325 -s "server hello, secure renegotiation extension" \
1326 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001327 -c "=> renegotiate" \
1328 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001329 -S "write hello request"
1330
Hanno Becker78891132017-10-24 11:54:55 +01001331requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001332run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001333 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001334 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001335 0 \
1336 -c "client hello, adding renegotiation extension" \
1337 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1338 -s "found renegotiation extension" \
1339 -s "server hello, secure renegotiation extension" \
1340 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001341 -c "=> renegotiate" \
1342 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001343 -s "write hello request"
1344
Janos Follath5f1dd802017-10-05 12:29:42 +01001345# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1346# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1347# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker78891132017-10-24 11:54:55 +01001348requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath5f1dd802017-10-05 12:29:42 +01001349run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1350 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1351 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1352 0 \
1353 -c "client hello, adding renegotiation extension" \
1354 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1355 -s "found renegotiation extension" \
1356 -s "server hello, secure renegotiation extension" \
1357 -c "found renegotiation extension" \
1358 -c "=> renegotiate" \
1359 -s "=> renegotiate" \
1360 -S "write hello request" \
1361 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1362
1363# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1364# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1365# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker78891132017-10-24 11:54:55 +01001366requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath5f1dd802017-10-05 12:29:42 +01001367run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1368 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1369 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1370 0 \
1371 -c "client hello, adding renegotiation extension" \
1372 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1373 -s "found renegotiation extension" \
1374 -s "server hello, secure renegotiation extension" \
1375 -c "found renegotiation extension" \
1376 -c "=> renegotiate" \
1377 -s "=> renegotiate" \
1378 -s "write hello request" \
1379 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1380
Hanno Becker78891132017-10-24 11:54:55 +01001381requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001382run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001383 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001384 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001385 0 \
1386 -c "client hello, adding renegotiation extension" \
1387 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1388 -s "found renegotiation extension" \
1389 -s "server hello, secure renegotiation extension" \
1390 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001391 -c "=> renegotiate" \
1392 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001393 -s "write hello request"
1394
Hanno Becker78891132017-10-24 11:54:55 +01001395requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001396run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001397 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001398 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001399 1 \
1400 -c "client hello, adding renegotiation extension" \
1401 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1402 -S "found renegotiation extension" \
1403 -s "server hello, secure renegotiation extension" \
1404 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001405 -c "=> renegotiate" \
1406 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001407 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001408 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001409 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001410
Hanno Becker78891132017-10-24 11:54:55 +01001411requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001412run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001413 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001414 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001415 0 \
1416 -C "client hello, adding renegotiation extension" \
1417 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1418 -S "found renegotiation extension" \
1419 -s "server hello, secure renegotiation extension" \
1420 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001421 -C "=> renegotiate" \
1422 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001423 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001424 -S "SSL - An unexpected message was received from our peer" \
1425 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001426
Hanno Becker78891132017-10-24 11:54:55 +01001427requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001428run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001429 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001430 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001431 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001432 0 \
1433 -C "client hello, adding renegotiation extension" \
1434 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1435 -S "found renegotiation extension" \
1436 -s "server hello, secure renegotiation extension" \
1437 -c "found renegotiation extension" \
1438 -C "=> renegotiate" \
1439 -S "=> renegotiate" \
1440 -s "write hello request" \
1441 -S "SSL - An unexpected message was received from our peer" \
1442 -S "failed"
1443
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001444# delay 2 for 1 alert record + 1 application data record
Hanno Becker78891132017-10-24 11:54:55 +01001445requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001446run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001447 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001448 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001449 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001450 0 \
1451 -C "client hello, adding renegotiation extension" \
1452 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1453 -S "found renegotiation extension" \
1454 -s "server hello, secure renegotiation extension" \
1455 -c "found renegotiation extension" \
1456 -C "=> renegotiate" \
1457 -S "=> renegotiate" \
1458 -s "write hello request" \
1459 -S "SSL - An unexpected message was received from our peer" \
1460 -S "failed"
1461
Hanno Becker78891132017-10-24 11:54:55 +01001462requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001463run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001464 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001465 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001466 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001467 0 \
1468 -C "client hello, adding renegotiation extension" \
1469 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1470 -S "found renegotiation extension" \
1471 -s "server hello, secure renegotiation extension" \
1472 -c "found renegotiation extension" \
1473 -C "=> renegotiate" \
1474 -S "=> renegotiate" \
1475 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001476 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001477
Hanno Becker78891132017-10-24 11:54:55 +01001478requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001479run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001480 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001481 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001482 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001483 0 \
1484 -c "client hello, adding renegotiation extension" \
1485 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1486 -s "found renegotiation extension" \
1487 -s "server hello, secure renegotiation extension" \
1488 -c "found renegotiation extension" \
1489 -c "=> renegotiate" \
1490 -s "=> renegotiate" \
1491 -s "write hello request" \
1492 -S "SSL - An unexpected message was received from our peer" \
1493 -S "failed"
1494
Hanno Becker78891132017-10-24 11:54:55 +01001495requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001496run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001497 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001498 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1499 0 \
1500 -C "client hello, adding renegotiation extension" \
1501 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1502 -S "found renegotiation extension" \
1503 -s "server hello, secure renegotiation extension" \
1504 -c "found renegotiation extension" \
1505 -S "record counter limit reached: renegotiate" \
1506 -C "=> renegotiate" \
1507 -S "=> renegotiate" \
1508 -S "write hello request" \
1509 -S "SSL - An unexpected message was received from our peer" \
1510 -S "failed"
1511
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001512# one extra exchange to be able to complete renego
Hanno Becker78891132017-10-24 11:54:55 +01001513requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001514run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001515 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001516 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001517 0 \
1518 -c "client hello, adding renegotiation extension" \
1519 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1520 -s "found renegotiation extension" \
1521 -s "server hello, secure renegotiation extension" \
1522 -c "found renegotiation extension" \
1523 -s "record counter limit reached: renegotiate" \
1524 -c "=> renegotiate" \
1525 -s "=> renegotiate" \
1526 -s "write hello request" \
1527 -S "SSL - An unexpected message was received from our peer" \
1528 -S "failed"
1529
Hanno Becker78891132017-10-24 11:54:55 +01001530requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001531run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001532 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001533 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001534 0 \
1535 -c "client hello, adding renegotiation extension" \
1536 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1537 -s "found renegotiation extension" \
1538 -s "server hello, secure renegotiation extension" \
1539 -c "found renegotiation extension" \
1540 -s "record counter limit reached: renegotiate" \
1541 -c "=> renegotiate" \
1542 -s "=> renegotiate" \
1543 -s "write hello request" \
1544 -S "SSL - An unexpected message was received from our peer" \
1545 -S "failed"
1546
Hanno Becker78891132017-10-24 11:54:55 +01001547requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001548run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001549 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001550 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1551 0 \
1552 -C "client hello, adding renegotiation extension" \
1553 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1554 -S "found renegotiation extension" \
1555 -s "server hello, secure renegotiation extension" \
1556 -c "found renegotiation extension" \
1557 -S "record counter limit reached: renegotiate" \
1558 -C "=> renegotiate" \
1559 -S "=> renegotiate" \
1560 -S "write hello request" \
1561 -S "SSL - An unexpected message was received from our peer" \
1562 -S "failed"
1563
Hanno Becker78891132017-10-24 11:54:55 +01001564requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001565run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001566 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001567 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001568 0 \
1569 -c "client hello, adding renegotiation extension" \
1570 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1571 -s "found renegotiation extension" \
1572 -s "server hello, secure renegotiation extension" \
1573 -c "found renegotiation extension" \
1574 -c "=> renegotiate" \
1575 -s "=> renegotiate" \
1576 -S "write hello request"
1577
Hanno Becker78891132017-10-24 11:54:55 +01001578requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001579run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001580 "$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 +02001581 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001582 0 \
1583 -c "client hello, adding renegotiation extension" \
1584 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1585 -s "found renegotiation extension" \
1586 -s "server hello, secure renegotiation extension" \
1587 -c "found renegotiation extension" \
1588 -c "=> renegotiate" \
1589 -s "=> renegotiate" \
1590 -s "write hello request"
1591
Hanno Becker78891132017-10-24 11:54:55 +01001592requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001593run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001594 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001595 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001596 0 \
1597 -c "client hello, adding renegotiation extension" \
1598 -c "found renegotiation extension" \
1599 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001600 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001601 -C "error" \
1602 -c "HTTP/1.0 200 [Oo][Kk]"
1603
Paul Bakker539d9722015-02-08 16:18:35 +01001604requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001605requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001606run_test "Renegotiation: gnutls server strict, client-initiated" \
1607 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001608 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001609 0 \
1610 -c "client hello, adding renegotiation extension" \
1611 -c "found renegotiation extension" \
1612 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001613 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001614 -C "error" \
1615 -c "HTTP/1.0 200 [Oo][Kk]"
1616
Paul Bakker539d9722015-02-08 16:18:35 +01001617requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001618requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001619run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1620 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1621 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1622 1 \
1623 -c "client hello, adding renegotiation extension" \
1624 -C "found renegotiation extension" \
1625 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001626 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001627 -c "error" \
1628 -C "HTTP/1.0 200 [Oo][Kk]"
1629
Paul Bakker539d9722015-02-08 16:18:35 +01001630requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001631requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001632run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1633 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1634 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1635 allow_legacy=0" \
1636 1 \
1637 -c "client hello, adding renegotiation extension" \
1638 -C "found renegotiation extension" \
1639 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001640 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001641 -c "error" \
1642 -C "HTTP/1.0 200 [Oo][Kk]"
1643
Paul Bakker539d9722015-02-08 16:18:35 +01001644requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001645requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001646run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1647 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1648 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1649 allow_legacy=1" \
1650 0 \
1651 -c "client hello, adding renegotiation extension" \
1652 -C "found renegotiation extension" \
1653 -c "=> renegotiate" \
1654 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001655 -C "error" \
1656 -c "HTTP/1.0 200 [Oo][Kk]"
1657
Hanno Becker78891132017-10-24 11:54:55 +01001658requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001659run_test "Renegotiation: DTLS, client-initiated" \
1660 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1661 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1662 0 \
1663 -c "client hello, adding renegotiation extension" \
1664 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1665 -s "found renegotiation extension" \
1666 -s "server hello, secure renegotiation extension" \
1667 -c "found renegotiation extension" \
1668 -c "=> renegotiate" \
1669 -s "=> renegotiate" \
1670 -S "write hello request"
1671
Hanno Becker78891132017-10-24 11:54:55 +01001672requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001673run_test "Renegotiation: DTLS, server-initiated" \
1674 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001675 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1676 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001677 0 \
1678 -c "client hello, adding renegotiation extension" \
1679 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1680 -s "found renegotiation extension" \
1681 -s "server hello, secure renegotiation extension" \
1682 -c "found renegotiation extension" \
1683 -c "=> renegotiate" \
1684 -s "=> renegotiate" \
1685 -s "write hello request"
1686
Hanno Becker78891132017-10-24 11:54:55 +01001687requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG9b1927b2017-01-19 16:30:57 +00001688run_test "Renegotiation: DTLS, renego_period overflow" \
1689 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1690 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1691 0 \
1692 -c "client hello, adding renegotiation extension" \
1693 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1694 -s "found renegotiation extension" \
1695 -s "server hello, secure renegotiation extension" \
1696 -s "record counter limit reached: renegotiate" \
1697 -c "=> renegotiate" \
1698 -s "=> renegotiate" \
Hanno Becker78891132017-10-24 11:54:55 +01001699 -s "write hello request"
Andres AG9b1927b2017-01-19 16:30:57 +00001700
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001701requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001702requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001703run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1704 "$G_SRV -u --mtu 4096" \
1705 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1706 0 \
1707 -c "client hello, adding renegotiation extension" \
1708 -c "found renegotiation extension" \
1709 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001710 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001711 -C "error" \
1712 -s "Extra-header:"
1713
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001714# Test for the "secure renegotation" extension only (no actual renegotiation)
1715
Paul Bakker539d9722015-02-08 16:18:35 +01001716requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001717run_test "Renego ext: gnutls server strict, client default" \
1718 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1719 "$P_CLI debug_level=3" \
1720 0 \
1721 -c "found renegotiation extension" \
1722 -C "error" \
1723 -c "HTTP/1.0 200 [Oo][Kk]"
1724
Paul Bakker539d9722015-02-08 16:18:35 +01001725requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001726run_test "Renego ext: gnutls server unsafe, client default" \
1727 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1728 "$P_CLI debug_level=3" \
1729 0 \
1730 -C "found renegotiation extension" \
1731 -C "error" \
1732 -c "HTTP/1.0 200 [Oo][Kk]"
1733
Paul Bakker539d9722015-02-08 16:18:35 +01001734requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001735run_test "Renego ext: gnutls server unsafe, client break legacy" \
1736 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1737 "$P_CLI debug_level=3 allow_legacy=-1" \
1738 1 \
1739 -C "found renegotiation extension" \
1740 -c "error" \
1741 -C "HTTP/1.0 200 [Oo][Kk]"
1742
Paul Bakker539d9722015-02-08 16:18:35 +01001743requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001744run_test "Renego ext: gnutls client strict, server default" \
1745 "$P_SRV debug_level=3" \
1746 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1747 0 \
1748 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1749 -s "server hello, secure renegotiation extension"
1750
Paul Bakker539d9722015-02-08 16:18:35 +01001751requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001752run_test "Renego ext: gnutls client unsafe, server default" \
1753 "$P_SRV debug_level=3" \
1754 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1755 0 \
1756 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1757 -S "server hello, secure renegotiation extension"
1758
Paul Bakker539d9722015-02-08 16:18:35 +01001759requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001760run_test "Renego ext: gnutls client unsafe, server break legacy" \
1761 "$P_SRV debug_level=3 allow_legacy=-1" \
1762 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1763 1 \
1764 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1765 -S "server hello, secure renegotiation extension"
1766
Janos Follath365b2262016-02-17 10:11:21 +00001767# Tests for silently dropping trailing extra bytes in .der certificates
1768
1769requires_gnutls
1770run_test "DER format: no trailing bytes" \
1771 "$P_SRV crt_file=data_files/server5-der0.crt \
1772 key_file=data_files/server5.key" \
1773 "$G_CLI " \
1774 0 \
1775 -c "Handshake was completed" \
1776
1777requires_gnutls
1778run_test "DER format: with a trailing zero byte" \
1779 "$P_SRV crt_file=data_files/server5-der1a.crt \
1780 key_file=data_files/server5.key" \
1781 "$G_CLI " \
1782 0 \
1783 -c "Handshake was completed" \
1784
1785requires_gnutls
1786run_test "DER format: with a trailing random byte" \
1787 "$P_SRV crt_file=data_files/server5-der1b.crt \
1788 key_file=data_files/server5.key" \
1789 "$G_CLI " \
1790 0 \
1791 -c "Handshake was completed" \
1792
1793requires_gnutls
1794run_test "DER format: with 2 trailing random bytes" \
1795 "$P_SRV crt_file=data_files/server5-der2.crt \
1796 key_file=data_files/server5.key" \
1797 "$G_CLI " \
1798 0 \
1799 -c "Handshake was completed" \
1800
1801requires_gnutls
1802run_test "DER format: with 4 trailing random bytes" \
1803 "$P_SRV crt_file=data_files/server5-der4.crt \
1804 key_file=data_files/server5.key" \
1805 "$G_CLI " \
1806 0 \
1807 -c "Handshake was completed" \
1808
1809requires_gnutls
1810run_test "DER format: with 8 trailing random bytes" \
1811 "$P_SRV crt_file=data_files/server5-der8.crt \
1812 key_file=data_files/server5.key" \
1813 "$G_CLI " \
1814 0 \
1815 -c "Handshake was completed" \
1816
1817requires_gnutls
1818run_test "DER format: with 9 trailing random bytes" \
1819 "$P_SRV crt_file=data_files/server5-der9.crt \
1820 key_file=data_files/server5.key" \
1821 "$G_CLI " \
1822 0 \
1823 -c "Handshake was completed" \
1824
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001825# Tests for auth_mode
1826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001827run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001828 "$P_SRV crt_file=data_files/server5-badsign.crt \
1829 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001830 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001831 1 \
1832 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001833 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001834 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001835 -c "X509 - Certificate verification failed"
1836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001837run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001838 "$P_SRV crt_file=data_files/server5-badsign.crt \
1839 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001840 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001841 0 \
1842 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001843 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001844 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001845 -C "X509 - Certificate verification failed"
1846
Hanno Becker61c0c702017-05-15 16:05:15 +01001847run_test "Authentication: server goodcert, client optional, no trusted CA" \
1848 "$P_SRV" \
1849 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1850 0 \
1851 -c "x509_verify_cert() returned" \
1852 -c "! The certificate is not correctly signed by the trusted CA" \
1853 -c "! Certificate verification flags"\
1854 -C "! mbedtls_ssl_handshake returned" \
1855 -C "X509 - Certificate verification failed" \
1856 -C "SSL - No CA Chain is set, but required to operate"
1857
1858run_test "Authentication: server goodcert, client required, no trusted CA" \
1859 "$P_SRV" \
1860 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1861 1 \
1862 -c "x509_verify_cert() returned" \
1863 -c "! The certificate is not correctly signed by the trusted CA" \
1864 -c "! Certificate verification flags"\
1865 -c "! mbedtls_ssl_handshake returned" \
1866 -c "SSL - No CA Chain is set, but required to operate"
1867
1868# The purpose of the next two tests is to test the client's behaviour when receiving a server
1869# certificate with an unsupported elliptic curve. This should usually not happen because
1870# the client informs the server about the supported curves - it does, though, in the
1871# corner case of a static ECDH suite, because the server doesn't check the curve on that
1872# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1873# different means to have the server ignoring the client's supported curve list.
1874
1875requires_config_enabled MBEDTLS_ECP_C
1876run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1877 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1878 crt_file=data_files/server5.ku-ka.crt" \
1879 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1880 1 \
1881 -c "bad certificate (EC key curve)"\
1882 -c "! Certificate verification flags"\
1883 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1884
1885requires_config_enabled MBEDTLS_ECP_C
1886run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1887 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1888 crt_file=data_files/server5.ku-ka.crt" \
1889 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1890 1 \
1891 -c "bad certificate (EC key curve)"\
1892 -c "! Certificate verification flags"\
1893 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1894
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001895run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001896 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001897 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001898 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001899 0 \
1900 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001901 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001902 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001903 -C "X509 - Certificate verification failed"
1904
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001905run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001906 "$P_SRV debug_level=3 auth_mode=required" \
1907 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001908 key_file=data_files/server5.key" \
1909 1 \
1910 -S "skip write certificate request" \
1911 -C "skip parse certificate request" \
1912 -c "got a certificate request" \
1913 -C "skip write certificate" \
1914 -C "skip write certificate verify" \
1915 -S "skip parse certificate verify" \
1916 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001917 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001918 -s "! mbedtls_ssl_handshake returned" \
1919 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001920 -s "X509 - Certificate verification failed"
1921
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001922run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001923 "$P_SRV debug_level=3 auth_mode=optional" \
1924 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001925 key_file=data_files/server5.key" \
1926 0 \
1927 -S "skip write certificate request" \
1928 -C "skip parse certificate request" \
1929 -c "got a certificate request" \
1930 -C "skip write certificate" \
1931 -C "skip write certificate verify" \
1932 -S "skip parse certificate verify" \
1933 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001934 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001935 -S "! mbedtls_ssl_handshake returned" \
1936 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001937 -S "X509 - Certificate verification failed"
1938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001939run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001940 "$P_SRV debug_level=3 auth_mode=none" \
1941 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001942 key_file=data_files/server5.key" \
1943 0 \
1944 -s "skip write certificate request" \
1945 -C "skip parse certificate request" \
1946 -c "got no certificate request" \
1947 -c "skip write certificate" \
1948 -c "skip write certificate verify" \
1949 -s "skip parse certificate verify" \
1950 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001951 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001952 -S "! mbedtls_ssl_handshake returned" \
1953 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001954 -S "X509 - Certificate verification failed"
1955
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001956run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001957 "$P_SRV debug_level=3 auth_mode=optional" \
1958 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001959 0 \
1960 -S "skip write certificate request" \
1961 -C "skip parse certificate request" \
1962 -c "got a certificate request" \
1963 -C "skip write certificate$" \
1964 -C "got no certificate to send" \
1965 -S "SSLv3 client has no certificate" \
1966 -c "skip write certificate verify" \
1967 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001968 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001969 -S "! mbedtls_ssl_handshake returned" \
1970 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001971 -S "X509 - Certificate verification failed"
1972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001973run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001974 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001975 "$O_CLI" \
1976 0 \
1977 -S "skip write certificate request" \
1978 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001979 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001980 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001981 -S "X509 - Certificate verification failed"
1982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001983run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001984 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001985 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001986 0 \
1987 -C "skip parse certificate request" \
1988 -c "got a certificate request" \
1989 -C "skip write certificate$" \
1990 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001991 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001992
Janos Follath542ee5d2016-03-07 15:57:05 +00001993requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001994run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001995 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001996 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001997 0 \
1998 -S "skip write certificate request" \
1999 -C "skip parse certificate request" \
2000 -c "got a certificate request" \
2001 -C "skip write certificate$" \
2002 -c "skip write certificate verify" \
2003 -c "got no certificate to send" \
2004 -s "SSLv3 client has no certificate" \
2005 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002006 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002007 -S "! mbedtls_ssl_handshake returned" \
2008 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002009 -S "X509 - Certificate verification failed"
2010
Manuel Pégourié-Gonnard591035d2017-06-26 10:45:33 +02002011run_test "Authentication: server max_int chain, client default" \
2012 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2013 key_file=data_files/dir-maxpath/09.key" \
2014 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2015 0 \
2016 -C "X509 - A fatal error occured"
2017
2018run_test "Authentication: server max_int+1 chain, client default" \
2019 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2020 key_file=data_files/dir-maxpath/10.key" \
2021 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2022 1 \
2023 -c "X509 - A fatal error occured"
2024
2025run_test "Authentication: server max_int+1 chain, client optional" \
2026 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2027 key_file=data_files/dir-maxpath/10.key" \
2028 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2029 auth_mode=optional" \
2030 1 \
2031 -c "X509 - A fatal error occured"
2032
2033run_test "Authentication: server max_int+1 chain, client none" \
2034 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2035 key_file=data_files/dir-maxpath/10.key" \
2036 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2037 auth_mode=none" \
2038 0 \
2039 -C "X509 - A fatal error occured"
2040
2041run_test "Authentication: client max_int+1 chain, server default" \
2042 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2043 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2044 key_file=data_files/dir-maxpath/10.key" \
2045 0 \
2046 -S "X509 - A fatal error occured"
2047
2048run_test "Authentication: client max_int+1 chain, server optional" \
2049 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2050 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2051 key_file=data_files/dir-maxpath/10.key" \
2052 1 \
2053 -s "X509 - A fatal error occured"
2054
2055run_test "Authentication: client max_int+1 chain, server required" \
2056 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2057 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2058 key_file=data_files/dir-maxpath/10.key" \
2059 1 \
2060 -s "X509 - A fatal error occured"
2061
2062run_test "Authentication: client max_int chain, server required" \
2063 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2064 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2065 key_file=data_files/dir-maxpath/09.key" \
2066 0 \
2067 -S "X509 - A fatal error occured"
2068
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002069# Tests for certificate selection based on SHA verson
2070
2071run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2072 "$P_SRV crt_file=data_files/server5.crt \
2073 key_file=data_files/server5.key \
2074 crt_file2=data_files/server5-sha1.crt \
2075 key_file2=data_files/server5.key" \
2076 "$P_CLI force_version=tls1_2" \
2077 0 \
2078 -c "signed using.*ECDSA with SHA256" \
2079 -C "signed using.*ECDSA with SHA1"
2080
2081run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2082 "$P_SRV crt_file=data_files/server5.crt \
2083 key_file=data_files/server5.key \
2084 crt_file2=data_files/server5-sha1.crt \
2085 key_file2=data_files/server5.key" \
2086 "$P_CLI force_version=tls1_1" \
2087 0 \
2088 -C "signed using.*ECDSA with SHA256" \
2089 -c "signed using.*ECDSA with SHA1"
2090
2091run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2092 "$P_SRV crt_file=data_files/server5.crt \
2093 key_file=data_files/server5.key \
2094 crt_file2=data_files/server5-sha1.crt \
2095 key_file2=data_files/server5.key" \
2096 "$P_CLI force_version=tls1" \
2097 0 \
2098 -C "signed using.*ECDSA with SHA256" \
2099 -c "signed using.*ECDSA with SHA1"
2100
2101run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2102 "$P_SRV crt_file=data_files/server5.crt \
2103 key_file=data_files/server5.key \
2104 crt_file2=data_files/server6.crt \
2105 key_file2=data_files/server6.key" \
2106 "$P_CLI force_version=tls1_1" \
2107 0 \
2108 -c "serial number.*09" \
2109 -c "signed using.*ECDSA with SHA256" \
2110 -C "signed using.*ECDSA with SHA1"
2111
2112run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2113 "$P_SRV crt_file=data_files/server6.crt \
2114 key_file=data_files/server6.key \
2115 crt_file2=data_files/server5.crt \
2116 key_file2=data_files/server5.key" \
2117 "$P_CLI force_version=tls1_1" \
2118 0 \
2119 -c "serial number.*0A" \
2120 -c "signed using.*ECDSA with SHA256" \
2121 -C "signed using.*ECDSA with SHA1"
2122
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002123# tests for SNI
2124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002125run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002126 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002127 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002128 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002129 0 \
2130 -S "parse ServerName extension" \
2131 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2132 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002134run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002135 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002136 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002137 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 +02002138 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002139 0 \
2140 -s "parse ServerName extension" \
2141 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2142 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002144run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002145 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002146 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002147 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 +02002148 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002149 0 \
2150 -s "parse ServerName extension" \
2151 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2152 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002154run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002155 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002156 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002157 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 +02002158 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002159 1 \
2160 -s "parse ServerName extension" \
2161 -s "ssl_sni_wrapper() returned" \
2162 -s "mbedtls_ssl_handshake returned" \
2163 -c "mbedtls_ssl_handshake returned" \
2164 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002165
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002166run_test "SNI: client auth no override: optional" \
2167 "$P_SRV debug_level=3 auth_mode=optional \
2168 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2169 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2170 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002171 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002172 -S "skip write certificate request" \
2173 -C "skip parse certificate request" \
2174 -c "got a certificate request" \
2175 -C "skip write certificate" \
2176 -C "skip write certificate verify" \
2177 -S "skip parse certificate verify"
2178
2179run_test "SNI: client auth override: none -> optional" \
2180 "$P_SRV debug_level=3 auth_mode=none \
2181 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2182 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2183 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002184 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002185 -S "skip write certificate request" \
2186 -C "skip parse certificate request" \
2187 -c "got a certificate request" \
2188 -C "skip write certificate" \
2189 -C "skip write certificate verify" \
2190 -S "skip parse certificate verify"
2191
2192run_test "SNI: client auth override: optional -> none" \
2193 "$P_SRV debug_level=3 auth_mode=optional \
2194 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2195 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2196 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002197 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002198 -s "skip write certificate request" \
2199 -C "skip parse certificate request" \
2200 -c "got no certificate request" \
2201 -c "skip write certificate" \
2202 -c "skip write certificate verify" \
2203 -s "skip parse certificate verify"
2204
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002205run_test "SNI: CA no override" \
2206 "$P_SRV debug_level=3 auth_mode=optional \
2207 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2208 ca_file=data_files/test-ca.crt \
2209 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2210 "$P_CLI debug_level=3 server_name=localhost \
2211 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2212 1 \
2213 -S "skip write certificate request" \
2214 -C "skip parse certificate request" \
2215 -c "got a certificate request" \
2216 -C "skip write certificate" \
2217 -C "skip write certificate verify" \
2218 -S "skip parse certificate verify" \
2219 -s "x509_verify_cert() returned" \
2220 -s "! The certificate is not correctly signed by the trusted CA" \
2221 -S "The certificate has been revoked (is on a CRL)"
2222
2223run_test "SNI: CA override" \
2224 "$P_SRV debug_level=3 auth_mode=optional \
2225 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2226 ca_file=data_files/test-ca.crt \
2227 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2228 "$P_CLI debug_level=3 server_name=localhost \
2229 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2230 0 \
2231 -S "skip write certificate request" \
2232 -C "skip parse certificate request" \
2233 -c "got a certificate request" \
2234 -C "skip write certificate" \
2235 -C "skip write certificate verify" \
2236 -S "skip parse certificate verify" \
2237 -S "x509_verify_cert() returned" \
2238 -S "! The certificate is not correctly signed by the trusted CA" \
2239 -S "The certificate has been revoked (is on a CRL)"
2240
2241run_test "SNI: CA override with CRL" \
2242 "$P_SRV debug_level=3 auth_mode=optional \
2243 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2244 ca_file=data_files/test-ca.crt \
2245 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2246 "$P_CLI debug_level=3 server_name=localhost \
2247 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2248 1 \
2249 -S "skip write certificate request" \
2250 -C "skip parse certificate request" \
2251 -c "got a certificate request" \
2252 -C "skip write certificate" \
2253 -C "skip write certificate verify" \
2254 -S "skip parse certificate verify" \
2255 -s "x509_verify_cert() returned" \
2256 -S "! The certificate is not correctly signed by the trusted CA" \
2257 -s "The certificate has been revoked (is on a CRL)"
2258
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002259# Tests for non-blocking I/O: exercise a variety of handshake flows
2260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002261run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002262 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2263 "$P_CLI nbio=2 tickets=0" \
2264 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002265 -S "mbedtls_ssl_handshake returned" \
2266 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002267 -c "Read from server: .* bytes read"
2268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002269run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002270 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2271 "$P_CLI nbio=2 tickets=0" \
2272 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002273 -S "mbedtls_ssl_handshake returned" \
2274 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002275 -c "Read from server: .* bytes read"
2276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002277run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002278 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2279 "$P_CLI nbio=2 tickets=1" \
2280 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002281 -S "mbedtls_ssl_handshake returned" \
2282 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002283 -c "Read from server: .* bytes read"
2284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002285run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002286 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2287 "$P_CLI nbio=2 tickets=1" \
2288 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002289 -S "mbedtls_ssl_handshake returned" \
2290 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002291 -c "Read from server: .* bytes read"
2292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002293run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002294 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2295 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2296 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002297 -S "mbedtls_ssl_handshake returned" \
2298 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002299 -c "Read from server: .* bytes read"
2300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002301run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002302 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2303 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2304 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002305 -S "mbedtls_ssl_handshake returned" \
2306 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002307 -c "Read from server: .* bytes read"
2308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002309run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002310 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2311 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2312 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002313 -S "mbedtls_ssl_handshake returned" \
2314 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002315 -c "Read from server: .* bytes read"
2316
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002317# Tests for version negotiation
2318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002319run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002320 "$P_SRV" \
2321 "$P_CLI" \
2322 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002323 -S "mbedtls_ssl_handshake returned" \
2324 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002325 -s "Protocol is TLSv1.2" \
2326 -c "Protocol is TLSv1.2"
2327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002328run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002329 "$P_SRV" \
2330 "$P_CLI max_version=tls1_1" \
2331 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002332 -S "mbedtls_ssl_handshake returned" \
2333 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002334 -s "Protocol is TLSv1.1" \
2335 -c "Protocol is TLSv1.1"
2336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002337run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002338 "$P_SRV max_version=tls1_1" \
2339 "$P_CLI" \
2340 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002341 -S "mbedtls_ssl_handshake returned" \
2342 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002343 -s "Protocol is TLSv1.1" \
2344 -c "Protocol is TLSv1.1"
2345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002346run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002347 "$P_SRV max_version=tls1_1" \
2348 "$P_CLI max_version=tls1_1" \
2349 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002350 -S "mbedtls_ssl_handshake returned" \
2351 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002352 -s "Protocol is TLSv1.1" \
2353 -c "Protocol is TLSv1.1"
2354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002355run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002356 "$P_SRV min_version=tls1_1" \
2357 "$P_CLI max_version=tls1_1" \
2358 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002359 -S "mbedtls_ssl_handshake returned" \
2360 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002361 -s "Protocol is TLSv1.1" \
2362 -c "Protocol is TLSv1.1"
2363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002364run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002365 "$P_SRV max_version=tls1_1" \
2366 "$P_CLI min_version=tls1_1" \
2367 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002368 -S "mbedtls_ssl_handshake returned" \
2369 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002370 -s "Protocol is TLSv1.1" \
2371 -c "Protocol is TLSv1.1"
2372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002373run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002374 "$P_SRV max_version=tls1_1" \
2375 "$P_CLI min_version=tls1_2" \
2376 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002377 -s "mbedtls_ssl_handshake returned" \
2378 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002379 -c "SSL - Handshake protocol not within min/max boundaries"
2380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002381run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002382 "$P_SRV min_version=tls1_2" \
2383 "$P_CLI max_version=tls1_1" \
2384 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002385 -s "mbedtls_ssl_handshake returned" \
2386 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002387 -s "SSL - Handshake protocol not within min/max boundaries"
2388
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002389# Tests for ALPN extension
2390
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002391run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002392 "$P_SRV debug_level=3" \
2393 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002394 0 \
2395 -C "client hello, adding alpn extension" \
2396 -S "found alpn extension" \
2397 -C "got an alert message, type: \\[2:120]" \
2398 -S "server hello, adding alpn extension" \
2399 -C "found alpn extension " \
2400 -C "Application Layer Protocol is" \
2401 -S "Application Layer Protocol is"
2402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002403run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002404 "$P_SRV debug_level=3" \
2405 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002406 0 \
2407 -c "client hello, adding alpn extension" \
2408 -s "found alpn extension" \
2409 -C "got an alert message, type: \\[2:120]" \
2410 -S "server hello, adding alpn extension" \
2411 -C "found alpn extension " \
2412 -c "Application Layer Protocol is (none)" \
2413 -S "Application Layer Protocol is"
2414
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002415run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002416 "$P_SRV debug_level=3 alpn=abc,1234" \
2417 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002418 0 \
2419 -C "client hello, adding alpn extension" \
2420 -S "found alpn extension" \
2421 -C "got an alert message, type: \\[2:120]" \
2422 -S "server hello, adding alpn extension" \
2423 -C "found alpn extension " \
2424 -C "Application Layer Protocol is" \
2425 -s "Application Layer Protocol is (none)"
2426
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002427run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002428 "$P_SRV debug_level=3 alpn=abc,1234" \
2429 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002430 0 \
2431 -c "client hello, adding alpn extension" \
2432 -s "found alpn extension" \
2433 -C "got an alert message, type: \\[2:120]" \
2434 -s "server hello, adding alpn extension" \
2435 -c "found alpn extension" \
2436 -c "Application Layer Protocol is abc" \
2437 -s "Application Layer Protocol is abc"
2438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002439run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002440 "$P_SRV debug_level=3 alpn=abc,1234" \
2441 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002442 0 \
2443 -c "client hello, adding alpn extension" \
2444 -s "found alpn extension" \
2445 -C "got an alert message, type: \\[2:120]" \
2446 -s "server hello, adding alpn extension" \
2447 -c "found alpn extension" \
2448 -c "Application Layer Protocol is abc" \
2449 -s "Application Layer Protocol is abc"
2450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002451run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002452 "$P_SRV debug_level=3 alpn=abc,1234" \
2453 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002454 0 \
2455 -c "client hello, adding alpn extension" \
2456 -s "found alpn extension" \
2457 -C "got an alert message, type: \\[2:120]" \
2458 -s "server hello, adding alpn extension" \
2459 -c "found alpn extension" \
2460 -c "Application Layer Protocol is 1234" \
2461 -s "Application Layer Protocol is 1234"
2462
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002463run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002464 "$P_SRV debug_level=3 alpn=abc,123" \
2465 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002466 1 \
2467 -c "client hello, adding alpn extension" \
2468 -s "found alpn extension" \
2469 -c "got an alert message, type: \\[2:120]" \
2470 -S "server hello, adding alpn extension" \
2471 -C "found alpn extension" \
2472 -C "Application Layer Protocol is 1234" \
2473 -S "Application Layer Protocol is 1234"
2474
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002475
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002476# Tests for keyUsage in leaf certificates, part 1:
2477# server-side certificate/suite selection
2478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002479run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002480 "$P_SRV key_file=data_files/server2.key \
2481 crt_file=data_files/server2.ku-ds.crt" \
2482 "$P_CLI" \
2483 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002484 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002485
2486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002487run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002488 "$P_SRV key_file=data_files/server2.key \
2489 crt_file=data_files/server2.ku-ke.crt" \
2490 "$P_CLI" \
2491 0 \
2492 -c "Ciphersuite is TLS-RSA-WITH-"
2493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002494run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002495 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002496 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002497 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002498 1 \
2499 -C "Ciphersuite is "
2500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002501run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002502 "$P_SRV key_file=data_files/server5.key \
2503 crt_file=data_files/server5.ku-ds.crt" \
2504 "$P_CLI" \
2505 0 \
2506 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2507
2508
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002509run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002510 "$P_SRV key_file=data_files/server5.key \
2511 crt_file=data_files/server5.ku-ka.crt" \
2512 "$P_CLI" \
2513 0 \
2514 -c "Ciphersuite is TLS-ECDH-"
2515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002516run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002517 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002518 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002519 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002520 1 \
2521 -C "Ciphersuite is "
2522
2523# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002524# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002526run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002527 "$O_SRV -key data_files/server2.key \
2528 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002529 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002530 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2531 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002532 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002533 -C "Processing of the Certificate handshake message failed" \
2534 -c "Ciphersuite is TLS-"
2535
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002536run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002537 "$O_SRV -key data_files/server2.key \
2538 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002539 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002540 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2541 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002542 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002543 -C "Processing of the Certificate handshake message failed" \
2544 -c "Ciphersuite is TLS-"
2545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002546run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002547 "$O_SRV -key data_files/server2.key \
2548 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002549 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002550 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2551 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002552 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002553 -C "Processing of the Certificate handshake message failed" \
2554 -c "Ciphersuite is TLS-"
2555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002556run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002557 "$O_SRV -key data_files/server2.key \
2558 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002559 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002560 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2561 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002562 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002563 -c "Processing of the Certificate handshake message failed" \
2564 -C "Ciphersuite is TLS-"
2565
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002566run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2567 "$O_SRV -key data_files/server2.key \
2568 -cert data_files/server2.ku-ke.crt" \
2569 "$P_CLI debug_level=1 auth_mode=optional \
2570 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2571 0 \
2572 -c "bad certificate (usage extensions)" \
2573 -C "Processing of the Certificate handshake message failed" \
2574 -c "Ciphersuite is TLS-" \
2575 -c "! Usage does not match the keyUsage extension"
2576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002577run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002578 "$O_SRV -key data_files/server2.key \
2579 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002580 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002581 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2582 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002583 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002584 -C "Processing of the Certificate handshake message failed" \
2585 -c "Ciphersuite is TLS-"
2586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002587run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002588 "$O_SRV -key data_files/server2.key \
2589 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002590 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002591 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2592 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002593 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002594 -c "Processing of the Certificate handshake message failed" \
2595 -C "Ciphersuite is TLS-"
2596
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002597run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2598 "$O_SRV -key data_files/server2.key \
2599 -cert data_files/server2.ku-ds.crt" \
2600 "$P_CLI debug_level=1 auth_mode=optional \
2601 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2602 0 \
2603 -c "bad certificate (usage extensions)" \
2604 -C "Processing of the Certificate handshake message failed" \
2605 -c "Ciphersuite is TLS-" \
2606 -c "! Usage does not match the keyUsage extension"
2607
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002608# Tests for keyUsage in leaf certificates, part 3:
2609# server-side checking of client cert
2610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002611run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002612 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002613 "$O_CLI -key data_files/server2.key \
2614 -cert data_files/server2.ku-ds.crt" \
2615 0 \
2616 -S "bad certificate (usage extensions)" \
2617 -S "Processing of the Certificate handshake message failed"
2618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002619run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002620 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002621 "$O_CLI -key data_files/server2.key \
2622 -cert data_files/server2.ku-ke.crt" \
2623 0 \
2624 -s "bad certificate (usage extensions)" \
2625 -S "Processing of the Certificate handshake message failed"
2626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002627run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002628 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002629 "$O_CLI -key data_files/server2.key \
2630 -cert data_files/server2.ku-ke.crt" \
2631 1 \
2632 -s "bad certificate (usage extensions)" \
2633 -s "Processing of the Certificate handshake message failed"
2634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002635run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002636 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002637 "$O_CLI -key data_files/server5.key \
2638 -cert data_files/server5.ku-ds.crt" \
2639 0 \
2640 -S "bad certificate (usage extensions)" \
2641 -S "Processing of the Certificate handshake message failed"
2642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002643run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002644 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002645 "$O_CLI -key data_files/server5.key \
2646 -cert data_files/server5.ku-ka.crt" \
2647 0 \
2648 -s "bad certificate (usage extensions)" \
2649 -S "Processing of the Certificate handshake message failed"
2650
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002651# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002653run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002654 "$P_SRV key_file=data_files/server5.key \
2655 crt_file=data_files/server5.eku-srv.crt" \
2656 "$P_CLI" \
2657 0
2658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002659run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002660 "$P_SRV key_file=data_files/server5.key \
2661 crt_file=data_files/server5.eku-srv.crt" \
2662 "$P_CLI" \
2663 0
2664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002665run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002666 "$P_SRV key_file=data_files/server5.key \
2667 crt_file=data_files/server5.eku-cs_any.crt" \
2668 "$P_CLI" \
2669 0
2670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002671run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002672 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002673 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002674 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002675 1
2676
2677# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002679run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002680 "$O_SRV -key data_files/server5.key \
2681 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002682 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002683 0 \
2684 -C "bad certificate (usage extensions)" \
2685 -C "Processing of the Certificate handshake message failed" \
2686 -c "Ciphersuite is TLS-"
2687
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002688run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002689 "$O_SRV -key data_files/server5.key \
2690 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002691 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002692 0 \
2693 -C "bad certificate (usage extensions)" \
2694 -C "Processing of the Certificate handshake message failed" \
2695 -c "Ciphersuite is TLS-"
2696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002697run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002698 "$O_SRV -key data_files/server5.key \
2699 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002700 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002701 0 \
2702 -C "bad certificate (usage extensions)" \
2703 -C "Processing of the Certificate handshake message failed" \
2704 -c "Ciphersuite is TLS-"
2705
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002706run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002707 "$O_SRV -key data_files/server5.key \
2708 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002709 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002710 1 \
2711 -c "bad certificate (usage extensions)" \
2712 -c "Processing of the Certificate handshake message failed" \
2713 -C "Ciphersuite is TLS-"
2714
2715# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002717run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002718 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002719 "$O_CLI -key data_files/server5.key \
2720 -cert data_files/server5.eku-cli.crt" \
2721 0 \
2722 -S "bad certificate (usage extensions)" \
2723 -S "Processing of the Certificate handshake message failed"
2724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002725run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002726 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002727 "$O_CLI -key data_files/server5.key \
2728 -cert data_files/server5.eku-srv_cli.crt" \
2729 0 \
2730 -S "bad certificate (usage extensions)" \
2731 -S "Processing of the Certificate handshake message failed"
2732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002733run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002734 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002735 "$O_CLI -key data_files/server5.key \
2736 -cert data_files/server5.eku-cs_any.crt" \
2737 0 \
2738 -S "bad certificate (usage extensions)" \
2739 -S "Processing of the Certificate handshake message failed"
2740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002741run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002742 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002743 "$O_CLI -key data_files/server5.key \
2744 -cert data_files/server5.eku-cs.crt" \
2745 0 \
2746 -s "bad certificate (usage extensions)" \
2747 -S "Processing of the Certificate handshake message failed"
2748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002749run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002750 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002751 "$O_CLI -key data_files/server5.key \
2752 -cert data_files/server5.eku-cs.crt" \
2753 1 \
2754 -s "bad certificate (usage extensions)" \
2755 -s "Processing of the Certificate handshake message failed"
2756
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002757# Tests for DHM parameters loading
2758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002759run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002760 "$P_SRV" \
2761 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2762 debug_level=3" \
2763 0 \
2764 -c "value of 'DHM: P ' (2048 bits)" \
2765 -c "value of 'DHM: G ' (2048 bits)"
2766
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002767run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002768 "$P_SRV dhm_file=data_files/dhparams.pem" \
2769 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2770 debug_level=3" \
2771 0 \
2772 -c "value of 'DHM: P ' (1024 bits)" \
2773 -c "value of 'DHM: G ' (2 bits)"
2774
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002775# Tests for DHM client-side size checking
2776
2777run_test "DHM size: server default, client default, OK" \
2778 "$P_SRV" \
2779 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2780 debug_level=1" \
2781 0 \
2782 -C "DHM prime too short:"
2783
2784run_test "DHM size: server default, client 2048, OK" \
2785 "$P_SRV" \
2786 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2787 debug_level=1 dhmlen=2048" \
2788 0 \
2789 -C "DHM prime too short:"
2790
2791run_test "DHM size: server 1024, client default, OK" \
2792 "$P_SRV dhm_file=data_files/dhparams.pem" \
2793 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2794 debug_level=1" \
2795 0 \
2796 -C "DHM prime too short:"
2797
2798run_test "DHM size: server 1000, client default, rejected" \
2799 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2800 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2801 debug_level=1" \
2802 1 \
2803 -c "DHM prime too short:"
2804
2805run_test "DHM size: server default, client 2049, rejected" \
2806 "$P_SRV" \
2807 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2808 debug_level=1 dhmlen=2049" \
2809 1 \
2810 -c "DHM prime too short:"
2811
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002812# Tests for PSK callback
2813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002814run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002815 "$P_SRV psk=abc123 psk_identity=foo" \
2816 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2817 psk_identity=foo psk=abc123" \
2818 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002819 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002820 -S "SSL - Unknown identity received" \
2821 -S "SSL - Verification of the message MAC failed"
2822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002823run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002824 "$P_SRV" \
2825 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2826 psk_identity=foo psk=abc123" \
2827 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002828 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002829 -S "SSL - Unknown identity received" \
2830 -S "SSL - Verification of the message MAC failed"
2831
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002832run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002833 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2834 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2835 psk_identity=foo psk=abc123" \
2836 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002837 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002838 -s "SSL - Unknown identity received" \
2839 -S "SSL - Verification of the message MAC failed"
2840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002841run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002842 "$P_SRV psk_list=abc,dead,def,beef" \
2843 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2844 psk_identity=abc psk=dead" \
2845 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002846 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002847 -S "SSL - Unknown identity received" \
2848 -S "SSL - Verification of the message MAC failed"
2849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002850run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002851 "$P_SRV psk_list=abc,dead,def,beef" \
2852 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2853 psk_identity=def psk=beef" \
2854 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002855 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002856 -S "SSL - Unknown identity received" \
2857 -S "SSL - Verification of the message MAC failed"
2858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002859run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002860 "$P_SRV psk_list=abc,dead,def,beef" \
2861 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2862 psk_identity=ghi psk=beef" \
2863 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002864 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002865 -s "SSL - Unknown identity received" \
2866 -S "SSL - Verification of the message MAC failed"
2867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002868run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002869 "$P_SRV psk_list=abc,dead,def,beef" \
2870 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2871 psk_identity=abc psk=beef" \
2872 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002873 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002874 -S "SSL - Unknown identity received" \
2875 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002876
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002877# Tests for ciphersuites per version
2878
Janos Follath542ee5d2016-03-07 15:57:05 +00002879requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002880run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002881 "$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 +02002882 "$P_CLI force_version=ssl3" \
2883 0 \
2884 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002886run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002887 "$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 +01002888 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002889 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002890 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002892run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002893 "$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 +02002894 "$P_CLI force_version=tls1_1" \
2895 0 \
2896 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2897
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002898run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002899 "$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 +02002900 "$P_CLI force_version=tls1_2" \
2901 0 \
2902 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2903
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002904# Test for ClientHello without extensions
2905
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002906requires_gnutls
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002907run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002908 "$P_SRV debug_level=3" \
2909 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2910 0 \
2911 -s "dumping 'client hello extensions' (0 bytes)"
2912
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002913requires_gnutls
2914run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
2915 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
2916 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2917 0 \
2918 -s "dumping 'client hello extensions' (0 bytes)"
2919
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002920# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002921
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002922run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002923 "$P_SRV" \
2924 "$P_CLI request_size=100" \
2925 0 \
2926 -s "Read from client: 100 bytes read$"
2927
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002928run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002929 "$P_SRV" \
2930 "$P_CLI request_size=500" \
2931 0 \
2932 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002933
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002934# Tests for small packets
2935
Janos Follath542ee5d2016-03-07 15:57:05 +00002936requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002937run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002938 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002939 "$P_CLI request_size=1 force_version=ssl3 \
2940 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2941 0 \
2942 -s "Read from client: 1 bytes read"
2943
Janos Follath542ee5d2016-03-07 15:57:05 +00002944requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002945run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002946 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002947 "$P_CLI request_size=1 force_version=ssl3 \
2948 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2949 0 \
2950 -s "Read from client: 1 bytes read"
2951
2952run_test "Small packet TLS 1.0 BlockCipher" \
2953 "$P_SRV" \
2954 "$P_CLI request_size=1 force_version=tls1 \
2955 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2956 0 \
2957 -s "Read from client: 1 bytes read"
2958
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002959run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2960 "$P_SRV" \
2961 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2962 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2963 0 \
2964 -s "Read from client: 1 bytes read"
2965
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002966run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2967 "$P_SRV" \
2968 "$P_CLI request_size=1 force_version=tls1 \
2969 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2970 trunc_hmac=1" \
2971 0 \
2972 -s "Read from client: 1 bytes read"
2973
2974run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002975 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002976 "$P_CLI request_size=1 force_version=tls1 \
2977 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2978 trunc_hmac=1" \
2979 0 \
2980 -s "Read from client: 1 bytes read"
2981
2982run_test "Small packet TLS 1.1 BlockCipher" \
2983 "$P_SRV" \
2984 "$P_CLI request_size=1 force_version=tls1_1 \
2985 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2986 0 \
2987 -s "Read from client: 1 bytes read"
2988
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002989run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2990 "$P_SRV" \
2991 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2992 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2993 0 \
2994 -s "Read from client: 1 bytes read"
2995
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002996run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002997 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002998 "$P_CLI request_size=1 force_version=tls1_1 \
2999 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3000 0 \
3001 -s "Read from client: 1 bytes read"
3002
3003run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3004 "$P_SRV" \
3005 "$P_CLI request_size=1 force_version=tls1_1 \
3006 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3007 trunc_hmac=1" \
3008 0 \
3009 -s "Read from client: 1 bytes read"
3010
3011run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003012 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003013 "$P_CLI request_size=1 force_version=tls1_1 \
3014 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3015 trunc_hmac=1" \
3016 0 \
3017 -s "Read from client: 1 bytes read"
3018
3019run_test "Small packet TLS 1.2 BlockCipher" \
3020 "$P_SRV" \
3021 "$P_CLI request_size=1 force_version=tls1_2 \
3022 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3023 0 \
3024 -s "Read from client: 1 bytes read"
3025
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003026run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3027 "$P_SRV" \
3028 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3029 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3030 0 \
3031 -s "Read from client: 1 bytes read"
3032
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003033run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3034 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003035 "$P_CLI request_size=1 force_version=tls1_2 \
3036 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003037 0 \
3038 -s "Read from client: 1 bytes read"
3039
3040run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3041 "$P_SRV" \
3042 "$P_CLI request_size=1 force_version=tls1_2 \
3043 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3044 trunc_hmac=1" \
3045 0 \
3046 -s "Read from client: 1 bytes read"
3047
3048run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003049 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003050 "$P_CLI request_size=1 force_version=tls1_2 \
3051 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3052 0 \
3053 -s "Read from client: 1 bytes read"
3054
3055run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003056 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003057 "$P_CLI request_size=1 force_version=tls1_2 \
3058 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3059 trunc_hmac=1" \
3060 0 \
3061 -s "Read from client: 1 bytes read"
3062
3063run_test "Small packet TLS 1.2 AEAD" \
3064 "$P_SRV" \
3065 "$P_CLI request_size=1 force_version=tls1_2 \
3066 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3067 0 \
3068 -s "Read from client: 1 bytes read"
3069
3070run_test "Small packet TLS 1.2 AEAD shorter tag" \
3071 "$P_SRV" \
3072 "$P_CLI request_size=1 force_version=tls1_2 \
3073 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3074 0 \
3075 -s "Read from client: 1 bytes read"
3076
Janos Follathb700c462016-05-06 13:48:23 +01003077# A test for extensions in SSLv3
3078
3079requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3080run_test "SSLv3 with extensions, server side" \
3081 "$P_SRV min_version=ssl3 debug_level=3" \
3082 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3083 0 \
3084 -S "dumping 'client hello extensions'" \
3085 -S "server hello, total extension length:"
3086
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003087# Test for large packets
3088
Janos Follath542ee5d2016-03-07 15:57:05 +00003089requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003090run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003091 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003092 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003093 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3094 0 \
3095 -s "Read from client: 16384 bytes read"
3096
Janos Follath542ee5d2016-03-07 15:57:05 +00003097requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003098run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003099 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003100 "$P_CLI request_size=16384 force_version=ssl3 \
3101 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3102 0 \
3103 -s "Read from client: 16384 bytes read"
3104
3105run_test "Large packet TLS 1.0 BlockCipher" \
3106 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003107 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003108 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3109 0 \
3110 -s "Read from client: 16384 bytes read"
3111
3112run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3113 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003114 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003115 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3116 trunc_hmac=1" \
3117 0 \
3118 -s "Read from client: 16384 bytes read"
3119
3120run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003121 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003122 "$P_CLI request_size=16384 force_version=tls1 \
3123 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3124 trunc_hmac=1" \
3125 0 \
3126 -s "Read from client: 16384 bytes read"
3127
3128run_test "Large packet TLS 1.1 BlockCipher" \
3129 "$P_SRV" \
3130 "$P_CLI request_size=16384 force_version=tls1_1 \
3131 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3132 0 \
3133 -s "Read from client: 16384 bytes read"
3134
3135run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003136 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003137 "$P_CLI request_size=16384 force_version=tls1_1 \
3138 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3139 0 \
3140 -s "Read from client: 16384 bytes read"
3141
3142run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3143 "$P_SRV" \
3144 "$P_CLI request_size=16384 force_version=tls1_1 \
3145 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3146 trunc_hmac=1" \
3147 0 \
3148 -s "Read from client: 16384 bytes read"
3149
3150run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003151 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003152 "$P_CLI request_size=16384 force_version=tls1_1 \
3153 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3154 trunc_hmac=1" \
3155 0 \
3156 -s "Read from client: 16384 bytes read"
3157
3158run_test "Large packet TLS 1.2 BlockCipher" \
3159 "$P_SRV" \
3160 "$P_CLI request_size=16384 force_version=tls1_2 \
3161 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3162 0 \
3163 -s "Read from client: 16384 bytes read"
3164
3165run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3166 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003167 "$P_CLI request_size=16384 force_version=tls1_2 \
3168 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003169 0 \
3170 -s "Read from client: 16384 bytes read"
3171
3172run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3173 "$P_SRV" \
3174 "$P_CLI request_size=16384 force_version=tls1_2 \
3175 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3176 trunc_hmac=1" \
3177 0 \
3178 -s "Read from client: 16384 bytes read"
3179
3180run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003181 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003182 "$P_CLI request_size=16384 force_version=tls1_2 \
3183 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3184 0 \
3185 -s "Read from client: 16384 bytes read"
3186
3187run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003188 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003189 "$P_CLI request_size=16384 force_version=tls1_2 \
3190 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3191 trunc_hmac=1" \
3192 0 \
3193 -s "Read from client: 16384 bytes read"
3194
3195run_test "Large packet TLS 1.2 AEAD" \
3196 "$P_SRV" \
3197 "$P_CLI request_size=16384 force_version=tls1_2 \
3198 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3199 0 \
3200 -s "Read from client: 16384 bytes read"
3201
3202run_test "Large packet TLS 1.2 AEAD shorter tag" \
3203 "$P_SRV" \
3204 "$P_CLI request_size=16384 force_version=tls1_2 \
3205 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3206 0 \
3207 -s "Read from client: 16384 bytes read"
3208
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003209# Tests for DTLS HelloVerifyRequest
3210
3211run_test "DTLS cookie: enabled" \
3212 "$P_SRV dtls=1 debug_level=2" \
3213 "$P_CLI dtls=1 debug_level=2" \
3214 0 \
3215 -s "cookie verification failed" \
3216 -s "cookie verification passed" \
3217 -S "cookie verification skipped" \
3218 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003219 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003220 -S "SSL - The requested feature is not available"
3221
3222run_test "DTLS cookie: disabled" \
3223 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3224 "$P_CLI dtls=1 debug_level=2" \
3225 0 \
3226 -S "cookie verification failed" \
3227 -S "cookie verification passed" \
3228 -s "cookie verification skipped" \
3229 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003230 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003231 -S "SSL - The requested feature is not available"
3232
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003233run_test "DTLS cookie: default (failing)" \
3234 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3235 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3236 1 \
3237 -s "cookie verification failed" \
3238 -S "cookie verification passed" \
3239 -S "cookie verification skipped" \
3240 -C "received hello verify request" \
3241 -S "hello verification requested" \
3242 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003243
3244requires_ipv6
3245run_test "DTLS cookie: enabled, IPv6" \
3246 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3247 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3248 0 \
3249 -s "cookie verification failed" \
3250 -s "cookie verification passed" \
3251 -S "cookie verification skipped" \
3252 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003253 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003254 -S "SSL - The requested feature is not available"
3255
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003256run_test "DTLS cookie: enabled, nbio" \
3257 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3258 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3259 0 \
3260 -s "cookie verification failed" \
3261 -s "cookie verification passed" \
3262 -S "cookie verification skipped" \
3263 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003264 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003265 -S "SSL - The requested feature is not available"
3266
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003267# Tests for client reconnecting from the same port with DTLS
3268
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003269not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003270run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003271 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3272 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003273 0 \
3274 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003275 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003276 -S "Client initiated reconnection from same port"
3277
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003278not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003279run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003280 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3281 "$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 +02003282 0 \
3283 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003284 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003285 -s "Client initiated reconnection from same port"
3286
Paul Bakker3b224ff2016-05-13 10:33:25 +01003287not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3288run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003289 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3290 "$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 +02003291 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003292 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003293 -s "Client initiated reconnection from same port"
3294
Paul Bakker3b224ff2016-05-13 10:33:25 +01003295only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3296run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3297 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3298 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3299 0 \
3300 -S "The operation timed out" \
3301 -s "Client initiated reconnection from same port"
3302
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003303run_test "DTLS client reconnect from same port: no cookies" \
3304 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003305 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3306 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003307 -s "The operation timed out" \
3308 -S "Client initiated reconnection from same port"
3309
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003310# Tests for various cases of client authentication with DTLS
3311# (focused on handshake flows and message parsing)
3312
3313run_test "DTLS client auth: required" \
3314 "$P_SRV dtls=1 auth_mode=required" \
3315 "$P_CLI dtls=1" \
3316 0 \
3317 -s "Verifying peer X.509 certificate... ok"
3318
3319run_test "DTLS client auth: optional, client has no cert" \
3320 "$P_SRV dtls=1 auth_mode=optional" \
3321 "$P_CLI dtls=1 crt_file=none key_file=none" \
3322 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003323 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003324
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003325run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003326 "$P_SRV dtls=1 auth_mode=none" \
3327 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3328 0 \
3329 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003330 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003331
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003332run_test "DTLS wrong PSK: badmac alert" \
3333 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3334 "$P_CLI dtls=1 psk=abc124" \
3335 1 \
3336 -s "SSL - Verification of the message MAC failed" \
3337 -c "SSL - A fatal alert message was received from our peer"
3338
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003339# Tests for receiving fragmented handshake messages with DTLS
3340
3341requires_gnutls
3342run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3343 "$G_SRV -u --mtu 2048 -a" \
3344 "$P_CLI dtls=1 debug_level=2" \
3345 0 \
3346 -C "found fragmented DTLS handshake message" \
3347 -C "error"
3348
3349requires_gnutls
3350run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3351 "$G_SRV -u --mtu 512" \
3352 "$P_CLI dtls=1 debug_level=2" \
3353 0 \
3354 -c "found fragmented DTLS handshake message" \
3355 -C "error"
3356
3357requires_gnutls
3358run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3359 "$G_SRV -u --mtu 128" \
3360 "$P_CLI dtls=1 debug_level=2" \
3361 0 \
3362 -c "found fragmented DTLS handshake message" \
3363 -C "error"
3364
3365requires_gnutls
3366run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3367 "$G_SRV -u --mtu 128" \
3368 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3369 0 \
3370 -c "found fragmented DTLS handshake message" \
3371 -C "error"
3372
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003373requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01003374requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003375run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3376 "$G_SRV -u --mtu 256" \
3377 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3378 0 \
3379 -c "found fragmented DTLS handshake message" \
3380 -c "client hello, adding renegotiation extension" \
3381 -c "found renegotiation extension" \
3382 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003383 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003384 -C "error" \
3385 -s "Extra-header:"
3386
3387requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01003388requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003389run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3390 "$G_SRV -u --mtu 256" \
3391 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3392 0 \
3393 -c "found fragmented DTLS handshake message" \
3394 -c "client hello, adding renegotiation extension" \
3395 -c "found renegotiation extension" \
3396 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003397 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003398 -C "error" \
3399 -s "Extra-header:"
3400
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003401run_test "DTLS reassembly: no fragmentation (openssl server)" \
3402 "$O_SRV -dtls1 -mtu 2048" \
3403 "$P_CLI dtls=1 debug_level=2" \
3404 0 \
3405 -C "found fragmented DTLS handshake message" \
3406 -C "error"
3407
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003408run_test "DTLS reassembly: some fragmentation (openssl server)" \
3409 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003410 "$P_CLI dtls=1 debug_level=2" \
3411 0 \
3412 -c "found fragmented DTLS handshake message" \
3413 -C "error"
3414
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003415run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003416 "$O_SRV -dtls1 -mtu 256" \
3417 "$P_CLI dtls=1 debug_level=2" \
3418 0 \
3419 -c "found fragmented DTLS handshake message" \
3420 -C "error"
3421
3422run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3423 "$O_SRV -dtls1 -mtu 256" \
3424 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3425 0 \
3426 -c "found fragmented DTLS handshake message" \
3427 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003428
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003429# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003430
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003431not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003432run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003433 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003434 "$P_SRV dtls=1 debug_level=2" \
3435 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003436 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003437 -C "replayed record" \
3438 -S "replayed record" \
3439 -C "record from another epoch" \
3440 -S "record from another epoch" \
3441 -C "discarding invalid record" \
3442 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003443 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003444 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003445 -c "HTTP/1.0 200 OK"
3446
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003447not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003448run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003449 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003450 "$P_SRV dtls=1 debug_level=2" \
3451 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003452 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003453 -c "replayed record" \
3454 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003455 -c "discarding invalid record" \
3456 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003457 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003458 -s "Extra-header:" \
3459 -c "HTTP/1.0 200 OK"
3460
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003461run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3462 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003463 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3464 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003465 0 \
3466 -c "replayed record" \
3467 -S "replayed record" \
3468 -c "discarding invalid record" \
3469 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003470 -c "resend" \
3471 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003472 -s "Extra-header:" \
3473 -c "HTTP/1.0 200 OK"
3474
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003475run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003476 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003477 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003478 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003479 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003480 -c "discarding invalid record (mac)" \
3481 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003482 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003483 -c "HTTP/1.0 200 OK" \
3484 -S "too many records with bad MAC" \
3485 -S "Verification of the message MAC failed"
3486
3487run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3488 -p "$P_PXY bad_ad=1" \
3489 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3490 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3491 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003492 -C "discarding invalid record (mac)" \
3493 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003494 -S "Extra-header:" \
3495 -C "HTTP/1.0 200 OK" \
3496 -s "too many records with bad MAC" \
3497 -s "Verification of the message MAC failed"
3498
3499run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3500 -p "$P_PXY bad_ad=1" \
3501 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3502 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3503 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003504 -c "discarding invalid record (mac)" \
3505 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003506 -s "Extra-header:" \
3507 -c "HTTP/1.0 200 OK" \
3508 -S "too many records with bad MAC" \
3509 -S "Verification of the message MAC failed"
3510
3511run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3512 -p "$P_PXY bad_ad=1" \
3513 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3514 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3515 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003516 -c "discarding invalid record (mac)" \
3517 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003518 -s "Extra-header:" \
3519 -c "HTTP/1.0 200 OK" \
3520 -s "too many records with bad MAC" \
3521 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003522
3523run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003524 -p "$P_PXY delay_ccs=1" \
3525 "$P_SRV dtls=1 debug_level=1" \
3526 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003527 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003528 -c "record from another epoch" \
3529 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003530 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003531 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003532 -s "Extra-header:" \
3533 -c "HTTP/1.0 200 OK"
3534
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003535# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003536
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003537needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003538run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003539 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003540 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3541 psk=abc123" \
3542 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003543 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3544 0 \
3545 -s "Extra-header:" \
3546 -c "HTTP/1.0 200 OK"
3547
3548needs_more_time 2
3549run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3550 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003551 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3552 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003553 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3554 0 \
3555 -s "Extra-header:" \
3556 -c "HTTP/1.0 200 OK"
3557
3558needs_more_time 2
3559run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3560 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003561 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3562 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003563 0 \
3564 -s "Extra-header:" \
3565 -c "HTTP/1.0 200 OK"
3566
3567needs_more_time 2
3568run_test "DTLS proxy: 3d, FS, client auth" \
3569 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003570 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3571 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003572 0 \
3573 -s "Extra-header:" \
3574 -c "HTTP/1.0 200 OK"
3575
3576needs_more_time 2
3577run_test "DTLS proxy: 3d, FS, ticket" \
3578 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003579 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3580 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003581 0 \
3582 -s "Extra-header:" \
3583 -c "HTTP/1.0 200 OK"
3584
3585needs_more_time 2
3586run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3587 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003588 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3589 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003590 0 \
3591 -s "Extra-header:" \
3592 -c "HTTP/1.0 200 OK"
3593
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003594needs_more_time 2
3595run_test "DTLS proxy: 3d, max handshake, nbio" \
3596 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003597 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3598 auth_mode=required" \
3599 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003600 0 \
3601 -s "Extra-header:" \
3602 -c "HTTP/1.0 200 OK"
3603
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003604needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003605run_test "DTLS proxy: 3d, min handshake, resumption" \
3606 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3607 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3608 psk=abc123 debug_level=3" \
3609 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3610 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3611 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3612 0 \
3613 -s "a session has been resumed" \
3614 -c "a session has been resumed" \
3615 -s "Extra-header:" \
3616 -c "HTTP/1.0 200 OK"
3617
3618needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003619run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3620 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3621 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3622 psk=abc123 debug_level=3 nbio=2" \
3623 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3624 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3625 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3626 0 \
3627 -s "a session has been resumed" \
3628 -c "a session has been resumed" \
3629 -s "Extra-header:" \
3630 -c "HTTP/1.0 200 OK"
3631
3632needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01003633requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003634run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003635 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003636 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3637 psk=abc123 renegotiation=1 debug_level=2" \
3638 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3639 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003640 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3641 0 \
3642 -c "=> renegotiate" \
3643 -s "=> renegotiate" \
3644 -s "Extra-header:" \
3645 -c "HTTP/1.0 200 OK"
3646
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003647needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01003648requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003649run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3650 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003651 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3652 psk=abc123 renegotiation=1 debug_level=2" \
3653 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3654 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003655 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3656 0 \
3657 -c "=> renegotiate" \
3658 -s "=> renegotiate" \
3659 -s "Extra-header:" \
3660 -c "HTTP/1.0 200 OK"
3661
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003662needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01003663requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003664run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003665 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003666 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003667 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003668 debug_level=2" \
3669 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003670 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003671 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3672 0 \
3673 -c "=> renegotiate" \
3674 -s "=> renegotiate" \
3675 -s "Extra-header:" \
3676 -c "HTTP/1.0 200 OK"
3677
3678needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01003679requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003680run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003681 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003682 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003683 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003684 debug_level=2 nbio=2" \
3685 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003686 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003687 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3688 0 \
3689 -c "=> renegotiate" \
3690 -s "=> renegotiate" \
3691 -s "Extra-header:" \
3692 -c "HTTP/1.0 200 OK"
3693
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003694needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003695not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003696run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003697 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3698 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003699 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003700 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003701 -c "HTTP/1.0 200 OK"
3702
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003703needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003704not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003705run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3706 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3707 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003708 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003709 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003710 -c "HTTP/1.0 200 OK"
3711
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003712needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003713not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003714run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3715 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3716 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003717 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003718 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003719 -c "HTTP/1.0 200 OK"
3720
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003721requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003722needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003723not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003724run_test "DTLS proxy: 3d, gnutls server" \
3725 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3726 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003727 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003728 0 \
3729 -s "Extra-header:" \
3730 -c "Extra-header:"
3731
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003732requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003733needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003734not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003735run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3736 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3737 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003738 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003739 0 \
3740 -s "Extra-header:" \
3741 -c "Extra-header:"
3742
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003743requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003744needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003745not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003746run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3747 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3748 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003749 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003750 0 \
3751 -s "Extra-header:" \
3752 -c "Extra-header:"
3753
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003754# Final report
3755
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003756echo "------------------------------------------------------------------------"
3757
3758if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003759 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003760else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003761 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003762fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003763PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003764echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003765
3766exit $FAILS