blob: 5f47bb5d9ad66e1822ffafa31e686f54f7357256 [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
Hanno Becker64691dc2017-09-22 16:58:50 +01001221MAX_CONTENT_LEN_EXPECT='16384'
1222MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1223
1224if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1225 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1226 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1227 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1228 printf "\n"
1229 printf "The tests assume this value and if it changes, the tests in this\n"
1230 printf "script should also be adjusted.\n"
1231 printf "\n"
1232
1233 exit 1
1234fi
1235
Hanno Becker05607782017-09-18 15:00:34 +01001236requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001237run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001238 "$P_SRV debug_level=3" \
1239 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001240 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001241 -c "Maximum fragment length is 16384" \
1242 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001243 -C "client hello, adding max_fragment_length extension" \
1244 -S "found max fragment length extension" \
1245 -S "server hello, max_fragment_length extension" \
1246 -C "found max_fragment_length extension"
1247
Hanno Becker05607782017-09-18 15:00:34 +01001248requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001249run_test "Max fragment length: enabled, default, larger message" \
1250 "$P_SRV debug_level=3" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001251 "$P_CLI debug_level=3 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001252 0 \
1253 -c "Maximum fragment length is 16384" \
1254 -s "Maximum fragment length is 16384" \
1255 -C "client hello, adding max_fragment_length extension" \
1256 -S "found max fragment length extension" \
1257 -S "server hello, max_fragment_length extension" \
1258 -C "found max_fragment_length extension" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001259 -c "16385 bytes written in 2 fragments" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001260 -s "16384 bytes read" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001261 -s "1 bytes read"
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001262
1263requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1264run_test "Max fragment length, DTLS: enabled, default, larger message" \
1265 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001266 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001267 1 \
1268 -c "Maximum fragment length is 16384" \
1269 -s "Maximum fragment length is 16384" \
1270 -C "client hello, adding max_fragment_length extension" \
1271 -S "found max fragment length extension" \
1272 -S "server hello, max_fragment_length extension" \
1273 -C "found max_fragment_length extension" \
1274 -c "fragment larger than.*maximum "
1275
1276requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1277run_test "Max fragment length: disabled, larger message" \
1278 "$P_SRV debug_level=3" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001279 "$P_CLI debug_level=3 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001280 0 \
1281 -C "Maximum fragment length is 16384" \
1282 -S "Maximum fragment length is 16384" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001283 -c "16385 bytes written in 2 fragments" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001284 -s "16384 bytes read" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001285 -s "1 bytes read"
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001286
1287requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1288run_test "Max fragment length DTLS: disabled, larger message" \
1289 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001290 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001291 1 \
1292 -C "Maximum fragment length is 16384" \
1293 -S "Maximum fragment length is 16384" \
1294 -c "fragment larger than.*maximum "
1295
1296requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001297run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001298 "$P_SRV debug_level=3" \
1299 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001300 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001301 -c "Maximum fragment length is 4096" \
1302 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001303 -c "client hello, adding max_fragment_length extension" \
1304 -s "found max fragment length extension" \
1305 -s "server hello, max_fragment_length extension" \
1306 -c "found max_fragment_length extension"
1307
Hanno Becker05607782017-09-18 15:00:34 +01001308requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001309run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001310 "$P_SRV debug_level=3 max_frag_len=4096" \
1311 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001312 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001313 -c "Maximum fragment length is 16384" \
1314 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001315 -C "client hello, adding max_fragment_length extension" \
1316 -S "found max fragment length extension" \
1317 -S "server hello, max_fragment_length extension" \
1318 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001319
Hanno Becker05607782017-09-18 15:00:34 +01001320requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001321requires_gnutls
1322run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001323 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001324 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001325 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001326 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001327 -c "client hello, adding max_fragment_length extension" \
1328 -c "found max_fragment_length extension"
1329
Hanno Becker05607782017-09-18 15:00:34 +01001330requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001331run_test "Max fragment length: client, message just fits" \
1332 "$P_SRV debug_level=3" \
1333 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1334 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001335 -c "Maximum fragment length is 2048" \
1336 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001337 -c "client hello, adding max_fragment_length extension" \
1338 -s "found max fragment length extension" \
1339 -s "server hello, max_fragment_length extension" \
1340 -c "found max_fragment_length extension" \
1341 -c "2048 bytes written in 1 fragments" \
1342 -s "2048 bytes read"
1343
Hanno Becker05607782017-09-18 15:00:34 +01001344requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001345run_test "Max fragment length: client, larger message" \
1346 "$P_SRV debug_level=3" \
1347 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1348 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001349 -c "Maximum fragment length is 2048" \
1350 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001351 -c "client hello, adding max_fragment_length extension" \
1352 -s "found max fragment length extension" \
1353 -s "server hello, max_fragment_length extension" \
1354 -c "found max_fragment_length extension" \
1355 -c "2345 bytes written in 2 fragments" \
1356 -s "2048 bytes read" \
1357 -s "297 bytes read"
1358
Hanno Becker05607782017-09-18 15:00:34 +01001359requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001360run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001361 "$P_SRV debug_level=3 dtls=1" \
1362 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1363 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001364 -c "Maximum fragment length is 2048" \
1365 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001366 -c "client hello, adding max_fragment_length extension" \
1367 -s "found max fragment length extension" \
1368 -s "server hello, max_fragment_length extension" \
1369 -c "found max_fragment_length extension" \
1370 -c "fragment larger than.*maximum"
1371
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001372# Tests for renegotiation
1373
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001374run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001375 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001376 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001377 0 \
1378 -C "client hello, adding renegotiation extension" \
1379 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1380 -S "found renegotiation extension" \
1381 -s "server hello, secure renegotiation extension" \
1382 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001383 -C "=> renegotiate" \
1384 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001385 -S "write hello request"
1386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001387run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001388 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001389 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001390 0 \
1391 -c "client hello, adding renegotiation extension" \
1392 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1393 -s "found renegotiation extension" \
1394 -s "server hello, secure renegotiation extension" \
1395 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001396 -c "=> renegotiate" \
1397 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001398 -S "write hello request"
1399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001400run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001401 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001402 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001403 0 \
1404 -c "client hello, adding renegotiation extension" \
1405 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1406 -s "found renegotiation extension" \
1407 -s "server hello, secure renegotiation extension" \
1408 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001409 -c "=> renegotiate" \
1410 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001411 -s "write hello request"
1412
Janos Follath5f1dd802017-10-05 12:29:42 +01001413# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1414# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1415# algorithm stronger than SHA-1 is enabled in config.h
1416run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1417 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1418 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1419 0 \
1420 -c "client hello, adding renegotiation extension" \
1421 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1422 -s "found renegotiation extension" \
1423 -s "server hello, secure renegotiation extension" \
1424 -c "found renegotiation extension" \
1425 -c "=> renegotiate" \
1426 -s "=> renegotiate" \
1427 -S "write hello request" \
1428 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1429
1430# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1431# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1432# algorithm stronger than SHA-1 is enabled in config.h
1433run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1434 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1435 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1436 0 \
1437 -c "client hello, adding renegotiation extension" \
1438 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1439 -s "found renegotiation extension" \
1440 -s "server hello, secure renegotiation extension" \
1441 -c "found renegotiation extension" \
1442 -c "=> renegotiate" \
1443 -s "=> renegotiate" \
1444 -s "write hello request" \
1445 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001447run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001448 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001449 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001450 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" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001456 -c "=> renegotiate" \
1457 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001458 -s "write hello request"
1459
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001460run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001461 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001462 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001463 1 \
1464 -c "client hello, adding renegotiation extension" \
1465 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1466 -S "found renegotiation extension" \
1467 -s "server hello, secure renegotiation extension" \
1468 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001469 -c "=> renegotiate" \
1470 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001471 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001472 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001473 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001474
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001475run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001476 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001477 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001478 0 \
1479 -C "client hello, adding renegotiation extension" \
1480 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1481 -S "found renegotiation extension" \
1482 -s "server hello, secure renegotiation extension" \
1483 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001484 -C "=> renegotiate" \
1485 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001486 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001487 -S "SSL - An unexpected message was received from our peer" \
1488 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001490run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001491 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001492 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001493 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001494 0 \
1495 -C "client hello, adding renegotiation extension" \
1496 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1497 -S "found renegotiation extension" \
1498 -s "server hello, secure renegotiation extension" \
1499 -c "found renegotiation extension" \
1500 -C "=> renegotiate" \
1501 -S "=> renegotiate" \
1502 -s "write hello request" \
1503 -S "SSL - An unexpected message was received from our peer" \
1504 -S "failed"
1505
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001506# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001508 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001509 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001510 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001511 0 \
1512 -C "client hello, adding renegotiation extension" \
1513 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1514 -S "found renegotiation extension" \
1515 -s "server hello, secure renegotiation extension" \
1516 -c "found renegotiation extension" \
1517 -C "=> renegotiate" \
1518 -S "=> renegotiate" \
1519 -s "write hello request" \
1520 -S "SSL - An unexpected message was received from our peer" \
1521 -S "failed"
1522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001523run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001524 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001525 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001526 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001527 0 \
1528 -C "client hello, adding renegotiation extension" \
1529 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1530 -S "found renegotiation extension" \
1531 -s "server hello, secure renegotiation extension" \
1532 -c "found renegotiation extension" \
1533 -C "=> renegotiate" \
1534 -S "=> renegotiate" \
1535 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001536 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001538run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001539 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001540 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001541 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001542 0 \
1543 -c "client hello, adding renegotiation extension" \
1544 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1545 -s "found renegotiation extension" \
1546 -s "server hello, secure renegotiation extension" \
1547 -c "found renegotiation extension" \
1548 -c "=> renegotiate" \
1549 -s "=> renegotiate" \
1550 -s "write hello request" \
1551 -S "SSL - An unexpected message was received from our peer" \
1552 -S "failed"
1553
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001554run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001555 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001556 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1557 0 \
1558 -C "client hello, adding renegotiation extension" \
1559 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1560 -S "found renegotiation extension" \
1561 -s "server hello, secure renegotiation extension" \
1562 -c "found renegotiation extension" \
1563 -S "record counter limit reached: renegotiate" \
1564 -C "=> renegotiate" \
1565 -S "=> renegotiate" \
1566 -S "write hello request" \
1567 -S "SSL - An unexpected message was received from our peer" \
1568 -S "failed"
1569
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001570# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001571run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001572 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001573 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001574 0 \
1575 -c "client hello, adding renegotiation extension" \
1576 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1577 -s "found renegotiation extension" \
1578 -s "server hello, secure renegotiation extension" \
1579 -c "found renegotiation extension" \
1580 -s "record counter limit reached: renegotiate" \
1581 -c "=> renegotiate" \
1582 -s "=> renegotiate" \
1583 -s "write hello request" \
1584 -S "SSL - An unexpected message was received from our peer" \
1585 -S "failed"
1586
1587run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001588 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001589 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001590 0 \
1591 -c "client hello, adding renegotiation extension" \
1592 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1593 -s "found renegotiation extension" \
1594 -s "server hello, secure renegotiation extension" \
1595 -c "found renegotiation extension" \
1596 -s "record counter limit reached: renegotiate" \
1597 -c "=> renegotiate" \
1598 -s "=> renegotiate" \
1599 -s "write hello request" \
1600 -S "SSL - An unexpected message was received from our peer" \
1601 -S "failed"
1602
1603run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001604 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001605 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1606 0 \
1607 -C "client hello, adding renegotiation extension" \
1608 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1609 -S "found renegotiation extension" \
1610 -s "server hello, secure renegotiation extension" \
1611 -c "found renegotiation extension" \
1612 -S "record counter limit reached: renegotiate" \
1613 -C "=> renegotiate" \
1614 -S "=> renegotiate" \
1615 -S "write hello request" \
1616 -S "SSL - An unexpected message was received from our peer" \
1617 -S "failed"
1618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001619run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001620 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001621 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001622 0 \
1623 -c "client hello, adding renegotiation extension" \
1624 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1625 -s "found renegotiation extension" \
1626 -s "server hello, secure renegotiation extension" \
1627 -c "found renegotiation extension" \
1628 -c "=> renegotiate" \
1629 -s "=> renegotiate" \
1630 -S "write hello request"
1631
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001632run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001633 "$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 +02001634 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001635 0 \
1636 -c "client hello, adding renegotiation extension" \
1637 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1638 -s "found renegotiation extension" \
1639 -s "server hello, secure renegotiation extension" \
1640 -c "found renegotiation extension" \
1641 -c "=> renegotiate" \
1642 -s "=> renegotiate" \
1643 -s "write hello request"
1644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001645run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001646 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001647 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001648 0 \
1649 -c "client hello, adding renegotiation extension" \
1650 -c "found renegotiation extension" \
1651 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001652 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001653 -C "error" \
1654 -c "HTTP/1.0 200 [Oo][Kk]"
1655
Paul Bakker539d9722015-02-08 16:18:35 +01001656requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001657run_test "Renegotiation: gnutls server strict, client-initiated" \
1658 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001659 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001660 0 \
1661 -c "client hello, adding renegotiation extension" \
1662 -c "found renegotiation extension" \
1663 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001664 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001665 -C "error" \
1666 -c "HTTP/1.0 200 [Oo][Kk]"
1667
Paul Bakker539d9722015-02-08 16:18:35 +01001668requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001669run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1670 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1671 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1672 1 \
1673 -c "client hello, adding renegotiation extension" \
1674 -C "found renegotiation extension" \
1675 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001676 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001677 -c "error" \
1678 -C "HTTP/1.0 200 [Oo][Kk]"
1679
Paul Bakker539d9722015-02-08 16:18:35 +01001680requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001681run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1682 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1683 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1684 allow_legacy=0" \
1685 1 \
1686 -c "client hello, adding renegotiation extension" \
1687 -C "found renegotiation extension" \
1688 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001689 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001690 -c "error" \
1691 -C "HTTP/1.0 200 [Oo][Kk]"
1692
Paul Bakker539d9722015-02-08 16:18:35 +01001693requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001694run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1695 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1696 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1697 allow_legacy=1" \
1698 0 \
1699 -c "client hello, adding renegotiation extension" \
1700 -C "found renegotiation extension" \
1701 -c "=> renegotiate" \
1702 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001703 -C "error" \
1704 -c "HTTP/1.0 200 [Oo][Kk]"
1705
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001706run_test "Renegotiation: DTLS, client-initiated" \
1707 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1708 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1709 0 \
1710 -c "client hello, adding renegotiation extension" \
1711 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1712 -s "found renegotiation extension" \
1713 -s "server hello, secure renegotiation extension" \
1714 -c "found renegotiation extension" \
1715 -c "=> renegotiate" \
1716 -s "=> renegotiate" \
1717 -S "write hello request"
1718
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001719run_test "Renegotiation: DTLS, server-initiated" \
1720 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001721 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1722 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001723 0 \
1724 -c "client hello, adding renegotiation extension" \
1725 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1726 -s "found renegotiation extension" \
1727 -s "server hello, secure renegotiation extension" \
1728 -c "found renegotiation extension" \
1729 -c "=> renegotiate" \
1730 -s "=> renegotiate" \
1731 -s "write hello request"
1732
Andres AG9b1927b2017-01-19 16:30:57 +00001733run_test "Renegotiation: DTLS, renego_period overflow" \
1734 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1735 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1736 0 \
1737 -c "client hello, adding renegotiation extension" \
1738 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1739 -s "found renegotiation extension" \
1740 -s "server hello, secure renegotiation extension" \
1741 -s "record counter limit reached: renegotiate" \
1742 -c "=> renegotiate" \
1743 -s "=> renegotiate" \
1744 -s "write hello request" \
1745
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001746requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001747run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1748 "$G_SRV -u --mtu 4096" \
1749 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1750 0 \
1751 -c "client hello, adding renegotiation extension" \
1752 -c "found renegotiation extension" \
1753 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001754 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001755 -C "error" \
1756 -s "Extra-header:"
1757
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001758# Test for the "secure renegotation" extension only (no actual renegotiation)
1759
Paul Bakker539d9722015-02-08 16:18:35 +01001760requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001761run_test "Renego ext: gnutls server strict, client default" \
1762 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1763 "$P_CLI debug_level=3" \
1764 0 \
1765 -c "found renegotiation extension" \
1766 -C "error" \
1767 -c "HTTP/1.0 200 [Oo][Kk]"
1768
Paul Bakker539d9722015-02-08 16:18:35 +01001769requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001770run_test "Renego ext: gnutls server unsafe, client default" \
1771 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1772 "$P_CLI debug_level=3" \
1773 0 \
1774 -C "found renegotiation extension" \
1775 -C "error" \
1776 -c "HTTP/1.0 200 [Oo][Kk]"
1777
Paul Bakker539d9722015-02-08 16:18:35 +01001778requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001779run_test "Renego ext: gnutls server unsafe, client break legacy" \
1780 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1781 "$P_CLI debug_level=3 allow_legacy=-1" \
1782 1 \
1783 -C "found renegotiation extension" \
1784 -c "error" \
1785 -C "HTTP/1.0 200 [Oo][Kk]"
1786
Paul Bakker539d9722015-02-08 16:18:35 +01001787requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001788run_test "Renego ext: gnutls client strict, server default" \
1789 "$P_SRV debug_level=3" \
1790 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1791 0 \
1792 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1793 -s "server hello, secure renegotiation extension"
1794
Paul Bakker539d9722015-02-08 16:18:35 +01001795requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001796run_test "Renego ext: gnutls client unsafe, server default" \
1797 "$P_SRV debug_level=3" \
1798 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1799 0 \
1800 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1801 -S "server hello, secure renegotiation extension"
1802
Paul Bakker539d9722015-02-08 16:18:35 +01001803requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001804run_test "Renego ext: gnutls client unsafe, server break legacy" \
1805 "$P_SRV debug_level=3 allow_legacy=-1" \
1806 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1807 1 \
1808 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1809 -S "server hello, secure renegotiation extension"
1810
Janos Follath365b2262016-02-17 10:11:21 +00001811# Tests for silently dropping trailing extra bytes in .der certificates
1812
1813requires_gnutls
1814run_test "DER format: no trailing bytes" \
1815 "$P_SRV crt_file=data_files/server5-der0.crt \
1816 key_file=data_files/server5.key" \
1817 "$G_CLI " \
1818 0 \
1819 -c "Handshake was completed" \
1820
1821requires_gnutls
1822run_test "DER format: with a trailing zero byte" \
1823 "$P_SRV crt_file=data_files/server5-der1a.crt \
1824 key_file=data_files/server5.key" \
1825 "$G_CLI " \
1826 0 \
1827 -c "Handshake was completed" \
1828
1829requires_gnutls
1830run_test "DER format: with a trailing random byte" \
1831 "$P_SRV crt_file=data_files/server5-der1b.crt \
1832 key_file=data_files/server5.key" \
1833 "$G_CLI " \
1834 0 \
1835 -c "Handshake was completed" \
1836
1837requires_gnutls
1838run_test "DER format: with 2 trailing random bytes" \
1839 "$P_SRV crt_file=data_files/server5-der2.crt \
1840 key_file=data_files/server5.key" \
1841 "$G_CLI " \
1842 0 \
1843 -c "Handshake was completed" \
1844
1845requires_gnutls
1846run_test "DER format: with 4 trailing random bytes" \
1847 "$P_SRV crt_file=data_files/server5-der4.crt \
1848 key_file=data_files/server5.key" \
1849 "$G_CLI " \
1850 0 \
1851 -c "Handshake was completed" \
1852
1853requires_gnutls
1854run_test "DER format: with 8 trailing random bytes" \
1855 "$P_SRV crt_file=data_files/server5-der8.crt \
1856 key_file=data_files/server5.key" \
1857 "$G_CLI " \
1858 0 \
1859 -c "Handshake was completed" \
1860
1861requires_gnutls
1862run_test "DER format: with 9 trailing random bytes" \
1863 "$P_SRV crt_file=data_files/server5-der9.crt \
1864 key_file=data_files/server5.key" \
1865 "$G_CLI " \
1866 0 \
1867 -c "Handshake was completed" \
1868
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001869# Tests for auth_mode
1870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001871run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001872 "$P_SRV crt_file=data_files/server5-badsign.crt \
1873 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001874 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001875 1 \
1876 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001877 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001878 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001879 -c "X509 - Certificate verification failed"
1880
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001881run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001882 "$P_SRV crt_file=data_files/server5-badsign.crt \
1883 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001884 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001885 0 \
1886 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001887 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001888 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001889 -C "X509 - Certificate verification failed"
1890
Hanno Becker61c0c702017-05-15 16:05:15 +01001891run_test "Authentication: server goodcert, client optional, no trusted CA" \
1892 "$P_SRV" \
1893 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1894 0 \
1895 -c "x509_verify_cert() returned" \
1896 -c "! The certificate is not correctly signed by the trusted CA" \
1897 -c "! Certificate verification flags"\
1898 -C "! mbedtls_ssl_handshake returned" \
1899 -C "X509 - Certificate verification failed" \
1900 -C "SSL - No CA Chain is set, but required to operate"
1901
1902run_test "Authentication: server goodcert, client required, no trusted CA" \
1903 "$P_SRV" \
1904 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1905 1 \
1906 -c "x509_verify_cert() returned" \
1907 -c "! The certificate is not correctly signed by the trusted CA" \
1908 -c "! Certificate verification flags"\
1909 -c "! mbedtls_ssl_handshake returned" \
1910 -c "SSL - No CA Chain is set, but required to operate"
1911
1912# The purpose of the next two tests is to test the client's behaviour when receiving a server
1913# certificate with an unsupported elliptic curve. This should usually not happen because
1914# the client informs the server about the supported curves - it does, though, in the
1915# corner case of a static ECDH suite, because the server doesn't check the curve on that
1916# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1917# different means to have the server ignoring the client's supported curve list.
1918
1919requires_config_enabled MBEDTLS_ECP_C
1920run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1921 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1922 crt_file=data_files/server5.ku-ka.crt" \
1923 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1924 1 \
1925 -c "bad certificate (EC key curve)"\
1926 -c "! Certificate verification flags"\
1927 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1928
1929requires_config_enabled MBEDTLS_ECP_C
1930run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1931 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1932 crt_file=data_files/server5.ku-ka.crt" \
1933 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1934 1 \
1935 -c "bad certificate (EC key curve)"\
1936 -c "! Certificate verification flags"\
1937 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001939run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001940 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001941 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001942 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001943 0 \
1944 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001945 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001946 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001947 -C "X509 - Certificate verification failed"
1948
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001949run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001950 "$P_SRV debug_level=3 auth_mode=required" \
1951 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001952 key_file=data_files/server5.key" \
1953 1 \
1954 -S "skip write certificate request" \
1955 -C "skip parse certificate request" \
1956 -c "got a certificate request" \
1957 -C "skip write certificate" \
1958 -C "skip write certificate verify" \
1959 -S "skip parse certificate verify" \
1960 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001961 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001962 -s "! mbedtls_ssl_handshake returned" \
1963 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001964 -s "X509 - Certificate verification failed"
1965
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001966run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001967 "$P_SRV debug_level=3 auth_mode=optional" \
1968 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001969 key_file=data_files/server5.key" \
1970 0 \
1971 -S "skip write certificate request" \
1972 -C "skip parse certificate request" \
1973 -c "got a certificate request" \
1974 -C "skip write certificate" \
1975 -C "skip write certificate verify" \
1976 -S "skip parse certificate verify" \
1977 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001978 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001979 -S "! mbedtls_ssl_handshake returned" \
1980 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001981 -S "X509 - Certificate verification failed"
1982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001983run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001984 "$P_SRV debug_level=3 auth_mode=none" \
1985 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001986 key_file=data_files/server5.key" \
1987 0 \
1988 -s "skip write certificate request" \
1989 -C "skip parse certificate request" \
1990 -c "got no certificate request" \
1991 -c "skip write certificate" \
1992 -c "skip write certificate verify" \
1993 -s "skip parse certificate verify" \
1994 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001995 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001996 -S "! mbedtls_ssl_handshake returned" \
1997 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001998 -S "X509 - Certificate verification failed"
1999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002000run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002001 "$P_SRV debug_level=3 auth_mode=optional" \
2002 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002003 0 \
2004 -S "skip write certificate request" \
2005 -C "skip parse certificate request" \
2006 -c "got a certificate request" \
2007 -C "skip write certificate$" \
2008 -C "got no certificate to send" \
2009 -S "SSLv3 client has no certificate" \
2010 -c "skip write certificate verify" \
2011 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002012 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002013 -S "! mbedtls_ssl_handshake returned" \
2014 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002015 -S "X509 - Certificate verification failed"
2016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002017run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002018 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002019 "$O_CLI" \
2020 0 \
2021 -S "skip write certificate request" \
2022 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002023 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002024 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002025 -S "X509 - Certificate verification failed"
2026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002027run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002028 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002029 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002030 0 \
2031 -C "skip parse certificate request" \
2032 -c "got a certificate request" \
2033 -C "skip write certificate$" \
2034 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002035 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002036
Janos Follath542ee5d2016-03-07 15:57:05 +00002037requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002038run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002039 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002040 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002041 0 \
2042 -S "skip write certificate request" \
2043 -C "skip parse certificate request" \
2044 -c "got a certificate request" \
2045 -C "skip write certificate$" \
2046 -c "skip write certificate verify" \
2047 -c "got no certificate to send" \
2048 -s "SSLv3 client has no certificate" \
2049 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002050 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002051 -S "! mbedtls_ssl_handshake returned" \
2052 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002053 -S "X509 - Certificate verification failed"
2054
Manuel Pégourié-Gonnard591035d2017-06-26 10:45:33 +02002055run_test "Authentication: server max_int chain, client default" \
2056 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2057 key_file=data_files/dir-maxpath/09.key" \
2058 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2059 0 \
2060 -C "X509 - A fatal error occured"
2061
2062run_test "Authentication: server max_int+1 chain, client default" \
2063 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2064 key_file=data_files/dir-maxpath/10.key" \
2065 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2066 1 \
2067 -c "X509 - A fatal error occured"
2068
2069run_test "Authentication: server max_int+1 chain, client optional" \
2070 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2071 key_file=data_files/dir-maxpath/10.key" \
2072 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2073 auth_mode=optional" \
2074 1 \
2075 -c "X509 - A fatal error occured"
2076
2077run_test "Authentication: server max_int+1 chain, client none" \
2078 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2079 key_file=data_files/dir-maxpath/10.key" \
2080 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2081 auth_mode=none" \
2082 0 \
2083 -C "X509 - A fatal error occured"
2084
2085run_test "Authentication: client max_int+1 chain, server default" \
2086 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2087 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2088 key_file=data_files/dir-maxpath/10.key" \
2089 0 \
2090 -S "X509 - A fatal error occured"
2091
2092run_test "Authentication: client max_int+1 chain, server optional" \
2093 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2094 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2095 key_file=data_files/dir-maxpath/10.key" \
2096 1 \
2097 -s "X509 - A fatal error occured"
2098
2099run_test "Authentication: client max_int+1 chain, server required" \
2100 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2101 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2102 key_file=data_files/dir-maxpath/10.key" \
2103 1 \
2104 -s "X509 - A fatal error occured"
2105
2106run_test "Authentication: client max_int chain, server required" \
2107 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2108 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2109 key_file=data_files/dir-maxpath/09.key" \
2110 0 \
2111 -S "X509 - A fatal error occured"
2112
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002113# Tests for certificate selection based on SHA verson
2114
2115run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2116 "$P_SRV crt_file=data_files/server5.crt \
2117 key_file=data_files/server5.key \
2118 crt_file2=data_files/server5-sha1.crt \
2119 key_file2=data_files/server5.key" \
2120 "$P_CLI force_version=tls1_2" \
2121 0 \
2122 -c "signed using.*ECDSA with SHA256" \
2123 -C "signed using.*ECDSA with SHA1"
2124
2125run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2126 "$P_SRV crt_file=data_files/server5.crt \
2127 key_file=data_files/server5.key \
2128 crt_file2=data_files/server5-sha1.crt \
2129 key_file2=data_files/server5.key" \
2130 "$P_CLI force_version=tls1_1" \
2131 0 \
2132 -C "signed using.*ECDSA with SHA256" \
2133 -c "signed using.*ECDSA with SHA1"
2134
2135run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2136 "$P_SRV crt_file=data_files/server5.crt \
2137 key_file=data_files/server5.key \
2138 crt_file2=data_files/server5-sha1.crt \
2139 key_file2=data_files/server5.key" \
2140 "$P_CLI force_version=tls1" \
2141 0 \
2142 -C "signed using.*ECDSA with SHA256" \
2143 -c "signed using.*ECDSA with SHA1"
2144
2145run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2146 "$P_SRV crt_file=data_files/server5.crt \
2147 key_file=data_files/server5.key \
2148 crt_file2=data_files/server6.crt \
2149 key_file2=data_files/server6.key" \
2150 "$P_CLI force_version=tls1_1" \
2151 0 \
2152 -c "serial number.*09" \
2153 -c "signed using.*ECDSA with SHA256" \
2154 -C "signed using.*ECDSA with SHA1"
2155
2156run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2157 "$P_SRV crt_file=data_files/server6.crt \
2158 key_file=data_files/server6.key \
2159 crt_file2=data_files/server5.crt \
2160 key_file2=data_files/server5.key" \
2161 "$P_CLI force_version=tls1_1" \
2162 0 \
2163 -c "serial number.*0A" \
2164 -c "signed using.*ECDSA with SHA256" \
2165 -C "signed using.*ECDSA with SHA1"
2166
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002167# tests for SNI
2168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002169run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002170 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002171 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002172 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002173 0 \
2174 -S "parse ServerName extension" \
2175 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2176 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002178run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002179 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002180 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002181 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 +02002182 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002183 0 \
2184 -s "parse ServerName extension" \
2185 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2186 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002188run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002189 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002190 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002191 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 +02002192 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002193 0 \
2194 -s "parse ServerName extension" \
2195 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2196 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002198run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002199 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002200 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002201 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 +02002202 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002203 1 \
2204 -s "parse ServerName extension" \
2205 -s "ssl_sni_wrapper() returned" \
2206 -s "mbedtls_ssl_handshake returned" \
2207 -c "mbedtls_ssl_handshake returned" \
2208 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002209
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002210run_test "SNI: client auth no override: optional" \
2211 "$P_SRV debug_level=3 auth_mode=optional \
2212 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2213 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2214 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002215 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002216 -S "skip write certificate request" \
2217 -C "skip parse certificate request" \
2218 -c "got a certificate request" \
2219 -C "skip write certificate" \
2220 -C "skip write certificate verify" \
2221 -S "skip parse certificate verify"
2222
2223run_test "SNI: client auth override: none -> optional" \
2224 "$P_SRV debug_level=3 auth_mode=none \
2225 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2226 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2227 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002228 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002229 -S "skip write certificate request" \
2230 -C "skip parse certificate request" \
2231 -c "got a certificate request" \
2232 -C "skip write certificate" \
2233 -C "skip write certificate verify" \
2234 -S "skip parse certificate verify"
2235
2236run_test "SNI: client auth override: optional -> none" \
2237 "$P_SRV debug_level=3 auth_mode=optional \
2238 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2239 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2240 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002241 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002242 -s "skip write certificate request" \
2243 -C "skip parse certificate request" \
2244 -c "got no certificate request" \
2245 -c "skip write certificate" \
2246 -c "skip write certificate verify" \
2247 -s "skip parse certificate verify"
2248
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002249run_test "SNI: CA no override" \
2250 "$P_SRV debug_level=3 auth_mode=optional \
2251 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2252 ca_file=data_files/test-ca.crt \
2253 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2254 "$P_CLI debug_level=3 server_name=localhost \
2255 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2256 1 \
2257 -S "skip write certificate request" \
2258 -C "skip parse certificate request" \
2259 -c "got a certificate request" \
2260 -C "skip write certificate" \
2261 -C "skip write certificate verify" \
2262 -S "skip parse certificate verify" \
2263 -s "x509_verify_cert() returned" \
2264 -s "! The certificate is not correctly signed by the trusted CA" \
2265 -S "The certificate has been revoked (is on a CRL)"
2266
2267run_test "SNI: CA override" \
2268 "$P_SRV debug_level=3 auth_mode=optional \
2269 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2270 ca_file=data_files/test-ca.crt \
2271 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2272 "$P_CLI debug_level=3 server_name=localhost \
2273 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2274 0 \
2275 -S "skip write certificate request" \
2276 -C "skip parse certificate request" \
2277 -c "got a certificate request" \
2278 -C "skip write certificate" \
2279 -C "skip write certificate verify" \
2280 -S "skip parse certificate verify" \
2281 -S "x509_verify_cert() returned" \
2282 -S "! The certificate is not correctly signed by the trusted CA" \
2283 -S "The certificate has been revoked (is on a CRL)"
2284
2285run_test "SNI: CA override with CRL" \
2286 "$P_SRV debug_level=3 auth_mode=optional \
2287 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2288 ca_file=data_files/test-ca.crt \
2289 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2290 "$P_CLI debug_level=3 server_name=localhost \
2291 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2292 1 \
2293 -S "skip write certificate request" \
2294 -C "skip parse certificate request" \
2295 -c "got a certificate request" \
2296 -C "skip write certificate" \
2297 -C "skip write certificate verify" \
2298 -S "skip parse certificate verify" \
2299 -s "x509_verify_cert() returned" \
2300 -S "! The certificate is not correctly signed by the trusted CA" \
2301 -s "The certificate has been revoked (is on a CRL)"
2302
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002303# Tests for non-blocking I/O: exercise a variety of handshake flows
2304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002305run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002306 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2307 "$P_CLI nbio=2 tickets=0" \
2308 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002309 -S "mbedtls_ssl_handshake returned" \
2310 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002311 -c "Read from server: .* bytes read"
2312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002313run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002314 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2315 "$P_CLI nbio=2 tickets=0" \
2316 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002317 -S "mbedtls_ssl_handshake returned" \
2318 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002319 -c "Read from server: .* bytes read"
2320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002321run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002322 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2323 "$P_CLI nbio=2 tickets=1" \
2324 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002325 -S "mbedtls_ssl_handshake returned" \
2326 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002327 -c "Read from server: .* bytes read"
2328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002329run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002330 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2331 "$P_CLI nbio=2 tickets=1" \
2332 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002333 -S "mbedtls_ssl_handshake returned" \
2334 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002335 -c "Read from server: .* bytes read"
2336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002337run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002338 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2339 "$P_CLI nbio=2 tickets=1 reconnect=1" \
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é-Gonnard0b6609b2014-02-26 14:45:12 +01002343 -c "Read from server: .* bytes read"
2344
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002345run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002346 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2347 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2348 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002349 -S "mbedtls_ssl_handshake returned" \
2350 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002351 -c "Read from server: .* bytes read"
2352
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002353run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002354 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2355 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2356 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002357 -S "mbedtls_ssl_handshake returned" \
2358 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002359 -c "Read from server: .* bytes read"
2360
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002361# Tests for version negotiation
2362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002363run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002364 "$P_SRV" \
2365 "$P_CLI" \
2366 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002367 -S "mbedtls_ssl_handshake returned" \
2368 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002369 -s "Protocol is TLSv1.2" \
2370 -c "Protocol is TLSv1.2"
2371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002372run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002373 "$P_SRV" \
2374 "$P_CLI max_version=tls1_1" \
2375 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002376 -S "mbedtls_ssl_handshake returned" \
2377 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002378 -s "Protocol is TLSv1.1" \
2379 -c "Protocol is TLSv1.1"
2380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002381run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002382 "$P_SRV max_version=tls1_1" \
2383 "$P_CLI" \
2384 0 \
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 "Protocol is TLSv1.1" \
2388 -c "Protocol is TLSv1.1"
2389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002390run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002391 "$P_SRV max_version=tls1_1" \
2392 "$P_CLI max_version=tls1_1" \
2393 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002394 -S "mbedtls_ssl_handshake returned" \
2395 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002396 -s "Protocol is TLSv1.1" \
2397 -c "Protocol is TLSv1.1"
2398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002399run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002400 "$P_SRV min_version=tls1_1" \
2401 "$P_CLI max_version=tls1_1" \
2402 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002403 -S "mbedtls_ssl_handshake returned" \
2404 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002405 -s "Protocol is TLSv1.1" \
2406 -c "Protocol is TLSv1.1"
2407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002408run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002409 "$P_SRV max_version=tls1_1" \
2410 "$P_CLI min_version=tls1_1" \
2411 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002412 -S "mbedtls_ssl_handshake returned" \
2413 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002414 -s "Protocol is TLSv1.1" \
2415 -c "Protocol is TLSv1.1"
2416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002417run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002418 "$P_SRV max_version=tls1_1" \
2419 "$P_CLI min_version=tls1_2" \
2420 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002421 -s "mbedtls_ssl_handshake returned" \
2422 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002423 -c "SSL - Handshake protocol not within min/max boundaries"
2424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002425run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002426 "$P_SRV min_version=tls1_2" \
2427 "$P_CLI max_version=tls1_1" \
2428 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002429 -s "mbedtls_ssl_handshake returned" \
2430 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002431 -s "SSL - Handshake protocol not within min/max boundaries"
2432
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002433# Tests for ALPN extension
2434
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002435run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002436 "$P_SRV debug_level=3" \
2437 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002438 0 \
2439 -C "client hello, adding alpn extension" \
2440 -S "found alpn extension" \
2441 -C "got an alert message, type: \\[2:120]" \
2442 -S "server hello, adding alpn extension" \
2443 -C "found alpn extension " \
2444 -C "Application Layer Protocol is" \
2445 -S "Application Layer Protocol is"
2446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002447run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002448 "$P_SRV debug_level=3" \
2449 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002450 0 \
2451 -c "client hello, adding alpn extension" \
2452 -s "found alpn extension" \
2453 -C "got an alert message, type: \\[2:120]" \
2454 -S "server hello, adding alpn extension" \
2455 -C "found alpn extension " \
2456 -c "Application Layer Protocol is (none)" \
2457 -S "Application Layer Protocol is"
2458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002459run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002460 "$P_SRV debug_level=3 alpn=abc,1234" \
2461 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002462 0 \
2463 -C "client hello, adding alpn extension" \
2464 -S "found alpn extension" \
2465 -C "got an alert message, type: \\[2:120]" \
2466 -S "server hello, adding alpn extension" \
2467 -C "found alpn extension " \
2468 -C "Application Layer Protocol is" \
2469 -s "Application Layer Protocol is (none)"
2470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002471run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002472 "$P_SRV debug_level=3 alpn=abc,1234" \
2473 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002474 0 \
2475 -c "client hello, adding alpn extension" \
2476 -s "found alpn extension" \
2477 -C "got an alert message, type: \\[2:120]" \
2478 -s "server hello, adding alpn extension" \
2479 -c "found alpn extension" \
2480 -c "Application Layer Protocol is abc" \
2481 -s "Application Layer Protocol is abc"
2482
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002483run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002484 "$P_SRV debug_level=3 alpn=abc,1234" \
2485 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002486 0 \
2487 -c "client hello, adding alpn extension" \
2488 -s "found alpn extension" \
2489 -C "got an alert message, type: \\[2:120]" \
2490 -s "server hello, adding alpn extension" \
2491 -c "found alpn extension" \
2492 -c "Application Layer Protocol is abc" \
2493 -s "Application Layer Protocol is abc"
2494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002495run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002496 "$P_SRV debug_level=3 alpn=abc,1234" \
2497 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002498 0 \
2499 -c "client hello, adding alpn extension" \
2500 -s "found alpn extension" \
2501 -C "got an alert message, type: \\[2:120]" \
2502 -s "server hello, adding alpn extension" \
2503 -c "found alpn extension" \
2504 -c "Application Layer Protocol is 1234" \
2505 -s "Application Layer Protocol is 1234"
2506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002507run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002508 "$P_SRV debug_level=3 alpn=abc,123" \
2509 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002510 1 \
2511 -c "client hello, adding alpn extension" \
2512 -s "found alpn extension" \
2513 -c "got an alert message, type: \\[2:120]" \
2514 -S "server hello, adding alpn extension" \
2515 -C "found alpn extension" \
2516 -C "Application Layer Protocol is 1234" \
2517 -S "Application Layer Protocol is 1234"
2518
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002519
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002520# Tests for keyUsage in leaf certificates, part 1:
2521# server-side certificate/suite selection
2522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002523run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002524 "$P_SRV key_file=data_files/server2.key \
2525 crt_file=data_files/server2.ku-ds.crt" \
2526 "$P_CLI" \
2527 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002528 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002529
2530
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002531run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002532 "$P_SRV key_file=data_files/server2.key \
2533 crt_file=data_files/server2.ku-ke.crt" \
2534 "$P_CLI" \
2535 0 \
2536 -c "Ciphersuite is TLS-RSA-WITH-"
2537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002538run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002539 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002540 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002541 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002542 1 \
2543 -C "Ciphersuite is "
2544
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002545run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002546 "$P_SRV key_file=data_files/server5.key \
2547 crt_file=data_files/server5.ku-ds.crt" \
2548 "$P_CLI" \
2549 0 \
2550 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2551
2552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002553run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002554 "$P_SRV key_file=data_files/server5.key \
2555 crt_file=data_files/server5.ku-ka.crt" \
2556 "$P_CLI" \
2557 0 \
2558 -c "Ciphersuite is TLS-ECDH-"
2559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002560run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002561 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002562 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002563 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002564 1 \
2565 -C "Ciphersuite is "
2566
2567# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002568# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002570run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002571 "$O_SRV -key data_files/server2.key \
2572 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002573 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002574 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2575 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002576 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002577 -C "Processing of the Certificate handshake message failed" \
2578 -c "Ciphersuite is TLS-"
2579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002580run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002581 "$O_SRV -key data_files/server2.key \
2582 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002583 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002584 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2585 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002586 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002587 -C "Processing of the Certificate handshake message failed" \
2588 -c "Ciphersuite is TLS-"
2589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002590run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002591 "$O_SRV -key data_files/server2.key \
2592 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002593 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002594 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2595 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002596 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002597 -C "Processing of the Certificate handshake message failed" \
2598 -c "Ciphersuite is TLS-"
2599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002600run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002601 "$O_SRV -key data_files/server2.key \
2602 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002603 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002604 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2605 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002606 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002607 -c "Processing of the Certificate handshake message failed" \
2608 -C "Ciphersuite is TLS-"
2609
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002610run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2611 "$O_SRV -key data_files/server2.key \
2612 -cert data_files/server2.ku-ke.crt" \
2613 "$P_CLI debug_level=1 auth_mode=optional \
2614 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2615 0 \
2616 -c "bad certificate (usage extensions)" \
2617 -C "Processing of the Certificate handshake message failed" \
2618 -c "Ciphersuite is TLS-" \
2619 -c "! Usage does not match the keyUsage extension"
2620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002621run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002622 "$O_SRV -key data_files/server2.key \
2623 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002624 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002625 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2626 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002627 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002628 -C "Processing of the Certificate handshake message failed" \
2629 -c "Ciphersuite is TLS-"
2630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002631run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002632 "$O_SRV -key data_files/server2.key \
2633 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002634 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002635 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2636 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002637 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002638 -c "Processing of the Certificate handshake message failed" \
2639 -C "Ciphersuite is TLS-"
2640
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002641run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2642 "$O_SRV -key data_files/server2.key \
2643 -cert data_files/server2.ku-ds.crt" \
2644 "$P_CLI debug_level=1 auth_mode=optional \
2645 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2646 0 \
2647 -c "bad certificate (usage extensions)" \
2648 -C "Processing of the Certificate handshake message failed" \
2649 -c "Ciphersuite is TLS-" \
2650 -c "! Usage does not match the keyUsage extension"
2651
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002652# Tests for keyUsage in leaf certificates, part 3:
2653# server-side checking of client cert
2654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002655run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002656 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002657 "$O_CLI -key data_files/server2.key \
2658 -cert data_files/server2.ku-ds.crt" \
2659 0 \
2660 -S "bad certificate (usage extensions)" \
2661 -S "Processing of the Certificate handshake message failed"
2662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002663run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002664 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002665 "$O_CLI -key data_files/server2.key \
2666 -cert data_files/server2.ku-ke.crt" \
2667 0 \
2668 -s "bad certificate (usage extensions)" \
2669 -S "Processing of the Certificate handshake message failed"
2670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002671run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002672 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002673 "$O_CLI -key data_files/server2.key \
2674 -cert data_files/server2.ku-ke.crt" \
2675 1 \
2676 -s "bad certificate (usage extensions)" \
2677 -s "Processing of the Certificate handshake message failed"
2678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002679run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002680 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002681 "$O_CLI -key data_files/server5.key \
2682 -cert data_files/server5.ku-ds.crt" \
2683 0 \
2684 -S "bad certificate (usage extensions)" \
2685 -S "Processing of the Certificate handshake message failed"
2686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002687run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002688 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002689 "$O_CLI -key data_files/server5.key \
2690 -cert data_files/server5.ku-ka.crt" \
2691 0 \
2692 -s "bad certificate (usage extensions)" \
2693 -S "Processing of the Certificate handshake message failed"
2694
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002695# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002697run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002698 "$P_SRV key_file=data_files/server5.key \
2699 crt_file=data_files/server5.eku-srv.crt" \
2700 "$P_CLI" \
2701 0
2702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002703run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002704 "$P_SRV key_file=data_files/server5.key \
2705 crt_file=data_files/server5.eku-srv.crt" \
2706 "$P_CLI" \
2707 0
2708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002709run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002710 "$P_SRV key_file=data_files/server5.key \
2711 crt_file=data_files/server5.eku-cs_any.crt" \
2712 "$P_CLI" \
2713 0
2714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002715run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002716 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002717 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002718 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002719 1
2720
2721# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002723run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002724 "$O_SRV -key data_files/server5.key \
2725 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002726 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002727 0 \
2728 -C "bad certificate (usage extensions)" \
2729 -C "Processing of the Certificate handshake message failed" \
2730 -c "Ciphersuite is TLS-"
2731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002732run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002733 "$O_SRV -key data_files/server5.key \
2734 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002735 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002736 0 \
2737 -C "bad certificate (usage extensions)" \
2738 -C "Processing of the Certificate handshake message failed" \
2739 -c "Ciphersuite is TLS-"
2740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002741run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002742 "$O_SRV -key data_files/server5.key \
2743 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002744 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002745 0 \
2746 -C "bad certificate (usage extensions)" \
2747 -C "Processing of the Certificate handshake message failed" \
2748 -c "Ciphersuite is TLS-"
2749
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002750run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002751 "$O_SRV -key data_files/server5.key \
2752 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002753 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002754 1 \
2755 -c "bad certificate (usage extensions)" \
2756 -c "Processing of the Certificate handshake message failed" \
2757 -C "Ciphersuite is TLS-"
2758
2759# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2760
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002761run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002762 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002763 "$O_CLI -key data_files/server5.key \
2764 -cert data_files/server5.eku-cli.crt" \
2765 0 \
2766 -S "bad certificate (usage extensions)" \
2767 -S "Processing of the Certificate handshake message failed"
2768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002769run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002770 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002771 "$O_CLI -key data_files/server5.key \
2772 -cert data_files/server5.eku-srv_cli.crt" \
2773 0 \
2774 -S "bad certificate (usage extensions)" \
2775 -S "Processing of the Certificate handshake message failed"
2776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002777run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002778 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002779 "$O_CLI -key data_files/server5.key \
2780 -cert data_files/server5.eku-cs_any.crt" \
2781 0 \
2782 -S "bad certificate (usage extensions)" \
2783 -S "Processing of the Certificate handshake message failed"
2784
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002785run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002786 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002787 "$O_CLI -key data_files/server5.key \
2788 -cert data_files/server5.eku-cs.crt" \
2789 0 \
2790 -s "bad certificate (usage extensions)" \
2791 -S "Processing of the Certificate handshake message failed"
2792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002793run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002794 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002795 "$O_CLI -key data_files/server5.key \
2796 -cert data_files/server5.eku-cs.crt" \
2797 1 \
2798 -s "bad certificate (usage extensions)" \
2799 -s "Processing of the Certificate handshake message failed"
2800
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002801# Tests for DHM parameters loading
2802
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002803run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002804 "$P_SRV" \
2805 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2806 debug_level=3" \
2807 0 \
2808 -c "value of 'DHM: P ' (2048 bits)" \
2809 -c "value of 'DHM: G ' (2048 bits)"
2810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002811run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002812 "$P_SRV dhm_file=data_files/dhparams.pem" \
2813 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2814 debug_level=3" \
2815 0 \
2816 -c "value of 'DHM: P ' (1024 bits)" \
2817 -c "value of 'DHM: G ' (2 bits)"
2818
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002819# Tests for DHM client-side size checking
2820
2821run_test "DHM size: server default, client default, OK" \
2822 "$P_SRV" \
2823 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2824 debug_level=1" \
2825 0 \
2826 -C "DHM prime too short:"
2827
2828run_test "DHM size: server default, client 2048, OK" \
2829 "$P_SRV" \
2830 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2831 debug_level=1 dhmlen=2048" \
2832 0 \
2833 -C "DHM prime too short:"
2834
2835run_test "DHM size: server 1024, client default, OK" \
2836 "$P_SRV dhm_file=data_files/dhparams.pem" \
2837 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2838 debug_level=1" \
2839 0 \
2840 -C "DHM prime too short:"
2841
2842run_test "DHM size: server 1000, client default, rejected" \
2843 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2844 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2845 debug_level=1" \
2846 1 \
2847 -c "DHM prime too short:"
2848
2849run_test "DHM size: server default, client 2049, rejected" \
2850 "$P_SRV" \
2851 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2852 debug_level=1 dhmlen=2049" \
2853 1 \
2854 -c "DHM prime too short:"
2855
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002856# Tests for PSK callback
2857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002858run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002859 "$P_SRV psk=abc123 psk_identity=foo" \
2860 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2861 psk_identity=foo psk=abc123" \
2862 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002863 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002864 -S "SSL - Unknown identity received" \
2865 -S "SSL - Verification of the message MAC failed"
2866
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002867run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002868 "$P_SRV" \
2869 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2870 psk_identity=foo psk=abc123" \
2871 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002872 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002873 -S "SSL - Unknown identity received" \
2874 -S "SSL - Verification of the message MAC failed"
2875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002876run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002877 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2878 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2879 psk_identity=foo psk=abc123" \
2880 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002881 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002882 -s "SSL - Unknown identity received" \
2883 -S "SSL - Verification of the message MAC failed"
2884
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002885run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002886 "$P_SRV psk_list=abc,dead,def,beef" \
2887 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2888 psk_identity=abc psk=dead" \
2889 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002890 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002891 -S "SSL - Unknown identity received" \
2892 -S "SSL - Verification of the message MAC failed"
2893
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002894run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002895 "$P_SRV psk_list=abc,dead,def,beef" \
2896 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2897 psk_identity=def psk=beef" \
2898 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002899 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002900 -S "SSL - Unknown identity received" \
2901 -S "SSL - Verification of the message MAC failed"
2902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002903run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002904 "$P_SRV psk_list=abc,dead,def,beef" \
2905 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2906 psk_identity=ghi psk=beef" \
2907 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002908 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002909 -s "SSL - Unknown identity received" \
2910 -S "SSL - Verification of the message MAC failed"
2911
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002912run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002913 "$P_SRV psk_list=abc,dead,def,beef" \
2914 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2915 psk_identity=abc psk=beef" \
2916 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002917 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002918 -S "SSL - Unknown identity received" \
2919 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002920
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002921# Tests for ciphersuites per version
2922
Janos Follath542ee5d2016-03-07 15:57:05 +00002923requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002924run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002925 "$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 +02002926 "$P_CLI force_version=ssl3" \
2927 0 \
2928 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002930run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002931 "$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 +01002932 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002933 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002934 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002935
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002936run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002937 "$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 +02002938 "$P_CLI force_version=tls1_1" \
2939 0 \
2940 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002942run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002943 "$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 +02002944 "$P_CLI force_version=tls1_2" \
2945 0 \
2946 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2947
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002948# Test for ClientHello without extensions
2949
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002950requires_gnutls
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002951run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002952 "$P_SRV debug_level=3" \
2953 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2954 0 \
2955 -s "dumping 'client hello extensions' (0 bytes)"
2956
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002957requires_gnutls
2958run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
2959 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
2960 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2961 0 \
2962 -s "dumping 'client hello extensions' (0 bytes)"
2963
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002964# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002965
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002966run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002967 "$P_SRV" \
2968 "$P_CLI request_size=100" \
2969 0 \
2970 -s "Read from client: 100 bytes read$"
2971
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002972run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002973 "$P_SRV" \
2974 "$P_CLI request_size=500" \
2975 0 \
2976 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002977
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002978# Tests for small packets
2979
Janos Follath542ee5d2016-03-07 15:57:05 +00002980requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002981run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002982 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002983 "$P_CLI request_size=1 force_version=ssl3 \
2984 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2985 0 \
2986 -s "Read from client: 1 bytes read"
2987
Janos Follath542ee5d2016-03-07 15:57:05 +00002988requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002989run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002990 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002991 "$P_CLI request_size=1 force_version=ssl3 \
2992 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2993 0 \
2994 -s "Read from client: 1 bytes read"
2995
2996run_test "Small packet TLS 1.0 BlockCipher" \
2997 "$P_SRV" \
2998 "$P_CLI request_size=1 force_version=tls1 \
2999 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3000 0 \
3001 -s "Read from client: 1 bytes read"
3002
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003003run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3004 "$P_SRV" \
3005 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3006 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3007 0 \
3008 -s "Read from client: 1 bytes read"
3009
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003010run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3011 "$P_SRV" \
3012 "$P_CLI request_size=1 force_version=tls1 \
3013 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3014 trunc_hmac=1" \
3015 0 \
3016 -s "Read from client: 1 bytes read"
3017
3018run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003019 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003020 "$P_CLI request_size=1 force_version=tls1 \
3021 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3022 trunc_hmac=1" \
3023 0 \
3024 -s "Read from client: 1 bytes read"
3025
3026run_test "Small packet TLS 1.1 BlockCipher" \
3027 "$P_SRV" \
3028 "$P_CLI request_size=1 force_version=tls1_1 \
3029 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3030 0 \
3031 -s "Read from client: 1 bytes read"
3032
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003033run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3034 "$P_SRV" \
3035 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3036 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3037 0 \
3038 -s "Read from client: 1 bytes read"
3039
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003040run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003041 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003042 "$P_CLI request_size=1 force_version=tls1_1 \
3043 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3044 0 \
3045 -s "Read from client: 1 bytes read"
3046
3047run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3048 "$P_SRV" \
3049 "$P_CLI request_size=1 force_version=tls1_1 \
3050 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3051 trunc_hmac=1" \
3052 0 \
3053 -s "Read from client: 1 bytes read"
3054
3055run_test "Small packet TLS 1.1 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_1 \
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 BlockCipher" \
3064 "$P_SRV" \
3065 "$P_CLI request_size=1 force_version=tls1_2 \
3066 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3067 0 \
3068 -s "Read from client: 1 bytes read"
3069
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003070run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3071 "$P_SRV" \
3072 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3073 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3074 0 \
3075 -s "Read from client: 1 bytes read"
3076
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003077run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3078 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003079 "$P_CLI request_size=1 force_version=tls1_2 \
3080 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003081 0 \
3082 -s "Read from client: 1 bytes read"
3083
3084run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3085 "$P_SRV" \
3086 "$P_CLI request_size=1 force_version=tls1_2 \
3087 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3088 trunc_hmac=1" \
3089 0 \
3090 -s "Read from client: 1 bytes read"
3091
3092run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003093 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003094 "$P_CLI request_size=1 force_version=tls1_2 \
3095 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3096 0 \
3097 -s "Read from client: 1 bytes read"
3098
3099run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003100 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003101 "$P_CLI request_size=1 force_version=tls1_2 \
3102 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3103 trunc_hmac=1" \
3104 0 \
3105 -s "Read from client: 1 bytes read"
3106
3107run_test "Small packet TLS 1.2 AEAD" \
3108 "$P_SRV" \
3109 "$P_CLI request_size=1 force_version=tls1_2 \
3110 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3111 0 \
3112 -s "Read from client: 1 bytes read"
3113
3114run_test "Small packet TLS 1.2 AEAD shorter tag" \
3115 "$P_SRV" \
3116 "$P_CLI request_size=1 force_version=tls1_2 \
3117 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3118 0 \
3119 -s "Read from client: 1 bytes read"
3120
Janos Follathb700c462016-05-06 13:48:23 +01003121# A test for extensions in SSLv3
3122
3123requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3124run_test "SSLv3 with extensions, server side" \
3125 "$P_SRV min_version=ssl3 debug_level=3" \
3126 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3127 0 \
3128 -S "dumping 'client hello extensions'" \
3129 -S "server hello, total extension length:"
3130
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003131# Test for large packets
3132
Janos Follath542ee5d2016-03-07 15:57:05 +00003133requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003134run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003135 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003136 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003137 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3138 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003139 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003140 -s "Read from client: 16384 bytes read"
3141
Janos Follath542ee5d2016-03-07 15:57:05 +00003142requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003143run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003144 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003145 "$P_CLI request_size=16384 force_version=ssl3 \
3146 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3147 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003148 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003149 -s "Read from client: 16384 bytes read"
3150
3151run_test "Large packet TLS 1.0 BlockCipher" \
3152 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003153 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003154 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3155 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003156 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003157 -s "Read from client: 16384 bytes read"
3158
3159run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3160 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003161 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003162 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3163 trunc_hmac=1" \
3164 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003165 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003166 -s "Read from client: 16384 bytes read"
3167
3168run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003169 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003170 "$P_CLI request_size=16384 force_version=tls1 \
3171 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3172 trunc_hmac=1" \
3173 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003174 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003175 -s "Read from client: 16384 bytes read"
3176
3177run_test "Large packet TLS 1.1 BlockCipher" \
3178 "$P_SRV" \
3179 "$P_CLI request_size=16384 force_version=tls1_1 \
3180 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3181 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003182 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003183 -s "Read from client: 16384 bytes read"
3184
3185run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003186 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003187 "$P_CLI request_size=16384 force_version=tls1_1 \
3188 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3189 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003190 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003191 -s "Read from client: 16384 bytes read"
3192
3193run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3194 "$P_SRV" \
3195 "$P_CLI request_size=16384 force_version=tls1_1 \
3196 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3197 trunc_hmac=1" \
3198 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003199 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003200 -s "Read from client: 16384 bytes read"
3201
3202run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003203 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003204 "$P_CLI request_size=16384 force_version=tls1_1 \
3205 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3206 trunc_hmac=1" \
3207 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003208 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003209 -s "Read from client: 16384 bytes read"
3210
3211run_test "Large packet TLS 1.2 BlockCipher" \
3212 "$P_SRV" \
3213 "$P_CLI request_size=16384 force_version=tls1_2 \
3214 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3215 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003216 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003217 -s "Read from client: 16384 bytes read"
3218
3219run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3220 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003221 "$P_CLI request_size=16384 force_version=tls1_2 \
3222 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003223 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003224 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003225 -s "Read from client: 16384 bytes read"
3226
3227run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3228 "$P_SRV" \
3229 "$P_CLI request_size=16384 force_version=tls1_2 \
3230 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3231 trunc_hmac=1" \
3232 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003233 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003234 -s "Read from client: 16384 bytes read"
3235
3236run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003237 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003238 "$P_CLI request_size=16384 force_version=tls1_2 \
3239 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3240 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003241 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003242 -s "Read from client: 16384 bytes read"
3243
3244run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003245 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003246 "$P_CLI request_size=16384 force_version=tls1_2 \
3247 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3248 trunc_hmac=1" \
3249 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003250 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003251 -s "Read from client: 16384 bytes read"
3252
3253run_test "Large packet TLS 1.2 AEAD" \
3254 "$P_SRV" \
3255 "$P_CLI request_size=16384 force_version=tls1_2 \
3256 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3257 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003258 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003259 -s "Read from client: 16384 bytes read"
3260
3261run_test "Large packet TLS 1.2 AEAD shorter tag" \
3262 "$P_SRV" \
3263 "$P_CLI request_size=16384 force_version=tls1_2 \
3264 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3265 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003266 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003267 -s "Read from client: 16384 bytes read"
3268
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003269# Tests for DTLS HelloVerifyRequest
3270
3271run_test "DTLS cookie: enabled" \
3272 "$P_SRV dtls=1 debug_level=2" \
3273 "$P_CLI dtls=1 debug_level=2" \
3274 0 \
3275 -s "cookie verification failed" \
3276 -s "cookie verification passed" \
3277 -S "cookie verification skipped" \
3278 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003279 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003280 -S "SSL - The requested feature is not available"
3281
3282run_test "DTLS cookie: disabled" \
3283 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3284 "$P_CLI dtls=1 debug_level=2" \
3285 0 \
3286 -S "cookie verification failed" \
3287 -S "cookie verification passed" \
3288 -s "cookie verification skipped" \
3289 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003290 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003291 -S "SSL - The requested feature is not available"
3292
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003293run_test "DTLS cookie: default (failing)" \
3294 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3295 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3296 1 \
3297 -s "cookie verification failed" \
3298 -S "cookie verification passed" \
3299 -S "cookie verification skipped" \
3300 -C "received hello verify request" \
3301 -S "hello verification requested" \
3302 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003303
3304requires_ipv6
3305run_test "DTLS cookie: enabled, IPv6" \
3306 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3307 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3308 0 \
3309 -s "cookie verification failed" \
3310 -s "cookie verification passed" \
3311 -S "cookie verification skipped" \
3312 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003313 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003314 -S "SSL - The requested feature is not available"
3315
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003316run_test "DTLS cookie: enabled, nbio" \
3317 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3318 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3319 0 \
3320 -s "cookie verification failed" \
3321 -s "cookie verification passed" \
3322 -S "cookie verification skipped" \
3323 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003324 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003325 -S "SSL - The requested feature is not available"
3326
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003327# Tests for client reconnecting from the same port with DTLS
3328
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003329not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003330run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003331 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3332 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003333 0 \
3334 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003335 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003336 -S "Client initiated reconnection from same port"
3337
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003338not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003339run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003340 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3341 "$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 +02003342 0 \
3343 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003344 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003345 -s "Client initiated reconnection from same port"
3346
Paul Bakker3b224ff2016-05-13 10:33:25 +01003347not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3348run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003349 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3350 "$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 +02003351 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003352 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003353 -s "Client initiated reconnection from same port"
3354
Paul Bakker3b224ff2016-05-13 10:33:25 +01003355only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3356run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3357 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3358 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3359 0 \
3360 -S "The operation timed out" \
3361 -s "Client initiated reconnection from same port"
3362
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003363run_test "DTLS client reconnect from same port: no cookies" \
3364 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003365 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3366 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003367 -s "The operation timed out" \
3368 -S "Client initiated reconnection from same port"
3369
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003370# Tests for various cases of client authentication with DTLS
3371# (focused on handshake flows and message parsing)
3372
3373run_test "DTLS client auth: required" \
3374 "$P_SRV dtls=1 auth_mode=required" \
3375 "$P_CLI dtls=1" \
3376 0 \
3377 -s "Verifying peer X.509 certificate... ok"
3378
3379run_test "DTLS client auth: optional, client has no cert" \
3380 "$P_SRV dtls=1 auth_mode=optional" \
3381 "$P_CLI dtls=1 crt_file=none key_file=none" \
3382 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003383 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003384
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003385run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003386 "$P_SRV dtls=1 auth_mode=none" \
3387 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3388 0 \
3389 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003390 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003391
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003392run_test "DTLS wrong PSK: badmac alert" \
3393 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3394 "$P_CLI dtls=1 psk=abc124" \
3395 1 \
3396 -s "SSL - Verification of the message MAC failed" \
3397 -c "SSL - A fatal alert message was received from our peer"
3398
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003399# Tests for receiving fragmented handshake messages with DTLS
3400
3401requires_gnutls
3402run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3403 "$G_SRV -u --mtu 2048 -a" \
3404 "$P_CLI dtls=1 debug_level=2" \
3405 0 \
3406 -C "found fragmented DTLS handshake message" \
3407 -C "error"
3408
3409requires_gnutls
3410run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3411 "$G_SRV -u --mtu 512" \
3412 "$P_CLI dtls=1 debug_level=2" \
3413 0 \
3414 -c "found fragmented DTLS handshake message" \
3415 -C "error"
3416
3417requires_gnutls
3418run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3419 "$G_SRV -u --mtu 128" \
3420 "$P_CLI dtls=1 debug_level=2" \
3421 0 \
3422 -c "found fragmented DTLS handshake message" \
3423 -C "error"
3424
3425requires_gnutls
3426run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3427 "$G_SRV -u --mtu 128" \
3428 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3429 0 \
3430 -c "found fragmented DTLS handshake message" \
3431 -C "error"
3432
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003433requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003434run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3435 "$G_SRV -u --mtu 256" \
3436 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3437 0 \
3438 -c "found fragmented DTLS handshake message" \
3439 -c "client hello, adding renegotiation extension" \
3440 -c "found renegotiation extension" \
3441 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003442 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003443 -C "error" \
3444 -s "Extra-header:"
3445
3446requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003447run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3448 "$G_SRV -u --mtu 256" \
3449 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3450 0 \
3451 -c "found fragmented DTLS handshake message" \
3452 -c "client hello, adding renegotiation extension" \
3453 -c "found renegotiation extension" \
3454 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003455 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003456 -C "error" \
3457 -s "Extra-header:"
3458
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003459run_test "DTLS reassembly: no fragmentation (openssl server)" \
3460 "$O_SRV -dtls1 -mtu 2048" \
3461 "$P_CLI dtls=1 debug_level=2" \
3462 0 \
3463 -C "found fragmented DTLS handshake message" \
3464 -C "error"
3465
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003466run_test "DTLS reassembly: some fragmentation (openssl server)" \
3467 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003468 "$P_CLI dtls=1 debug_level=2" \
3469 0 \
3470 -c "found fragmented DTLS handshake message" \
3471 -C "error"
3472
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003473run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003474 "$O_SRV -dtls1 -mtu 256" \
3475 "$P_CLI dtls=1 debug_level=2" \
3476 0 \
3477 -c "found fragmented DTLS handshake message" \
3478 -C "error"
3479
3480run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3481 "$O_SRV -dtls1 -mtu 256" \
3482 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3483 0 \
3484 -c "found fragmented DTLS handshake message" \
3485 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003486
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003487# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003488
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003489not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003490run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003491 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003492 "$P_SRV dtls=1 debug_level=2" \
3493 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003494 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003495 -C "replayed record" \
3496 -S "replayed record" \
3497 -C "record from another epoch" \
3498 -S "record from another epoch" \
3499 -C "discarding invalid record" \
3500 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003501 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003502 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003503 -c "HTTP/1.0 200 OK"
3504
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003505not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003506run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003507 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003508 "$P_SRV dtls=1 debug_level=2" \
3509 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003510 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003511 -c "replayed record" \
3512 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003513 -c "discarding invalid record" \
3514 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003515 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003516 -s "Extra-header:" \
3517 -c "HTTP/1.0 200 OK"
3518
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003519run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3520 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003521 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3522 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003523 0 \
3524 -c "replayed record" \
3525 -S "replayed record" \
3526 -c "discarding invalid record" \
3527 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003528 -c "resend" \
3529 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003530 -s "Extra-header:" \
3531 -c "HTTP/1.0 200 OK"
3532
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003533run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003534 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003535 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003536 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003537 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003538 -c "discarding invalid record (mac)" \
3539 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003540 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003541 -c "HTTP/1.0 200 OK" \
3542 -S "too many records with bad MAC" \
3543 -S "Verification of the message MAC failed"
3544
3545run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3546 -p "$P_PXY bad_ad=1" \
3547 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3548 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3549 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003550 -C "discarding invalid record (mac)" \
3551 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003552 -S "Extra-header:" \
3553 -C "HTTP/1.0 200 OK" \
3554 -s "too many records with bad MAC" \
3555 -s "Verification of the message MAC failed"
3556
3557run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3558 -p "$P_PXY bad_ad=1" \
3559 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3560 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3561 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003562 -c "discarding invalid record (mac)" \
3563 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003564 -s "Extra-header:" \
3565 -c "HTTP/1.0 200 OK" \
3566 -S "too many records with bad MAC" \
3567 -S "Verification of the message MAC failed"
3568
3569run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3570 -p "$P_PXY bad_ad=1" \
3571 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3572 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3573 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003574 -c "discarding invalid record (mac)" \
3575 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003576 -s "Extra-header:" \
3577 -c "HTTP/1.0 200 OK" \
3578 -s "too many records with bad MAC" \
3579 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003580
3581run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003582 -p "$P_PXY delay_ccs=1" \
3583 "$P_SRV dtls=1 debug_level=1" \
3584 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003585 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003586 -c "record from another epoch" \
3587 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003588 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003589 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003590 -s "Extra-header:" \
3591 -c "HTTP/1.0 200 OK"
3592
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003593# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003594
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003595needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003596run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003597 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003598 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3599 psk=abc123" \
3600 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003601 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3602 0 \
3603 -s "Extra-header:" \
3604 -c "HTTP/1.0 200 OK"
3605
3606needs_more_time 2
3607run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3608 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003609 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3610 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003611 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3612 0 \
3613 -s "Extra-header:" \
3614 -c "HTTP/1.0 200 OK"
3615
3616needs_more_time 2
3617run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3618 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003619 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3620 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003621 0 \
3622 -s "Extra-header:" \
3623 -c "HTTP/1.0 200 OK"
3624
3625needs_more_time 2
3626run_test "DTLS proxy: 3d, FS, client auth" \
3627 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003628 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3629 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003630 0 \
3631 -s "Extra-header:" \
3632 -c "HTTP/1.0 200 OK"
3633
3634needs_more_time 2
3635run_test "DTLS proxy: 3d, FS, ticket" \
3636 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003637 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3638 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003639 0 \
3640 -s "Extra-header:" \
3641 -c "HTTP/1.0 200 OK"
3642
3643needs_more_time 2
3644run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3645 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003646 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3647 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003648 0 \
3649 -s "Extra-header:" \
3650 -c "HTTP/1.0 200 OK"
3651
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003652needs_more_time 2
3653run_test "DTLS proxy: 3d, max handshake, nbio" \
3654 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003655 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3656 auth_mode=required" \
3657 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003658 0 \
3659 -s "Extra-header:" \
3660 -c "HTTP/1.0 200 OK"
3661
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003662needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003663run_test "DTLS proxy: 3d, min handshake, resumption" \
3664 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3665 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3666 psk=abc123 debug_level=3" \
3667 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3668 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3669 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3670 0 \
3671 -s "a session has been resumed" \
3672 -c "a session has been resumed" \
3673 -s "Extra-header:" \
3674 -c "HTTP/1.0 200 OK"
3675
3676needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003677run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3678 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3679 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3680 psk=abc123 debug_level=3 nbio=2" \
3681 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3682 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3683 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3684 0 \
3685 -s "a session has been resumed" \
3686 -c "a session has been resumed" \
3687 -s "Extra-header:" \
3688 -c "HTTP/1.0 200 OK"
3689
3690needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003691run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003692 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003693 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3694 psk=abc123 renegotiation=1 debug_level=2" \
3695 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3696 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003697 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3698 0 \
3699 -c "=> renegotiate" \
3700 -s "=> renegotiate" \
3701 -s "Extra-header:" \
3702 -c "HTTP/1.0 200 OK"
3703
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003704needs_more_time 4
3705run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3706 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003707 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3708 psk=abc123 renegotiation=1 debug_level=2" \
3709 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3710 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003711 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3712 0 \
3713 -c "=> renegotiate" \
3714 -s "=> renegotiate" \
3715 -s "Extra-header:" \
3716 -c "HTTP/1.0 200 OK"
3717
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003718needs_more_time 4
3719run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003720 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003721 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003722 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003723 debug_level=2" \
3724 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003725 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003726 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3727 0 \
3728 -c "=> renegotiate" \
3729 -s "=> renegotiate" \
3730 -s "Extra-header:" \
3731 -c "HTTP/1.0 200 OK"
3732
3733needs_more_time 4
3734run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003735 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003736 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003737 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003738 debug_level=2 nbio=2" \
3739 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003740 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003741 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3742 0 \
3743 -c "=> renegotiate" \
3744 -s "=> renegotiate" \
3745 -s "Extra-header:" \
3746 -c "HTTP/1.0 200 OK"
3747
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003748needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003749not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003750run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003751 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3752 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003753 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003754 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003755 -c "HTTP/1.0 200 OK"
3756
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003757needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003758not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003759run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3760 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3761 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003762 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003763 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003764 -c "HTTP/1.0 200 OK"
3765
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003766needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003767not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003768run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3769 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3770 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003771 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003772 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003773 -c "HTTP/1.0 200 OK"
3774
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003775requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003776needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003777not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003778run_test "DTLS proxy: 3d, gnutls server" \
3779 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3780 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003781 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003782 0 \
3783 -s "Extra-header:" \
3784 -c "Extra-header:"
3785
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003786requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003787needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003788not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003789run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3790 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3791 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003792 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003793 0 \
3794 -s "Extra-header:" \
3795 -c "Extra-header:"
3796
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003797requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003798needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003799not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003800run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3801 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3802 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003803 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003804 0 \
3805 -s "Extra-header:" \
3806 -c "Extra-header:"
3807
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003808# Final report
3809
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003810echo "------------------------------------------------------------------------"
3811
3812if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003813 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003814else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003815 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003816fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003817PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003818echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003819
3820exit $FAILS