blob: 21dd45d9e7b7e5bcc9efe5ad22b2c3de5e963a10 [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 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000702 -s "dumping 'expected mac' (20 bytes)" \
703 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100704
Hanno Beckera83fafa2017-11-10 08:42:54 +0000705requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100706run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200707 "$P_SRV debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000708 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100709 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000710 -s "dumping 'expected mac' (20 bytes)" \
711 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100712
Hanno Beckera83fafa2017-11-10 08:42:54 +0000713requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100714run_test "Truncated HMAC: client enabled, server default" \
715 "$P_SRV debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000716 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100717 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000718 -s "dumping 'expected mac' (20 bytes)" \
719 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100720
Hanno Beckera83fafa2017-11-10 08:42:54 +0000721requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100722run_test "Truncated HMAC: client enabled, server disabled" \
723 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000724 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100725 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000726 -s "dumping 'expected mac' (20 bytes)" \
727 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100728
Hanno Beckera83fafa2017-11-10 08:42:54 +0000729requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Beckerd51bec72017-11-17 15:46:24 +0000730run_test "Truncated HMAC: client disabled, server enabled" \
731 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000732 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Beckerd51bec72017-11-17 15:46:24 +0000733 0 \
734 -s "dumping 'expected mac' (20 bytes)" \
735 -S "dumping 'expected mac' (10 bytes)"
736
737requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100738run_test "Truncated HMAC: client enabled, server enabled" \
739 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000740 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100741 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000742 -S "dumping 'expected mac' (20 bytes)" \
743 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100744
Hanno Becker02f632e2017-11-10 09:16:05 +0000745run_test "Truncated HMAC, DTLS: client default, server default" \
746 "$P_SRV dtls=1 debug_level=4" \
747 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
748 0 \
749 -s "dumping 'expected mac' (20 bytes)" \
750 -S "dumping 'expected mac' (10 bytes)"
751
752requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
753run_test "Truncated HMAC, DTLS: client disabled, server default" \
754 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000755 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000756 0 \
757 -s "dumping 'expected mac' (20 bytes)" \
758 -S "dumping 'expected mac' (10 bytes)"
759
760requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
761run_test "Truncated HMAC, DTLS: client enabled, server default" \
762 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000763 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000764 0 \
765 -s "dumping 'expected mac' (20 bytes)" \
766 -S "dumping 'expected mac' (10 bytes)"
767
768requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
769run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
770 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000771 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000772 0 \
773 -s "dumping 'expected mac' (20 bytes)" \
774 -S "dumping 'expected mac' (10 bytes)"
775
776requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
777run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
778 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000779 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000780 0 \
781 -s "dumping 'expected mac' (20 bytes)" \
782 -S "dumping 'expected mac' (10 bytes)"
783
784requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
785run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
786 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000787 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000788 0 \
789 -S "dumping 'expected mac' (20 bytes)" \
790 -s "dumping 'expected mac' (10 bytes)"
791
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100792# Tests for Encrypt-then-MAC extension
793
794run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100795 "$P_SRV debug_level=3 \
796 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100797 "$P_CLI debug_level=3" \
798 0 \
799 -c "client hello, adding encrypt_then_mac extension" \
800 -s "found encrypt then mac extension" \
801 -s "server hello, adding encrypt then mac extension" \
802 -c "found encrypt_then_mac extension" \
803 -c "using encrypt then mac" \
804 -s "using encrypt then mac"
805
806run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100807 "$P_SRV debug_level=3 etm=0 \
808 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100809 "$P_CLI debug_level=3 etm=1" \
810 0 \
811 -c "client hello, adding encrypt_then_mac extension" \
812 -s "found encrypt then mac extension" \
813 -S "server hello, adding encrypt then mac extension" \
814 -C "found encrypt_then_mac extension" \
815 -C "using encrypt then mac" \
816 -S "using encrypt then mac"
817
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100818run_test "Encrypt then MAC: client enabled, aead cipher" \
819 "$P_SRV debug_level=3 etm=1 \
820 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
821 "$P_CLI debug_level=3 etm=1" \
822 0 \
823 -c "client hello, adding encrypt_then_mac extension" \
824 -s "found encrypt then mac extension" \
825 -S "server hello, adding encrypt then mac extension" \
826 -C "found encrypt_then_mac extension" \
827 -C "using encrypt then mac" \
828 -S "using encrypt then mac"
829
830run_test "Encrypt then MAC: client enabled, stream cipher" \
831 "$P_SRV debug_level=3 etm=1 \
832 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100833 "$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 +0100834 0 \
835 -c "client hello, adding encrypt_then_mac extension" \
836 -s "found encrypt then mac extension" \
837 -S "server hello, adding encrypt then mac extension" \
838 -C "found encrypt_then_mac extension" \
839 -C "using encrypt then mac" \
840 -S "using encrypt then mac"
841
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100842run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100843 "$P_SRV debug_level=3 etm=1 \
844 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100845 "$P_CLI debug_level=3 etm=0" \
846 0 \
847 -C "client hello, adding encrypt_then_mac extension" \
848 -S "found encrypt then mac extension" \
849 -S "server hello, adding encrypt then mac extension" \
850 -C "found encrypt_then_mac extension" \
851 -C "using encrypt then mac" \
852 -S "using encrypt then mac"
853
Janos Follath542ee5d2016-03-07 15:57:05 +0000854requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100855run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100856 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100857 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100858 "$P_CLI debug_level=3 force_version=ssl3" \
859 0 \
860 -C "client hello, adding encrypt_then_mac extension" \
861 -S "found encrypt then mac extension" \
862 -S "server hello, adding encrypt then mac extension" \
863 -C "found encrypt_then_mac extension" \
864 -C "using encrypt then mac" \
865 -S "using encrypt then mac"
866
Janos Follath542ee5d2016-03-07 15:57:05 +0000867requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100868run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100869 "$P_SRV debug_level=3 force_version=ssl3 \
870 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100871 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100872 0 \
873 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100874 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100875 -S "server hello, adding encrypt then mac extension" \
876 -C "found encrypt_then_mac extension" \
877 -C "using encrypt then mac" \
878 -S "using encrypt then mac"
879
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200880# Tests for Extended Master Secret extension
881
882run_test "Extended Master Secret: default" \
883 "$P_SRV debug_level=3" \
884 "$P_CLI debug_level=3" \
885 0 \
886 -c "client hello, adding extended_master_secret extension" \
887 -s "found extended master secret extension" \
888 -s "server hello, adding extended master secret extension" \
889 -c "found extended_master_secret extension" \
890 -c "using extended master secret" \
891 -s "using extended master secret"
892
893run_test "Extended Master Secret: client enabled, server disabled" \
894 "$P_SRV debug_level=3 extended_ms=0" \
895 "$P_CLI debug_level=3 extended_ms=1" \
896 0 \
897 -c "client hello, adding extended_master_secret extension" \
898 -s "found extended master secret extension" \
899 -S "server hello, adding extended master secret extension" \
900 -C "found extended_master_secret extension" \
901 -C "using extended master secret" \
902 -S "using extended master secret"
903
904run_test "Extended Master Secret: client disabled, server enabled" \
905 "$P_SRV debug_level=3 extended_ms=1" \
906 "$P_CLI debug_level=3 extended_ms=0" \
907 0 \
908 -C "client hello, adding extended_master_secret extension" \
909 -S "found extended master secret extension" \
910 -S "server hello, adding extended master secret extension" \
911 -C "found extended_master_secret extension" \
912 -C "using extended master secret" \
913 -S "using extended master secret"
914
Janos Follath542ee5d2016-03-07 15:57:05 +0000915requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200916run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100917 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200918 "$P_CLI debug_level=3 force_version=ssl3" \
919 0 \
920 -C "client hello, adding extended_master_secret extension" \
921 -S "found extended master secret extension" \
922 -S "server hello, adding extended master secret extension" \
923 -C "found extended_master_secret extension" \
924 -C "using extended master secret" \
925 -S "using extended master secret"
926
Janos Follath542ee5d2016-03-07 15:57:05 +0000927requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200928run_test "Extended Master Secret: client enabled, server SSLv3" \
929 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100930 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200931 0 \
932 -c "client hello, adding extended_master_secret extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100933 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200934 -S "server hello, adding extended master secret extension" \
935 -C "found extended_master_secret extension" \
936 -C "using extended master secret" \
937 -S "using extended master secret"
938
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200939# Tests for FALLBACK_SCSV
940
941run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200942 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200943 "$P_CLI debug_level=3 force_version=tls1_1" \
944 0 \
945 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200946 -S "received FALLBACK_SCSV" \
947 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200948 -C "is a fatal alert message (msg 86)"
949
950run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200951 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200952 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
953 0 \
954 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200955 -S "received FALLBACK_SCSV" \
956 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200957 -C "is a fatal alert message (msg 86)"
958
959run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200960 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200961 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200962 1 \
963 -c "adding FALLBACK_SCSV" \
964 -s "received FALLBACK_SCSV" \
965 -s "inapropriate fallback" \
966 -c "is a fatal alert message (msg 86)"
967
968run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200969 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200970 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200971 0 \
972 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200973 -s "received FALLBACK_SCSV" \
974 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200975 -C "is a fatal alert message (msg 86)"
976
977requires_openssl_with_fallback_scsv
978run_test "Fallback SCSV: default, openssl server" \
979 "$O_SRV" \
980 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
981 0 \
982 -C "adding FALLBACK_SCSV" \
983 -C "is a fatal alert message (msg 86)"
984
985requires_openssl_with_fallback_scsv
986run_test "Fallback SCSV: enabled, openssl server" \
987 "$O_SRV" \
988 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
989 1 \
990 -c "adding FALLBACK_SCSV" \
991 -c "is a fatal alert message (msg 86)"
992
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200993requires_openssl_with_fallback_scsv
994run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200995 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200996 "$O_CLI -tls1_1" \
997 0 \
998 -S "received FALLBACK_SCSV" \
999 -S "inapropriate fallback"
1000
1001requires_openssl_with_fallback_scsv
1002run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001003 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001004 "$O_CLI -tls1_1 -fallback_scsv" \
1005 1 \
1006 -s "received FALLBACK_SCSV" \
1007 -s "inapropriate fallback"
1008
1009requires_openssl_with_fallback_scsv
1010run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001011 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001012 "$O_CLI -fallback_scsv" \
1013 0 \
1014 -s "received FALLBACK_SCSV" \
1015 -S "inapropriate fallback"
1016
Gilles Peskine39e29812017-05-16 17:53:03 +02001017## ClientHello generated with
1018## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1019## then manually twiddling the ciphersuite list.
1020## The ClientHello content is spelled out below as a hex string as
1021## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1022## The expected response is an inappropriate_fallback alert.
1023requires_openssl_with_fallback_scsv
1024run_test "Fallback SCSV: beginning of list" \
1025 "$P_SRV debug_level=2" \
1026 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1027 0 \
1028 -s "received FALLBACK_SCSV" \
1029 -s "inapropriate fallback"
1030
1031requires_openssl_with_fallback_scsv
1032run_test "Fallback SCSV: end of list" \
1033 "$P_SRV debug_level=2" \
1034 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1035 0 \
1036 -s "received FALLBACK_SCSV" \
1037 -s "inapropriate fallback"
1038
1039## Here the expected response is a valid ServerHello prefix, up to the random.
1040requires_openssl_with_fallback_scsv
1041run_test "Fallback SCSV: not in list" \
1042 "$P_SRV debug_level=2" \
1043 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1044 0 \
1045 -S "received FALLBACK_SCSV" \
1046 -S "inapropriate fallback"
1047
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001048# Tests for CBC 1/n-1 record splitting
1049
1050run_test "CBC Record splitting: TLS 1.2, no splitting" \
1051 "$P_SRV" \
1052 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1053 request_size=123 force_version=tls1_2" \
1054 0 \
1055 -s "Read from client: 123 bytes read" \
1056 -S "Read from client: 1 bytes read" \
1057 -S "122 bytes read"
1058
1059run_test "CBC Record splitting: TLS 1.1, no splitting" \
1060 "$P_SRV" \
1061 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1062 request_size=123 force_version=tls1_1" \
1063 0 \
1064 -s "Read from client: 123 bytes read" \
1065 -S "Read from client: 1 bytes read" \
1066 -S "122 bytes read"
1067
1068run_test "CBC Record splitting: TLS 1.0, splitting" \
1069 "$P_SRV" \
1070 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1071 request_size=123 force_version=tls1" \
1072 0 \
1073 -S "Read from client: 123 bytes read" \
1074 -s "Read from client: 1 bytes read" \
1075 -s "122 bytes read"
1076
Janos Follath542ee5d2016-03-07 15:57:05 +00001077requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001078run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001079 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001080 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1081 request_size=123 force_version=ssl3" \
1082 0 \
1083 -S "Read from client: 123 bytes read" \
1084 -s "Read from client: 1 bytes read" \
1085 -s "122 bytes read"
1086
1087run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001088 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001089 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1090 request_size=123 force_version=tls1" \
1091 0 \
1092 -s "Read from client: 123 bytes read" \
1093 -S "Read from client: 1 bytes read" \
1094 -S "122 bytes read"
1095
1096run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1097 "$P_SRV" \
1098 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1099 request_size=123 force_version=tls1 recsplit=0" \
1100 0 \
1101 -s "Read from client: 123 bytes read" \
1102 -S "Read from client: 1 bytes read" \
1103 -S "122 bytes read"
1104
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001105run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1106 "$P_SRV nbio=2" \
1107 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1108 request_size=123 force_version=tls1" \
1109 0 \
1110 -S "Read from client: 123 bytes read" \
1111 -s "Read from client: 1 bytes read" \
1112 -s "122 bytes read"
1113
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001114# Tests for Session Tickets
1115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001116run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001117 "$P_SRV debug_level=3 tickets=1" \
1118 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001119 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001120 -c "client hello, adding session ticket extension" \
1121 -s "found session ticket extension" \
1122 -s "server hello, adding session ticket extension" \
1123 -c "found session_ticket extension" \
1124 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001125 -S "session successfully restored from cache" \
1126 -s "session successfully restored from ticket" \
1127 -s "a session has been resumed" \
1128 -c "a session has been resumed"
1129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001130run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001131 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1132 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001133 0 \
1134 -c "client hello, adding session ticket extension" \
1135 -s "found session ticket extension" \
1136 -s "server hello, adding session ticket extension" \
1137 -c "found session_ticket extension" \
1138 -c "parse new session ticket" \
1139 -S "session successfully restored from cache" \
1140 -s "session successfully restored from ticket" \
1141 -s "a session has been resumed" \
1142 -c "a session has been resumed"
1143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001144run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001145 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1146 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001147 0 \
1148 -c "client hello, adding session ticket extension" \
1149 -s "found session ticket extension" \
1150 -s "server hello, adding session ticket extension" \
1151 -c "found session_ticket extension" \
1152 -c "parse new session ticket" \
1153 -S "session successfully restored from cache" \
1154 -S "session successfully restored from ticket" \
1155 -S "a session has been resumed" \
1156 -C "a session has been resumed"
1157
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001158run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001159 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001160 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001161 0 \
1162 -c "client hello, adding session ticket extension" \
1163 -c "found session_ticket extension" \
1164 -c "parse new session ticket" \
1165 -c "a session has been resumed"
1166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001167run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001168 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001169 "( $O_CLI -sess_out $SESSION; \
1170 $O_CLI -sess_in $SESSION; \
1171 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001172 0 \
1173 -s "found session ticket extension" \
1174 -s "server hello, adding session ticket extension" \
1175 -S "session successfully restored from cache" \
1176 -s "session successfully restored from ticket" \
1177 -s "a session has been resumed"
1178
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001179# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001181run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001182 "$P_SRV debug_level=3 tickets=0" \
1183 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001184 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001185 -c "client hello, adding session ticket extension" \
1186 -s "found session ticket extension" \
1187 -S "server hello, adding session ticket extension" \
1188 -C "found session_ticket extension" \
1189 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001190 -s "session successfully restored from cache" \
1191 -S "session successfully restored from ticket" \
1192 -s "a session has been resumed" \
1193 -c "a session has been resumed"
1194
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001195run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001196 "$P_SRV debug_level=3 tickets=1" \
1197 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001198 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001199 -C "client hello, adding session ticket extension" \
1200 -S "found session ticket extension" \
1201 -S "server hello, adding session ticket extension" \
1202 -C "found session_ticket extension" \
1203 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001204 -s "session successfully restored from cache" \
1205 -S "session successfully restored from ticket" \
1206 -s "a session has been resumed" \
1207 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001209run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001210 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1211 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001212 0 \
1213 -S "session successfully restored from cache" \
1214 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001215 -S "a session has been resumed" \
1216 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001218run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001219 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1220 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001221 0 \
1222 -s "session successfully restored from cache" \
1223 -S "session successfully restored from ticket" \
1224 -s "a session has been resumed" \
1225 -c "a session has been resumed"
1226
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001227run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001228 "$P_SRV debug_level=3 tickets=0" \
1229 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001230 0 \
1231 -s "session successfully restored from cache" \
1232 -S "session successfully restored from ticket" \
1233 -s "a session has been resumed" \
1234 -c "a session has been resumed"
1235
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001236run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001237 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1238 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001239 0 \
1240 -S "session successfully restored from cache" \
1241 -S "session successfully restored from ticket" \
1242 -S "a session has been resumed" \
1243 -C "a session has been resumed"
1244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001245run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001246 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1247 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001248 0 \
1249 -s "session successfully restored from cache" \
1250 -S "session successfully restored from ticket" \
1251 -s "a session has been resumed" \
1252 -c "a session has been resumed"
1253
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001254run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001255 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001256 "( $O_CLI -sess_out $SESSION; \
1257 $O_CLI -sess_in $SESSION; \
1258 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001259 0 \
1260 -s "found session ticket extension" \
1261 -S "server hello, adding session ticket extension" \
1262 -s "session successfully restored from cache" \
1263 -S "session successfully restored from ticket" \
1264 -s "a session has been resumed"
1265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001266run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001267 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001268 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001269 0 \
1270 -C "found session_ticket extension" \
1271 -C "parse new session ticket" \
1272 -c "a session has been resumed"
1273
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001274# Tests for Max Fragment Length extension
1275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001276run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001277 "$P_SRV debug_level=3" \
1278 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001279 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001280 -c "Maximum fragment length is 16384" \
1281 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001282 -C "client hello, adding max_fragment_length extension" \
1283 -S "found max fragment length extension" \
1284 -S "server hello, max_fragment_length extension" \
1285 -C "found max_fragment_length extension"
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_SRV debug_level=3" \
1289 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001290 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001291 -c "Maximum fragment length is 4096" \
1292 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001293 -c "client hello, adding max_fragment_length extension" \
1294 -s "found max fragment length extension" \
1295 -s "server hello, max_fragment_length extension" \
1296 -c "found max_fragment_length extension"
1297
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001298run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001299 "$P_SRV debug_level=3 max_frag_len=4096" \
1300 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001301 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001302 -c "Maximum fragment length is 16384" \
1303 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001304 -C "client hello, adding max_fragment_length extension" \
1305 -S "found max fragment length extension" \
1306 -S "server hello, max_fragment_length extension" \
1307 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001309requires_gnutls
1310run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001311 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001312 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001313 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001314 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001315 -c "client hello, adding max_fragment_length extension" \
1316 -c "found max_fragment_length extension"
1317
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001318run_test "Max fragment length: client, message just fits" \
1319 "$P_SRV debug_level=3" \
1320 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1321 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001322 -c "Maximum fragment length is 2048" \
1323 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001324 -c "client hello, adding max_fragment_length extension" \
1325 -s "found max fragment length extension" \
1326 -s "server hello, max_fragment_length extension" \
1327 -c "found max_fragment_length extension" \
1328 -c "2048 bytes written in 1 fragments" \
1329 -s "2048 bytes read"
1330
1331run_test "Max fragment length: client, larger message" \
1332 "$P_SRV debug_level=3" \
1333 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
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 "2345 bytes written in 2 fragments" \
1342 -s "2048 bytes read" \
1343 -s "297 bytes read"
1344
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001345run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001346 "$P_SRV debug_level=3 dtls=1" \
1347 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1348 1 \
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 "fragment larger than.*maximum"
1356
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001357# Tests for renegotiation
1358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001359run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001360 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001361 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001362 0 \
1363 -C "client hello, adding renegotiation extension" \
1364 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1365 -S "found renegotiation extension" \
1366 -s "server hello, secure renegotiation extension" \
1367 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001368 -C "=> renegotiate" \
1369 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001370 -S "write hello request"
1371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001372run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001373 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001374 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001375 0 \
1376 -c "client hello, adding renegotiation extension" \
1377 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1378 -s "found renegotiation extension" \
1379 -s "server hello, secure renegotiation extension" \
1380 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001381 -c "=> renegotiate" \
1382 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001383 -S "write hello request"
1384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001385run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001386 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001387 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001388 0 \
1389 -c "client hello, adding renegotiation extension" \
1390 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1391 -s "found renegotiation extension" \
1392 -s "server hello, secure renegotiation extension" \
1393 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001394 -c "=> renegotiate" \
1395 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001396 -s "write hello request"
1397
Janos Follath5f1dd802017-10-05 12:29:42 +01001398# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1399# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1400# algorithm stronger than SHA-1 is enabled in config.h
1401run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1402 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1403 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1404 0 \
1405 -c "client hello, adding renegotiation extension" \
1406 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1407 -s "found renegotiation extension" \
1408 -s "server hello, secure renegotiation extension" \
1409 -c "found renegotiation extension" \
1410 -c "=> renegotiate" \
1411 -s "=> renegotiate" \
1412 -S "write hello request" \
1413 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1414
1415# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1416# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1417# algorithm stronger than SHA-1 is enabled in config.h
1418run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1419 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1420 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1421 0 \
1422 -c "client hello, adding renegotiation extension" \
1423 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1424 -s "found renegotiation extension" \
1425 -s "server hello, secure renegotiation extension" \
1426 -c "found renegotiation extension" \
1427 -c "=> renegotiate" \
1428 -s "=> renegotiate" \
1429 -s "write hello request" \
1430 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001432run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001433 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001434 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001435 0 \
1436 -c "client hello, adding renegotiation extension" \
1437 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1438 -s "found renegotiation extension" \
1439 -s "server hello, secure renegotiation extension" \
1440 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001441 -c "=> renegotiate" \
1442 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001443 -s "write hello request"
1444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001445run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001446 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001447 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001448 1 \
1449 -c "client hello, adding renegotiation extension" \
1450 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1451 -S "found renegotiation extension" \
1452 -s "server hello, secure renegotiation extension" \
1453 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001454 -c "=> renegotiate" \
1455 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001456 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001457 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001458 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001459
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001460run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001461 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001462 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001463 0 \
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é-Gonnard780d6712014-02-20 17:19:59 +01001471 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001472 -S "SSL - An unexpected message was received from our peer" \
1473 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001474
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001475run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001476 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001477 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001478 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001479 0 \
1480 -C "client hello, adding renegotiation extension" \
1481 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1482 -S "found renegotiation extension" \
1483 -s "server hello, secure renegotiation extension" \
1484 -c "found renegotiation extension" \
1485 -C "=> renegotiate" \
1486 -S "=> renegotiate" \
1487 -s "write hello request" \
1488 -S "SSL - An unexpected message was received from our peer" \
1489 -S "failed"
1490
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001491# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001492run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001493 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001494 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001495 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001496 0 \
1497 -C "client hello, adding renegotiation extension" \
1498 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1499 -S "found renegotiation extension" \
1500 -s "server hello, secure renegotiation extension" \
1501 -c "found renegotiation extension" \
1502 -C "=> renegotiate" \
1503 -S "=> renegotiate" \
1504 -s "write hello request" \
1505 -S "SSL - An unexpected message was received from our peer" \
1506 -S "failed"
1507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001508run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001509 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001510 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001511 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001512 0 \
1513 -C "client hello, adding renegotiation extension" \
1514 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1515 -S "found renegotiation extension" \
1516 -s "server hello, secure renegotiation extension" \
1517 -c "found renegotiation extension" \
1518 -C "=> renegotiate" \
1519 -S "=> renegotiate" \
1520 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001521 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001523run_test "Renegotiation: server-initiated, client-accepted, 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=1" \
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" \
1536 -S "SSL - An unexpected message was received from our peer" \
1537 -S "failed"
1538
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001539run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001540 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001541 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1542 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 -S "record counter limit reached: renegotiate" \
1549 -C "=> renegotiate" \
1550 -S "=> renegotiate" \
1551 -S "write hello request" \
1552 -S "SSL - An unexpected message was received from our peer" \
1553 -S "failed"
1554
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001555# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001556run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001557 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001558 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001559 0 \
1560 -c "client hello, adding renegotiation extension" \
1561 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1562 -s "found renegotiation extension" \
1563 -s "server hello, secure renegotiation extension" \
1564 -c "found renegotiation extension" \
1565 -s "record counter limit reached: renegotiate" \
1566 -c "=> renegotiate" \
1567 -s "=> renegotiate" \
1568 -s "write hello request" \
1569 -S "SSL - An unexpected message was received from our peer" \
1570 -S "failed"
1571
1572run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001573 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001574 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001575 0 \
1576 -c "client hello, adding renegotiation extension" \
1577 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1578 -s "found renegotiation extension" \
1579 -s "server hello, secure renegotiation extension" \
1580 -c "found renegotiation extension" \
1581 -s "record counter limit reached: renegotiate" \
1582 -c "=> renegotiate" \
1583 -s "=> renegotiate" \
1584 -s "write hello request" \
1585 -S "SSL - An unexpected message was received from our peer" \
1586 -S "failed"
1587
1588run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001589 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001590 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1591 0 \
1592 -C "client hello, adding renegotiation extension" \
1593 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1594 -S "found renegotiation extension" \
1595 -s "server hello, secure renegotiation extension" \
1596 -c "found renegotiation extension" \
1597 -S "record counter limit reached: renegotiate" \
1598 -C "=> renegotiate" \
1599 -S "=> renegotiate" \
1600 -S "write hello request" \
1601 -S "SSL - An unexpected message was received from our peer" \
1602 -S "failed"
1603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001604run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001605 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001606 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001607 0 \
1608 -c "client hello, adding renegotiation extension" \
1609 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1610 -s "found renegotiation extension" \
1611 -s "server hello, secure renegotiation extension" \
1612 -c "found renegotiation extension" \
1613 -c "=> renegotiate" \
1614 -s "=> renegotiate" \
1615 -S "write hello request"
1616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001617run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001618 "$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 +02001619 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001620 0 \
1621 -c "client hello, adding renegotiation extension" \
1622 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1623 -s "found renegotiation extension" \
1624 -s "server hello, secure renegotiation extension" \
1625 -c "found renegotiation extension" \
1626 -c "=> renegotiate" \
1627 -s "=> renegotiate" \
1628 -s "write hello request"
1629
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001630run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001631 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001632 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001633 0 \
1634 -c "client hello, adding renegotiation extension" \
1635 -c "found renegotiation extension" \
1636 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001637 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001638 -C "error" \
1639 -c "HTTP/1.0 200 [Oo][Kk]"
1640
Paul Bakker539d9722015-02-08 16:18:35 +01001641requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001642run_test "Renegotiation: gnutls server strict, client-initiated" \
1643 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001644 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001645 0 \
1646 -c "client hello, adding renegotiation extension" \
1647 -c "found renegotiation extension" \
1648 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001649 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001650 -C "error" \
1651 -c "HTTP/1.0 200 [Oo][Kk]"
1652
Paul Bakker539d9722015-02-08 16:18:35 +01001653requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001654run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1655 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1656 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1657 1 \
1658 -c "client hello, adding renegotiation extension" \
1659 -C "found renegotiation extension" \
1660 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001661 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001662 -c "error" \
1663 -C "HTTP/1.0 200 [Oo][Kk]"
1664
Paul Bakker539d9722015-02-08 16:18:35 +01001665requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001666run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1667 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1668 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1669 allow_legacy=0" \
1670 1 \
1671 -c "client hello, adding renegotiation extension" \
1672 -C "found renegotiation extension" \
1673 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001674 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001675 -c "error" \
1676 -C "HTTP/1.0 200 [Oo][Kk]"
1677
Paul Bakker539d9722015-02-08 16:18:35 +01001678requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001679run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1680 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1681 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1682 allow_legacy=1" \
1683 0 \
1684 -c "client hello, adding renegotiation extension" \
1685 -C "found renegotiation extension" \
1686 -c "=> renegotiate" \
1687 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001688 -C "error" \
1689 -c "HTTP/1.0 200 [Oo][Kk]"
1690
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001691run_test "Renegotiation: DTLS, client-initiated" \
1692 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1693 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1694 0 \
1695 -c "client hello, adding renegotiation extension" \
1696 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1697 -s "found renegotiation extension" \
1698 -s "server hello, secure renegotiation extension" \
1699 -c "found renegotiation extension" \
1700 -c "=> renegotiate" \
1701 -s "=> renegotiate" \
1702 -S "write hello request"
1703
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001704run_test "Renegotiation: DTLS, server-initiated" \
1705 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001706 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1707 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001708 0 \
1709 -c "client hello, adding renegotiation extension" \
1710 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1711 -s "found renegotiation extension" \
1712 -s "server hello, secure renegotiation extension" \
1713 -c "found renegotiation extension" \
1714 -c "=> renegotiate" \
1715 -s "=> renegotiate" \
1716 -s "write hello request"
1717
Andres AG9b1927b2017-01-19 16:30:57 +00001718run_test "Renegotiation: DTLS, renego_period overflow" \
1719 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1720 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1721 0 \
1722 -c "client hello, adding renegotiation extension" \
1723 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1724 -s "found renegotiation extension" \
1725 -s "server hello, secure renegotiation extension" \
1726 -s "record counter limit reached: renegotiate" \
1727 -c "=> renegotiate" \
1728 -s "=> renegotiate" \
1729 -s "write hello request" \
1730
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001731requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001732run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1733 "$G_SRV -u --mtu 4096" \
1734 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1735 0 \
1736 -c "client hello, adding renegotiation extension" \
1737 -c "found renegotiation extension" \
1738 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001739 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001740 -C "error" \
1741 -s "Extra-header:"
1742
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001743# Test for the "secure renegotation" extension only (no actual renegotiation)
1744
Paul Bakker539d9722015-02-08 16:18:35 +01001745requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001746run_test "Renego ext: gnutls server strict, client default" \
1747 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1748 "$P_CLI debug_level=3" \
1749 0 \
1750 -c "found renegotiation extension" \
1751 -C "error" \
1752 -c "HTTP/1.0 200 [Oo][Kk]"
1753
Paul Bakker539d9722015-02-08 16:18:35 +01001754requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001755run_test "Renego ext: gnutls server unsafe, client default" \
1756 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1757 "$P_CLI debug_level=3" \
1758 0 \
1759 -C "found renegotiation extension" \
1760 -C "error" \
1761 -c "HTTP/1.0 200 [Oo][Kk]"
1762
Paul Bakker539d9722015-02-08 16:18:35 +01001763requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001764run_test "Renego ext: gnutls server unsafe, client break legacy" \
1765 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1766 "$P_CLI debug_level=3 allow_legacy=-1" \
1767 1 \
1768 -C "found renegotiation extension" \
1769 -c "error" \
1770 -C "HTTP/1.0 200 [Oo][Kk]"
1771
Paul Bakker539d9722015-02-08 16:18:35 +01001772requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001773run_test "Renego ext: gnutls client strict, server default" \
1774 "$P_SRV debug_level=3" \
1775 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1776 0 \
1777 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1778 -s "server hello, secure renegotiation extension"
1779
Paul Bakker539d9722015-02-08 16:18:35 +01001780requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001781run_test "Renego ext: gnutls client unsafe, server default" \
1782 "$P_SRV debug_level=3" \
1783 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1784 0 \
1785 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1786 -S "server hello, secure renegotiation extension"
1787
Paul Bakker539d9722015-02-08 16:18:35 +01001788requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001789run_test "Renego ext: gnutls client unsafe, server break legacy" \
1790 "$P_SRV debug_level=3 allow_legacy=-1" \
1791 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1792 1 \
1793 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1794 -S "server hello, secure renegotiation extension"
1795
Janos Follath365b2262016-02-17 10:11:21 +00001796# Tests for silently dropping trailing extra bytes in .der certificates
1797
1798requires_gnutls
1799run_test "DER format: no trailing bytes" \
1800 "$P_SRV crt_file=data_files/server5-der0.crt \
1801 key_file=data_files/server5.key" \
1802 "$G_CLI " \
1803 0 \
1804 -c "Handshake was completed" \
1805
1806requires_gnutls
1807run_test "DER format: with a trailing zero byte" \
1808 "$P_SRV crt_file=data_files/server5-der1a.crt \
1809 key_file=data_files/server5.key" \
1810 "$G_CLI " \
1811 0 \
1812 -c "Handshake was completed" \
1813
1814requires_gnutls
1815run_test "DER format: with a trailing random byte" \
1816 "$P_SRV crt_file=data_files/server5-der1b.crt \
1817 key_file=data_files/server5.key" \
1818 "$G_CLI " \
1819 0 \
1820 -c "Handshake was completed" \
1821
1822requires_gnutls
1823run_test "DER format: with 2 trailing random bytes" \
1824 "$P_SRV crt_file=data_files/server5-der2.crt \
1825 key_file=data_files/server5.key" \
1826 "$G_CLI " \
1827 0 \
1828 -c "Handshake was completed" \
1829
1830requires_gnutls
1831run_test "DER format: with 4 trailing random bytes" \
1832 "$P_SRV crt_file=data_files/server5-der4.crt \
1833 key_file=data_files/server5.key" \
1834 "$G_CLI " \
1835 0 \
1836 -c "Handshake was completed" \
1837
1838requires_gnutls
1839run_test "DER format: with 8 trailing random bytes" \
1840 "$P_SRV crt_file=data_files/server5-der8.crt \
1841 key_file=data_files/server5.key" \
1842 "$G_CLI " \
1843 0 \
1844 -c "Handshake was completed" \
1845
1846requires_gnutls
1847run_test "DER format: with 9 trailing random bytes" \
1848 "$P_SRV crt_file=data_files/server5-der9.crt \
1849 key_file=data_files/server5.key" \
1850 "$G_CLI " \
1851 0 \
1852 -c "Handshake was completed" \
1853
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001854# Tests for auth_mode
1855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001856run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001857 "$P_SRV crt_file=data_files/server5-badsign.crt \
1858 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001859 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001860 1 \
1861 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001862 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001863 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001864 -c "X509 - Certificate verification failed"
1865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001866run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001867 "$P_SRV crt_file=data_files/server5-badsign.crt \
1868 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001869 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001870 0 \
1871 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001872 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001873 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001874 -C "X509 - Certificate verification failed"
1875
Hanno Becker61c0c702017-05-15 16:05:15 +01001876run_test "Authentication: server goodcert, client optional, no trusted CA" \
1877 "$P_SRV" \
1878 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1879 0 \
1880 -c "x509_verify_cert() returned" \
1881 -c "! The certificate is not correctly signed by the trusted CA" \
1882 -c "! Certificate verification flags"\
1883 -C "! mbedtls_ssl_handshake returned" \
1884 -C "X509 - Certificate verification failed" \
1885 -C "SSL - No CA Chain is set, but required to operate"
1886
1887run_test "Authentication: server goodcert, client required, no trusted CA" \
1888 "$P_SRV" \
1889 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1890 1 \
1891 -c "x509_verify_cert() returned" \
1892 -c "! The certificate is not correctly signed by the trusted CA" \
1893 -c "! Certificate verification flags"\
1894 -c "! mbedtls_ssl_handshake returned" \
1895 -c "SSL - No CA Chain is set, but required to operate"
1896
1897# The purpose of the next two tests is to test the client's behaviour when receiving a server
1898# certificate with an unsupported elliptic curve. This should usually not happen because
1899# the client informs the server about the supported curves - it does, though, in the
1900# corner case of a static ECDH suite, because the server doesn't check the curve on that
1901# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1902# different means to have the server ignoring the client's supported curve list.
1903
1904requires_config_enabled MBEDTLS_ECP_C
1905run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1906 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1907 crt_file=data_files/server5.ku-ka.crt" \
1908 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1909 1 \
1910 -c "bad certificate (EC key curve)"\
1911 -c "! Certificate verification flags"\
1912 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1913
1914requires_config_enabled MBEDTLS_ECP_C
1915run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1916 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1917 crt_file=data_files/server5.ku-ka.crt" \
1918 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1919 1 \
1920 -c "bad certificate (EC key curve)"\
1921 -c "! Certificate verification flags"\
1922 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001924run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001925 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001926 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001927 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001928 0 \
1929 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001930 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001931 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001932 -C "X509 - Certificate verification failed"
1933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001934run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001935 "$P_SRV debug_level=3 auth_mode=required" \
1936 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001937 key_file=data_files/server5.key" \
1938 1 \
1939 -S "skip write certificate request" \
1940 -C "skip parse certificate request" \
1941 -c "got a certificate request" \
1942 -C "skip write certificate" \
1943 -C "skip write certificate verify" \
1944 -S "skip parse certificate verify" \
1945 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001946 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001947 -s "! mbedtls_ssl_handshake returned" \
1948 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001949 -s "X509 - Certificate verification failed"
1950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001951run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001952 "$P_SRV debug_level=3 auth_mode=optional" \
1953 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001954 key_file=data_files/server5.key" \
1955 0 \
1956 -S "skip write certificate request" \
1957 -C "skip parse certificate request" \
1958 -c "got a certificate request" \
1959 -C "skip write certificate" \
1960 -C "skip write certificate verify" \
1961 -S "skip parse certificate verify" \
1962 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001963 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001964 -S "! mbedtls_ssl_handshake returned" \
1965 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001966 -S "X509 - Certificate verification failed"
1967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001968run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001969 "$P_SRV debug_level=3 auth_mode=none" \
1970 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001971 key_file=data_files/server5.key" \
1972 0 \
1973 -s "skip write certificate request" \
1974 -C "skip parse certificate request" \
1975 -c "got no certificate request" \
1976 -c "skip write certificate" \
1977 -c "skip write certificate verify" \
1978 -s "skip parse certificate verify" \
1979 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001980 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001981 -S "! mbedtls_ssl_handshake returned" \
1982 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001983 -S "X509 - Certificate verification failed"
1984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001985run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001986 "$P_SRV debug_level=3 auth_mode=optional" \
1987 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001988 0 \
1989 -S "skip write certificate request" \
1990 -C "skip parse certificate request" \
1991 -c "got a certificate request" \
1992 -C "skip write certificate$" \
1993 -C "got no certificate to send" \
1994 -S "SSLv3 client has no certificate" \
1995 -c "skip write certificate verify" \
1996 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001997 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001998 -S "! mbedtls_ssl_handshake returned" \
1999 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002000 -S "X509 - Certificate verification failed"
2001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002002run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002003 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002004 "$O_CLI" \
2005 0 \
2006 -S "skip write certificate request" \
2007 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002008 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002009 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002010 -S "X509 - Certificate verification failed"
2011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002012run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002013 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002014 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002015 0 \
2016 -C "skip parse certificate request" \
2017 -c "got a certificate request" \
2018 -C "skip write certificate$" \
2019 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002020 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002021
Janos Follath542ee5d2016-03-07 15:57:05 +00002022requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002023run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002024 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002025 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002026 0 \
2027 -S "skip write certificate request" \
2028 -C "skip parse certificate request" \
2029 -c "got a certificate request" \
2030 -C "skip write certificate$" \
2031 -c "skip write certificate verify" \
2032 -c "got no certificate to send" \
2033 -s "SSLv3 client has no certificate" \
2034 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002035 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002036 -S "! mbedtls_ssl_handshake returned" \
2037 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002038 -S "X509 - Certificate verification failed"
2039
Manuel Pégourié-Gonnard591035d2017-06-26 10:45:33 +02002040run_test "Authentication: server max_int chain, client default" \
2041 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2042 key_file=data_files/dir-maxpath/09.key" \
2043 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2044 0 \
2045 -C "X509 - A fatal error occured"
2046
2047run_test "Authentication: server max_int+1 chain, client default" \
2048 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2049 key_file=data_files/dir-maxpath/10.key" \
2050 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2051 1 \
2052 -c "X509 - A fatal error occured"
2053
2054run_test "Authentication: server max_int+1 chain, client optional" \
2055 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2056 key_file=data_files/dir-maxpath/10.key" \
2057 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2058 auth_mode=optional" \
2059 1 \
2060 -c "X509 - A fatal error occured"
2061
2062run_test "Authentication: server max_int+1 chain, client none" \
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 auth_mode=none" \
2067 0 \
2068 -C "X509 - A fatal error occured"
2069
2070run_test "Authentication: client max_int+1 chain, server default" \
2071 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2072 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2073 key_file=data_files/dir-maxpath/10.key" \
2074 0 \
2075 -S "X509 - A fatal error occured"
2076
2077run_test "Authentication: client max_int+1 chain, server optional" \
2078 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2079 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2080 key_file=data_files/dir-maxpath/10.key" \
2081 1 \
2082 -s "X509 - A fatal error occured"
2083
2084run_test "Authentication: client max_int+1 chain, server required" \
2085 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2086 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2087 key_file=data_files/dir-maxpath/10.key" \
2088 1 \
2089 -s "X509 - A fatal error occured"
2090
2091run_test "Authentication: client max_int chain, server required" \
2092 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2093 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2094 key_file=data_files/dir-maxpath/09.key" \
2095 0 \
2096 -S "X509 - A fatal error occured"
2097
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002098# Tests for certificate selection based on SHA verson
2099
2100run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2101 "$P_SRV crt_file=data_files/server5.crt \
2102 key_file=data_files/server5.key \
2103 crt_file2=data_files/server5-sha1.crt \
2104 key_file2=data_files/server5.key" \
2105 "$P_CLI force_version=tls1_2" \
2106 0 \
2107 -c "signed using.*ECDSA with SHA256" \
2108 -C "signed using.*ECDSA with SHA1"
2109
2110run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2111 "$P_SRV crt_file=data_files/server5.crt \
2112 key_file=data_files/server5.key \
2113 crt_file2=data_files/server5-sha1.crt \
2114 key_file2=data_files/server5.key" \
2115 "$P_CLI force_version=tls1_1" \
2116 0 \
2117 -C "signed using.*ECDSA with SHA256" \
2118 -c "signed using.*ECDSA with SHA1"
2119
2120run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2121 "$P_SRV crt_file=data_files/server5.crt \
2122 key_file=data_files/server5.key \
2123 crt_file2=data_files/server5-sha1.crt \
2124 key_file2=data_files/server5.key" \
2125 "$P_CLI force_version=tls1" \
2126 0 \
2127 -C "signed using.*ECDSA with SHA256" \
2128 -c "signed using.*ECDSA with SHA1"
2129
2130run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2131 "$P_SRV crt_file=data_files/server5.crt \
2132 key_file=data_files/server5.key \
2133 crt_file2=data_files/server6.crt \
2134 key_file2=data_files/server6.key" \
2135 "$P_CLI force_version=tls1_1" \
2136 0 \
2137 -c "serial number.*09" \
2138 -c "signed using.*ECDSA with SHA256" \
2139 -C "signed using.*ECDSA with SHA1"
2140
2141run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2142 "$P_SRV crt_file=data_files/server6.crt \
2143 key_file=data_files/server6.key \
2144 crt_file2=data_files/server5.crt \
2145 key_file2=data_files/server5.key" \
2146 "$P_CLI force_version=tls1_1" \
2147 0 \
2148 -c "serial number.*0A" \
2149 -c "signed using.*ECDSA with SHA256" \
2150 -C "signed using.*ECDSA with SHA1"
2151
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002152# tests for SNI
2153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002154run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002155 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002156 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002157 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002158 0 \
2159 -S "parse ServerName extension" \
2160 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2161 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002163run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002164 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002165 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002166 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 +02002167 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002168 0 \
2169 -s "parse ServerName extension" \
2170 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2171 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002172
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002173run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002174 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002175 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002176 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 +02002177 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002178 0 \
2179 -s "parse ServerName extension" \
2180 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2181 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002183run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002184 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002185 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002186 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 +02002187 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002188 1 \
2189 -s "parse ServerName extension" \
2190 -s "ssl_sni_wrapper() returned" \
2191 -s "mbedtls_ssl_handshake returned" \
2192 -c "mbedtls_ssl_handshake returned" \
2193 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002194
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002195run_test "SNI: client auth no override: optional" \
2196 "$P_SRV debug_level=3 auth_mode=optional \
2197 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2198 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2199 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002200 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002201 -S "skip write certificate request" \
2202 -C "skip parse certificate request" \
2203 -c "got a certificate request" \
2204 -C "skip write certificate" \
2205 -C "skip write certificate verify" \
2206 -S "skip parse certificate verify"
2207
2208run_test "SNI: client auth override: none -> optional" \
2209 "$P_SRV debug_level=3 auth_mode=none \
2210 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2211 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2212 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002213 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002214 -S "skip write certificate request" \
2215 -C "skip parse certificate request" \
2216 -c "got a certificate request" \
2217 -C "skip write certificate" \
2218 -C "skip write certificate verify" \
2219 -S "skip parse certificate verify"
2220
2221run_test "SNI: client auth override: optional -> none" \
2222 "$P_SRV debug_level=3 auth_mode=optional \
2223 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2224 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2225 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002226 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002227 -s "skip write certificate request" \
2228 -C "skip parse certificate request" \
2229 -c "got no certificate request" \
2230 -c "skip write certificate" \
2231 -c "skip write certificate verify" \
2232 -s "skip parse certificate verify"
2233
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002234run_test "SNI: CA no override" \
2235 "$P_SRV debug_level=3 auth_mode=optional \
2236 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2237 ca_file=data_files/test-ca.crt \
2238 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2239 "$P_CLI debug_level=3 server_name=localhost \
2240 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2241 1 \
2242 -S "skip write certificate request" \
2243 -C "skip parse certificate request" \
2244 -c "got a certificate request" \
2245 -C "skip write certificate" \
2246 -C "skip write certificate verify" \
2247 -S "skip parse certificate verify" \
2248 -s "x509_verify_cert() returned" \
2249 -s "! The certificate is not correctly signed by the trusted CA" \
2250 -S "The certificate has been revoked (is on a CRL)"
2251
2252run_test "SNI: CA override" \
2253 "$P_SRV debug_level=3 auth_mode=optional \
2254 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2255 ca_file=data_files/test-ca.crt \
2256 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2257 "$P_CLI debug_level=3 server_name=localhost \
2258 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2259 0 \
2260 -S "skip write certificate request" \
2261 -C "skip parse certificate request" \
2262 -c "got a certificate request" \
2263 -C "skip write certificate" \
2264 -C "skip write certificate verify" \
2265 -S "skip parse certificate verify" \
2266 -S "x509_verify_cert() returned" \
2267 -S "! The certificate is not correctly signed by the trusted CA" \
2268 -S "The certificate has been revoked (is on a CRL)"
2269
2270run_test "SNI: CA override with CRL" \
2271 "$P_SRV debug_level=3 auth_mode=optional \
2272 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2273 ca_file=data_files/test-ca.crt \
2274 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2275 "$P_CLI debug_level=3 server_name=localhost \
2276 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2277 1 \
2278 -S "skip write certificate request" \
2279 -C "skip parse certificate request" \
2280 -c "got a certificate request" \
2281 -C "skip write certificate" \
2282 -C "skip write certificate verify" \
2283 -S "skip parse certificate verify" \
2284 -s "x509_verify_cert() returned" \
2285 -S "! The certificate is not correctly signed by the trusted CA" \
2286 -s "The certificate has been revoked (is on a CRL)"
2287
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002288# Tests for non-blocking I/O: exercise a variety of handshake flows
2289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002290run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002291 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2292 "$P_CLI nbio=2 tickets=0" \
2293 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002294 -S "mbedtls_ssl_handshake returned" \
2295 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002296 -c "Read from server: .* bytes read"
2297
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002298run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002299 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2300 "$P_CLI nbio=2 tickets=0" \
2301 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002302 -S "mbedtls_ssl_handshake returned" \
2303 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002304 -c "Read from server: .* bytes read"
2305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002306run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002307 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2308 "$P_CLI nbio=2 tickets=1" \
2309 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002310 -S "mbedtls_ssl_handshake returned" \
2311 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002312 -c "Read from server: .* bytes read"
2313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002314run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002315 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2316 "$P_CLI nbio=2 tickets=1" \
2317 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002318 -S "mbedtls_ssl_handshake returned" \
2319 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002320 -c "Read from server: .* bytes read"
2321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002322run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002323 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2324 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2325 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002326 -S "mbedtls_ssl_handshake returned" \
2327 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002328 -c "Read from server: .* bytes read"
2329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002330run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002331 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2332 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2333 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002334 -S "mbedtls_ssl_handshake returned" \
2335 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002336 -c "Read from server: .* bytes read"
2337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002338run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002339 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2340 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2341 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002342 -S "mbedtls_ssl_handshake returned" \
2343 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002344 -c "Read from server: .* bytes read"
2345
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002346# Tests for version negotiation
2347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002348run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002349 "$P_SRV" \
2350 "$P_CLI" \
2351 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002352 -S "mbedtls_ssl_handshake returned" \
2353 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002354 -s "Protocol is TLSv1.2" \
2355 -c "Protocol is TLSv1.2"
2356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002357run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002358 "$P_SRV" \
2359 "$P_CLI max_version=tls1_1" \
2360 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002361 -S "mbedtls_ssl_handshake returned" \
2362 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002363 -s "Protocol is TLSv1.1" \
2364 -c "Protocol is TLSv1.1"
2365
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002366run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002367 "$P_SRV max_version=tls1_1" \
2368 "$P_CLI" \
2369 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002370 -S "mbedtls_ssl_handshake returned" \
2371 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002372 -s "Protocol is TLSv1.1" \
2373 -c "Protocol is TLSv1.1"
2374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002375run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002376 "$P_SRV max_version=tls1_1" \
2377 "$P_CLI max_version=tls1_1" \
2378 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002379 -S "mbedtls_ssl_handshake returned" \
2380 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002381 -s "Protocol is TLSv1.1" \
2382 -c "Protocol is TLSv1.1"
2383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002384run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002385 "$P_SRV min_version=tls1_1" \
2386 "$P_CLI max_version=tls1_1" \
2387 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002388 -S "mbedtls_ssl_handshake returned" \
2389 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002390 -s "Protocol is TLSv1.1" \
2391 -c "Protocol is TLSv1.1"
2392
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002393run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002394 "$P_SRV max_version=tls1_1" \
2395 "$P_CLI min_version=tls1_1" \
2396 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002397 -S "mbedtls_ssl_handshake returned" \
2398 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002399 -s "Protocol is TLSv1.1" \
2400 -c "Protocol is TLSv1.1"
2401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002402run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002403 "$P_SRV max_version=tls1_1" \
2404 "$P_CLI min_version=tls1_2" \
2405 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002406 -s "mbedtls_ssl_handshake returned" \
2407 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002408 -c "SSL - Handshake protocol not within min/max boundaries"
2409
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002410run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002411 "$P_SRV min_version=tls1_2" \
2412 "$P_CLI max_version=tls1_1" \
2413 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002414 -s "mbedtls_ssl_handshake returned" \
2415 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002416 -s "SSL - Handshake protocol not within min/max boundaries"
2417
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002418# Tests for ALPN extension
2419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002420run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002421 "$P_SRV debug_level=3" \
2422 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002423 0 \
2424 -C "client hello, adding alpn extension" \
2425 -S "found alpn extension" \
2426 -C "got an alert message, type: \\[2:120]" \
2427 -S "server hello, adding alpn extension" \
2428 -C "found alpn extension " \
2429 -C "Application Layer Protocol is" \
2430 -S "Application Layer Protocol is"
2431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002432run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002433 "$P_SRV debug_level=3" \
2434 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002435 0 \
2436 -c "client hello, adding alpn extension" \
2437 -s "found alpn extension" \
2438 -C "got an alert message, type: \\[2:120]" \
2439 -S "server hello, adding alpn extension" \
2440 -C "found alpn extension " \
2441 -c "Application Layer Protocol is (none)" \
2442 -S "Application Layer Protocol is"
2443
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002444run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002445 "$P_SRV debug_level=3 alpn=abc,1234" \
2446 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002447 0 \
2448 -C "client hello, adding alpn extension" \
2449 -S "found alpn extension" \
2450 -C "got an alert message, type: \\[2:120]" \
2451 -S "server hello, adding alpn extension" \
2452 -C "found alpn extension " \
2453 -C "Application Layer Protocol is" \
2454 -s "Application Layer Protocol is (none)"
2455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002456run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002457 "$P_SRV debug_level=3 alpn=abc,1234" \
2458 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002459 0 \
2460 -c "client hello, adding alpn extension" \
2461 -s "found alpn extension" \
2462 -C "got an alert message, type: \\[2:120]" \
2463 -s "server hello, adding alpn extension" \
2464 -c "found alpn extension" \
2465 -c "Application Layer Protocol is abc" \
2466 -s "Application Layer Protocol is abc"
2467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002468run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002469 "$P_SRV debug_level=3 alpn=abc,1234" \
2470 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002471 0 \
2472 -c "client hello, adding alpn extension" \
2473 -s "found alpn extension" \
2474 -C "got an alert message, type: \\[2:120]" \
2475 -s "server hello, adding alpn extension" \
2476 -c "found alpn extension" \
2477 -c "Application Layer Protocol is abc" \
2478 -s "Application Layer Protocol is abc"
2479
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002480run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002481 "$P_SRV debug_level=3 alpn=abc,1234" \
2482 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002483 0 \
2484 -c "client hello, adding alpn extension" \
2485 -s "found alpn extension" \
2486 -C "got an alert message, type: \\[2:120]" \
2487 -s "server hello, adding alpn extension" \
2488 -c "found alpn extension" \
2489 -c "Application Layer Protocol is 1234" \
2490 -s "Application Layer Protocol is 1234"
2491
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002492run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002493 "$P_SRV debug_level=3 alpn=abc,123" \
2494 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002495 1 \
2496 -c "client hello, adding alpn extension" \
2497 -s "found alpn extension" \
2498 -c "got an alert message, type: \\[2:120]" \
2499 -S "server hello, adding alpn extension" \
2500 -C "found alpn extension" \
2501 -C "Application Layer Protocol is 1234" \
2502 -S "Application Layer Protocol is 1234"
2503
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002504
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002505# Tests for keyUsage in leaf certificates, part 1:
2506# server-side certificate/suite selection
2507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002508run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002509 "$P_SRV key_file=data_files/server2.key \
2510 crt_file=data_files/server2.ku-ds.crt" \
2511 "$P_CLI" \
2512 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002513 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002514
2515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002516run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002517 "$P_SRV key_file=data_files/server2.key \
2518 crt_file=data_files/server2.ku-ke.crt" \
2519 "$P_CLI" \
2520 0 \
2521 -c "Ciphersuite is TLS-RSA-WITH-"
2522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002523run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002524 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002525 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002526 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002527 1 \
2528 -C "Ciphersuite is "
2529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002530run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002531 "$P_SRV key_file=data_files/server5.key \
2532 crt_file=data_files/server5.ku-ds.crt" \
2533 "$P_CLI" \
2534 0 \
2535 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2536
2537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002538run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002539 "$P_SRV key_file=data_files/server5.key \
2540 crt_file=data_files/server5.ku-ka.crt" \
2541 "$P_CLI" \
2542 0 \
2543 -c "Ciphersuite is TLS-ECDH-"
2544
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002545run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002546 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002547 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002548 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002549 1 \
2550 -C "Ciphersuite is "
2551
2552# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002553# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002554
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002555run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002556 "$O_SRV -key data_files/server2.key \
2557 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002558 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002559 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2560 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002561 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002562 -C "Processing of the Certificate handshake message failed" \
2563 -c "Ciphersuite is TLS-"
2564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002565run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002566 "$O_SRV -key data_files/server2.key \
2567 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002568 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002569 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2570 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002571 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002572 -C "Processing of the Certificate handshake message failed" \
2573 -c "Ciphersuite is TLS-"
2574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002576 "$O_SRV -key data_files/server2.key \
2577 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002578 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002579 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2580 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002581 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002582 -C "Processing of the Certificate handshake message failed" \
2583 -c "Ciphersuite is TLS-"
2584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002585run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002586 "$O_SRV -key data_files/server2.key \
2587 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002588 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002589 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2590 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002591 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002592 -c "Processing of the Certificate handshake message failed" \
2593 -C "Ciphersuite is TLS-"
2594
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002595run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2596 "$O_SRV -key data_files/server2.key \
2597 -cert data_files/server2.ku-ke.crt" \
2598 "$P_CLI debug_level=1 auth_mode=optional \
2599 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2600 0 \
2601 -c "bad certificate (usage extensions)" \
2602 -C "Processing of the Certificate handshake message failed" \
2603 -c "Ciphersuite is TLS-" \
2604 -c "! Usage does not match the keyUsage extension"
2605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002606run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002607 "$O_SRV -key data_files/server2.key \
2608 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002609 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002610 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2611 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002612 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002613 -C "Processing of the Certificate handshake message failed" \
2614 -c "Ciphersuite is TLS-"
2615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002616run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002617 "$O_SRV -key data_files/server2.key \
2618 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002619 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002620 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2621 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002622 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002623 -c "Processing of the Certificate handshake message failed" \
2624 -C "Ciphersuite is TLS-"
2625
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002626run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2627 "$O_SRV -key data_files/server2.key \
2628 -cert data_files/server2.ku-ds.crt" \
2629 "$P_CLI debug_level=1 auth_mode=optional \
2630 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2631 0 \
2632 -c "bad certificate (usage extensions)" \
2633 -C "Processing of the Certificate handshake message failed" \
2634 -c "Ciphersuite is TLS-" \
2635 -c "! Usage does not match the keyUsage extension"
2636
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002637# Tests for keyUsage in leaf certificates, part 3:
2638# server-side checking of client cert
2639
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002640run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002641 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002642 "$O_CLI -key data_files/server2.key \
2643 -cert data_files/server2.ku-ds.crt" \
2644 0 \
2645 -S "bad certificate (usage extensions)" \
2646 -S "Processing of the Certificate handshake message failed"
2647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002648run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002649 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002650 "$O_CLI -key data_files/server2.key \
2651 -cert data_files/server2.ku-ke.crt" \
2652 0 \
2653 -s "bad certificate (usage extensions)" \
2654 -S "Processing of the Certificate handshake message failed"
2655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002656run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002657 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002658 "$O_CLI -key data_files/server2.key \
2659 -cert data_files/server2.ku-ke.crt" \
2660 1 \
2661 -s "bad certificate (usage extensions)" \
2662 -s "Processing of the Certificate handshake message failed"
2663
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002664run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002665 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002666 "$O_CLI -key data_files/server5.key \
2667 -cert data_files/server5.ku-ds.crt" \
2668 0 \
2669 -S "bad certificate (usage extensions)" \
2670 -S "Processing of the Certificate handshake message failed"
2671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002672run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002673 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002674 "$O_CLI -key data_files/server5.key \
2675 -cert data_files/server5.ku-ka.crt" \
2676 0 \
2677 -s "bad certificate (usage extensions)" \
2678 -S "Processing of the Certificate handshake message failed"
2679
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002680# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002682run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002683 "$P_SRV key_file=data_files/server5.key \
2684 crt_file=data_files/server5.eku-srv.crt" \
2685 "$P_CLI" \
2686 0
2687
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002688run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002689 "$P_SRV key_file=data_files/server5.key \
2690 crt_file=data_files/server5.eku-srv.crt" \
2691 "$P_CLI" \
2692 0
2693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002694run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002695 "$P_SRV key_file=data_files/server5.key \
2696 crt_file=data_files/server5.eku-cs_any.crt" \
2697 "$P_CLI" \
2698 0
2699
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002700run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002701 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002702 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002703 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002704 1
2705
2706# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2707
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002708run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002709 "$O_SRV -key data_files/server5.key \
2710 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002711 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002712 0 \
2713 -C "bad certificate (usage extensions)" \
2714 -C "Processing of the Certificate handshake message failed" \
2715 -c "Ciphersuite is TLS-"
2716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002717run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002718 "$O_SRV -key data_files/server5.key \
2719 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002720 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002721 0 \
2722 -C "bad certificate (usage extensions)" \
2723 -C "Processing of the Certificate handshake message failed" \
2724 -c "Ciphersuite is TLS-"
2725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002726run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002727 "$O_SRV -key data_files/server5.key \
2728 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002729 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002730 0 \
2731 -C "bad certificate (usage extensions)" \
2732 -C "Processing of the Certificate handshake message failed" \
2733 -c "Ciphersuite is TLS-"
2734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002735run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002736 "$O_SRV -key data_files/server5.key \
2737 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002738 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002739 1 \
2740 -c "bad certificate (usage extensions)" \
2741 -c "Processing of the Certificate handshake message failed" \
2742 -C "Ciphersuite is TLS-"
2743
2744# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002746run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002747 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002748 "$O_CLI -key data_files/server5.key \
2749 -cert data_files/server5.eku-cli.crt" \
2750 0 \
2751 -S "bad certificate (usage extensions)" \
2752 -S "Processing of the Certificate handshake message failed"
2753
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002754run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002755 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002756 "$O_CLI -key data_files/server5.key \
2757 -cert data_files/server5.eku-srv_cli.crt" \
2758 0 \
2759 -S "bad certificate (usage extensions)" \
2760 -S "Processing of the Certificate handshake message failed"
2761
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002762run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002763 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002764 "$O_CLI -key data_files/server5.key \
2765 -cert data_files/server5.eku-cs_any.crt" \
2766 0 \
2767 -S "bad certificate (usage extensions)" \
2768 -S "Processing of the Certificate handshake message failed"
2769
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002770run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002771 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002772 "$O_CLI -key data_files/server5.key \
2773 -cert data_files/server5.eku-cs.crt" \
2774 0 \
2775 -s "bad certificate (usage extensions)" \
2776 -S "Processing of the Certificate handshake message failed"
2777
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002778run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002779 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002780 "$O_CLI -key data_files/server5.key \
2781 -cert data_files/server5.eku-cs.crt" \
2782 1 \
2783 -s "bad certificate (usage extensions)" \
2784 -s "Processing of the Certificate handshake message failed"
2785
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002786# Tests for DHM parameters loading
2787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002788run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002789 "$P_SRV" \
2790 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2791 debug_level=3" \
2792 0 \
2793 -c "value of 'DHM: P ' (2048 bits)" \
2794 -c "value of 'DHM: G ' (2048 bits)"
2795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002796run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002797 "$P_SRV dhm_file=data_files/dhparams.pem" \
2798 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2799 debug_level=3" \
2800 0 \
2801 -c "value of 'DHM: P ' (1024 bits)" \
2802 -c "value of 'DHM: G ' (2 bits)"
2803
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002804# Tests for DHM client-side size checking
2805
2806run_test "DHM size: server default, client default, OK" \
2807 "$P_SRV" \
2808 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2809 debug_level=1" \
2810 0 \
2811 -C "DHM prime too short:"
2812
2813run_test "DHM size: server default, client 2048, OK" \
2814 "$P_SRV" \
2815 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2816 debug_level=1 dhmlen=2048" \
2817 0 \
2818 -C "DHM prime too short:"
2819
2820run_test "DHM size: server 1024, client default, OK" \
2821 "$P_SRV dhm_file=data_files/dhparams.pem" \
2822 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2823 debug_level=1" \
2824 0 \
2825 -C "DHM prime too short:"
2826
2827run_test "DHM size: server 1000, client default, rejected" \
2828 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2829 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2830 debug_level=1" \
2831 1 \
2832 -c "DHM prime too short:"
2833
2834run_test "DHM size: server default, client 2049, rejected" \
2835 "$P_SRV" \
2836 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2837 debug_level=1 dhmlen=2049" \
2838 1 \
2839 -c "DHM prime too short:"
2840
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002841# Tests for PSK callback
2842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002843run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002844 "$P_SRV psk=abc123 psk_identity=foo" \
2845 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2846 psk_identity=foo psk=abc123" \
2847 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002848 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002849 -S "SSL - Unknown identity received" \
2850 -S "SSL - Verification of the message MAC failed"
2851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002852run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002853 "$P_SRV" \
2854 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2855 psk_identity=foo psk=abc123" \
2856 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002857 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002858 -S "SSL - Unknown identity received" \
2859 -S "SSL - Verification of the message MAC failed"
2860
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002861run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002862 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2863 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2864 psk_identity=foo psk=abc123" \
2865 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002866 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002867 -s "SSL - Unknown identity received" \
2868 -S "SSL - Verification of the message MAC failed"
2869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002870run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002871 "$P_SRV psk_list=abc,dead,def,beef" \
2872 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2873 psk_identity=abc psk=dead" \
2874 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002875 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002876 -S "SSL - Unknown identity received" \
2877 -S "SSL - Verification of the message MAC failed"
2878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002879run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002880 "$P_SRV psk_list=abc,dead,def,beef" \
2881 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2882 psk_identity=def psk=beef" \
2883 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002884 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002885 -S "SSL - Unknown identity received" \
2886 -S "SSL - Verification of the message MAC failed"
2887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002888run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002889 "$P_SRV psk_list=abc,dead,def,beef" \
2890 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2891 psk_identity=ghi psk=beef" \
2892 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002893 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002894 -s "SSL - Unknown identity received" \
2895 -S "SSL - Verification of the message MAC failed"
2896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002897run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002898 "$P_SRV psk_list=abc,dead,def,beef" \
2899 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2900 psk_identity=abc psk=beef" \
2901 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002902 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002903 -S "SSL - Unknown identity received" \
2904 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002905
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002906# Tests for ciphersuites per version
2907
Janos Follath542ee5d2016-03-07 15:57:05 +00002908requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002909run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002910 "$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 +02002911 "$P_CLI force_version=ssl3" \
2912 0 \
2913 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002915run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002916 "$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 +01002917 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002918 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002919 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002920
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002921run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002922 "$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 +02002923 "$P_CLI force_version=tls1_1" \
2924 0 \
2925 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2926
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002927run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002928 "$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 +02002929 "$P_CLI force_version=tls1_2" \
2930 0 \
2931 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2932
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002933# Test for ClientHello without extensions
2934
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002935requires_gnutls
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002936run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002937 "$P_SRV debug_level=3" \
2938 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2939 0 \
2940 -s "dumping 'client hello extensions' (0 bytes)"
2941
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002942requires_gnutls
2943run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
2944 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
2945 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2946 0 \
2947 -s "dumping 'client hello extensions' (0 bytes)"
2948
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002949# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002950
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002951run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002952 "$P_SRV" \
2953 "$P_CLI request_size=100" \
2954 0 \
2955 -s "Read from client: 100 bytes read$"
2956
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002957run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002958 "$P_SRV" \
2959 "$P_CLI request_size=500" \
2960 0 \
2961 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002962
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002963# Tests for small packets
2964
Janos Follath542ee5d2016-03-07 15:57:05 +00002965requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002966run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002967 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002968 "$P_CLI request_size=1 force_version=ssl3 \
2969 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2970 0 \
2971 -s "Read from client: 1 bytes read"
2972
Janos Follath542ee5d2016-03-07 15:57:05 +00002973requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002974run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002975 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002976 "$P_CLI request_size=1 force_version=ssl3 \
2977 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2978 0 \
2979 -s "Read from client: 1 bytes read"
2980
2981run_test "Small packet TLS 1.0 BlockCipher" \
2982 "$P_SRV" \
2983 "$P_CLI request_size=1 force_version=tls1 \
2984 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2985 0 \
2986 -s "Read from client: 1 bytes read"
2987
Hanno Becker7aae46c2017-11-10 08:59:04 +00002988run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002989 "$P_SRV" \
2990 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2991 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2992 0 \
2993 -s "Read from client: 1 bytes read"
2994
Hanno Beckera83fafa2017-11-10 08:42:54 +00002995requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00002996run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00002997 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002998 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00002999 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003000 0 \
3001 -s "Read from client: 1 bytes read"
3002
Hanno Beckera83fafa2017-11-10 08:42:54 +00003003requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003004run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003005 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003006 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003007 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003008 0 \
3009 -s "Read from client: 1 bytes read"
3010
3011run_test "Small packet TLS 1.0 StreamCipher" \
3012 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3013 "$P_CLI request_size=1 force_version=tls1 \
3014 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3015 0 \
3016 -s "Read from client: 1 bytes read"
3017
3018run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3019 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3020 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003021 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003022 0 \
3023 -s "Read from client: 1 bytes read"
3024
3025requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3026run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003027 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003028 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003029 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003030 0 \
3031 -s "Read from client: 1 bytes read"
3032
Hanno Becker7aae46c2017-11-10 08:59:04 +00003033requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3034run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003035 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3036 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3037 trunc_hmac=1 etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003038 0 \
3039 -s "Read from client: 1 bytes read"
3040
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003041run_test "Small packet TLS 1.1 BlockCipher" \
3042 "$P_SRV" \
3043 "$P_CLI request_size=1 force_version=tls1_1 \
3044 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3045 0 \
3046 -s "Read from client: 1 bytes read"
3047
Hanno Becker7aae46c2017-11-10 08:59:04 +00003048run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003049 "$P_SRV" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003050 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003051 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003052 0 \
3053 -s "Read from client: 1 bytes read"
3054
3055requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3056run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003057 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003058 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003059 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003060 0 \
3061 -s "Read from client: 1 bytes read"
3062
3063requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3064run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003065 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003066 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003067 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003068 0 \
3069 -s "Read from client: 1 bytes read"
3070
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003071run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003072 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003073 "$P_CLI request_size=1 force_version=tls1_1 \
3074 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3075 0 \
3076 -s "Read from client: 1 bytes read"
3077
Hanno Becker7aae46c2017-11-10 08:59:04 +00003078run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3079 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003080 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003081 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003082 0 \
3083 -s "Read from client: 1 bytes read"
3084
3085requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3086run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003087 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003088 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003089 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003090 0 \
3091 -s "Read from client: 1 bytes read"
3092
Hanno Beckera83fafa2017-11-10 08:42:54 +00003093requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003094run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003095 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003096 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003097 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003098 0 \
3099 -s "Read from client: 1 bytes read"
3100
3101run_test "Small packet TLS 1.2 BlockCipher" \
3102 "$P_SRV" \
3103 "$P_CLI request_size=1 force_version=tls1_2 \
3104 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3105 0 \
3106 -s "Read from client: 1 bytes read"
3107
Hanno Becker7aae46c2017-11-10 08:59:04 +00003108run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003109 "$P_SRV" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003110 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003111 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003112 0 \
3113 -s "Read from client: 1 bytes read"
3114
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003115run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3116 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003117 "$P_CLI request_size=1 force_version=tls1_2 \
3118 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003119 0 \
3120 -s "Read from client: 1 bytes read"
3121
Hanno Beckera83fafa2017-11-10 08:42:54 +00003122requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003123run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003124 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003125 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003126 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003127 0 \
3128 -s "Read from client: 1 bytes read"
3129
Hanno Becker7aae46c2017-11-10 08:59:04 +00003130requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3131run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003132 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003133 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003134 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003135 0 \
3136 -s "Read from client: 1 bytes read"
3137
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003138run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003139 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003140 "$P_CLI request_size=1 force_version=tls1_2 \
3141 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3142 0 \
3143 -s "Read from client: 1 bytes read"
3144
Hanno Becker7aae46c2017-11-10 08:59:04 +00003145run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
3146 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3147 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003148 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003149 0 \
3150 -s "Read from client: 1 bytes read"
3151
Hanno Beckera83fafa2017-11-10 08:42:54 +00003152requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003153run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003154 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003155 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003156 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003157 0 \
3158 -s "Read from client: 1 bytes read"
3159
Hanno Becker7aae46c2017-11-10 08:59:04 +00003160requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3161run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003162 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003163 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003164 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003165 0 \
3166 -s "Read from client: 1 bytes read"
3167
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003168run_test "Small packet TLS 1.2 AEAD" \
3169 "$P_SRV" \
3170 "$P_CLI request_size=1 force_version=tls1_2 \
3171 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3172 0 \
3173 -s "Read from client: 1 bytes read"
3174
3175run_test "Small packet TLS 1.2 AEAD shorter tag" \
3176 "$P_SRV" \
3177 "$P_CLI request_size=1 force_version=tls1_2 \
3178 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3179 0 \
3180 -s "Read from client: 1 bytes read"
3181
Hanno Becker461cb812017-11-10 08:59:18 +00003182# Tests for small packets in DTLS
3183
3184requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3185run_test "Small packet DTLS 1.0" \
3186 "$P_SRV dtls=1 force_version=dtls1" \
3187 "$P_CLI dtls=1 request_size=1 \
3188 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3189 0 \
3190 -s "Read from client: 1 bytes read"
3191
3192requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3193run_test "Small packet DTLS 1.0, without EtM" \
3194 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3195 "$P_CLI dtls=1 request_size=1 \
3196 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3197 0 \
3198 -s "Read from client: 1 bytes read"
3199
3200requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3201requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3202run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003203 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3204 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Becker461cb812017-11-10 08:59:18 +00003205 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3206 0 \
3207 -s "Read from client: 1 bytes read"
3208
3209requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3210requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3211run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003212 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003213 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003214 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Becker461cb812017-11-10 08:59:18 +00003215 0 \
3216 -s "Read from client: 1 bytes read"
3217
3218requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3219run_test "Small packet DTLS 1.2" \
3220 "$P_SRV dtls=1 force_version=dtls1_2" \
3221 "$P_CLI dtls=1 request_size=1 \
3222 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3223 0 \
3224 -s "Read from client: 1 bytes read"
3225
3226requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3227run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003228 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003229 "$P_CLI dtls=1 request_size=1 \
3230 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3231 0 \
3232 -s "Read from client: 1 bytes read"
3233
3234requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3235requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3236run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003237 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Becker461cb812017-11-10 08:59:18 +00003238 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003239 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker461cb812017-11-10 08:59:18 +00003240 0 \
3241 -s "Read from client: 1 bytes read"
3242
3243requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3244requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3245run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003246 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003247 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003248 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Becker461cb812017-11-10 08:59:18 +00003249 0 \
3250 -s "Read from client: 1 bytes read"
3251
Janos Follathb700c462016-05-06 13:48:23 +01003252# A test for extensions in SSLv3
3253
3254requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3255run_test "SSLv3 with extensions, server side" \
3256 "$P_SRV min_version=ssl3 debug_level=3" \
3257 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3258 0 \
3259 -S "dumping 'client hello extensions'" \
3260 -S "server hello, total extension length:"
3261
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003262# Test for large packets
3263
Janos Follath542ee5d2016-03-07 15:57:05 +00003264requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003265run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003266 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003267 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003268 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3269 0 \
3270 -s "Read from client: 16384 bytes read"
3271
Janos Follath542ee5d2016-03-07 15:57:05 +00003272requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003273run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003274 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003275 "$P_CLI request_size=16384 force_version=ssl3 \
3276 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3277 0 \
3278 -s "Read from client: 16384 bytes read"
3279
3280run_test "Large packet TLS 1.0 BlockCipher" \
3281 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003282 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003283 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3284 0 \
3285 -s "Read from client: 16384 bytes read"
3286
Hanno Becker0b9d9132017-11-10 09:16:28 +00003287run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
3288 "$P_SRV" \
3289 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3290 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3291 0 \
3292 -s "Read from client: 16384 bytes read"
3293
Hanno Beckera83fafa2017-11-10 08:42:54 +00003294requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003295run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003296 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003297 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003298 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003299 0 \
3300 -s "Read from client: 16384 bytes read"
3301
Hanno Beckera83fafa2017-11-10 08:42:54 +00003302requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003303run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003304 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003305 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003306 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003307 0 \
3308 -s "Read from client: 16384 bytes read"
3309
3310run_test "Large packet TLS 1.0 StreamCipher" \
3311 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3312 "$P_CLI request_size=16384 force_version=tls1 \
3313 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3314 0 \
3315 -s "Read from client: 16384 bytes read"
3316
3317run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3318 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3319 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003320 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003321 0 \
3322 -s "Read from client: 16384 bytes read"
3323
3324requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3325run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003326 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003327 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003328 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003329 0 \
3330 -s "Read from client: 16384 bytes read"
3331
Hanno Becker0b9d9132017-11-10 09:16:28 +00003332requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3333run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003334 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003335 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003336 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003337 0 \
3338 -s "Read from client: 16384 bytes read"
3339
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003340run_test "Large packet TLS 1.1 BlockCipher" \
3341 "$P_SRV" \
3342 "$P_CLI request_size=16384 force_version=tls1_1 \
3343 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3344 0 \
3345 -s "Read from client: 16384 bytes read"
3346
Hanno Becker0b9d9132017-11-10 09:16:28 +00003347run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3348 "$P_SRV" \
3349 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3350 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003351 0 \
3352 -s "Read from client: 16384 bytes read"
3353
Hanno Beckera83fafa2017-11-10 08:42:54 +00003354requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003355run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003356 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003357 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003358 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003359 0 \
3360 -s "Read from client: 16384 bytes read"
3361
Hanno Beckera83fafa2017-11-10 08:42:54 +00003362requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003363run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003364 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003365 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003366 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003367 0 \
3368 -s "Read from client: 16384 bytes read"
3369
3370run_test "Large packet TLS 1.1 StreamCipher" \
3371 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3372 "$P_CLI request_size=16384 force_version=tls1_1 \
3373 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3374 0 \
3375 -s "Read from client: 16384 bytes read"
3376
3377run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
3378 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3379 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003380 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003381 0 \
3382 -s "Read from client: 16384 bytes read"
3383
3384requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3385run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003386 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003387 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003388 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003389 0 \
3390 -s "Read from client: 16384 bytes read"
3391
Hanno Becker0b9d9132017-11-10 09:16:28 +00003392requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3393run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003394 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003395 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003396 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003397 0 \
3398 -s "Read from client: 16384 bytes read"
3399
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003400run_test "Large packet TLS 1.2 BlockCipher" \
3401 "$P_SRV" \
3402 "$P_CLI request_size=16384 force_version=tls1_2 \
3403 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3404 0 \
3405 -s "Read from client: 16384 bytes read"
3406
Hanno Becker0b9d9132017-11-10 09:16:28 +00003407run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
3408 "$P_SRV" \
3409 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
3410 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3411 0 \
3412 -s "Read from client: 16384 bytes read"
3413
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003414run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3415 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003416 "$P_CLI request_size=16384 force_version=tls1_2 \
3417 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003418 0 \
3419 -s "Read from client: 16384 bytes read"
3420
Hanno Beckera83fafa2017-11-10 08:42:54 +00003421requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003422run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003423 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003424 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003425 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003426 0 \
3427 -s "Read from client: 16384 bytes read"
3428
Hanno Becker0b9d9132017-11-10 09:16:28 +00003429requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3430run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003431 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003432 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003433 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003434 0 \
3435 -s "Read from client: 16384 bytes read"
3436
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003437run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003438 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003439 "$P_CLI request_size=16384 force_version=tls1_2 \
3440 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3441 0 \
3442 -s "Read from client: 16384 bytes read"
3443
Hanno Becker0b9d9132017-11-10 09:16:28 +00003444run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
3445 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3446 "$P_CLI request_size=16384 force_version=tls1_2 \
3447 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
3448 0 \
3449 -s "Read from client: 16384 bytes read"
3450
Hanno Beckera83fafa2017-11-10 08:42:54 +00003451requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003452run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003453 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003454 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003455 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003456 0 \
3457 -s "Read from client: 16384 bytes read"
3458
Hanno Becker0b9d9132017-11-10 09:16:28 +00003459requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3460run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003461 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003462 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003463 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003464 0 \
3465 -s "Read from client: 16384 bytes read"
3466
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003467run_test "Large packet TLS 1.2 AEAD" \
3468 "$P_SRV" \
3469 "$P_CLI request_size=16384 force_version=tls1_2 \
3470 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3471 0 \
3472 -s "Read from client: 16384 bytes read"
3473
3474run_test "Large packet TLS 1.2 AEAD shorter tag" \
3475 "$P_SRV" \
3476 "$P_CLI request_size=16384 force_version=tls1_2 \
3477 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3478 0 \
3479 -s "Read from client: 16384 bytes read"
3480
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003481# Tests for DTLS HelloVerifyRequest
3482
3483run_test "DTLS cookie: enabled" \
3484 "$P_SRV dtls=1 debug_level=2" \
3485 "$P_CLI dtls=1 debug_level=2" \
3486 0 \
3487 -s "cookie verification failed" \
3488 -s "cookie verification passed" \
3489 -S "cookie verification skipped" \
3490 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003491 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003492 -S "SSL - The requested feature is not available"
3493
3494run_test "DTLS cookie: disabled" \
3495 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3496 "$P_CLI dtls=1 debug_level=2" \
3497 0 \
3498 -S "cookie verification failed" \
3499 -S "cookie verification passed" \
3500 -s "cookie verification skipped" \
3501 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003502 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003503 -S "SSL - The requested feature is not available"
3504
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003505run_test "DTLS cookie: default (failing)" \
3506 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3507 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3508 1 \
3509 -s "cookie verification failed" \
3510 -S "cookie verification passed" \
3511 -S "cookie verification skipped" \
3512 -C "received hello verify request" \
3513 -S "hello verification requested" \
3514 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003515
3516requires_ipv6
3517run_test "DTLS cookie: enabled, IPv6" \
3518 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3519 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3520 0 \
3521 -s "cookie verification failed" \
3522 -s "cookie verification passed" \
3523 -S "cookie verification skipped" \
3524 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003525 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003526 -S "SSL - The requested feature is not available"
3527
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003528run_test "DTLS cookie: enabled, nbio" \
3529 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3530 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3531 0 \
3532 -s "cookie verification failed" \
3533 -s "cookie verification passed" \
3534 -S "cookie verification skipped" \
3535 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003536 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003537 -S "SSL - The requested feature is not available"
3538
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003539# Tests for client reconnecting from the same port with DTLS
3540
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003541not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003542run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003543 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3544 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003545 0 \
3546 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003547 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003548 -S "Client initiated reconnection from same port"
3549
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003550not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003551run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003552 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3553 "$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 +02003554 0 \
3555 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003556 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003557 -s "Client initiated reconnection from same port"
3558
Paul Bakker3b224ff2016-05-13 10:33:25 +01003559not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3560run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003561 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3562 "$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 +02003563 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003564 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003565 -s "Client initiated reconnection from same port"
3566
Paul Bakker3b224ff2016-05-13 10:33:25 +01003567only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3568run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3569 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3570 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3571 0 \
3572 -S "The operation timed out" \
3573 -s "Client initiated reconnection from same port"
3574
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003575run_test "DTLS client reconnect from same port: no cookies" \
3576 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003577 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3578 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003579 -s "The operation timed out" \
3580 -S "Client initiated reconnection from same port"
3581
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003582# Tests for various cases of client authentication with DTLS
3583# (focused on handshake flows and message parsing)
3584
3585run_test "DTLS client auth: required" \
3586 "$P_SRV dtls=1 auth_mode=required" \
3587 "$P_CLI dtls=1" \
3588 0 \
3589 -s "Verifying peer X.509 certificate... ok"
3590
3591run_test "DTLS client auth: optional, client has no cert" \
3592 "$P_SRV dtls=1 auth_mode=optional" \
3593 "$P_CLI dtls=1 crt_file=none key_file=none" \
3594 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003595 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003596
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003597run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003598 "$P_SRV dtls=1 auth_mode=none" \
3599 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3600 0 \
3601 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003602 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003603
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003604run_test "DTLS wrong PSK: badmac alert" \
3605 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3606 "$P_CLI dtls=1 psk=abc124" \
3607 1 \
3608 -s "SSL - Verification of the message MAC failed" \
3609 -c "SSL - A fatal alert message was received from our peer"
3610
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003611# Tests for receiving fragmented handshake messages with DTLS
3612
3613requires_gnutls
3614run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3615 "$G_SRV -u --mtu 2048 -a" \
3616 "$P_CLI dtls=1 debug_level=2" \
3617 0 \
3618 -C "found fragmented DTLS handshake message" \
3619 -C "error"
3620
3621requires_gnutls
3622run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3623 "$G_SRV -u --mtu 512" \
3624 "$P_CLI dtls=1 debug_level=2" \
3625 0 \
3626 -c "found fragmented DTLS handshake message" \
3627 -C "error"
3628
3629requires_gnutls
3630run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3631 "$G_SRV -u --mtu 128" \
3632 "$P_CLI dtls=1 debug_level=2" \
3633 0 \
3634 -c "found fragmented DTLS handshake message" \
3635 -C "error"
3636
3637requires_gnutls
3638run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3639 "$G_SRV -u --mtu 128" \
3640 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3641 0 \
3642 -c "found fragmented DTLS handshake message" \
3643 -C "error"
3644
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003645requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003646run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3647 "$G_SRV -u --mtu 256" \
3648 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3649 0 \
3650 -c "found fragmented DTLS handshake message" \
3651 -c "client hello, adding renegotiation extension" \
3652 -c "found renegotiation extension" \
3653 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003654 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003655 -C "error" \
3656 -s "Extra-header:"
3657
3658requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003659run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3660 "$G_SRV -u --mtu 256" \
3661 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3662 0 \
3663 -c "found fragmented DTLS handshake message" \
3664 -c "client hello, adding renegotiation extension" \
3665 -c "found renegotiation extension" \
3666 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003667 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003668 -C "error" \
3669 -s "Extra-header:"
3670
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003671run_test "DTLS reassembly: no fragmentation (openssl server)" \
3672 "$O_SRV -dtls1 -mtu 2048" \
3673 "$P_CLI dtls=1 debug_level=2" \
3674 0 \
3675 -C "found fragmented DTLS handshake message" \
3676 -C "error"
3677
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003678run_test "DTLS reassembly: some fragmentation (openssl server)" \
3679 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003680 "$P_CLI dtls=1 debug_level=2" \
3681 0 \
3682 -c "found fragmented DTLS handshake message" \
3683 -C "error"
3684
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003685run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003686 "$O_SRV -dtls1 -mtu 256" \
3687 "$P_CLI dtls=1 debug_level=2" \
3688 0 \
3689 -c "found fragmented DTLS handshake message" \
3690 -C "error"
3691
3692run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3693 "$O_SRV -dtls1 -mtu 256" \
3694 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3695 0 \
3696 -c "found fragmented DTLS handshake message" \
3697 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003698
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003699# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003700
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003701not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003702run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003703 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003704 "$P_SRV dtls=1 debug_level=2" \
3705 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003706 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003707 -C "replayed record" \
3708 -S "replayed record" \
3709 -C "record from another epoch" \
3710 -S "record from another epoch" \
3711 -C "discarding invalid record" \
3712 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003713 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003714 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003715 -c "HTTP/1.0 200 OK"
3716
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003717not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003718run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003719 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003720 "$P_SRV dtls=1 debug_level=2" \
3721 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003722 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003723 -c "replayed record" \
3724 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003725 -c "discarding invalid record" \
3726 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003727 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003728 -s "Extra-header:" \
3729 -c "HTTP/1.0 200 OK"
3730
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003731run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3732 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003733 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3734 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003735 0 \
3736 -c "replayed record" \
3737 -S "replayed record" \
3738 -c "discarding invalid record" \
3739 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003740 -c "resend" \
3741 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003742 -s "Extra-header:" \
3743 -c "HTTP/1.0 200 OK"
3744
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003745run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003746 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003747 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003748 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003749 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003750 -c "discarding invalid record (mac)" \
3751 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003752 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003753 -c "HTTP/1.0 200 OK" \
3754 -S "too many records with bad MAC" \
3755 -S "Verification of the message MAC failed"
3756
3757run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3758 -p "$P_PXY bad_ad=1" \
3759 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3760 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3761 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003762 -C "discarding invalid record (mac)" \
3763 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003764 -S "Extra-header:" \
3765 -C "HTTP/1.0 200 OK" \
3766 -s "too many records with bad MAC" \
3767 -s "Verification of the message MAC failed"
3768
3769run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3770 -p "$P_PXY bad_ad=1" \
3771 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3772 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3773 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003774 -c "discarding invalid record (mac)" \
3775 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003776 -s "Extra-header:" \
3777 -c "HTTP/1.0 200 OK" \
3778 -S "too many records with bad MAC" \
3779 -S "Verification of the message MAC failed"
3780
3781run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3782 -p "$P_PXY bad_ad=1" \
3783 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3784 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3785 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003786 -c "discarding invalid record (mac)" \
3787 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003788 -s "Extra-header:" \
3789 -c "HTTP/1.0 200 OK" \
3790 -s "too many records with bad MAC" \
3791 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003792
3793run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003794 -p "$P_PXY delay_ccs=1" \
3795 "$P_SRV dtls=1 debug_level=1" \
3796 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003797 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003798 -c "record from another epoch" \
3799 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003800 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003801 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003802 -s "Extra-header:" \
3803 -c "HTTP/1.0 200 OK"
3804
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003805# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003806
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003807needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003808run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003809 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003810 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3811 psk=abc123" \
3812 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003813 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3814 0 \
3815 -s "Extra-header:" \
3816 -c "HTTP/1.0 200 OK"
3817
3818needs_more_time 2
3819run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3820 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003821 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3822 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003823 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3824 0 \
3825 -s "Extra-header:" \
3826 -c "HTTP/1.0 200 OK"
3827
3828needs_more_time 2
3829run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3830 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003831 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3832 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003833 0 \
3834 -s "Extra-header:" \
3835 -c "HTTP/1.0 200 OK"
3836
3837needs_more_time 2
3838run_test "DTLS proxy: 3d, FS, client auth" \
3839 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003840 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3841 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003842 0 \
3843 -s "Extra-header:" \
3844 -c "HTTP/1.0 200 OK"
3845
3846needs_more_time 2
3847run_test "DTLS proxy: 3d, FS, ticket" \
3848 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003849 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3850 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003851 0 \
3852 -s "Extra-header:" \
3853 -c "HTTP/1.0 200 OK"
3854
3855needs_more_time 2
3856run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3857 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003858 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3859 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003860 0 \
3861 -s "Extra-header:" \
3862 -c "HTTP/1.0 200 OK"
3863
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003864needs_more_time 2
3865run_test "DTLS proxy: 3d, max handshake, nbio" \
3866 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003867 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3868 auth_mode=required" \
3869 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003870 0 \
3871 -s "Extra-header:" \
3872 -c "HTTP/1.0 200 OK"
3873
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003874needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003875run_test "DTLS proxy: 3d, min handshake, resumption" \
3876 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3877 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3878 psk=abc123 debug_level=3" \
3879 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3880 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3881 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3882 0 \
3883 -s "a session has been resumed" \
3884 -c "a session has been resumed" \
3885 -s "Extra-header:" \
3886 -c "HTTP/1.0 200 OK"
3887
3888needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003889run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3890 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3891 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3892 psk=abc123 debug_level=3 nbio=2" \
3893 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3894 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3895 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3896 0 \
3897 -s "a session has been resumed" \
3898 -c "a session has been resumed" \
3899 -s "Extra-header:" \
3900 -c "HTTP/1.0 200 OK"
3901
3902needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003903run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003904 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003905 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3906 psk=abc123 renegotiation=1 debug_level=2" \
3907 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3908 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003909 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3910 0 \
3911 -c "=> renegotiate" \
3912 -s "=> renegotiate" \
3913 -s "Extra-header:" \
3914 -c "HTTP/1.0 200 OK"
3915
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003916needs_more_time 4
3917run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3918 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003919 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3920 psk=abc123 renegotiation=1 debug_level=2" \
3921 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3922 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003923 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3924 0 \
3925 -c "=> renegotiate" \
3926 -s "=> renegotiate" \
3927 -s "Extra-header:" \
3928 -c "HTTP/1.0 200 OK"
3929
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003930needs_more_time 4
3931run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003932 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003933 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003934 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003935 debug_level=2" \
3936 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003937 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003938 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3939 0 \
3940 -c "=> renegotiate" \
3941 -s "=> renegotiate" \
3942 -s "Extra-header:" \
3943 -c "HTTP/1.0 200 OK"
3944
3945needs_more_time 4
3946run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003947 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003948 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003949 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003950 debug_level=2 nbio=2" \
3951 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003952 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003953 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3954 0 \
3955 -c "=> renegotiate" \
3956 -s "=> renegotiate" \
3957 -s "Extra-header:" \
3958 -c "HTTP/1.0 200 OK"
3959
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003960needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003961not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003962run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003963 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3964 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003965 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003966 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003967 -c "HTTP/1.0 200 OK"
3968
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003969needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003970not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003971run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3972 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3973 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003974 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003975 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003976 -c "HTTP/1.0 200 OK"
3977
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003978needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003979not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003980run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3981 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3982 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003983 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003984 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003985 -c "HTTP/1.0 200 OK"
3986
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003987requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003988needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003989not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003990run_test "DTLS proxy: 3d, gnutls server" \
3991 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3992 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003993 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003994 0 \
3995 -s "Extra-header:" \
3996 -c "Extra-header:"
3997
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003998requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003999needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004000not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004001run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4002 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4003 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004004 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004005 0 \
4006 -s "Extra-header:" \
4007 -c "Extra-header:"
4008
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004009requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004010needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004011not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004012run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4013 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4014 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004015 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004016 0 \
4017 -s "Extra-header:" \
4018 -c "Extra-header:"
4019
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004020# Final report
4021
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004022echo "------------------------------------------------------------------------"
4023
4024if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004025 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004026else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004027 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004028fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004029PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004030echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004031
4032exit $FAILS