blob: a8c975036d5692d3cc6b8f68b1f0dffb3ecc53d1 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskine39e29812017-05-16 17:53:03 +020020: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020022O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010023O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020024G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010025G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskine39e29812017-05-16 17:53:03 +020026TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010027
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028TESTS=0
29FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020030SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010031
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000032CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020033
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010035FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020036EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010037
38print_usage() {
39 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010040 printf " -h|--help\tPrint this help.\n"
41 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
42 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
43 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010044}
45
46get_options() {
47 while [ $# -gt 0 ]; do
48 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010049 -f|--filter)
50 shift; FILTER=$1
51 ;;
52 -e|--exclude)
53 shift; EXCLUDE=$1
54 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010055 -m|--memcheck)
56 MEMCHECK=1
57 ;;
58 -h|--help)
59 print_usage
60 exit 0
61 ;;
62 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020063 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010064 print_usage
65 exit 1
66 ;;
67 esac
68 shift
69 done
70}
71
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010072# skip next test if the flag is not enabled in config.h
73requires_config_enabled() {
74 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
75 SKIP_NEXT="YES"
76 fi
77}
78
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +020079# skip next test if the flag is enabled in config.h
80requires_config_disabled() {
81 if grep "^#define $1" $CONFIG_H > /dev/null; then
82 SKIP_NEXT="YES"
83 fi
84}
85
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020086# skip next test if OpenSSL doesn't support FALLBACK_SCSV
87requires_openssl_with_fallback_scsv() {
88 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
89 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
90 then
91 OPENSSL_HAS_FBSCSV="YES"
92 else
93 OPENSSL_HAS_FBSCSV="NO"
94 fi
95 fi
96 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
97 SKIP_NEXT="YES"
98 fi
99}
100
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200101# skip next test if GnuTLS isn't available
102requires_gnutls() {
103 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200104 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200105 GNUTLS_AVAILABLE="YES"
106 else
107 GNUTLS_AVAILABLE="NO"
108 fi
109 fi
110 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
111 SKIP_NEXT="YES"
112 fi
113}
114
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200115# skip next test if IPv6 isn't available on this host
116requires_ipv6() {
117 if [ -z "${HAS_IPV6:-}" ]; then
118 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
119 SRV_PID=$!
120 sleep 1
121 kill $SRV_PID >/dev/null 2>&1
122 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
123 HAS_IPV6="NO"
124 else
125 HAS_IPV6="YES"
126 fi
127 rm -r $SRV_OUT
128 fi
129
130 if [ "$HAS_IPV6" = "NO" ]; then
131 SKIP_NEXT="YES"
132 fi
133}
134
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200135# skip the next test if valgrind is in use
136not_with_valgrind() {
137 if [ "$MEMCHECK" -gt 0 ]; then
138 SKIP_NEXT="YES"
139 fi
140}
141
Paul Bakker3b224ff2016-05-13 10:33:25 +0100142# skip the next test if valgrind is NOT in use
143only_with_valgrind() {
144 if [ "$MEMCHECK" -eq 0 ]; then
145 SKIP_NEXT="YES"
146 fi
147}
148
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200149# multiply the client timeout delay by the given factor for the next test
150needs_more_time() {
151 CLI_DELAY_FACTOR=$1
152}
153
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100154# print_name <name>
155print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100156 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200157 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100158 for i in `seq 1 $LEN`; do printf '.'; done
159 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100160
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200161 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100162}
163
164# fail <message>
165fail() {
166 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100167 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100168
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200169 mv $SRV_OUT o-srv-${TESTS}.log
170 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200171 if [ -n "$PXY_CMD" ]; then
172 mv $PXY_OUT o-pxy-${TESTS}.log
173 fi
174 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100175
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200176 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
177 echo " ! server output:"
178 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200179 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200180 echo " ! client output:"
181 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200182 if [ -n "$PXY_CMD" ]; then
183 echo " ! ========================================================"
184 echo " ! proxy output:"
185 cat o-pxy-${TESTS}.log
186 fi
187 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200188 fi
189
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200190 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100191}
192
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100193# is_polar <cmd_line>
194is_polar() {
195 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
196}
197
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200198# openssl s_server doesn't have -www with DTLS
199check_osrv_dtls() {
200 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
201 NEEDS_INPUT=1
202 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
203 else
204 NEEDS_INPUT=0
205 fi
206}
207
208# provide input to commands that need it
209provide_input() {
210 if [ $NEEDS_INPUT -eq 0 ]; then
211 return
212 fi
213
214 while true; do
215 echo "HTTP/1.0 200 OK"
216 sleep 1
217 done
218}
219
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100220# has_mem_err <log_file_name>
221has_mem_err() {
222 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
223 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
224 then
225 return 1 # false: does not have errors
226 else
227 return 0 # true: has errors
228 fi
229}
230
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200231# wait for server to start: two versions depending on lsof availability
232wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200233 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200234 START_TIME=$( date +%s )
235 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200236
237 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200238 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200239 while [ $DONE -eq 0 ]; do
240 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
241 then
242 DONE=1
243 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
244 echo "SERVERSTART TIMEOUT"
245 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
246 DONE=1
247 fi
248 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200249 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200250 while [ $DONE -eq 0 ]; do
251 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
252 then
253 DONE=1
254 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
255 echo "SERVERSTART TIMEOUT"
256 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
257 DONE=1
258 fi
259 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200260 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200261 else
262 sleep "$START_DELAY"
263 fi
264}
265
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200266# wait for client to terminate and set CLI_EXIT
267# must be called right after starting the client
268wait_client_done() {
269 CLI_PID=$!
270
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200271 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
272 CLI_DELAY_FACTOR=1
273
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200274 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200275 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200276
277 wait $CLI_PID
278 CLI_EXIT=$?
279
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200280 kill $DOG_PID >/dev/null 2>&1
281 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200282
283 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
284}
285
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200286# check if the given command uses dtls and sets global variable DTLS
287detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200288 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200289 DTLS=1
290 else
291 DTLS=0
292 fi
293}
294
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200295# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100296# Options: -s pattern pattern that must be present in server output
297# -c pattern pattern that must be present in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100298# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299# -S pattern pattern that must be absent in server output
300# -C pattern pattern that must be absent in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100301# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100302run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100303 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200304 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100305
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100306 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
307 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200308 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100309 return
310 fi
311
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100312 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100313
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200314 # should we skip?
315 if [ "X$SKIP_NEXT" = "XYES" ]; then
316 SKIP_NEXT="NO"
317 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200318 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200319 return
320 fi
321
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200322 # does this test use a proxy?
323 if [ "X$1" = "X-p" ]; then
324 PXY_CMD="$2"
325 shift 2
326 else
327 PXY_CMD=""
328 fi
329
330 # get commands and client output
331 SRV_CMD="$1"
332 CLI_CMD="$2"
333 CLI_EXPECT="$3"
334 shift 3
335
336 # fix client port
337 if [ -n "$PXY_CMD" ]; then
338 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
339 else
340 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
341 fi
342
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200343 # update DTLS variable
344 detect_dtls "$SRV_CMD"
345
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100346 # prepend valgrind to our commands if active
347 if [ "$MEMCHECK" -gt 0 ]; then
348 if is_polar "$SRV_CMD"; then
349 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
350 fi
351 if is_polar "$CLI_CMD"; then
352 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
353 fi
354 fi
355
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200356 TIMES_LEFT=2
357 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200358 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200359
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200360 # run the commands
361 if [ -n "$PXY_CMD" ]; then
362 echo "$PXY_CMD" > $PXY_OUT
363 $PXY_CMD >> $PXY_OUT 2>&1 &
364 PXY_PID=$!
365 # assume proxy starts faster than server
366 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200367
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200368 check_osrv_dtls
369 echo "$SRV_CMD" > $SRV_OUT
370 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
371 SRV_PID=$!
372 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200373
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200374 echo "$CLI_CMD" > $CLI_OUT
375 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
376 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100377
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200378 # terminate the server (and the proxy)
379 kill $SRV_PID
380 wait $SRV_PID
381 if [ -n "$PXY_CMD" ]; then
382 kill $PXY_PID >/dev/null 2>&1
383 wait $PXY_PID
384 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100385
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200386 # retry only on timeouts
387 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
388 printf "RETRY "
389 else
390 TIMES_LEFT=0
391 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200392 done
393
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100394 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200395 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100396 # expected client exit to incorrectly succeed in case of catastrophic
397 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100398 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200399 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100400 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100401 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100402 return
403 fi
404 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100405 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200406 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100407 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100408 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100409 return
410 fi
411 fi
412
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100413 # check server exit code
414 if [ $? != 0 ]; then
415 fail "server fail"
416 return
417 fi
418
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100419 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100420 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
421 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100422 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200423 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100424 return
425 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100427 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200428 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100429 while [ $# -gt 0 ]
430 do
431 case $1 in
432 "-s")
Janos Follath6d3e3382016-09-07 15:48:48 +0100433 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
434 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100435 return
436 fi
437 ;;
438
439 "-c")
Janos Follath6d3e3382016-09-07 15:48:48 +0100440 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
441 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100442 return
443 fi
444 ;;
445
446 "-S")
Janos Follath6d3e3382016-09-07 15:48:48 +0100447 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
448 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100449 return
450 fi
451 ;;
452
453 "-C")
Janos Follath6d3e3382016-09-07 15:48:48 +0100454 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
455 fail "pattern '$2' MUST NOT be present in the Client output"
456 return
457 fi
458 ;;
459
460 # The filtering in the following two options (-u and -U) do the following
461 # - ignore valgrind output
462 # - filter out everything but lines right after the pattern occurances
463 # - keep one of each non-unique line
464 # - count how many lines remain
465 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
466 # if there were no duplicates.
467 "-U")
468 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
469 fail "lines following pattern '$2' must be unique in Server output"
470 return
471 fi
472 ;;
473
474 "-u")
475 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
476 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100477 return
478 fi
479 ;;
480
481 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200482 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100483 exit 1
484 esac
485 shift 2
486 done
487
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100488 # check valgrind's results
489 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200490 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100491 fail "Server has memory errors"
492 return
493 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200494 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100495 fail "Client has memory errors"
496 return
497 fi
498 fi
499
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100500 # if we're here, everything is ok
501 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200502 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100503}
504
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100505cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200506 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200507 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
508 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
509 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
510 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100511 exit 1
512}
513
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100514#
515# MAIN
516#
517
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000518if cd $( dirname $0 ); then :; else
519 echo "cd $( dirname $0 ) failed" >&2
520 exit 1
521fi
522
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100523get_options "$@"
524
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100525# sanity checks, avoid an avalanche of errors
526if [ ! -x "$P_SRV" ]; then
527 echo "Command '$P_SRV' is not an executable file"
528 exit 1
529fi
530if [ ! -x "$P_CLI" ]; then
531 echo "Command '$P_CLI' is not an executable file"
532 exit 1
533fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200534if [ ! -x "$P_PXY" ]; then
535 echo "Command '$P_PXY' is not an executable file"
536 exit 1
537fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100538if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
539 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100540 exit 1
541fi
542
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200543# used by watchdog
544MAIN_PID="$$"
545
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200546# be more patient with valgrind
547if [ "$MEMCHECK" -gt 0 ]; then
548 START_DELAY=3
549 DOG_DELAY=30
550else
551 START_DELAY=1
552 DOG_DELAY=10
553fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200554CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200555
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200556# Pick a "unique" server port in the range 10000-19999, and a proxy port
557PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000558PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200559SRV_PORT="1$PORT_BASE"
560PXY_PORT="2$PORT_BASE"
561unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200562
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200563# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000564# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200565P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
566P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
567P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200568O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200569O_CLI="$O_CLI -connect localhost:+SRV_PORT"
570G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000571G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200572
Gilles Peskine35db5ba2017-05-10 10:13:59 +0200573# Allow SHA-1, because many of our test certificates use it
574P_SRV="$P_SRV allow_sha1=1"
575P_CLI="$P_CLI allow_sha1=1"
576
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200577# Also pick a unique name for intermediate files
578SRV_OUT="srv_out.$$"
579CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200580PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200581SESSION="session.$$"
582
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200583SKIP_NEXT="NO"
584
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100585trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100586
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200587# Basic test
588
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200589# Checks that:
590# - things work with all ciphersuites active (used with config-full in all.sh)
591# - the expected (highest security) parameters are selected
592# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200593run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200594 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200595 "$P_CLI" \
596 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200597 -s "Protocol is TLSv1.2" \
598 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
599 -s "client hello v3, signature_algorithm ext: 6" \
600 -s "ECDHE curve: secp521r1" \
601 -S "error" \
602 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200603
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000604run_test "Default, DTLS" \
605 "$P_SRV dtls=1" \
606 "$P_CLI dtls=1" \
607 0 \
608 -s "Protocol is DTLSv1.2" \
609 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
610
Janos Follath6d3e3382016-09-07 15:48:48 +0100611# Test for uniqueness of IVs in AEAD ciphersuites
612run_test "Unique IV in GCM" \
613 "$P_SRV exchanges=20 debug_level=4" \
614 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
615 0 \
616 -u "IV used" \
617 -U "IV used"
618
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100619# Tests for rc4 option
620
Simon Butcher6eb066e2016-05-19 22:12:18 +0100621requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100622run_test "RC4: server disabled, client enabled" \
623 "$P_SRV" \
624 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
625 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100626 -s "SSL - The server has no ciphersuites in common"
627
Simon Butcher6eb066e2016-05-19 22:12:18 +0100628requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100629run_test "RC4: server half, client enabled" \
630 "$P_SRV arc4=1" \
631 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
632 1 \
633 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100634
635run_test "RC4: server enabled, client disabled" \
636 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
637 "$P_CLI" \
638 1 \
639 -s "SSL - The server has no ciphersuites in common"
640
641run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100642 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100643 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
644 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100645 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100646 -S "SSL - The server has no ciphersuites in common"
647
Gilles Peskineae765992017-05-09 15:59:24 +0200648# Tests for SHA-1 support
649
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200650requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200651run_test "SHA-1 forbidden by default in server certificate" \
652 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
653 "$P_CLI debug_level=2 allow_sha1=0" \
654 1 \
655 -c "The certificate is signed with an unacceptable hash"
656
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200657requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
658run_test "SHA-1 forbidden by default in server certificate" \
659 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
660 "$P_CLI debug_level=2 allow_sha1=0" \
661 0
662
Gilles Peskineae765992017-05-09 15:59:24 +0200663run_test "SHA-1 explicitly allowed in server certificate" \
664 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
665 "$P_CLI allow_sha1=1" \
666 0
667
668run_test "SHA-256 allowed by default in server certificate" \
669 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
670 "$P_CLI allow_sha1=0" \
671 0
672
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200673requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200674run_test "SHA-1 forbidden by default in client certificate" \
675 "$P_SRV auth_mode=required allow_sha1=0" \
676 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
677 1 \
678 -s "The certificate is signed with an unacceptable hash"
679
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200680requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
681run_test "SHA-1 forbidden by default in client certificate" \
682 "$P_SRV auth_mode=required allow_sha1=0" \
683 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
684 0
685
Gilles Peskineae765992017-05-09 15:59:24 +0200686run_test "SHA-1 explicitly allowed in client certificate" \
687 "$P_SRV auth_mode=required allow_sha1=1" \
688 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
689 0
690
691run_test "SHA-256 allowed by default in client certificate" \
692 "$P_SRV auth_mode=required allow_sha1=0" \
693 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
694 0
695
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100696# Tests for Truncated HMAC extension
697
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100698run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200699 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100700 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100701 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100702 -s "dumping 'computed mac' (20 bytes)" \
703 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100704
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100705run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200706 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100707 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
708 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100709 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100710 -s "dumping 'computed mac' (20 bytes)" \
711 -S "dumping 'computed mac' (10 bytes)"
712
713run_test "Truncated HMAC: client enabled, server default" \
714 "$P_SRV debug_level=4" \
715 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
716 trunc_hmac=1" \
717 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100718 -s "dumping 'computed mac' (20 bytes)" \
719 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100720
721run_test "Truncated HMAC: client enabled, server disabled" \
722 "$P_SRV debug_level=4 trunc_hmac=0" \
723 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
724 trunc_hmac=1" \
725 0 \
726 -s "dumping 'computed mac' (20 bytes)" \
727 -S "dumping 'computed mac' (10 bytes)"
728
729run_test "Truncated HMAC: client enabled, server enabled" \
730 "$P_SRV debug_level=4 trunc_hmac=1" \
731 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
732 trunc_hmac=1" \
733 0 \
734 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100735 -s "dumping 'computed mac' (10 bytes)"
736
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100737# Tests for Encrypt-then-MAC extension
738
739run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100740 "$P_SRV debug_level=3 \
741 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100742 "$P_CLI debug_level=3" \
743 0 \
744 -c "client hello, adding encrypt_then_mac extension" \
745 -s "found encrypt then mac extension" \
746 -s "server hello, adding encrypt then mac extension" \
747 -c "found encrypt_then_mac extension" \
748 -c "using encrypt then mac" \
749 -s "using encrypt then mac"
750
751run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100752 "$P_SRV debug_level=3 etm=0 \
753 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100754 "$P_CLI debug_level=3 etm=1" \
755 0 \
756 -c "client hello, adding encrypt_then_mac extension" \
757 -s "found encrypt then mac extension" \
758 -S "server hello, adding encrypt then mac extension" \
759 -C "found encrypt_then_mac extension" \
760 -C "using encrypt then mac" \
761 -S "using encrypt then mac"
762
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100763run_test "Encrypt then MAC: client enabled, aead cipher" \
764 "$P_SRV debug_level=3 etm=1 \
765 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
766 "$P_CLI debug_level=3 etm=1" \
767 0 \
768 -c "client hello, adding encrypt_then_mac extension" \
769 -s "found encrypt then mac extension" \
770 -S "server hello, adding encrypt then mac extension" \
771 -C "found encrypt_then_mac extension" \
772 -C "using encrypt then mac" \
773 -S "using encrypt then mac"
774
775run_test "Encrypt then MAC: client enabled, stream cipher" \
776 "$P_SRV debug_level=3 etm=1 \
777 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100778 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100779 0 \
780 -c "client hello, adding encrypt_then_mac extension" \
781 -s "found encrypt then mac extension" \
782 -S "server hello, adding encrypt then mac extension" \
783 -C "found encrypt_then_mac extension" \
784 -C "using encrypt then mac" \
785 -S "using encrypt then mac"
786
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100787run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100788 "$P_SRV debug_level=3 etm=1 \
789 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100790 "$P_CLI debug_level=3 etm=0" \
791 0 \
792 -C "client hello, adding encrypt_then_mac extension" \
793 -S "found encrypt then mac extension" \
794 -S "server hello, adding encrypt then mac extension" \
795 -C "found encrypt_then_mac extension" \
796 -C "using encrypt then mac" \
797 -S "using encrypt then mac"
798
Janos Follath542ee5d2016-03-07 15:57:05 +0000799requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100800run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100801 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100802 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100803 "$P_CLI debug_level=3 force_version=ssl3" \
804 0 \
805 -C "client hello, adding encrypt_then_mac extension" \
806 -S "found encrypt then mac extension" \
807 -S "server hello, adding encrypt then mac extension" \
808 -C "found encrypt_then_mac extension" \
809 -C "using encrypt then mac" \
810 -S "using encrypt then mac"
811
Janos Follath542ee5d2016-03-07 15:57:05 +0000812requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100813run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100814 "$P_SRV debug_level=3 force_version=ssl3 \
815 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100816 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100817 0 \
818 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100819 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100820 -S "server hello, adding encrypt then mac extension" \
821 -C "found encrypt_then_mac extension" \
822 -C "using encrypt then mac" \
823 -S "using encrypt then mac"
824
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200825# Tests for Extended Master Secret extension
826
827run_test "Extended Master Secret: default" \
828 "$P_SRV debug_level=3" \
829 "$P_CLI debug_level=3" \
830 0 \
831 -c "client hello, adding extended_master_secret extension" \
832 -s "found extended master secret extension" \
833 -s "server hello, adding extended master secret extension" \
834 -c "found extended_master_secret extension" \
835 -c "using extended master secret" \
836 -s "using extended master secret"
837
838run_test "Extended Master Secret: client enabled, server disabled" \
839 "$P_SRV debug_level=3 extended_ms=0" \
840 "$P_CLI debug_level=3 extended_ms=1" \
841 0 \
842 -c "client hello, adding extended_master_secret extension" \
843 -s "found extended master secret extension" \
844 -S "server hello, adding extended master secret extension" \
845 -C "found extended_master_secret extension" \
846 -C "using extended master secret" \
847 -S "using extended master secret"
848
849run_test "Extended Master Secret: client disabled, server enabled" \
850 "$P_SRV debug_level=3 extended_ms=1" \
851 "$P_CLI debug_level=3 extended_ms=0" \
852 0 \
853 -C "client hello, adding extended_master_secret extension" \
854 -S "found extended master secret extension" \
855 -S "server hello, adding extended master secret extension" \
856 -C "found extended_master_secret extension" \
857 -C "using extended master secret" \
858 -S "using extended master secret"
859
Janos Follath542ee5d2016-03-07 15:57:05 +0000860requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200861run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100862 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200863 "$P_CLI debug_level=3 force_version=ssl3" \
864 0 \
865 -C "client hello, adding extended_master_secret extension" \
866 -S "found extended master secret extension" \
867 -S "server hello, adding extended master secret extension" \
868 -C "found extended_master_secret extension" \
869 -C "using extended master secret" \
870 -S "using extended master secret"
871
Janos Follath542ee5d2016-03-07 15:57:05 +0000872requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200873run_test "Extended Master Secret: client enabled, server SSLv3" \
874 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100875 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200876 0 \
877 -c "client hello, adding extended_master_secret extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100878 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200879 -S "server hello, adding extended master secret extension" \
880 -C "found extended_master_secret extension" \
881 -C "using extended master secret" \
882 -S "using extended master secret"
883
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200884# Tests for FALLBACK_SCSV
885
886run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200887 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200888 "$P_CLI debug_level=3 force_version=tls1_1" \
889 0 \
890 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200891 -S "received FALLBACK_SCSV" \
892 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200893 -C "is a fatal alert message (msg 86)"
894
895run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200896 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200897 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
898 0 \
899 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200900 -S "received FALLBACK_SCSV" \
901 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200902 -C "is a fatal alert message (msg 86)"
903
904run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200905 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200906 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200907 1 \
908 -c "adding FALLBACK_SCSV" \
909 -s "received FALLBACK_SCSV" \
910 -s "inapropriate fallback" \
911 -c "is a fatal alert message (msg 86)"
912
913run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200914 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200915 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200916 0 \
917 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200918 -s "received FALLBACK_SCSV" \
919 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200920 -C "is a fatal alert message (msg 86)"
921
922requires_openssl_with_fallback_scsv
923run_test "Fallback SCSV: default, openssl server" \
924 "$O_SRV" \
925 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
926 0 \
927 -C "adding FALLBACK_SCSV" \
928 -C "is a fatal alert message (msg 86)"
929
930requires_openssl_with_fallback_scsv
931run_test "Fallback SCSV: enabled, openssl server" \
932 "$O_SRV" \
933 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
934 1 \
935 -c "adding FALLBACK_SCSV" \
936 -c "is a fatal alert message (msg 86)"
937
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200938requires_openssl_with_fallback_scsv
939run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200940 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200941 "$O_CLI -tls1_1" \
942 0 \
943 -S "received FALLBACK_SCSV" \
944 -S "inapropriate fallback"
945
946requires_openssl_with_fallback_scsv
947run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200948 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200949 "$O_CLI -tls1_1 -fallback_scsv" \
950 1 \
951 -s "received FALLBACK_SCSV" \
952 -s "inapropriate fallback"
953
954requires_openssl_with_fallback_scsv
955run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200956 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200957 "$O_CLI -fallback_scsv" \
958 0 \
959 -s "received FALLBACK_SCSV" \
960 -S "inapropriate fallback"
961
Gilles Peskine39e29812017-05-16 17:53:03 +0200962## ClientHello generated with
963## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
964## then manually twiddling the ciphersuite list.
965## The ClientHello content is spelled out below as a hex string as
966## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
967## The expected response is an inappropriate_fallback alert.
968requires_openssl_with_fallback_scsv
969run_test "Fallback SCSV: beginning of list" \
970 "$P_SRV debug_level=2" \
971 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
972 0 \
973 -s "received FALLBACK_SCSV" \
974 -s "inapropriate fallback"
975
976requires_openssl_with_fallback_scsv
977run_test "Fallback SCSV: end of list" \
978 "$P_SRV debug_level=2" \
979 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
980 0 \
981 -s "received FALLBACK_SCSV" \
982 -s "inapropriate fallback"
983
984## Here the expected response is a valid ServerHello prefix, up to the random.
985requires_openssl_with_fallback_scsv
986run_test "Fallback SCSV: not in list" \
987 "$P_SRV debug_level=2" \
988 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
989 0 \
990 -S "received FALLBACK_SCSV" \
991 -S "inapropriate fallback"
992
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100993# Tests for CBC 1/n-1 record splitting
994
995run_test "CBC Record splitting: TLS 1.2, no splitting" \
996 "$P_SRV" \
997 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
998 request_size=123 force_version=tls1_2" \
999 0 \
1000 -s "Read from client: 123 bytes read" \
1001 -S "Read from client: 1 bytes read" \
1002 -S "122 bytes read"
1003
1004run_test "CBC Record splitting: TLS 1.1, no splitting" \
1005 "$P_SRV" \
1006 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1007 request_size=123 force_version=tls1_1" \
1008 0 \
1009 -s "Read from client: 123 bytes read" \
1010 -S "Read from client: 1 bytes read" \
1011 -S "122 bytes read"
1012
1013run_test "CBC Record splitting: TLS 1.0, splitting" \
1014 "$P_SRV" \
1015 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1016 request_size=123 force_version=tls1" \
1017 0 \
1018 -S "Read from client: 123 bytes read" \
1019 -s "Read from client: 1 bytes read" \
1020 -s "122 bytes read"
1021
Janos Follath542ee5d2016-03-07 15:57:05 +00001022requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001023run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001024 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001025 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1026 request_size=123 force_version=ssl3" \
1027 0 \
1028 -S "Read from client: 123 bytes read" \
1029 -s "Read from client: 1 bytes read" \
1030 -s "122 bytes read"
1031
1032run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001033 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001034 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1035 request_size=123 force_version=tls1" \
1036 0 \
1037 -s "Read from client: 123 bytes read" \
1038 -S "Read from client: 1 bytes read" \
1039 -S "122 bytes read"
1040
1041run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1042 "$P_SRV" \
1043 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1044 request_size=123 force_version=tls1 recsplit=0" \
1045 0 \
1046 -s "Read from client: 123 bytes read" \
1047 -S "Read from client: 1 bytes read" \
1048 -S "122 bytes read"
1049
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001050run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1051 "$P_SRV nbio=2" \
1052 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1053 request_size=123 force_version=tls1" \
1054 0 \
1055 -S "Read from client: 123 bytes read" \
1056 -s "Read from client: 1 bytes read" \
1057 -s "122 bytes read"
1058
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001059# Tests for Session Tickets
1060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001061run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001062 "$P_SRV debug_level=3 tickets=1" \
1063 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001064 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001065 -c "client hello, adding session ticket extension" \
1066 -s "found session ticket extension" \
1067 -s "server hello, adding session ticket extension" \
1068 -c "found session_ticket extension" \
1069 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001070 -S "session successfully restored from cache" \
1071 -s "session successfully restored from ticket" \
1072 -s "a session has been resumed" \
1073 -c "a session has been resumed"
1074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001075run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001076 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1077 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001078 0 \
1079 -c "client hello, adding session ticket extension" \
1080 -s "found session ticket extension" \
1081 -s "server hello, adding session ticket extension" \
1082 -c "found session_ticket extension" \
1083 -c "parse new session ticket" \
1084 -S "session successfully restored from cache" \
1085 -s "session successfully restored from ticket" \
1086 -s "a session has been resumed" \
1087 -c "a session has been resumed"
1088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001089run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001090 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1091 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001092 0 \
1093 -c "client hello, adding session ticket extension" \
1094 -s "found session ticket extension" \
1095 -s "server hello, adding session ticket extension" \
1096 -c "found session_ticket extension" \
1097 -c "parse new session ticket" \
1098 -S "session successfully restored from cache" \
1099 -S "session successfully restored from ticket" \
1100 -S "a session has been resumed" \
1101 -C "a session has been resumed"
1102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001103run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001104 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001105 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001106 0 \
1107 -c "client hello, adding session ticket extension" \
1108 -c "found session_ticket extension" \
1109 -c "parse new session ticket" \
1110 -c "a session has been resumed"
1111
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001112run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001113 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001114 "( $O_CLI -sess_out $SESSION; \
1115 $O_CLI -sess_in $SESSION; \
1116 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001117 0 \
1118 -s "found session ticket extension" \
1119 -s "server hello, adding session ticket extension" \
1120 -S "session successfully restored from cache" \
1121 -s "session successfully restored from ticket" \
1122 -s "a session has been resumed"
1123
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001124# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001126run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001127 "$P_SRV debug_level=3 tickets=0" \
1128 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001129 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001130 -c "client hello, adding session ticket extension" \
1131 -s "found session ticket extension" \
1132 -S "server hello, adding session ticket extension" \
1133 -C "found session_ticket extension" \
1134 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001135 -s "session successfully restored from cache" \
1136 -S "session successfully restored from ticket" \
1137 -s "a session has been resumed" \
1138 -c "a session has been resumed"
1139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001140run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001141 "$P_SRV debug_level=3 tickets=1" \
1142 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001143 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001144 -C "client hello, adding session ticket extension" \
1145 -S "found session ticket extension" \
1146 -S "server hello, adding session ticket extension" \
1147 -C "found session_ticket extension" \
1148 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001149 -s "session successfully restored from cache" \
1150 -S "session successfully restored from ticket" \
1151 -s "a session has been resumed" \
1152 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001154run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001155 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1156 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001157 0 \
1158 -S "session successfully restored from cache" \
1159 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001160 -S "a session has been resumed" \
1161 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001163run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001164 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1165 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001166 0 \
1167 -s "session successfully restored from cache" \
1168 -S "session successfully restored from ticket" \
1169 -s "a session has been resumed" \
1170 -c "a session has been resumed"
1171
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001172run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001173 "$P_SRV debug_level=3 tickets=0" \
1174 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001175 0 \
1176 -s "session successfully restored from cache" \
1177 -S "session successfully restored from ticket" \
1178 -s "a session has been resumed" \
1179 -c "a session has been resumed"
1180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001181run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001182 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1183 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001184 0 \
1185 -S "session successfully restored from cache" \
1186 -S "session successfully restored from ticket" \
1187 -S "a session has been resumed" \
1188 -C "a session has been resumed"
1189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001190run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001191 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1192 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001193 0 \
1194 -s "session successfully restored from cache" \
1195 -S "session successfully restored from ticket" \
1196 -s "a session has been resumed" \
1197 -c "a session has been resumed"
1198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001199run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001200 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001201 "( $O_CLI -sess_out $SESSION; \
1202 $O_CLI -sess_in $SESSION; \
1203 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001204 0 \
1205 -s "found session ticket extension" \
1206 -S "server hello, adding session ticket extension" \
1207 -s "session successfully restored from cache" \
1208 -S "session successfully restored from ticket" \
1209 -s "a session has been resumed"
1210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001211run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001212 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001213 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001214 0 \
1215 -C "found session_ticket extension" \
1216 -C "parse new session ticket" \
1217 -c "a session has been resumed"
1218
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001219# Tests for Max Fragment Length extension
1220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001221run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001222 "$P_SRV debug_level=3" \
1223 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001224 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001225 -c "Maximum fragment length is 16384" \
1226 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001227 -C "client hello, adding max_fragment_length extension" \
1228 -S "found max fragment length extension" \
1229 -S "server hello, max_fragment_length extension" \
1230 -C "found max_fragment_length extension"
1231
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001232run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001233 "$P_SRV debug_level=3" \
1234 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001235 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001236 -c "Maximum fragment length is 4096" \
1237 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001238 -c "client hello, adding max_fragment_length extension" \
1239 -s "found max fragment length extension" \
1240 -s "server hello, max_fragment_length extension" \
1241 -c "found max_fragment_length extension"
1242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001243run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001244 "$P_SRV debug_level=3 max_frag_len=4096" \
1245 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001246 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001247 -c "Maximum fragment length is 16384" \
1248 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001249 -C "client hello, adding max_fragment_length extension" \
1250 -S "found max fragment length extension" \
1251 -S "server hello, max_fragment_length extension" \
1252 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001253
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001254requires_gnutls
1255run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001256 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001258 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001259 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001260 -c "client hello, adding max_fragment_length extension" \
1261 -c "found max_fragment_length extension"
1262
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001263run_test "Max fragment length: client, message just fits" \
1264 "$P_SRV debug_level=3" \
1265 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1266 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001267 -c "Maximum fragment length is 2048" \
1268 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001269 -c "client hello, adding max_fragment_length extension" \
1270 -s "found max fragment length extension" \
1271 -s "server hello, max_fragment_length extension" \
1272 -c "found max_fragment_length extension" \
1273 -c "2048 bytes written in 1 fragments" \
1274 -s "2048 bytes read"
1275
1276run_test "Max fragment length: client, larger message" \
1277 "$P_SRV debug_level=3" \
1278 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1279 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001280 -c "Maximum fragment length is 2048" \
1281 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001282 -c "client hello, adding max_fragment_length extension" \
1283 -s "found max fragment length extension" \
1284 -s "server hello, max_fragment_length extension" \
1285 -c "found max_fragment_length extension" \
1286 -c "2345 bytes written in 2 fragments" \
1287 -s "2048 bytes read" \
1288 -s "297 bytes read"
1289
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001290run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001291 "$P_SRV debug_level=3 dtls=1" \
1292 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1293 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001294 -c "Maximum fragment length is 2048" \
1295 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001296 -c "client hello, adding max_fragment_length extension" \
1297 -s "found max fragment length extension" \
1298 -s "server hello, max_fragment_length extension" \
1299 -c "found max_fragment_length extension" \
1300 -c "fragment larger than.*maximum"
1301
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001302# Tests for renegotiation
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001305 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001306 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001307 0 \
1308 -C "client hello, adding renegotiation extension" \
1309 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1310 -S "found renegotiation extension" \
1311 -s "server hello, secure renegotiation extension" \
1312 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001313 -C "=> renegotiate" \
1314 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001315 -S "write hello request"
1316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001317run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001318 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001319 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001320 0 \
1321 -c "client hello, adding renegotiation extension" \
1322 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1323 -s "found renegotiation extension" \
1324 -s "server hello, secure renegotiation extension" \
1325 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001326 -c "=> renegotiate" \
1327 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001328 -S "write hello request"
1329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001330run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001331 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001332 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001333 0 \
1334 -c "client hello, adding renegotiation extension" \
1335 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1336 -s "found renegotiation extension" \
1337 -s "server hello, secure renegotiation extension" \
1338 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001339 -c "=> renegotiate" \
1340 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001341 -s "write hello request"
1342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001343run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001344 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001345 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001346 0 \
1347 -c "client hello, adding renegotiation extension" \
1348 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1349 -s "found renegotiation extension" \
1350 -s "server hello, secure renegotiation extension" \
1351 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001352 -c "=> renegotiate" \
1353 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001354 -s "write hello request"
1355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001356run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001357 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001358 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001359 1 \
1360 -c "client hello, adding renegotiation extension" \
1361 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1362 -S "found renegotiation extension" \
1363 -s "server hello, secure renegotiation extension" \
1364 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001365 -c "=> renegotiate" \
1366 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001367 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001368 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001369 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001370
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001371run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001372 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001373 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001374 0 \
1375 -C "client hello, adding renegotiation extension" \
1376 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1377 -S "found renegotiation extension" \
1378 -s "server hello, secure renegotiation extension" \
1379 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001380 -C "=> renegotiate" \
1381 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001382 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001383 -S "SSL - An unexpected message was received from our peer" \
1384 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001386run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001387 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001388 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001389 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001390 0 \
1391 -C "client hello, adding renegotiation extension" \
1392 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1393 -S "found renegotiation extension" \
1394 -s "server hello, secure renegotiation extension" \
1395 -c "found renegotiation extension" \
1396 -C "=> renegotiate" \
1397 -S "=> renegotiate" \
1398 -s "write hello request" \
1399 -S "SSL - An unexpected message was received from our peer" \
1400 -S "failed"
1401
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001402# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001403run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001404 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001405 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001406 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001407 0 \
1408 -C "client hello, adding renegotiation extension" \
1409 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1410 -S "found renegotiation extension" \
1411 -s "server hello, secure renegotiation extension" \
1412 -c "found renegotiation extension" \
1413 -C "=> renegotiate" \
1414 -S "=> renegotiate" \
1415 -s "write hello request" \
1416 -S "SSL - An unexpected message was received from our peer" \
1417 -S "failed"
1418
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001419run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001420 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001421 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001422 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001423 0 \
1424 -C "client hello, adding renegotiation extension" \
1425 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1426 -S "found renegotiation extension" \
1427 -s "server hello, secure renegotiation extension" \
1428 -c "found renegotiation extension" \
1429 -C "=> renegotiate" \
1430 -S "=> renegotiate" \
1431 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001432 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001434run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001435 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001436 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001437 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001438 0 \
1439 -c "client hello, adding renegotiation extension" \
1440 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1441 -s "found renegotiation extension" \
1442 -s "server hello, secure renegotiation extension" \
1443 -c "found renegotiation extension" \
1444 -c "=> renegotiate" \
1445 -s "=> renegotiate" \
1446 -s "write hello request" \
1447 -S "SSL - An unexpected message was received from our peer" \
1448 -S "failed"
1449
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001450run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001451 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001452 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1453 0 \
1454 -C "client hello, adding renegotiation extension" \
1455 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1456 -S "found renegotiation extension" \
1457 -s "server hello, secure renegotiation extension" \
1458 -c "found renegotiation extension" \
1459 -S "record counter limit reached: renegotiate" \
1460 -C "=> renegotiate" \
1461 -S "=> renegotiate" \
1462 -S "write hello request" \
1463 -S "SSL - An unexpected message was received from our peer" \
1464 -S "failed"
1465
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001466# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001467run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001468 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001469 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001470 0 \
1471 -c "client hello, adding renegotiation extension" \
1472 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1473 -s "found renegotiation extension" \
1474 -s "server hello, secure renegotiation extension" \
1475 -c "found renegotiation extension" \
1476 -s "record counter limit reached: renegotiate" \
1477 -c "=> renegotiate" \
1478 -s "=> renegotiate" \
1479 -s "write hello request" \
1480 -S "SSL - An unexpected message was received from our peer" \
1481 -S "failed"
1482
1483run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001484 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001485 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001486 0 \
1487 -c "client hello, adding renegotiation extension" \
1488 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1489 -s "found renegotiation extension" \
1490 -s "server hello, secure renegotiation extension" \
1491 -c "found renegotiation extension" \
1492 -s "record counter limit reached: renegotiate" \
1493 -c "=> renegotiate" \
1494 -s "=> renegotiate" \
1495 -s "write hello request" \
1496 -S "SSL - An unexpected message was received from our peer" \
1497 -S "failed"
1498
1499run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001500 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001501 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1502 0 \
1503 -C "client hello, adding renegotiation extension" \
1504 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1505 -S "found renegotiation extension" \
1506 -s "server hello, secure renegotiation extension" \
1507 -c "found renegotiation extension" \
1508 -S "record counter limit reached: renegotiate" \
1509 -C "=> renegotiate" \
1510 -S "=> renegotiate" \
1511 -S "write hello request" \
1512 -S "SSL - An unexpected message was received from our peer" \
1513 -S "failed"
1514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001515run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001516 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001517 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001518 0 \
1519 -c "client hello, adding renegotiation extension" \
1520 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1521 -s "found renegotiation extension" \
1522 -s "server hello, secure renegotiation extension" \
1523 -c "found renegotiation extension" \
1524 -c "=> renegotiate" \
1525 -s "=> renegotiate" \
1526 -S "write hello request"
1527
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001528run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001529 "$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 +02001530 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001531 0 \
1532 -c "client hello, adding renegotiation extension" \
1533 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1534 -s "found renegotiation extension" \
1535 -s "server hello, secure renegotiation extension" \
1536 -c "found renegotiation extension" \
1537 -c "=> renegotiate" \
1538 -s "=> renegotiate" \
1539 -s "write hello request"
1540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001541run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001542 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001543 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001544 0 \
1545 -c "client hello, adding renegotiation extension" \
1546 -c "found renegotiation extension" \
1547 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001548 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001549 -C "error" \
1550 -c "HTTP/1.0 200 [Oo][Kk]"
1551
Paul Bakker539d9722015-02-08 16:18:35 +01001552requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001553run_test "Renegotiation: gnutls server strict, client-initiated" \
1554 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001555 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001556 0 \
1557 -c "client hello, adding renegotiation extension" \
1558 -c "found renegotiation extension" \
1559 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001560 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001561 -C "error" \
1562 -c "HTTP/1.0 200 [Oo][Kk]"
1563
Paul Bakker539d9722015-02-08 16:18:35 +01001564requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001565run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1566 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1567 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1568 1 \
1569 -c "client hello, adding renegotiation extension" \
1570 -C "found renegotiation extension" \
1571 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001572 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001573 -c "error" \
1574 -C "HTTP/1.0 200 [Oo][Kk]"
1575
Paul Bakker539d9722015-02-08 16:18:35 +01001576requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001577run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1578 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1579 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1580 allow_legacy=0" \
1581 1 \
1582 -c "client hello, adding renegotiation extension" \
1583 -C "found renegotiation extension" \
1584 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001585 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001586 -c "error" \
1587 -C "HTTP/1.0 200 [Oo][Kk]"
1588
Paul Bakker539d9722015-02-08 16:18:35 +01001589requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001590run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1591 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1592 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1593 allow_legacy=1" \
1594 0 \
1595 -c "client hello, adding renegotiation extension" \
1596 -C "found renegotiation extension" \
1597 -c "=> renegotiate" \
1598 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001599 -C "error" \
1600 -c "HTTP/1.0 200 [Oo][Kk]"
1601
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001602run_test "Renegotiation: DTLS, client-initiated" \
1603 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1604 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1605 0 \
1606 -c "client hello, adding renegotiation extension" \
1607 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1608 -s "found renegotiation extension" \
1609 -s "server hello, secure renegotiation extension" \
1610 -c "found renegotiation extension" \
1611 -c "=> renegotiate" \
1612 -s "=> renegotiate" \
1613 -S "write hello request"
1614
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001615run_test "Renegotiation: DTLS, server-initiated" \
1616 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001617 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1618 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001619 0 \
1620 -c "client hello, adding renegotiation extension" \
1621 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1622 -s "found renegotiation extension" \
1623 -s "server hello, secure renegotiation extension" \
1624 -c "found renegotiation extension" \
1625 -c "=> renegotiate" \
1626 -s "=> renegotiate" \
1627 -s "write hello request"
1628
Andres AG9b1927b2017-01-19 16:30:57 +00001629run_test "Renegotiation: DTLS, renego_period overflow" \
1630 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1631 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1632 0 \
1633 -c "client hello, adding renegotiation extension" \
1634 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1635 -s "found renegotiation extension" \
1636 -s "server hello, secure renegotiation extension" \
1637 -s "record counter limit reached: renegotiate" \
1638 -c "=> renegotiate" \
1639 -s "=> renegotiate" \
1640 -s "write hello request" \
1641
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001642requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001643run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1644 "$G_SRV -u --mtu 4096" \
1645 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1646 0 \
1647 -c "client hello, adding renegotiation extension" \
1648 -c "found renegotiation extension" \
1649 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001650 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001651 -C "error" \
1652 -s "Extra-header:"
1653
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001654# Test for the "secure renegotation" extension only (no actual renegotiation)
1655
Paul Bakker539d9722015-02-08 16:18:35 +01001656requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001657run_test "Renego ext: gnutls server strict, client default" \
1658 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1659 "$P_CLI debug_level=3" \
1660 0 \
1661 -c "found renegotiation extension" \
1662 -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 "Renego ext: gnutls server unsafe, client default" \
1667 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1668 "$P_CLI debug_level=3" \
1669 0 \
1670 -C "found renegotiation extension" \
1671 -C "error" \
1672 -c "HTTP/1.0 200 [Oo][Kk]"
1673
Paul Bakker539d9722015-02-08 16:18:35 +01001674requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001675run_test "Renego ext: gnutls server unsafe, client break legacy" \
1676 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1677 "$P_CLI debug_level=3 allow_legacy=-1" \
1678 1 \
1679 -C "found renegotiation extension" \
1680 -c "error" \
1681 -C "HTTP/1.0 200 [Oo][Kk]"
1682
Paul Bakker539d9722015-02-08 16:18:35 +01001683requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001684run_test "Renego ext: gnutls client strict, server default" \
1685 "$P_SRV debug_level=3" \
1686 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1687 0 \
1688 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1689 -s "server hello, secure renegotiation extension"
1690
Paul Bakker539d9722015-02-08 16:18:35 +01001691requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001692run_test "Renego ext: gnutls client unsafe, server default" \
1693 "$P_SRV debug_level=3" \
1694 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1695 0 \
1696 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1697 -S "server hello, secure renegotiation extension"
1698
Paul Bakker539d9722015-02-08 16:18:35 +01001699requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001700run_test "Renego ext: gnutls client unsafe, server break legacy" \
1701 "$P_SRV debug_level=3 allow_legacy=-1" \
1702 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1703 1 \
1704 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1705 -S "server hello, secure renegotiation extension"
1706
Janos Follath365b2262016-02-17 10:11:21 +00001707# Tests for silently dropping trailing extra bytes in .der certificates
1708
1709requires_gnutls
1710run_test "DER format: no trailing bytes" \
1711 "$P_SRV crt_file=data_files/server5-der0.crt \
1712 key_file=data_files/server5.key" \
1713 "$G_CLI " \
1714 0 \
1715 -c "Handshake was completed" \
1716
1717requires_gnutls
1718run_test "DER format: with a trailing zero byte" \
1719 "$P_SRV crt_file=data_files/server5-der1a.crt \
1720 key_file=data_files/server5.key" \
1721 "$G_CLI " \
1722 0 \
1723 -c "Handshake was completed" \
1724
1725requires_gnutls
1726run_test "DER format: with a trailing random byte" \
1727 "$P_SRV crt_file=data_files/server5-der1b.crt \
1728 key_file=data_files/server5.key" \
1729 "$G_CLI " \
1730 0 \
1731 -c "Handshake was completed" \
1732
1733requires_gnutls
1734run_test "DER format: with 2 trailing random bytes" \
1735 "$P_SRV crt_file=data_files/server5-der2.crt \
1736 key_file=data_files/server5.key" \
1737 "$G_CLI " \
1738 0 \
1739 -c "Handshake was completed" \
1740
1741requires_gnutls
1742run_test "DER format: with 4 trailing random bytes" \
1743 "$P_SRV crt_file=data_files/server5-der4.crt \
1744 key_file=data_files/server5.key" \
1745 "$G_CLI " \
1746 0 \
1747 -c "Handshake was completed" \
1748
1749requires_gnutls
1750run_test "DER format: with 8 trailing random bytes" \
1751 "$P_SRV crt_file=data_files/server5-der8.crt \
1752 key_file=data_files/server5.key" \
1753 "$G_CLI " \
1754 0 \
1755 -c "Handshake was completed" \
1756
1757requires_gnutls
1758run_test "DER format: with 9 trailing random bytes" \
1759 "$P_SRV crt_file=data_files/server5-der9.crt \
1760 key_file=data_files/server5.key" \
1761 "$G_CLI " \
1762 0 \
1763 -c "Handshake was completed" \
1764
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001765# Tests for auth_mode
1766
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001767run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001768 "$P_SRV crt_file=data_files/server5-badsign.crt \
1769 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001770 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001771 1 \
1772 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001773 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001774 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001775 -c "X509 - Certificate verification failed"
1776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001778 "$P_SRV crt_file=data_files/server5-badsign.crt \
1779 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001780 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001781 0 \
1782 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001783 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001784 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001785 -C "X509 - Certificate verification failed"
1786
Hanno Becker61c0c702017-05-15 16:05:15 +01001787run_test "Authentication: server goodcert, client optional, no trusted CA" \
1788 "$P_SRV" \
1789 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1790 0 \
1791 -c "x509_verify_cert() returned" \
1792 -c "! The certificate is not correctly signed by the trusted CA" \
1793 -c "! Certificate verification flags"\
1794 -C "! mbedtls_ssl_handshake returned" \
1795 -C "X509 - Certificate verification failed" \
1796 -C "SSL - No CA Chain is set, but required to operate"
1797
1798run_test "Authentication: server goodcert, client required, no trusted CA" \
1799 "$P_SRV" \
1800 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1801 1 \
1802 -c "x509_verify_cert() returned" \
1803 -c "! The certificate is not correctly signed by the trusted CA" \
1804 -c "! Certificate verification flags"\
1805 -c "! mbedtls_ssl_handshake returned" \
1806 -c "SSL - No CA Chain is set, but required to operate"
1807
1808# The purpose of the next two tests is to test the client's behaviour when receiving a server
1809# certificate with an unsupported elliptic curve. This should usually not happen because
1810# the client informs the server about the supported curves - it does, though, in the
1811# corner case of a static ECDH suite, because the server doesn't check the curve on that
1812# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1813# different means to have the server ignoring the client's supported curve list.
1814
1815requires_config_enabled MBEDTLS_ECP_C
1816run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1817 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1818 crt_file=data_files/server5.ku-ka.crt" \
1819 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1820 1 \
1821 -c "bad certificate (EC key curve)"\
1822 -c "! Certificate verification flags"\
1823 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1824
1825requires_config_enabled MBEDTLS_ECP_C
1826run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1827 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1828 crt_file=data_files/server5.ku-ka.crt" \
1829 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1830 1 \
1831 -c "bad certificate (EC key curve)"\
1832 -c "! Certificate verification flags"\
1833 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001835run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001836 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001837 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001838 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001839 0 \
1840 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001841 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001842 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001843 -C "X509 - Certificate verification failed"
1844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001845run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001846 "$P_SRV debug_level=3 auth_mode=required" \
1847 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001848 key_file=data_files/server5.key" \
1849 1 \
1850 -S "skip write certificate request" \
1851 -C "skip parse certificate request" \
1852 -c "got a certificate request" \
1853 -C "skip write certificate" \
1854 -C "skip write certificate verify" \
1855 -S "skip parse certificate verify" \
1856 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001857 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001858 -s "! mbedtls_ssl_handshake returned" \
1859 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001860 -s "X509 - Certificate verification failed"
1861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001862run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001863 "$P_SRV debug_level=3 auth_mode=optional" \
1864 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001865 key_file=data_files/server5.key" \
1866 0 \
1867 -S "skip write certificate request" \
1868 -C "skip parse certificate request" \
1869 -c "got a certificate request" \
1870 -C "skip write certificate" \
1871 -C "skip write certificate verify" \
1872 -S "skip parse certificate verify" \
1873 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001874 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001875 -S "! mbedtls_ssl_handshake returned" \
1876 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001877 -S "X509 - Certificate verification failed"
1878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001879run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001880 "$P_SRV debug_level=3 auth_mode=none" \
1881 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001882 key_file=data_files/server5.key" \
1883 0 \
1884 -s "skip write certificate request" \
1885 -C "skip parse certificate request" \
1886 -c "got no certificate request" \
1887 -c "skip write certificate" \
1888 -c "skip write certificate verify" \
1889 -s "skip parse certificate verify" \
1890 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001891 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001892 -S "! mbedtls_ssl_handshake returned" \
1893 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001894 -S "X509 - Certificate verification failed"
1895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001896run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001897 "$P_SRV debug_level=3 auth_mode=optional" \
1898 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001899 0 \
1900 -S "skip write certificate request" \
1901 -C "skip parse certificate request" \
1902 -c "got a certificate request" \
1903 -C "skip write certificate$" \
1904 -C "got no certificate to send" \
1905 -S "SSLv3 client has no certificate" \
1906 -c "skip write certificate verify" \
1907 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001908 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001909 -S "! mbedtls_ssl_handshake returned" \
1910 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001911 -S "X509 - Certificate verification failed"
1912
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001913run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001914 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001915 "$O_CLI" \
1916 0 \
1917 -S "skip write certificate request" \
1918 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001919 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001920 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001921 -S "X509 - Certificate verification failed"
1922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001923run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001924 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001925 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001926 0 \
1927 -C "skip parse certificate request" \
1928 -c "got a certificate request" \
1929 -C "skip write certificate$" \
1930 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001931 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001932
Janos Follath542ee5d2016-03-07 15:57:05 +00001933requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001934run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001935 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001936 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001937 0 \
1938 -S "skip write certificate request" \
1939 -C "skip parse certificate request" \
1940 -c "got a certificate request" \
1941 -C "skip write certificate$" \
1942 -c "skip write certificate verify" \
1943 -c "got no certificate to send" \
1944 -s "SSLv3 client has no certificate" \
1945 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001946 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001947 -S "! mbedtls_ssl_handshake returned" \
1948 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001949 -S "X509 - Certificate verification failed"
1950
Manuel Pégourié-Gonnard591035d2017-06-26 10:45:33 +02001951run_test "Authentication: server max_int chain, client default" \
1952 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
1953 key_file=data_files/dir-maxpath/09.key" \
1954 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
1955 0 \
1956 -C "X509 - A fatal error occured"
1957
1958run_test "Authentication: server max_int+1 chain, client default" \
1959 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1960 key_file=data_files/dir-maxpath/10.key" \
1961 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
1962 1 \
1963 -c "X509 - A fatal error occured"
1964
1965run_test "Authentication: server max_int+1 chain, client optional" \
1966 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1967 key_file=data_files/dir-maxpath/10.key" \
1968 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
1969 auth_mode=optional" \
1970 1 \
1971 -c "X509 - A fatal error occured"
1972
1973run_test "Authentication: server max_int+1 chain, client none" \
1974 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1975 key_file=data_files/dir-maxpath/10.key" \
1976 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
1977 auth_mode=none" \
1978 0 \
1979 -C "X509 - A fatal error occured"
1980
1981run_test "Authentication: client max_int+1 chain, server default" \
1982 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
1983 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1984 key_file=data_files/dir-maxpath/10.key" \
1985 0 \
1986 -S "X509 - A fatal error occured"
1987
1988run_test "Authentication: client max_int+1 chain, server optional" \
1989 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
1990 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1991 key_file=data_files/dir-maxpath/10.key" \
1992 1 \
1993 -s "X509 - A fatal error occured"
1994
1995run_test "Authentication: client max_int+1 chain, server required" \
1996 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
1997 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1998 key_file=data_files/dir-maxpath/10.key" \
1999 1 \
2000 -s "X509 - A fatal error occured"
2001
2002run_test "Authentication: client max_int chain, server required" \
2003 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2004 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2005 key_file=data_files/dir-maxpath/09.key" \
2006 0 \
2007 -S "X509 - A fatal error occured"
2008
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002009# Tests for certificate selection based on SHA verson
2010
2011run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2012 "$P_SRV crt_file=data_files/server5.crt \
2013 key_file=data_files/server5.key \
2014 crt_file2=data_files/server5-sha1.crt \
2015 key_file2=data_files/server5.key" \
2016 "$P_CLI force_version=tls1_2" \
2017 0 \
2018 -c "signed using.*ECDSA with SHA256" \
2019 -C "signed using.*ECDSA with SHA1"
2020
2021run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2022 "$P_SRV crt_file=data_files/server5.crt \
2023 key_file=data_files/server5.key \
2024 crt_file2=data_files/server5-sha1.crt \
2025 key_file2=data_files/server5.key" \
2026 "$P_CLI force_version=tls1_1" \
2027 0 \
2028 -C "signed using.*ECDSA with SHA256" \
2029 -c "signed using.*ECDSA with SHA1"
2030
2031run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2032 "$P_SRV crt_file=data_files/server5.crt \
2033 key_file=data_files/server5.key \
2034 crt_file2=data_files/server5-sha1.crt \
2035 key_file2=data_files/server5.key" \
2036 "$P_CLI force_version=tls1" \
2037 0 \
2038 -C "signed using.*ECDSA with SHA256" \
2039 -c "signed using.*ECDSA with SHA1"
2040
2041run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2042 "$P_SRV crt_file=data_files/server5.crt \
2043 key_file=data_files/server5.key \
2044 crt_file2=data_files/server6.crt \
2045 key_file2=data_files/server6.key" \
2046 "$P_CLI force_version=tls1_1" \
2047 0 \
2048 -c "serial number.*09" \
2049 -c "signed using.*ECDSA with SHA256" \
2050 -C "signed using.*ECDSA with SHA1"
2051
2052run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2053 "$P_SRV crt_file=data_files/server6.crt \
2054 key_file=data_files/server6.key \
2055 crt_file2=data_files/server5.crt \
2056 key_file2=data_files/server5.key" \
2057 "$P_CLI force_version=tls1_1" \
2058 0 \
2059 -c "serial number.*0A" \
2060 -c "signed using.*ECDSA with SHA256" \
2061 -C "signed using.*ECDSA with SHA1"
2062
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002063# tests for SNI
2064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002065run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002066 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002067 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002068 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002069 0 \
2070 -S "parse ServerName extension" \
2071 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2072 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002074run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002075 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002076 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002077 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 +02002078 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002079 0 \
2080 -s "parse ServerName extension" \
2081 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2082 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002084run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002085 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002086 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002087 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 +02002088 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002089 0 \
2090 -s "parse ServerName extension" \
2091 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2092 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002094run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002095 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002096 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002097 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 +02002098 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002099 1 \
2100 -s "parse ServerName extension" \
2101 -s "ssl_sni_wrapper() returned" \
2102 -s "mbedtls_ssl_handshake returned" \
2103 -c "mbedtls_ssl_handshake returned" \
2104 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002105
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002106run_test "SNI: client auth no override: optional" \
2107 "$P_SRV debug_level=3 auth_mode=optional \
2108 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2109 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2110 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002111 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002112 -S "skip write certificate request" \
2113 -C "skip parse certificate request" \
2114 -c "got a certificate request" \
2115 -C "skip write certificate" \
2116 -C "skip write certificate verify" \
2117 -S "skip parse certificate verify"
2118
2119run_test "SNI: client auth override: none -> optional" \
2120 "$P_SRV debug_level=3 auth_mode=none \
2121 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2122 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2123 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002124 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002125 -S "skip write certificate request" \
2126 -C "skip parse certificate request" \
2127 -c "got a certificate request" \
2128 -C "skip write certificate" \
2129 -C "skip write certificate verify" \
2130 -S "skip parse certificate verify"
2131
2132run_test "SNI: client auth override: optional -> none" \
2133 "$P_SRV debug_level=3 auth_mode=optional \
2134 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2135 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2136 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002137 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002138 -s "skip write certificate request" \
2139 -C "skip parse certificate request" \
2140 -c "got no certificate request" \
2141 -c "skip write certificate" \
2142 -c "skip write certificate verify" \
2143 -s "skip parse certificate verify"
2144
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002145run_test "SNI: CA no override" \
2146 "$P_SRV debug_level=3 auth_mode=optional \
2147 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2148 ca_file=data_files/test-ca.crt \
2149 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2150 "$P_CLI debug_level=3 server_name=localhost \
2151 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2152 1 \
2153 -S "skip write certificate request" \
2154 -C "skip parse certificate request" \
2155 -c "got a certificate request" \
2156 -C "skip write certificate" \
2157 -C "skip write certificate verify" \
2158 -S "skip parse certificate verify" \
2159 -s "x509_verify_cert() returned" \
2160 -s "! The certificate is not correctly signed by the trusted CA" \
2161 -S "The certificate has been revoked (is on a CRL)"
2162
2163run_test "SNI: CA override" \
2164 "$P_SRV debug_level=3 auth_mode=optional \
2165 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2166 ca_file=data_files/test-ca.crt \
2167 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2168 "$P_CLI debug_level=3 server_name=localhost \
2169 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2170 0 \
2171 -S "skip write certificate request" \
2172 -C "skip parse certificate request" \
2173 -c "got a certificate request" \
2174 -C "skip write certificate" \
2175 -C "skip write certificate verify" \
2176 -S "skip parse certificate verify" \
2177 -S "x509_verify_cert() returned" \
2178 -S "! The certificate is not correctly signed by the trusted CA" \
2179 -S "The certificate has been revoked (is on a CRL)"
2180
2181run_test "SNI: CA override with CRL" \
2182 "$P_SRV debug_level=3 auth_mode=optional \
2183 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2184 ca_file=data_files/test-ca.crt \
2185 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2186 "$P_CLI debug_level=3 server_name=localhost \
2187 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2188 1 \
2189 -S "skip write certificate request" \
2190 -C "skip parse certificate request" \
2191 -c "got a certificate request" \
2192 -C "skip write certificate" \
2193 -C "skip write certificate verify" \
2194 -S "skip parse certificate verify" \
2195 -s "x509_verify_cert() returned" \
2196 -S "! The certificate is not correctly signed by the trusted CA" \
2197 -s "The certificate has been revoked (is on a CRL)"
2198
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002199# Tests for non-blocking I/O: exercise a variety of handshake flows
2200
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002201run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002202 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2203 "$P_CLI nbio=2 tickets=0" \
2204 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002205 -S "mbedtls_ssl_handshake returned" \
2206 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002207 -c "Read from server: .* bytes read"
2208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002209run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002210 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2211 "$P_CLI nbio=2 tickets=0" \
2212 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002213 -S "mbedtls_ssl_handshake returned" \
2214 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002215 -c "Read from server: .* bytes read"
2216
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002217run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002218 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2219 "$P_CLI nbio=2 tickets=1" \
2220 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002221 -S "mbedtls_ssl_handshake returned" \
2222 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002223 -c "Read from server: .* bytes read"
2224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002225run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002226 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2227 "$P_CLI nbio=2 tickets=1" \
2228 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002229 -S "mbedtls_ssl_handshake returned" \
2230 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002231 -c "Read from server: .* bytes read"
2232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002233run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002234 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2235 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2236 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002237 -S "mbedtls_ssl_handshake returned" \
2238 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002239 -c "Read from server: .* bytes read"
2240
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002241run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002242 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2243 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2244 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002245 -S "mbedtls_ssl_handshake returned" \
2246 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002247 -c "Read from server: .* bytes read"
2248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002249run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002250 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2251 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2252 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002253 -S "mbedtls_ssl_handshake returned" \
2254 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002255 -c "Read from server: .* bytes read"
2256
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002257# Tests for version negotiation
2258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002259run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002260 "$P_SRV" \
2261 "$P_CLI" \
2262 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002263 -S "mbedtls_ssl_handshake returned" \
2264 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002265 -s "Protocol is TLSv1.2" \
2266 -c "Protocol is TLSv1.2"
2267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002268run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002269 "$P_SRV" \
2270 "$P_CLI max_version=tls1_1" \
2271 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002272 -S "mbedtls_ssl_handshake returned" \
2273 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002274 -s "Protocol is TLSv1.1" \
2275 -c "Protocol is TLSv1.1"
2276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002277run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002278 "$P_SRV max_version=tls1_1" \
2279 "$P_CLI" \
2280 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002281 -S "mbedtls_ssl_handshake returned" \
2282 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002283 -s "Protocol is TLSv1.1" \
2284 -c "Protocol is TLSv1.1"
2285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002286run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002287 "$P_SRV max_version=tls1_1" \
2288 "$P_CLI max_version=tls1_1" \
2289 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002290 -S "mbedtls_ssl_handshake returned" \
2291 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002292 -s "Protocol is TLSv1.1" \
2293 -c "Protocol is TLSv1.1"
2294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002295run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002296 "$P_SRV min_version=tls1_1" \
2297 "$P_CLI max_version=tls1_1" \
2298 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002299 -S "mbedtls_ssl_handshake returned" \
2300 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002301 -s "Protocol is TLSv1.1" \
2302 -c "Protocol is TLSv1.1"
2303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002304run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002305 "$P_SRV max_version=tls1_1" \
2306 "$P_CLI min_version=tls1_1" \
2307 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002308 -S "mbedtls_ssl_handshake returned" \
2309 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002310 -s "Protocol is TLSv1.1" \
2311 -c "Protocol is TLSv1.1"
2312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002313run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002314 "$P_SRV max_version=tls1_1" \
2315 "$P_CLI min_version=tls1_2" \
2316 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002317 -s "mbedtls_ssl_handshake returned" \
2318 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002319 -c "SSL - Handshake protocol not within min/max boundaries"
2320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002321run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002322 "$P_SRV min_version=tls1_2" \
2323 "$P_CLI max_version=tls1_1" \
2324 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002325 -s "mbedtls_ssl_handshake returned" \
2326 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002327 -s "SSL - Handshake protocol not within min/max boundaries"
2328
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002329# Tests for ALPN extension
2330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002331run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002332 "$P_SRV debug_level=3" \
2333 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002334 0 \
2335 -C "client hello, adding alpn extension" \
2336 -S "found alpn extension" \
2337 -C "got an alert message, type: \\[2:120]" \
2338 -S "server hello, adding alpn extension" \
2339 -C "found alpn extension " \
2340 -C "Application Layer Protocol is" \
2341 -S "Application Layer Protocol is"
2342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002343run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002344 "$P_SRV debug_level=3" \
2345 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002346 0 \
2347 -c "client hello, adding alpn extension" \
2348 -s "found alpn extension" \
2349 -C "got an alert message, type: \\[2:120]" \
2350 -S "server hello, adding alpn extension" \
2351 -C "found alpn extension " \
2352 -c "Application Layer Protocol is (none)" \
2353 -S "Application Layer Protocol is"
2354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002355run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002356 "$P_SRV debug_level=3 alpn=abc,1234" \
2357 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002358 0 \
2359 -C "client hello, adding alpn extension" \
2360 -S "found alpn extension" \
2361 -C "got an alert message, type: \\[2:120]" \
2362 -S "server hello, adding alpn extension" \
2363 -C "found alpn extension " \
2364 -C "Application Layer Protocol is" \
2365 -s "Application Layer Protocol is (none)"
2366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002367run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002368 "$P_SRV debug_level=3 alpn=abc,1234" \
2369 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002370 0 \
2371 -c "client hello, adding alpn extension" \
2372 -s "found alpn extension" \
2373 -C "got an alert message, type: \\[2:120]" \
2374 -s "server hello, adding alpn extension" \
2375 -c "found alpn extension" \
2376 -c "Application Layer Protocol is abc" \
2377 -s "Application Layer Protocol is abc"
2378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002379run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002380 "$P_SRV debug_level=3 alpn=abc,1234" \
2381 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002382 0 \
2383 -c "client hello, adding alpn extension" \
2384 -s "found alpn extension" \
2385 -C "got an alert message, type: \\[2:120]" \
2386 -s "server hello, adding alpn extension" \
2387 -c "found alpn extension" \
2388 -c "Application Layer Protocol is abc" \
2389 -s "Application Layer Protocol is abc"
2390
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002391run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002392 "$P_SRV debug_level=3 alpn=abc,1234" \
2393 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002394 0 \
2395 -c "client hello, adding alpn extension" \
2396 -s "found alpn extension" \
2397 -C "got an alert message, type: \\[2:120]" \
2398 -s "server hello, adding alpn extension" \
2399 -c "found alpn extension" \
2400 -c "Application Layer Protocol is 1234" \
2401 -s "Application Layer Protocol is 1234"
2402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002403run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002404 "$P_SRV debug_level=3 alpn=abc,123" \
2405 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002406 1 \
2407 -c "client hello, adding alpn extension" \
2408 -s "found alpn extension" \
2409 -c "got an alert message, type: \\[2:120]" \
2410 -S "server hello, adding alpn extension" \
2411 -C "found alpn extension" \
2412 -C "Application Layer Protocol is 1234" \
2413 -S "Application Layer Protocol is 1234"
2414
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002415
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002416# Tests for keyUsage in leaf certificates, part 1:
2417# server-side certificate/suite selection
2418
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002419run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002420 "$P_SRV key_file=data_files/server2.key \
2421 crt_file=data_files/server2.ku-ds.crt" \
2422 "$P_CLI" \
2423 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002424 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002425
2426
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002427run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002428 "$P_SRV key_file=data_files/server2.key \
2429 crt_file=data_files/server2.ku-ke.crt" \
2430 "$P_CLI" \
2431 0 \
2432 -c "Ciphersuite is TLS-RSA-WITH-"
2433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002434run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002435 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002436 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002437 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002438 1 \
2439 -C "Ciphersuite is "
2440
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002441run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002442 "$P_SRV key_file=data_files/server5.key \
2443 crt_file=data_files/server5.ku-ds.crt" \
2444 "$P_CLI" \
2445 0 \
2446 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2447
2448
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002449run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002450 "$P_SRV key_file=data_files/server5.key \
2451 crt_file=data_files/server5.ku-ka.crt" \
2452 "$P_CLI" \
2453 0 \
2454 -c "Ciphersuite is TLS-ECDH-"
2455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002456run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002457 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002458 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002459 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002460 1 \
2461 -C "Ciphersuite is "
2462
2463# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002464# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002466run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002467 "$O_SRV -key data_files/server2.key \
2468 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002469 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002470 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2471 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002472 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002473 -C "Processing of the Certificate handshake message failed" \
2474 -c "Ciphersuite is TLS-"
2475
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002476run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002477 "$O_SRV -key data_files/server2.key \
2478 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002479 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002480 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2481 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002482 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002483 -C "Processing of the Certificate handshake message failed" \
2484 -c "Ciphersuite is TLS-"
2485
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002486run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002487 "$O_SRV -key data_files/server2.key \
2488 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002489 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002490 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2491 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002492 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002493 -C "Processing of the Certificate handshake message failed" \
2494 -c "Ciphersuite is TLS-"
2495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002496run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002497 "$O_SRV -key data_files/server2.key \
2498 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002499 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002500 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2501 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002502 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002503 -c "Processing of the Certificate handshake message failed" \
2504 -C "Ciphersuite is TLS-"
2505
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002506run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2507 "$O_SRV -key data_files/server2.key \
2508 -cert data_files/server2.ku-ke.crt" \
2509 "$P_CLI debug_level=1 auth_mode=optional \
2510 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2511 0 \
2512 -c "bad certificate (usage extensions)" \
2513 -C "Processing of the Certificate handshake message failed" \
2514 -c "Ciphersuite is TLS-" \
2515 -c "! Usage does not match the keyUsage extension"
2516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002517run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002518 "$O_SRV -key data_files/server2.key \
2519 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002520 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002521 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2522 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002523 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002524 -C "Processing of the Certificate handshake message failed" \
2525 -c "Ciphersuite is TLS-"
2526
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002527run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002528 "$O_SRV -key data_files/server2.key \
2529 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002530 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002531 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2532 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002533 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002534 -c "Processing of the Certificate handshake message failed" \
2535 -C "Ciphersuite is TLS-"
2536
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002537run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2538 "$O_SRV -key data_files/server2.key \
2539 -cert data_files/server2.ku-ds.crt" \
2540 "$P_CLI debug_level=1 auth_mode=optional \
2541 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2542 0 \
2543 -c "bad certificate (usage extensions)" \
2544 -C "Processing of the Certificate handshake message failed" \
2545 -c "Ciphersuite is TLS-" \
2546 -c "! Usage does not match the keyUsage extension"
2547
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002548# Tests for keyUsage in leaf certificates, part 3:
2549# server-side checking of client cert
2550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002551run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002552 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002553 "$O_CLI -key data_files/server2.key \
2554 -cert data_files/server2.ku-ds.crt" \
2555 0 \
2556 -S "bad certificate (usage extensions)" \
2557 -S "Processing of the Certificate handshake message failed"
2558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002559run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002560 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002561 "$O_CLI -key data_files/server2.key \
2562 -cert data_files/server2.ku-ke.crt" \
2563 0 \
2564 -s "bad certificate (usage extensions)" \
2565 -S "Processing of the Certificate handshake message failed"
2566
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002567run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002568 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002569 "$O_CLI -key data_files/server2.key \
2570 -cert data_files/server2.ku-ke.crt" \
2571 1 \
2572 -s "bad certificate (usage extensions)" \
2573 -s "Processing of the Certificate handshake message failed"
2574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002576 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002577 "$O_CLI -key data_files/server5.key \
2578 -cert data_files/server5.ku-ds.crt" \
2579 0 \
2580 -S "bad certificate (usage extensions)" \
2581 -S "Processing of the Certificate handshake message failed"
2582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002583run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002584 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002585 "$O_CLI -key data_files/server5.key \
2586 -cert data_files/server5.ku-ka.crt" \
2587 0 \
2588 -s "bad certificate (usage extensions)" \
2589 -S "Processing of the Certificate handshake message failed"
2590
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002591# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002593run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002594 "$P_SRV key_file=data_files/server5.key \
2595 crt_file=data_files/server5.eku-srv.crt" \
2596 "$P_CLI" \
2597 0
2598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002599run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002600 "$P_SRV key_file=data_files/server5.key \
2601 crt_file=data_files/server5.eku-srv.crt" \
2602 "$P_CLI" \
2603 0
2604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002605run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002606 "$P_SRV key_file=data_files/server5.key \
2607 crt_file=data_files/server5.eku-cs_any.crt" \
2608 "$P_CLI" \
2609 0
2610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002611run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002612 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002613 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002614 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002615 1
2616
2617# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002619run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002620 "$O_SRV -key data_files/server5.key \
2621 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002622 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002623 0 \
2624 -C "bad certificate (usage extensions)" \
2625 -C "Processing of the Certificate handshake message failed" \
2626 -c "Ciphersuite is TLS-"
2627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002628run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002629 "$O_SRV -key data_files/server5.key \
2630 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002631 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002632 0 \
2633 -C "bad certificate (usage extensions)" \
2634 -C "Processing of the Certificate handshake message failed" \
2635 -c "Ciphersuite is TLS-"
2636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002637run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002638 "$O_SRV -key data_files/server5.key \
2639 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002640 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002641 0 \
2642 -C "bad certificate (usage extensions)" \
2643 -C "Processing of the Certificate handshake message failed" \
2644 -c "Ciphersuite is TLS-"
2645
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002646run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002647 "$O_SRV -key data_files/server5.key \
2648 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002649 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002650 1 \
2651 -c "bad certificate (usage extensions)" \
2652 -c "Processing of the Certificate handshake message failed" \
2653 -C "Ciphersuite is TLS-"
2654
2655# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002657run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002658 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002659 "$O_CLI -key data_files/server5.key \
2660 -cert data_files/server5.eku-cli.crt" \
2661 0 \
2662 -S "bad certificate (usage extensions)" \
2663 -S "Processing of the Certificate handshake message failed"
2664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002665run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002666 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002667 "$O_CLI -key data_files/server5.key \
2668 -cert data_files/server5.eku-srv_cli.crt" \
2669 0 \
2670 -S "bad certificate (usage extensions)" \
2671 -S "Processing of the Certificate handshake message failed"
2672
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002673run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002674 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002675 "$O_CLI -key data_files/server5.key \
2676 -cert data_files/server5.eku-cs_any.crt" \
2677 0 \
2678 -S "bad certificate (usage extensions)" \
2679 -S "Processing of the Certificate handshake message failed"
2680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002681run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002682 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002683 "$O_CLI -key data_files/server5.key \
2684 -cert data_files/server5.eku-cs.crt" \
2685 0 \
2686 -s "bad certificate (usage extensions)" \
2687 -S "Processing of the Certificate handshake message failed"
2688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002689run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002690 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002691 "$O_CLI -key data_files/server5.key \
2692 -cert data_files/server5.eku-cs.crt" \
2693 1 \
2694 -s "bad certificate (usage extensions)" \
2695 -s "Processing of the Certificate handshake message failed"
2696
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002697# Tests for DHM parameters loading
2698
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002699run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002700 "$P_SRV" \
2701 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2702 debug_level=3" \
2703 0 \
2704 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker80e0d462017-10-13 16:51:54 +01002705 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002707run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002708 "$P_SRV dhm_file=data_files/dhparams.pem" \
2709 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2710 debug_level=3" \
2711 0 \
2712 -c "value of 'DHM: P ' (1024 bits)" \
2713 -c "value of 'DHM: G ' (2 bits)"
2714
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002715# Tests for DHM client-side size checking
2716
2717run_test "DHM size: server default, client default, OK" \
2718 "$P_SRV" \
2719 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2720 debug_level=1" \
2721 0 \
2722 -C "DHM prime too short:"
2723
2724run_test "DHM size: server default, client 2048, OK" \
2725 "$P_SRV" \
2726 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2727 debug_level=1 dhmlen=2048" \
2728 0 \
2729 -C "DHM prime too short:"
2730
2731run_test "DHM size: server 1024, client default, OK" \
2732 "$P_SRV dhm_file=data_files/dhparams.pem" \
2733 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2734 debug_level=1" \
2735 0 \
2736 -C "DHM prime too short:"
2737
2738run_test "DHM size: server 1000, client default, rejected" \
2739 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2740 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2741 debug_level=1" \
2742 1 \
2743 -c "DHM prime too short:"
2744
2745run_test "DHM size: server default, client 2049, rejected" \
2746 "$P_SRV" \
2747 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2748 debug_level=1 dhmlen=2049" \
2749 1 \
2750 -c "DHM prime too short:"
2751
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002752# Tests for PSK callback
2753
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002754run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002755 "$P_SRV psk=abc123 psk_identity=foo" \
2756 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2757 psk_identity=foo psk=abc123" \
2758 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002759 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002760 -S "SSL - Unknown identity received" \
2761 -S "SSL - Verification of the message MAC failed"
2762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002763run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002764 "$P_SRV" \
2765 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2766 psk_identity=foo psk=abc123" \
2767 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002768 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002769 -S "SSL - Unknown identity received" \
2770 -S "SSL - Verification of the message MAC failed"
2771
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002772run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002773 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2774 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2775 psk_identity=foo psk=abc123" \
2776 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002777 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002778 -s "SSL - Unknown identity received" \
2779 -S "SSL - Verification of the message MAC failed"
2780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002781run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002782 "$P_SRV psk_list=abc,dead,def,beef" \
2783 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2784 psk_identity=abc psk=dead" \
2785 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002786 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002787 -S "SSL - Unknown identity received" \
2788 -S "SSL - Verification of the message MAC failed"
2789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002790run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002791 "$P_SRV psk_list=abc,dead,def,beef" \
2792 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2793 psk_identity=def psk=beef" \
2794 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002795 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002796 -S "SSL - Unknown identity received" \
2797 -S "SSL - Verification of the message MAC failed"
2798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002799run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002800 "$P_SRV psk_list=abc,dead,def,beef" \
2801 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2802 psk_identity=ghi psk=beef" \
2803 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002804 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002805 -s "SSL - Unknown identity received" \
2806 -S "SSL - Verification of the message MAC failed"
2807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002808run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002809 "$P_SRV psk_list=abc,dead,def,beef" \
2810 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2811 psk_identity=abc psk=beef" \
2812 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002813 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002814 -S "SSL - Unknown identity received" \
2815 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002816
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002817# Tests for ciphersuites per version
2818
Janos Follath542ee5d2016-03-07 15:57:05 +00002819requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002820run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002821 "$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 +02002822 "$P_CLI force_version=ssl3" \
2823 0 \
2824 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002826run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002827 "$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 +01002828 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002829 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002830 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002831
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002832run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002833 "$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 +02002834 "$P_CLI force_version=tls1_1" \
2835 0 \
2836 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2837
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002838run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002839 "$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 +02002840 "$P_CLI force_version=tls1_2" \
2841 0 \
2842 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2843
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002844# Test for ClientHello without extensions
2845
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002846requires_gnutls
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002847run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002848 "$P_SRV debug_level=3" \
2849 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2850 0 \
2851 -s "dumping 'client hello extensions' (0 bytes)"
2852
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002853requires_gnutls
2854run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
2855 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
2856 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2857 0 \
2858 -s "dumping 'client hello extensions' (0 bytes)"
2859
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002860# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002861
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002862run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002863 "$P_SRV" \
2864 "$P_CLI request_size=100" \
2865 0 \
2866 -s "Read from client: 100 bytes read$"
2867
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002868run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002869 "$P_SRV" \
2870 "$P_CLI request_size=500" \
2871 0 \
2872 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002873
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002874# Tests for small packets
2875
Janos Follath542ee5d2016-03-07 15:57:05 +00002876requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002877run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002878 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002879 "$P_CLI request_size=1 force_version=ssl3 \
2880 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2881 0 \
2882 -s "Read from client: 1 bytes read"
2883
Janos Follath542ee5d2016-03-07 15:57:05 +00002884requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002885run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002886 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002887 "$P_CLI request_size=1 force_version=ssl3 \
2888 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2889 0 \
2890 -s "Read from client: 1 bytes read"
2891
2892run_test "Small packet TLS 1.0 BlockCipher" \
2893 "$P_SRV" \
2894 "$P_CLI request_size=1 force_version=tls1 \
2895 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2896 0 \
2897 -s "Read from client: 1 bytes read"
2898
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002899run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2900 "$P_SRV" \
2901 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2902 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2903 0 \
2904 -s "Read from client: 1 bytes read"
2905
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002906run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2907 "$P_SRV" \
2908 "$P_CLI request_size=1 force_version=tls1 \
2909 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2910 trunc_hmac=1" \
2911 0 \
2912 -s "Read from client: 1 bytes read"
2913
2914run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002915 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002916 "$P_CLI request_size=1 force_version=tls1 \
2917 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2918 trunc_hmac=1" \
2919 0 \
2920 -s "Read from client: 1 bytes read"
2921
2922run_test "Small packet TLS 1.1 BlockCipher" \
2923 "$P_SRV" \
2924 "$P_CLI request_size=1 force_version=tls1_1 \
2925 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2926 0 \
2927 -s "Read from client: 1 bytes read"
2928
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002929run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2930 "$P_SRV" \
2931 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2932 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2933 0 \
2934 -s "Read from client: 1 bytes read"
2935
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002936run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002937 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002938 "$P_CLI request_size=1 force_version=tls1_1 \
2939 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2940 0 \
2941 -s "Read from client: 1 bytes read"
2942
2943run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2944 "$P_SRV" \
2945 "$P_CLI request_size=1 force_version=tls1_1 \
2946 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2947 trunc_hmac=1" \
2948 0 \
2949 -s "Read from client: 1 bytes read"
2950
2951run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002952 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002953 "$P_CLI request_size=1 force_version=tls1_1 \
2954 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2955 trunc_hmac=1" \
2956 0 \
2957 -s "Read from client: 1 bytes read"
2958
2959run_test "Small packet TLS 1.2 BlockCipher" \
2960 "$P_SRV" \
2961 "$P_CLI request_size=1 force_version=tls1_2 \
2962 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2963 0 \
2964 -s "Read from client: 1 bytes read"
2965
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002966run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2967 "$P_SRV" \
2968 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2969 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2970 0 \
2971 -s "Read from client: 1 bytes read"
2972
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002973run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2974 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002975 "$P_CLI request_size=1 force_version=tls1_2 \
2976 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002977 0 \
2978 -s "Read from client: 1 bytes read"
2979
2980run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2981 "$P_SRV" \
2982 "$P_CLI request_size=1 force_version=tls1_2 \
2983 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2984 trunc_hmac=1" \
2985 0 \
2986 -s "Read from client: 1 bytes read"
2987
2988run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002989 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002990 "$P_CLI request_size=1 force_version=tls1_2 \
2991 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2992 0 \
2993 -s "Read from client: 1 bytes read"
2994
2995run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002996 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002997 "$P_CLI request_size=1 force_version=tls1_2 \
2998 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2999 trunc_hmac=1" \
3000 0 \
3001 -s "Read from client: 1 bytes read"
3002
3003run_test "Small packet TLS 1.2 AEAD" \
3004 "$P_SRV" \
3005 "$P_CLI request_size=1 force_version=tls1_2 \
3006 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3007 0 \
3008 -s "Read from client: 1 bytes read"
3009
3010run_test "Small packet TLS 1.2 AEAD shorter tag" \
3011 "$P_SRV" \
3012 "$P_CLI request_size=1 force_version=tls1_2 \
3013 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3014 0 \
3015 -s "Read from client: 1 bytes read"
3016
Janos Follathb700c462016-05-06 13:48:23 +01003017# A test for extensions in SSLv3
3018
3019requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3020run_test "SSLv3 with extensions, server side" \
3021 "$P_SRV min_version=ssl3 debug_level=3" \
3022 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3023 0 \
3024 -S "dumping 'client hello extensions'" \
3025 -S "server hello, total extension length:"
3026
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003027# Test for large packets
3028
Janos Follath542ee5d2016-03-07 15:57:05 +00003029requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003030run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003031 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003032 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003033 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3034 0 \
3035 -s "Read from client: 16384 bytes read"
3036
Janos Follath542ee5d2016-03-07 15:57:05 +00003037requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003038run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003039 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003040 "$P_CLI request_size=16384 force_version=ssl3 \
3041 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3042 0 \
3043 -s "Read from client: 16384 bytes read"
3044
3045run_test "Large packet TLS 1.0 BlockCipher" \
3046 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003047 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003048 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3049 0 \
3050 -s "Read from client: 16384 bytes read"
3051
3052run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3053 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003054 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003055 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3056 trunc_hmac=1" \
3057 0 \
3058 -s "Read from client: 16384 bytes read"
3059
3060run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003061 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003062 "$P_CLI request_size=16384 force_version=tls1 \
3063 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3064 trunc_hmac=1" \
3065 0 \
3066 -s "Read from client: 16384 bytes read"
3067
3068run_test "Large packet TLS 1.1 BlockCipher" \
3069 "$P_SRV" \
3070 "$P_CLI request_size=16384 force_version=tls1_1 \
3071 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3072 0 \
3073 -s "Read from client: 16384 bytes read"
3074
3075run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003076 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003077 "$P_CLI request_size=16384 force_version=tls1_1 \
3078 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3079 0 \
3080 -s "Read from client: 16384 bytes read"
3081
3082run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3083 "$P_SRV" \
3084 "$P_CLI request_size=16384 force_version=tls1_1 \
3085 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3086 trunc_hmac=1" \
3087 0 \
3088 -s "Read from client: 16384 bytes read"
3089
3090run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003091 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003092 "$P_CLI request_size=16384 force_version=tls1_1 \
3093 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3094 trunc_hmac=1" \
3095 0 \
3096 -s "Read from client: 16384 bytes read"
3097
3098run_test "Large packet TLS 1.2 BlockCipher" \
3099 "$P_SRV" \
3100 "$P_CLI request_size=16384 force_version=tls1_2 \
3101 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3102 0 \
3103 -s "Read from client: 16384 bytes read"
3104
3105run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3106 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003107 "$P_CLI request_size=16384 force_version=tls1_2 \
3108 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003109 0 \
3110 -s "Read from client: 16384 bytes read"
3111
3112run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3113 "$P_SRV" \
3114 "$P_CLI request_size=16384 force_version=tls1_2 \
3115 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3116 trunc_hmac=1" \
3117 0 \
3118 -s "Read from client: 16384 bytes read"
3119
3120run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003121 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003122 "$P_CLI request_size=16384 force_version=tls1_2 \
3123 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3124 0 \
3125 -s "Read from client: 16384 bytes read"
3126
3127run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003128 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003129 "$P_CLI request_size=16384 force_version=tls1_2 \
3130 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3131 trunc_hmac=1" \
3132 0 \
3133 -s "Read from client: 16384 bytes read"
3134
3135run_test "Large packet TLS 1.2 AEAD" \
3136 "$P_SRV" \
3137 "$P_CLI request_size=16384 force_version=tls1_2 \
3138 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3139 0 \
3140 -s "Read from client: 16384 bytes read"
3141
3142run_test "Large packet TLS 1.2 AEAD shorter tag" \
3143 "$P_SRV" \
3144 "$P_CLI request_size=16384 force_version=tls1_2 \
3145 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3146 0 \
3147 -s "Read from client: 16384 bytes read"
3148
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003149# Tests for DTLS HelloVerifyRequest
3150
3151run_test "DTLS cookie: enabled" \
3152 "$P_SRV dtls=1 debug_level=2" \
3153 "$P_CLI dtls=1 debug_level=2" \
3154 0 \
3155 -s "cookie verification failed" \
3156 -s "cookie verification passed" \
3157 -S "cookie verification skipped" \
3158 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003159 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003160 -S "SSL - The requested feature is not available"
3161
3162run_test "DTLS cookie: disabled" \
3163 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3164 "$P_CLI dtls=1 debug_level=2" \
3165 0 \
3166 -S "cookie verification failed" \
3167 -S "cookie verification passed" \
3168 -s "cookie verification skipped" \
3169 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003170 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003171 -S "SSL - The requested feature is not available"
3172
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003173run_test "DTLS cookie: default (failing)" \
3174 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3175 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3176 1 \
3177 -s "cookie verification failed" \
3178 -S "cookie verification passed" \
3179 -S "cookie verification skipped" \
3180 -C "received hello verify request" \
3181 -S "hello verification requested" \
3182 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003183
3184requires_ipv6
3185run_test "DTLS cookie: enabled, IPv6" \
3186 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3187 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3188 0 \
3189 -s "cookie verification failed" \
3190 -s "cookie verification passed" \
3191 -S "cookie verification skipped" \
3192 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003193 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003194 -S "SSL - The requested feature is not available"
3195
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003196run_test "DTLS cookie: enabled, nbio" \
3197 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3198 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3199 0 \
3200 -s "cookie verification failed" \
3201 -s "cookie verification passed" \
3202 -S "cookie verification skipped" \
3203 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003204 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003205 -S "SSL - The requested feature is not available"
3206
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003207# Tests for client reconnecting from the same port with DTLS
3208
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003209not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003210run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003211 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3212 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003213 0 \
3214 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003215 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003216 -S "Client initiated reconnection from same port"
3217
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003218not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003219run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003220 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3221 "$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 +02003222 0 \
3223 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003224 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003225 -s "Client initiated reconnection from same port"
3226
Paul Bakker3b224ff2016-05-13 10:33:25 +01003227not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3228run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003229 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3230 "$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 +02003231 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003232 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003233 -s "Client initiated reconnection from same port"
3234
Paul Bakker3b224ff2016-05-13 10:33:25 +01003235only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3236run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3237 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3238 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3239 0 \
3240 -S "The operation timed out" \
3241 -s "Client initiated reconnection from same port"
3242
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003243run_test "DTLS client reconnect from same port: no cookies" \
3244 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003245 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3246 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003247 -s "The operation timed out" \
3248 -S "Client initiated reconnection from same port"
3249
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003250# Tests for various cases of client authentication with DTLS
3251# (focused on handshake flows and message parsing)
3252
3253run_test "DTLS client auth: required" \
3254 "$P_SRV dtls=1 auth_mode=required" \
3255 "$P_CLI dtls=1" \
3256 0 \
3257 -s "Verifying peer X.509 certificate... ok"
3258
3259run_test "DTLS client auth: optional, client has no cert" \
3260 "$P_SRV dtls=1 auth_mode=optional" \
3261 "$P_CLI dtls=1 crt_file=none key_file=none" \
3262 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003263 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003264
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003265run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003266 "$P_SRV dtls=1 auth_mode=none" \
3267 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3268 0 \
3269 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003270 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003271
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003272run_test "DTLS wrong PSK: badmac alert" \
3273 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3274 "$P_CLI dtls=1 psk=abc124" \
3275 1 \
3276 -s "SSL - Verification of the message MAC failed" \
3277 -c "SSL - A fatal alert message was received from our peer"
3278
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003279# Tests for receiving fragmented handshake messages with DTLS
3280
3281requires_gnutls
3282run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3283 "$G_SRV -u --mtu 2048 -a" \
3284 "$P_CLI dtls=1 debug_level=2" \
3285 0 \
3286 -C "found fragmented DTLS handshake message" \
3287 -C "error"
3288
3289requires_gnutls
3290run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3291 "$G_SRV -u --mtu 512" \
3292 "$P_CLI dtls=1 debug_level=2" \
3293 0 \
3294 -c "found fragmented DTLS handshake message" \
3295 -C "error"
3296
3297requires_gnutls
3298run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3299 "$G_SRV -u --mtu 128" \
3300 "$P_CLI dtls=1 debug_level=2" \
3301 0 \
3302 -c "found fragmented DTLS handshake message" \
3303 -C "error"
3304
3305requires_gnutls
3306run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3307 "$G_SRV -u --mtu 128" \
3308 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3309 0 \
3310 -c "found fragmented DTLS handshake message" \
3311 -C "error"
3312
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003313requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003314run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3315 "$G_SRV -u --mtu 256" \
3316 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3317 0 \
3318 -c "found fragmented DTLS handshake message" \
3319 -c "client hello, adding renegotiation extension" \
3320 -c "found renegotiation extension" \
3321 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003322 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003323 -C "error" \
3324 -s "Extra-header:"
3325
3326requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003327run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3328 "$G_SRV -u --mtu 256" \
3329 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3330 0 \
3331 -c "found fragmented DTLS handshake message" \
3332 -c "client hello, adding renegotiation extension" \
3333 -c "found renegotiation extension" \
3334 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003335 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003336 -C "error" \
3337 -s "Extra-header:"
3338
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003339run_test "DTLS reassembly: no fragmentation (openssl server)" \
3340 "$O_SRV -dtls1 -mtu 2048" \
3341 "$P_CLI dtls=1 debug_level=2" \
3342 0 \
3343 -C "found fragmented DTLS handshake message" \
3344 -C "error"
3345
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003346run_test "DTLS reassembly: some fragmentation (openssl server)" \
3347 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003348 "$P_CLI dtls=1 debug_level=2" \
3349 0 \
3350 -c "found fragmented DTLS handshake message" \
3351 -C "error"
3352
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003353run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003354 "$O_SRV -dtls1 -mtu 256" \
3355 "$P_CLI dtls=1 debug_level=2" \
3356 0 \
3357 -c "found fragmented DTLS handshake message" \
3358 -C "error"
3359
3360run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3361 "$O_SRV -dtls1 -mtu 256" \
3362 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3363 0 \
3364 -c "found fragmented DTLS handshake message" \
3365 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003366
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003367# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003368
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003369not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003370run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003371 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003372 "$P_SRV dtls=1 debug_level=2" \
3373 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003374 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003375 -C "replayed record" \
3376 -S "replayed record" \
3377 -C "record from another epoch" \
3378 -S "record from another epoch" \
3379 -C "discarding invalid record" \
3380 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003381 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003382 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003383 -c "HTTP/1.0 200 OK"
3384
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003385not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003386run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003387 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003388 "$P_SRV dtls=1 debug_level=2" \
3389 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003390 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003391 -c "replayed record" \
3392 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003393 -c "discarding invalid record" \
3394 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003395 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003396 -s "Extra-header:" \
3397 -c "HTTP/1.0 200 OK"
3398
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003399run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3400 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003401 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3402 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003403 0 \
3404 -c "replayed record" \
3405 -S "replayed record" \
3406 -c "discarding invalid record" \
3407 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003408 -c "resend" \
3409 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003410 -s "Extra-header:" \
3411 -c "HTTP/1.0 200 OK"
3412
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003413run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003414 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003415 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003416 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003417 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003418 -c "discarding invalid record (mac)" \
3419 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003420 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003421 -c "HTTP/1.0 200 OK" \
3422 -S "too many records with bad MAC" \
3423 -S "Verification of the message MAC failed"
3424
3425run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3426 -p "$P_PXY bad_ad=1" \
3427 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3428 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3429 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003430 -C "discarding invalid record (mac)" \
3431 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003432 -S "Extra-header:" \
3433 -C "HTTP/1.0 200 OK" \
3434 -s "too many records with bad MAC" \
3435 -s "Verification of the message MAC failed"
3436
3437run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3438 -p "$P_PXY bad_ad=1" \
3439 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3440 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3441 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003442 -c "discarding invalid record (mac)" \
3443 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003444 -s "Extra-header:" \
3445 -c "HTTP/1.0 200 OK" \
3446 -S "too many records with bad MAC" \
3447 -S "Verification of the message MAC failed"
3448
3449run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3450 -p "$P_PXY bad_ad=1" \
3451 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3452 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3453 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003454 -c "discarding invalid record (mac)" \
3455 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003456 -s "Extra-header:" \
3457 -c "HTTP/1.0 200 OK" \
3458 -s "too many records with bad MAC" \
3459 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003460
3461run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003462 -p "$P_PXY delay_ccs=1" \
3463 "$P_SRV dtls=1 debug_level=1" \
3464 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003465 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003466 -c "record from another epoch" \
3467 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003468 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003469 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003470 -s "Extra-header:" \
3471 -c "HTTP/1.0 200 OK"
3472
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003473# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003474
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003475needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003476run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003477 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003478 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3479 psk=abc123" \
3480 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003481 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3482 0 \
3483 -s "Extra-header:" \
3484 -c "HTTP/1.0 200 OK"
3485
3486needs_more_time 2
3487run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3488 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003489 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3490 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003491 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3492 0 \
3493 -s "Extra-header:" \
3494 -c "HTTP/1.0 200 OK"
3495
3496needs_more_time 2
3497run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3498 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003499 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3500 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003501 0 \
3502 -s "Extra-header:" \
3503 -c "HTTP/1.0 200 OK"
3504
3505needs_more_time 2
3506run_test "DTLS proxy: 3d, FS, client auth" \
3507 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003508 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3509 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003510 0 \
3511 -s "Extra-header:" \
3512 -c "HTTP/1.0 200 OK"
3513
3514needs_more_time 2
3515run_test "DTLS proxy: 3d, FS, ticket" \
3516 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003517 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3518 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003519 0 \
3520 -s "Extra-header:" \
3521 -c "HTTP/1.0 200 OK"
3522
3523needs_more_time 2
3524run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3525 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003526 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3527 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003528 0 \
3529 -s "Extra-header:" \
3530 -c "HTTP/1.0 200 OK"
3531
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003532needs_more_time 2
3533run_test "DTLS proxy: 3d, max handshake, nbio" \
3534 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003535 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3536 auth_mode=required" \
3537 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003538 0 \
3539 -s "Extra-header:" \
3540 -c "HTTP/1.0 200 OK"
3541
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003542needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003543run_test "DTLS proxy: 3d, min handshake, resumption" \
3544 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3545 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3546 psk=abc123 debug_level=3" \
3547 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3548 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3549 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3550 0 \
3551 -s "a session has been resumed" \
3552 -c "a session has been resumed" \
3553 -s "Extra-header:" \
3554 -c "HTTP/1.0 200 OK"
3555
3556needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003557run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3558 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3559 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3560 psk=abc123 debug_level=3 nbio=2" \
3561 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3562 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3563 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3564 0 \
3565 -s "a session has been resumed" \
3566 -c "a session has been resumed" \
3567 -s "Extra-header:" \
3568 -c "HTTP/1.0 200 OK"
3569
3570needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003571run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003572 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003573 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3574 psk=abc123 renegotiation=1 debug_level=2" \
3575 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3576 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003577 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3578 0 \
3579 -c "=> renegotiate" \
3580 -s "=> renegotiate" \
3581 -s "Extra-header:" \
3582 -c "HTTP/1.0 200 OK"
3583
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003584needs_more_time 4
3585run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3586 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003587 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3588 psk=abc123 renegotiation=1 debug_level=2" \
3589 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3590 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003591 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3592 0 \
3593 -c "=> renegotiate" \
3594 -s "=> renegotiate" \
3595 -s "Extra-header:" \
3596 -c "HTTP/1.0 200 OK"
3597
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003598needs_more_time 4
3599run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003600 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003601 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003602 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003603 debug_level=2" \
3604 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003605 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003606 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3607 0 \
3608 -c "=> renegotiate" \
3609 -s "=> renegotiate" \
3610 -s "Extra-header:" \
3611 -c "HTTP/1.0 200 OK"
3612
3613needs_more_time 4
3614run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003615 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003616 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003617 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003618 debug_level=2 nbio=2" \
3619 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003620 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003621 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3622 0 \
3623 -c "=> renegotiate" \
3624 -s "=> renegotiate" \
3625 -s "Extra-header:" \
3626 -c "HTTP/1.0 200 OK"
3627
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003628needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003629not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003630run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003631 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3632 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003633 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003634 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003635 -c "HTTP/1.0 200 OK"
3636
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003637needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003638not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003639run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3640 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3641 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003642 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003643 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003644 -c "HTTP/1.0 200 OK"
3645
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003646needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003647not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003648run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3649 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3650 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003651 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003652 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003653 -c "HTTP/1.0 200 OK"
3654
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003655requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003656needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003657not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003658run_test "DTLS proxy: 3d, gnutls server" \
3659 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3660 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003661 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003662 0 \
3663 -s "Extra-header:" \
3664 -c "Extra-header:"
3665
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003666requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003667needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003668not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003669run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3670 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3671 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003672 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003673 0 \
3674 -s "Extra-header:" \
3675 -c "Extra-header:"
3676
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003677requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003678needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003679not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003680run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3681 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3682 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003683 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003684 0 \
3685 -s "Extra-header:" \
3686 -c "Extra-header:"
3687
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003688# Final report
3689
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003690echo "------------------------------------------------------------------------"
3691
3692if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003693 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003694else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003695 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003696fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003697PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003698echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003699
3700exit $FAILS