blob: 5a1ef5bfb798c1ad0d6d6b6c14232ffde91fcc16 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskine39e29812017-05-16 17:53:03 +020020: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020022O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010023O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020024G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010025G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskine39e29812017-05-16 17:53:03 +020026TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010027
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028TESTS=0
29FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020030SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010031
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000032CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020033
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010035FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020036EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010037
38print_usage() {
39 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010040 printf " -h|--help\tPrint this help.\n"
41 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
42 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
43 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010044}
45
46get_options() {
47 while [ $# -gt 0 ]; do
48 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010049 -f|--filter)
50 shift; FILTER=$1
51 ;;
52 -e|--exclude)
53 shift; EXCLUDE=$1
54 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010055 -m|--memcheck)
56 MEMCHECK=1
57 ;;
58 -h|--help)
59 print_usage
60 exit 0
61 ;;
62 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020063 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010064 print_usage
65 exit 1
66 ;;
67 esac
68 shift
69 done
70}
71
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010072# skip next test if the flag is not enabled in config.h
73requires_config_enabled() {
74 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
75 SKIP_NEXT="YES"
76 fi
77}
78
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +020079# skip next test if the flag is enabled in config.h
80requires_config_disabled() {
81 if grep "^#define $1" $CONFIG_H > /dev/null; then
82 SKIP_NEXT="YES"
83 fi
84}
85
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020086# skip next test if OpenSSL doesn't support FALLBACK_SCSV
87requires_openssl_with_fallback_scsv() {
88 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
89 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
90 then
91 OPENSSL_HAS_FBSCSV="YES"
92 else
93 OPENSSL_HAS_FBSCSV="NO"
94 fi
95 fi
96 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
97 SKIP_NEXT="YES"
98 fi
99}
100
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200101# skip next test if GnuTLS isn't available
102requires_gnutls() {
103 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200104 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200105 GNUTLS_AVAILABLE="YES"
106 else
107 GNUTLS_AVAILABLE="NO"
108 fi
109 fi
110 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
111 SKIP_NEXT="YES"
112 fi
113}
114
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200115# skip next test if IPv6 isn't available on this host
116requires_ipv6() {
117 if [ -z "${HAS_IPV6:-}" ]; then
118 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
119 SRV_PID=$!
120 sleep 1
121 kill $SRV_PID >/dev/null 2>&1
122 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
123 HAS_IPV6="NO"
124 else
125 HAS_IPV6="YES"
126 fi
127 rm -r $SRV_OUT
128 fi
129
130 if [ "$HAS_IPV6" = "NO" ]; then
131 SKIP_NEXT="YES"
132 fi
133}
134
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200135# skip the next test if valgrind is in use
136not_with_valgrind() {
137 if [ "$MEMCHECK" -gt 0 ]; then
138 SKIP_NEXT="YES"
139 fi
140}
141
Paul Bakker3b224ff2016-05-13 10:33:25 +0100142# skip the next test if valgrind is NOT in use
143only_with_valgrind() {
144 if [ "$MEMCHECK" -eq 0 ]; then
145 SKIP_NEXT="YES"
146 fi
147}
148
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200149# multiply the client timeout delay by the given factor for the next test
150needs_more_time() {
151 CLI_DELAY_FACTOR=$1
152}
153
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100154# print_name <name>
155print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100156 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200157 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100158 for i in `seq 1 $LEN`; do printf '.'; done
159 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100160
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200161 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100162}
163
164# fail <message>
165fail() {
166 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100167 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100168
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200169 mv $SRV_OUT o-srv-${TESTS}.log
170 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200171 if [ -n "$PXY_CMD" ]; then
172 mv $PXY_OUT o-pxy-${TESTS}.log
173 fi
174 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100175
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200176 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
177 echo " ! server output:"
178 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200179 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200180 echo " ! client output:"
181 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200182 if [ -n "$PXY_CMD" ]; then
183 echo " ! ========================================================"
184 echo " ! proxy output:"
185 cat o-pxy-${TESTS}.log
186 fi
187 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200188 fi
189
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200190 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100191}
192
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100193# is_polar <cmd_line>
194is_polar() {
195 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
196}
197
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200198# openssl s_server doesn't have -www with DTLS
199check_osrv_dtls() {
200 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
201 NEEDS_INPUT=1
202 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
203 else
204 NEEDS_INPUT=0
205 fi
206}
207
208# provide input to commands that need it
209provide_input() {
210 if [ $NEEDS_INPUT -eq 0 ]; then
211 return
212 fi
213
214 while true; do
215 echo "HTTP/1.0 200 OK"
216 sleep 1
217 done
218}
219
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100220# has_mem_err <log_file_name>
221has_mem_err() {
222 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
223 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
224 then
225 return 1 # false: does not have errors
226 else
227 return 0 # true: has errors
228 fi
229}
230
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200231# wait for server to start: two versions depending on lsof availability
232wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200233 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200234 START_TIME=$( date +%s )
235 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200236
237 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200238 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200239 while [ $DONE -eq 0 ]; do
240 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
241 then
242 DONE=1
243 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
244 echo "SERVERSTART TIMEOUT"
245 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
246 DONE=1
247 fi
248 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200249 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200250 while [ $DONE -eq 0 ]; do
251 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
252 then
253 DONE=1
254 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
255 echo "SERVERSTART TIMEOUT"
256 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
257 DONE=1
258 fi
259 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200260 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200261 else
262 sleep "$START_DELAY"
263 fi
264}
265
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200266# wait for client to terminate and set CLI_EXIT
267# must be called right after starting the client
268wait_client_done() {
269 CLI_PID=$!
270
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200271 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
272 CLI_DELAY_FACTOR=1
273
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200274 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200275 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200276
277 wait $CLI_PID
278 CLI_EXIT=$?
279
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200280 kill $DOG_PID >/dev/null 2>&1
281 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200282
283 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
284}
285
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200286# check if the given command uses dtls and sets global variable DTLS
287detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200288 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200289 DTLS=1
290 else
291 DTLS=0
292 fi
293}
294
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200295# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100296# Options: -s pattern pattern that must be present in server output
297# -c pattern pattern that must be present in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100298# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299# -S pattern pattern that must be absent in server output
300# -C pattern pattern that must be absent in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100301# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100302run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100303 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200304 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100305
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100306 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
307 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200308 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100309 return
310 fi
311
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100312 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100313
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200314 # should we skip?
315 if [ "X$SKIP_NEXT" = "XYES" ]; then
316 SKIP_NEXT="NO"
317 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200318 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200319 return
320 fi
321
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200322 # does this test use a proxy?
323 if [ "X$1" = "X-p" ]; then
324 PXY_CMD="$2"
325 shift 2
326 else
327 PXY_CMD=""
328 fi
329
330 # get commands and client output
331 SRV_CMD="$1"
332 CLI_CMD="$2"
333 CLI_EXPECT="$3"
334 shift 3
335
336 # fix client port
337 if [ -n "$PXY_CMD" ]; then
338 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
339 else
340 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
341 fi
342
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200343 # update DTLS variable
344 detect_dtls "$SRV_CMD"
345
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100346 # prepend valgrind to our commands if active
347 if [ "$MEMCHECK" -gt 0 ]; then
348 if is_polar "$SRV_CMD"; then
349 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
350 fi
351 if is_polar "$CLI_CMD"; then
352 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
353 fi
354 fi
355
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200356 TIMES_LEFT=2
357 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200358 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200359
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200360 # run the commands
361 if [ -n "$PXY_CMD" ]; then
362 echo "$PXY_CMD" > $PXY_OUT
363 $PXY_CMD >> $PXY_OUT 2>&1 &
364 PXY_PID=$!
365 # assume proxy starts faster than server
366 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200367
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200368 check_osrv_dtls
369 echo "$SRV_CMD" > $SRV_OUT
370 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
371 SRV_PID=$!
372 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200373
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200374 echo "$CLI_CMD" > $CLI_OUT
375 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
376 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100377
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200378 # terminate the server (and the proxy)
379 kill $SRV_PID
380 wait $SRV_PID
381 if [ -n "$PXY_CMD" ]; then
382 kill $PXY_PID >/dev/null 2>&1
383 wait $PXY_PID
384 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100385
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200386 # retry only on timeouts
387 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
388 printf "RETRY "
389 else
390 TIMES_LEFT=0
391 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200392 done
393
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100394 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200395 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100396 # expected client exit to incorrectly succeed in case of catastrophic
397 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100398 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200399 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100400 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100401 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100402 return
403 fi
404 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100405 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200406 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100407 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100408 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100409 return
410 fi
411 fi
412
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100413 # check server exit code
414 if [ $? != 0 ]; then
415 fail "server fail"
416 return
417 fi
418
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100419 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100420 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
421 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100422 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200423 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100424 return
425 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100427 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200428 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100429 while [ $# -gt 0 ]
430 do
431 case $1 in
432 "-s")
Janos Follath6d3e3382016-09-07 15:48:48 +0100433 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
434 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100435 return
436 fi
437 ;;
438
439 "-c")
Janos Follath6d3e3382016-09-07 15:48:48 +0100440 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
441 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100442 return
443 fi
444 ;;
445
446 "-S")
Janos Follath6d3e3382016-09-07 15:48:48 +0100447 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
448 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100449 return
450 fi
451 ;;
452
453 "-C")
Janos Follath6d3e3382016-09-07 15:48:48 +0100454 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
455 fail "pattern '$2' MUST NOT be present in the Client output"
456 return
457 fi
458 ;;
459
460 # The filtering in the following two options (-u and -U) do the following
461 # - ignore valgrind output
462 # - filter out everything but lines right after the pattern occurances
463 # - keep one of each non-unique line
464 # - count how many lines remain
465 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
466 # if there were no duplicates.
467 "-U")
468 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
469 fail "lines following pattern '$2' must be unique in Server output"
470 return
471 fi
472 ;;
473
474 "-u")
475 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
476 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100477 return
478 fi
479 ;;
480
481 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200482 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100483 exit 1
484 esac
485 shift 2
486 done
487
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100488 # check valgrind's results
489 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200490 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100491 fail "Server has memory errors"
492 return
493 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200494 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100495 fail "Client has memory errors"
496 return
497 fi
498 fi
499
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100500 # if we're here, everything is ok
501 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200502 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100503}
504
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100505cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200506 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200507 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
508 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
509 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
510 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100511 exit 1
512}
513
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100514#
515# MAIN
516#
517
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000518if cd $( dirname $0 ); then :; else
519 echo "cd $( dirname $0 ) failed" >&2
520 exit 1
521fi
522
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100523get_options "$@"
524
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100525# sanity checks, avoid an avalanche of errors
526if [ ! -x "$P_SRV" ]; then
527 echo "Command '$P_SRV' is not an executable file"
528 exit 1
529fi
530if [ ! -x "$P_CLI" ]; then
531 echo "Command '$P_CLI' is not an executable file"
532 exit 1
533fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200534if [ ! -x "$P_PXY" ]; then
535 echo "Command '$P_PXY' is not an executable file"
536 exit 1
537fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100538if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
539 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100540 exit 1
541fi
542
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200543# used by watchdog
544MAIN_PID="$$"
545
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200546# be more patient with valgrind
547if [ "$MEMCHECK" -gt 0 ]; then
548 START_DELAY=3
549 DOG_DELAY=30
550else
551 START_DELAY=1
552 DOG_DELAY=10
553fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200554CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200555
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200556# Pick a "unique" server port in the range 10000-19999, and a proxy port
557PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000558PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200559SRV_PORT="1$PORT_BASE"
560PXY_PORT="2$PORT_BASE"
561unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200562
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200563# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000564# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200565P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
566P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
567P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200568O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200569O_CLI="$O_CLI -connect localhost:+SRV_PORT"
570G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000571G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200572
Gilles Peskine35db5ba2017-05-10 10:13:59 +0200573# Allow SHA-1, because many of our test certificates use it
574P_SRV="$P_SRV allow_sha1=1"
575P_CLI="$P_CLI allow_sha1=1"
576
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200577# Also pick a unique name for intermediate files
578SRV_OUT="srv_out.$$"
579CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200580PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200581SESSION="session.$$"
582
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200583SKIP_NEXT="NO"
584
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100585trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100586
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200587# Basic test
588
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200589# Checks that:
590# - things work with all ciphersuites active (used with config-full in all.sh)
591# - the expected (highest security) parameters are selected
592# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200593run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200594 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200595 "$P_CLI" \
596 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200597 -s "Protocol is TLSv1.2" \
598 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
599 -s "client hello v3, signature_algorithm ext: 6" \
600 -s "ECDHE curve: secp521r1" \
601 -S "error" \
602 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200603
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000604run_test "Default, DTLS" \
605 "$P_SRV dtls=1" \
606 "$P_CLI dtls=1" \
607 0 \
608 -s "Protocol is DTLSv1.2" \
609 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
610
Janos Follath6d3e3382016-09-07 15:48:48 +0100611# Test for uniqueness of IVs in AEAD ciphersuites
612run_test "Unique IV in GCM" \
613 "$P_SRV exchanges=20 debug_level=4" \
614 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
615 0 \
616 -u "IV used" \
617 -U "IV used"
618
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100619# Tests for rc4 option
620
Simon Butcher6eb066e2016-05-19 22:12:18 +0100621requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100622run_test "RC4: server disabled, client enabled" \
623 "$P_SRV" \
624 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
625 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100626 -s "SSL - The server has no ciphersuites in common"
627
Simon Butcher6eb066e2016-05-19 22:12:18 +0100628requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100629run_test "RC4: server half, client enabled" \
630 "$P_SRV arc4=1" \
631 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
632 1 \
633 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100634
635run_test "RC4: server enabled, client disabled" \
636 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
637 "$P_CLI" \
638 1 \
639 -s "SSL - The server has no ciphersuites in common"
640
641run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100642 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100643 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
644 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100645 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100646 -S "SSL - The server has no ciphersuites in common"
647
Gilles Peskineae765992017-05-09 15:59:24 +0200648# Tests for SHA-1 support
649
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200650requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200651run_test "SHA-1 forbidden by default in server certificate" \
652 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
653 "$P_CLI debug_level=2 allow_sha1=0" \
654 1 \
655 -c "The certificate is signed with an unacceptable hash"
656
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200657requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
658run_test "SHA-1 forbidden by default in server certificate" \
659 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
660 "$P_CLI debug_level=2 allow_sha1=0" \
661 0
662
Gilles Peskineae765992017-05-09 15:59:24 +0200663run_test "SHA-1 explicitly allowed in server certificate" \
664 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
665 "$P_CLI allow_sha1=1" \
666 0
667
668run_test "SHA-256 allowed by default in server certificate" \
669 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
670 "$P_CLI allow_sha1=0" \
671 0
672
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200673requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200674run_test "SHA-1 forbidden by default in client certificate" \
675 "$P_SRV auth_mode=required allow_sha1=0" \
676 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
677 1 \
678 -s "The certificate is signed with an unacceptable hash"
679
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200680requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
681run_test "SHA-1 forbidden by default in client certificate" \
682 "$P_SRV auth_mode=required allow_sha1=0" \
683 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
684 0
685
Gilles Peskineae765992017-05-09 15:59:24 +0200686run_test "SHA-1 explicitly allowed in client certificate" \
687 "$P_SRV auth_mode=required allow_sha1=1" \
688 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
689 0
690
691run_test "SHA-256 allowed by default in client certificate" \
692 "$P_SRV auth_mode=required allow_sha1=0" \
693 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
694 0
695
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100696# Tests for Truncated HMAC extension
697
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100698run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200699 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100700 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100701 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000702 -s "dumping 'expected mac' (20 bytes)" \
703 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100704
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 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000710 -s "dumping 'expected mac' (20 bytes)" \
711 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100712
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 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000718 -s "dumping 'expected mac' (20 bytes)" \
719 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100720
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 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000726 -s "dumping 'expected mac' (20 bytes)" \
727 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100728
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 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000734 -S "dumping 'expected mac' (20 bytes)" \
735 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100736
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
Janos Follath5f1dd802017-10-05 12:29:42 +01001343# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1344# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1345# algorithm stronger than SHA-1 is enabled in config.h
1346run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1347 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1348 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1349 0 \
1350 -c "client hello, adding renegotiation extension" \
1351 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1352 -s "found renegotiation extension" \
1353 -s "server hello, secure renegotiation extension" \
1354 -c "found renegotiation extension" \
1355 -c "=> renegotiate" \
1356 -s "=> renegotiate" \
1357 -S "write hello request" \
1358 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1359
1360# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1361# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1362# algorithm stronger than SHA-1 is enabled in config.h
1363run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1364 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1365 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1366 0 \
1367 -c "client hello, adding renegotiation extension" \
1368 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1369 -s "found renegotiation extension" \
1370 -s "server hello, secure renegotiation extension" \
1371 -c "found renegotiation extension" \
1372 -c "=> renegotiate" \
1373 -s "=> renegotiate" \
1374 -s "write hello request" \
1375 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001377run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001378 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001379 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001380 0 \
1381 -c "client hello, adding renegotiation extension" \
1382 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1383 -s "found renegotiation extension" \
1384 -s "server hello, secure renegotiation extension" \
1385 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001386 -c "=> renegotiate" \
1387 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001388 -s "write hello request"
1389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001390run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001391 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001392 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001393 1 \
1394 -c "client hello, adding renegotiation extension" \
1395 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1396 -S "found renegotiation extension" \
1397 -s "server hello, secure renegotiation extension" \
1398 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001399 -c "=> renegotiate" \
1400 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001401 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001402 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001403 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001405run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001406 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001407 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001408 0 \
1409 -C "client hello, adding renegotiation extension" \
1410 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1411 -S "found renegotiation extension" \
1412 -s "server hello, secure renegotiation extension" \
1413 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001414 -C "=> renegotiate" \
1415 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001416 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001417 -S "SSL - An unexpected message was received from our peer" \
1418 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001420run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001421 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001422 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001423 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001424 0 \
1425 -C "client hello, adding renegotiation extension" \
1426 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1427 -S "found renegotiation extension" \
1428 -s "server hello, secure renegotiation extension" \
1429 -c "found renegotiation extension" \
1430 -C "=> renegotiate" \
1431 -S "=> renegotiate" \
1432 -s "write hello request" \
1433 -S "SSL - An unexpected message was received from our peer" \
1434 -S "failed"
1435
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001436# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001437run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001438 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001439 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001440 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001441 0 \
1442 -C "client hello, adding renegotiation extension" \
1443 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1444 -S "found renegotiation extension" \
1445 -s "server hello, secure renegotiation extension" \
1446 -c "found renegotiation extension" \
1447 -C "=> renegotiate" \
1448 -S "=> renegotiate" \
1449 -s "write hello request" \
1450 -S "SSL - An unexpected message was received from our peer" \
1451 -S "failed"
1452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001453run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001454 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001455 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001456 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001457 0 \
1458 -C "client hello, adding renegotiation extension" \
1459 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1460 -S "found renegotiation extension" \
1461 -s "server hello, secure renegotiation extension" \
1462 -c "found renegotiation extension" \
1463 -C "=> renegotiate" \
1464 -S "=> renegotiate" \
1465 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001466 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001468run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001469 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001470 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001471 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001472 0 \
1473 -c "client hello, adding renegotiation extension" \
1474 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1475 -s "found renegotiation extension" \
1476 -s "server hello, secure renegotiation extension" \
1477 -c "found renegotiation extension" \
1478 -c "=> renegotiate" \
1479 -s "=> renegotiate" \
1480 -s "write hello request" \
1481 -S "SSL - An unexpected message was received from our peer" \
1482 -S "failed"
1483
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001484run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001485 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001486 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1487 0 \
1488 -C "client hello, adding renegotiation extension" \
1489 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1490 -S "found renegotiation extension" \
1491 -s "server hello, secure renegotiation extension" \
1492 -c "found renegotiation extension" \
1493 -S "record counter limit reached: renegotiate" \
1494 -C "=> renegotiate" \
1495 -S "=> renegotiate" \
1496 -S "write hello request" \
1497 -S "SSL - An unexpected message was received from our peer" \
1498 -S "failed"
1499
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001500# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001501run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001502 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001503 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001504 0 \
1505 -c "client hello, adding renegotiation extension" \
1506 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1507 -s "found renegotiation extension" \
1508 -s "server hello, secure renegotiation extension" \
1509 -c "found renegotiation extension" \
1510 -s "record counter limit reached: renegotiate" \
1511 -c "=> renegotiate" \
1512 -s "=> renegotiate" \
1513 -s "write hello request" \
1514 -S "SSL - An unexpected message was received from our peer" \
1515 -S "failed"
1516
1517run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001518 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001519 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001520 0 \
1521 -c "client hello, adding renegotiation extension" \
1522 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1523 -s "found renegotiation extension" \
1524 -s "server hello, secure renegotiation extension" \
1525 -c "found renegotiation extension" \
1526 -s "record counter limit reached: renegotiate" \
1527 -c "=> renegotiate" \
1528 -s "=> renegotiate" \
1529 -s "write hello request" \
1530 -S "SSL - An unexpected message was received from our peer" \
1531 -S "failed"
1532
1533run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001534 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001535 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1536 0 \
1537 -C "client hello, adding renegotiation extension" \
1538 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1539 -S "found renegotiation extension" \
1540 -s "server hello, secure renegotiation extension" \
1541 -c "found renegotiation extension" \
1542 -S "record counter limit reached: renegotiate" \
1543 -C "=> renegotiate" \
1544 -S "=> renegotiate" \
1545 -S "write hello request" \
1546 -S "SSL - An unexpected message was received from our peer" \
1547 -S "failed"
1548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001549run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001550 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001551 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001552 0 \
1553 -c "client hello, adding renegotiation extension" \
1554 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1555 -s "found renegotiation extension" \
1556 -s "server hello, secure renegotiation extension" \
1557 -c "found renegotiation extension" \
1558 -c "=> renegotiate" \
1559 -s "=> renegotiate" \
1560 -S "write hello request"
1561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001562run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001563 "$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 +02001564 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001565 0 \
1566 -c "client hello, adding renegotiation extension" \
1567 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1568 -s "found renegotiation extension" \
1569 -s "server hello, secure renegotiation extension" \
1570 -c "found renegotiation extension" \
1571 -c "=> renegotiate" \
1572 -s "=> renegotiate" \
1573 -s "write hello request"
1574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001575run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001576 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001577 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001578 0 \
1579 -c "client hello, adding renegotiation extension" \
1580 -c "found renegotiation extension" \
1581 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001582 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001583 -C "error" \
1584 -c "HTTP/1.0 200 [Oo][Kk]"
1585
Paul Bakker539d9722015-02-08 16:18:35 +01001586requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001587run_test "Renegotiation: gnutls server strict, client-initiated" \
1588 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001589 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001590 0 \
1591 -c "client hello, adding renegotiation extension" \
1592 -c "found renegotiation extension" \
1593 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001594 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001595 -C "error" \
1596 -c "HTTP/1.0 200 [Oo][Kk]"
1597
Paul Bakker539d9722015-02-08 16:18:35 +01001598requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001599run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1600 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1601 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1602 1 \
1603 -c "client hello, adding renegotiation extension" \
1604 -C "found renegotiation extension" \
1605 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001606 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001607 -c "error" \
1608 -C "HTTP/1.0 200 [Oo][Kk]"
1609
Paul Bakker539d9722015-02-08 16:18:35 +01001610requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001611run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1612 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1613 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1614 allow_legacy=0" \
1615 1 \
1616 -c "client hello, adding renegotiation extension" \
1617 -C "found renegotiation extension" \
1618 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001619 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001620 -c "error" \
1621 -C "HTTP/1.0 200 [Oo][Kk]"
1622
Paul Bakker539d9722015-02-08 16:18:35 +01001623requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001624run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1625 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1626 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1627 allow_legacy=1" \
1628 0 \
1629 -c "client hello, adding renegotiation extension" \
1630 -C "found renegotiation extension" \
1631 -c "=> renegotiate" \
1632 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001633 -C "error" \
1634 -c "HTTP/1.0 200 [Oo][Kk]"
1635
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001636run_test "Renegotiation: DTLS, client-initiated" \
1637 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1638 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1639 0 \
1640 -c "client hello, adding renegotiation extension" \
1641 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1642 -s "found renegotiation extension" \
1643 -s "server hello, secure renegotiation extension" \
1644 -c "found renegotiation extension" \
1645 -c "=> renegotiate" \
1646 -s "=> renegotiate" \
1647 -S "write hello request"
1648
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001649run_test "Renegotiation: DTLS, server-initiated" \
1650 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001651 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1652 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001653 0 \
1654 -c "client hello, adding renegotiation extension" \
1655 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1656 -s "found renegotiation extension" \
1657 -s "server hello, secure renegotiation extension" \
1658 -c "found renegotiation extension" \
1659 -c "=> renegotiate" \
1660 -s "=> renegotiate" \
1661 -s "write hello request"
1662
Andres AG9b1927b2017-01-19 16:30:57 +00001663run_test "Renegotiation: DTLS, renego_period overflow" \
1664 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1665 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1666 0 \
1667 -c "client hello, adding renegotiation extension" \
1668 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1669 -s "found renegotiation extension" \
1670 -s "server hello, secure renegotiation extension" \
1671 -s "record counter limit reached: renegotiate" \
1672 -c "=> renegotiate" \
1673 -s "=> renegotiate" \
1674 -s "write hello request" \
1675
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001676requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001677run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1678 "$G_SRV -u --mtu 4096" \
1679 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1680 0 \
1681 -c "client hello, adding renegotiation extension" \
1682 -c "found renegotiation extension" \
1683 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001684 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001685 -C "error" \
1686 -s "Extra-header:"
1687
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001688# Test for the "secure renegotation" extension only (no actual renegotiation)
1689
Paul Bakker539d9722015-02-08 16:18:35 +01001690requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001691run_test "Renego ext: gnutls server strict, client default" \
1692 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1693 "$P_CLI debug_level=3" \
1694 0 \
1695 -c "found renegotiation extension" \
1696 -C "error" \
1697 -c "HTTP/1.0 200 [Oo][Kk]"
1698
Paul Bakker539d9722015-02-08 16:18:35 +01001699requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001700run_test "Renego ext: gnutls server unsafe, client default" \
1701 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1702 "$P_CLI debug_level=3" \
1703 0 \
1704 -C "found renegotiation extension" \
1705 -C "error" \
1706 -c "HTTP/1.0 200 [Oo][Kk]"
1707
Paul Bakker539d9722015-02-08 16:18:35 +01001708requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001709run_test "Renego ext: gnutls server unsafe, client break legacy" \
1710 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1711 "$P_CLI debug_level=3 allow_legacy=-1" \
1712 1 \
1713 -C "found renegotiation extension" \
1714 -c "error" \
1715 -C "HTTP/1.0 200 [Oo][Kk]"
1716
Paul Bakker539d9722015-02-08 16:18:35 +01001717requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001718run_test "Renego ext: gnutls client strict, server default" \
1719 "$P_SRV debug_level=3" \
1720 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1721 0 \
1722 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1723 -s "server hello, secure renegotiation extension"
1724
Paul Bakker539d9722015-02-08 16:18:35 +01001725requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001726run_test "Renego ext: gnutls client unsafe, server default" \
1727 "$P_SRV debug_level=3" \
1728 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1729 0 \
1730 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1731 -S "server hello, secure renegotiation extension"
1732
Paul Bakker539d9722015-02-08 16:18:35 +01001733requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001734run_test "Renego ext: gnutls client unsafe, server break legacy" \
1735 "$P_SRV debug_level=3 allow_legacy=-1" \
1736 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1737 1 \
1738 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1739 -S "server hello, secure renegotiation extension"
1740
Janos Follath365b2262016-02-17 10:11:21 +00001741# Tests for silently dropping trailing extra bytes in .der certificates
1742
1743requires_gnutls
1744run_test "DER format: no trailing bytes" \
1745 "$P_SRV crt_file=data_files/server5-der0.crt \
1746 key_file=data_files/server5.key" \
1747 "$G_CLI " \
1748 0 \
1749 -c "Handshake was completed" \
1750
1751requires_gnutls
1752run_test "DER format: with a trailing zero byte" \
1753 "$P_SRV crt_file=data_files/server5-der1a.crt \
1754 key_file=data_files/server5.key" \
1755 "$G_CLI " \
1756 0 \
1757 -c "Handshake was completed" \
1758
1759requires_gnutls
1760run_test "DER format: with a trailing random byte" \
1761 "$P_SRV crt_file=data_files/server5-der1b.crt \
1762 key_file=data_files/server5.key" \
1763 "$G_CLI " \
1764 0 \
1765 -c "Handshake was completed" \
1766
1767requires_gnutls
1768run_test "DER format: with 2 trailing random bytes" \
1769 "$P_SRV crt_file=data_files/server5-der2.crt \
1770 key_file=data_files/server5.key" \
1771 "$G_CLI " \
1772 0 \
1773 -c "Handshake was completed" \
1774
1775requires_gnutls
1776run_test "DER format: with 4 trailing random bytes" \
1777 "$P_SRV crt_file=data_files/server5-der4.crt \
1778 key_file=data_files/server5.key" \
1779 "$G_CLI " \
1780 0 \
1781 -c "Handshake was completed" \
1782
1783requires_gnutls
1784run_test "DER format: with 8 trailing random bytes" \
1785 "$P_SRV crt_file=data_files/server5-der8.crt \
1786 key_file=data_files/server5.key" \
1787 "$G_CLI " \
1788 0 \
1789 -c "Handshake was completed" \
1790
1791requires_gnutls
1792run_test "DER format: with 9 trailing random bytes" \
1793 "$P_SRV crt_file=data_files/server5-der9.crt \
1794 key_file=data_files/server5.key" \
1795 "$G_CLI " \
1796 0 \
1797 -c "Handshake was completed" \
1798
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001799# Tests for auth_mode
1800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001801run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001802 "$P_SRV crt_file=data_files/server5-badsign.crt \
1803 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001804 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001805 1 \
1806 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001807 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001808 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001809 -c "X509 - Certificate verification failed"
1810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001811run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001812 "$P_SRV crt_file=data_files/server5-badsign.crt \
1813 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001814 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001815 0 \
1816 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001817 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001818 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001819 -C "X509 - Certificate verification failed"
1820
Hanno Becker61c0c702017-05-15 16:05:15 +01001821run_test "Authentication: server goodcert, client optional, no trusted CA" \
1822 "$P_SRV" \
1823 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1824 0 \
1825 -c "x509_verify_cert() returned" \
1826 -c "! The certificate is not correctly signed by the trusted CA" \
1827 -c "! Certificate verification flags"\
1828 -C "! mbedtls_ssl_handshake returned" \
1829 -C "X509 - Certificate verification failed" \
1830 -C "SSL - No CA Chain is set, but required to operate"
1831
1832run_test "Authentication: server goodcert, client required, no trusted CA" \
1833 "$P_SRV" \
1834 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1835 1 \
1836 -c "x509_verify_cert() returned" \
1837 -c "! The certificate is not correctly signed by the trusted CA" \
1838 -c "! Certificate verification flags"\
1839 -c "! mbedtls_ssl_handshake returned" \
1840 -c "SSL - No CA Chain is set, but required to operate"
1841
1842# The purpose of the next two tests is to test the client's behaviour when receiving a server
1843# certificate with an unsupported elliptic curve. This should usually not happen because
1844# the client informs the server about the supported curves - it does, though, in the
1845# corner case of a static ECDH suite, because the server doesn't check the curve on that
1846# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1847# different means to have the server ignoring the client's supported curve list.
1848
1849requires_config_enabled MBEDTLS_ECP_C
1850run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1851 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1852 crt_file=data_files/server5.ku-ka.crt" \
1853 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1854 1 \
1855 -c "bad certificate (EC key curve)"\
1856 -c "! Certificate verification flags"\
1857 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1858
1859requires_config_enabled MBEDTLS_ECP_C
1860run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1861 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1862 crt_file=data_files/server5.ku-ka.crt" \
1863 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1864 1 \
1865 -c "bad certificate (EC key curve)"\
1866 -c "! Certificate verification flags"\
1867 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1868
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001869run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001870 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001871 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001872 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001873 0 \
1874 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001875 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001876 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001877 -C "X509 - Certificate verification failed"
1878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001879run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001880 "$P_SRV debug_level=3 auth_mode=required" \
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 1 \
1884 -S "skip write certificate request" \
1885 -C "skip parse certificate request" \
1886 -c "got a 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é-Gonnard6ea831d2015-06-22 16:50:52 +02001891 -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 badcert, 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=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001899 key_file=data_files/server5.key" \
1900 0 \
1901 -S "skip write certificate request" \
1902 -C "skip parse certificate request" \
1903 -c "got a certificate request" \
1904 -C "skip write certificate" \
1905 -C "skip write certificate verify" \
1906 -S "skip parse certificate verify" \
1907 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001908 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001909 -S "! mbedtls_ssl_handshake returned" \
1910 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001911 -S "X509 - Certificate verification failed"
1912
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001913run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001914 "$P_SRV debug_level=3 auth_mode=none" \
1915 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001916 key_file=data_files/server5.key" \
1917 0 \
1918 -s "skip write certificate request" \
1919 -C "skip parse certificate request" \
1920 -c "got no certificate request" \
1921 -c "skip write certificate" \
1922 -c "skip write certificate verify" \
1923 -s "skip parse certificate verify" \
1924 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001925 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001926 -S "! mbedtls_ssl_handshake returned" \
1927 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001928 -S "X509 - Certificate verification failed"
1929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001930run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001931 "$P_SRV debug_level=3 auth_mode=optional" \
1932 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001933 0 \
1934 -S "skip write certificate request" \
1935 -C "skip parse certificate request" \
1936 -c "got a certificate request" \
1937 -C "skip write certificate$" \
1938 -C "got no certificate to send" \
1939 -S "SSLv3 client has no certificate" \
1940 -c "skip write certificate verify" \
1941 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001942 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001943 -S "! mbedtls_ssl_handshake returned" \
1944 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001945 -S "X509 - Certificate verification failed"
1946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001947run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001948 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001949 "$O_CLI" \
1950 0 \
1951 -S "skip write certificate request" \
1952 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001953 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001954 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001955 -S "X509 - Certificate verification failed"
1956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001957run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001958 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001959 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001960 0 \
1961 -C "skip parse certificate request" \
1962 -c "got a certificate request" \
1963 -C "skip write certificate$" \
1964 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001965 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001966
Janos Follath542ee5d2016-03-07 15:57:05 +00001967requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001968run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001969 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001970 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001971 0 \
1972 -S "skip write certificate request" \
1973 -C "skip parse certificate request" \
1974 -c "got a certificate request" \
1975 -C "skip write certificate$" \
1976 -c "skip write certificate verify" \
1977 -c "got no certificate to send" \
1978 -s "SSLv3 client has no certificate" \
1979 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001980 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001981 -S "! mbedtls_ssl_handshake returned" \
1982 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001983 -S "X509 - Certificate verification failed"
1984
Manuel Pégourié-Gonnard591035d2017-06-26 10:45:33 +02001985run_test "Authentication: server max_int chain, client default" \
1986 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
1987 key_file=data_files/dir-maxpath/09.key" \
1988 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
1989 0 \
1990 -C "X509 - A fatal error occured"
1991
1992run_test "Authentication: server max_int+1 chain, client default" \
1993 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1994 key_file=data_files/dir-maxpath/10.key" \
1995 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
1996 1 \
1997 -c "X509 - A fatal error occured"
1998
1999run_test "Authentication: server max_int+1 chain, client optional" \
2000 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2001 key_file=data_files/dir-maxpath/10.key" \
2002 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2003 auth_mode=optional" \
2004 1 \
2005 -c "X509 - A fatal error occured"
2006
2007run_test "Authentication: server max_int+1 chain, client none" \
2008 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2009 key_file=data_files/dir-maxpath/10.key" \
2010 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2011 auth_mode=none" \
2012 0 \
2013 -C "X509 - A fatal error occured"
2014
2015run_test "Authentication: client max_int+1 chain, server default" \
2016 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2017 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2018 key_file=data_files/dir-maxpath/10.key" \
2019 0 \
2020 -S "X509 - A fatal error occured"
2021
2022run_test "Authentication: client max_int+1 chain, server optional" \
2023 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2024 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2025 key_file=data_files/dir-maxpath/10.key" \
2026 1 \
2027 -s "X509 - A fatal error occured"
2028
2029run_test "Authentication: client max_int+1 chain, server required" \
2030 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2031 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2032 key_file=data_files/dir-maxpath/10.key" \
2033 1 \
2034 -s "X509 - A fatal error occured"
2035
2036run_test "Authentication: client max_int chain, server required" \
2037 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2038 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2039 key_file=data_files/dir-maxpath/09.key" \
2040 0 \
2041 -S "X509 - A fatal error occured"
2042
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002043# Tests for certificate selection based on SHA verson
2044
2045run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2046 "$P_SRV crt_file=data_files/server5.crt \
2047 key_file=data_files/server5.key \
2048 crt_file2=data_files/server5-sha1.crt \
2049 key_file2=data_files/server5.key" \
2050 "$P_CLI force_version=tls1_2" \
2051 0 \
2052 -c "signed using.*ECDSA with SHA256" \
2053 -C "signed using.*ECDSA with SHA1"
2054
2055run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2056 "$P_SRV crt_file=data_files/server5.crt \
2057 key_file=data_files/server5.key \
2058 crt_file2=data_files/server5-sha1.crt \
2059 key_file2=data_files/server5.key" \
2060 "$P_CLI force_version=tls1_1" \
2061 0 \
2062 -C "signed using.*ECDSA with SHA256" \
2063 -c "signed using.*ECDSA with SHA1"
2064
2065run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2066 "$P_SRV crt_file=data_files/server5.crt \
2067 key_file=data_files/server5.key \
2068 crt_file2=data_files/server5-sha1.crt \
2069 key_file2=data_files/server5.key" \
2070 "$P_CLI force_version=tls1" \
2071 0 \
2072 -C "signed using.*ECDSA with SHA256" \
2073 -c "signed using.*ECDSA with SHA1"
2074
2075run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2076 "$P_SRV crt_file=data_files/server5.crt \
2077 key_file=data_files/server5.key \
2078 crt_file2=data_files/server6.crt \
2079 key_file2=data_files/server6.key" \
2080 "$P_CLI force_version=tls1_1" \
2081 0 \
2082 -c "serial number.*09" \
2083 -c "signed using.*ECDSA with SHA256" \
2084 -C "signed using.*ECDSA with SHA1"
2085
2086run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2087 "$P_SRV crt_file=data_files/server6.crt \
2088 key_file=data_files/server6.key \
2089 crt_file2=data_files/server5.crt \
2090 key_file2=data_files/server5.key" \
2091 "$P_CLI force_version=tls1_1" \
2092 0 \
2093 -c "serial number.*0A" \
2094 -c "signed using.*ECDSA with SHA256" \
2095 -C "signed using.*ECDSA with SHA1"
2096
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002097# tests for SNI
2098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002099run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002100 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002101 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002102 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002103 0 \
2104 -S "parse ServerName extension" \
2105 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2106 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002108run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002109 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002110 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002111 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 +02002112 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002113 0 \
2114 -s "parse ServerName extension" \
2115 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2116 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002118run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002119 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002120 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002121 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 +02002122 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002123 0 \
2124 -s "parse ServerName extension" \
2125 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2126 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002127
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002128run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002129 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002130 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002131 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 +02002132 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002133 1 \
2134 -s "parse ServerName extension" \
2135 -s "ssl_sni_wrapper() returned" \
2136 -s "mbedtls_ssl_handshake returned" \
2137 -c "mbedtls_ssl_handshake returned" \
2138 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002139
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002140run_test "SNI: client auth no override: optional" \
2141 "$P_SRV debug_level=3 auth_mode=optional \
2142 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2143 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2144 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002145 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002146 -S "skip write certificate request" \
2147 -C "skip parse certificate request" \
2148 -c "got a certificate request" \
2149 -C "skip write certificate" \
2150 -C "skip write certificate verify" \
2151 -S "skip parse certificate verify"
2152
2153run_test "SNI: client auth override: none -> optional" \
2154 "$P_SRV debug_level=3 auth_mode=none \
2155 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2156 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2157 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002158 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002159 -S "skip write certificate request" \
2160 -C "skip parse certificate request" \
2161 -c "got a certificate request" \
2162 -C "skip write certificate" \
2163 -C "skip write certificate verify" \
2164 -S "skip parse certificate verify"
2165
2166run_test "SNI: client auth override: optional -> none" \
2167 "$P_SRV debug_level=3 auth_mode=optional \
2168 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2169 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2170 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002171 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002172 -s "skip write certificate request" \
2173 -C "skip parse certificate request" \
2174 -c "got no certificate request" \
2175 -c "skip write certificate" \
2176 -c "skip write certificate verify" \
2177 -s "skip parse certificate verify"
2178
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002179run_test "SNI: CA no override" \
2180 "$P_SRV debug_level=3 auth_mode=optional \
2181 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2182 ca_file=data_files/test-ca.crt \
2183 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2184 "$P_CLI debug_level=3 server_name=localhost \
2185 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2186 1 \
2187 -S "skip write certificate request" \
2188 -C "skip parse certificate request" \
2189 -c "got a certificate request" \
2190 -C "skip write certificate" \
2191 -C "skip write certificate verify" \
2192 -S "skip parse certificate verify" \
2193 -s "x509_verify_cert() returned" \
2194 -s "! The certificate is not correctly signed by the trusted CA" \
2195 -S "The certificate has been revoked (is on a CRL)"
2196
2197run_test "SNI: CA override" \
2198 "$P_SRV debug_level=3 auth_mode=optional \
2199 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2200 ca_file=data_files/test-ca.crt \
2201 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2202 "$P_CLI debug_level=3 server_name=localhost \
2203 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2204 0 \
2205 -S "skip write certificate request" \
2206 -C "skip parse certificate request" \
2207 -c "got a certificate request" \
2208 -C "skip write certificate" \
2209 -C "skip write certificate verify" \
2210 -S "skip parse certificate verify" \
2211 -S "x509_verify_cert() returned" \
2212 -S "! The certificate is not correctly signed by the trusted CA" \
2213 -S "The certificate has been revoked (is on a CRL)"
2214
2215run_test "SNI: CA override with CRL" \
2216 "$P_SRV debug_level=3 auth_mode=optional \
2217 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2218 ca_file=data_files/test-ca.crt \
2219 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2220 "$P_CLI debug_level=3 server_name=localhost \
2221 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2222 1 \
2223 -S "skip write certificate request" \
2224 -C "skip parse certificate request" \
2225 -c "got a certificate request" \
2226 -C "skip write certificate" \
2227 -C "skip write certificate verify" \
2228 -S "skip parse certificate verify" \
2229 -s "x509_verify_cert() returned" \
2230 -S "! The certificate is not correctly signed by the trusted CA" \
2231 -s "The certificate has been revoked (is on a CRL)"
2232
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002233# Tests for non-blocking I/O: exercise a variety of handshake flows
2234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002235run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002236 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2237 "$P_CLI nbio=2 tickets=0" \
2238 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002239 -S "mbedtls_ssl_handshake returned" \
2240 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002241 -c "Read from server: .* bytes read"
2242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002243run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002244 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2245 "$P_CLI nbio=2 tickets=0" \
2246 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002247 -S "mbedtls_ssl_handshake returned" \
2248 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002249 -c "Read from server: .* bytes read"
2250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002251run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002252 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2253 "$P_CLI nbio=2 tickets=1" \
2254 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002255 -S "mbedtls_ssl_handshake returned" \
2256 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002257 -c "Read from server: .* bytes read"
2258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002259run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002260 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2261 "$P_CLI nbio=2 tickets=1" \
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é-Gonnard0b6609b2014-02-26 14:45:12 +01002265 -c "Read from server: .* bytes read"
2266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002267run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002268 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2269 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2270 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002271 -S "mbedtls_ssl_handshake returned" \
2272 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002273 -c "Read from server: .* bytes read"
2274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002275run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002276 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2277 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2278 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002279 -S "mbedtls_ssl_handshake returned" \
2280 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002281 -c "Read from server: .* bytes read"
2282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002283run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002284 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2285 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2286 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002287 -S "mbedtls_ssl_handshake returned" \
2288 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002289 -c "Read from server: .* bytes read"
2290
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002291# Tests for version negotiation
2292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002293run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002294 "$P_SRV" \
2295 "$P_CLI" \
2296 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002297 -S "mbedtls_ssl_handshake returned" \
2298 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002299 -s "Protocol is TLSv1.2" \
2300 -c "Protocol is TLSv1.2"
2301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002302run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002303 "$P_SRV" \
2304 "$P_CLI max_version=tls1_1" \
2305 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002306 -S "mbedtls_ssl_handshake returned" \
2307 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002308 -s "Protocol is TLSv1.1" \
2309 -c "Protocol is TLSv1.1"
2310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002311run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002312 "$P_SRV max_version=tls1_1" \
2313 "$P_CLI" \
2314 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002315 -S "mbedtls_ssl_handshake returned" \
2316 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002317 -s "Protocol is TLSv1.1" \
2318 -c "Protocol is TLSv1.1"
2319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002320run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002321 "$P_SRV max_version=tls1_1" \
2322 "$P_CLI max_version=tls1_1" \
2323 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002324 -S "mbedtls_ssl_handshake returned" \
2325 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002326 -s "Protocol is TLSv1.1" \
2327 -c "Protocol is TLSv1.1"
2328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002329run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002330 "$P_SRV min_version=tls1_1" \
2331 "$P_CLI max_version=tls1_1" \
2332 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002333 -S "mbedtls_ssl_handshake returned" \
2334 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002335 -s "Protocol is TLSv1.1" \
2336 -c "Protocol is TLSv1.1"
2337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002338run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002339 "$P_SRV max_version=tls1_1" \
2340 "$P_CLI min_version=tls1_1" \
2341 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002342 -S "mbedtls_ssl_handshake returned" \
2343 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002344 -s "Protocol is TLSv1.1" \
2345 -c "Protocol is TLSv1.1"
2346
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002347run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002348 "$P_SRV max_version=tls1_1" \
2349 "$P_CLI min_version=tls1_2" \
2350 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002351 -s "mbedtls_ssl_handshake returned" \
2352 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002353 -c "SSL - Handshake protocol not within min/max boundaries"
2354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002355run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002356 "$P_SRV min_version=tls1_2" \
2357 "$P_CLI max_version=tls1_1" \
2358 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002359 -s "mbedtls_ssl_handshake returned" \
2360 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002361 -s "SSL - Handshake protocol not within min/max boundaries"
2362
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002363# Tests for ALPN extension
2364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002365run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002366 "$P_SRV debug_level=3" \
2367 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002368 0 \
2369 -C "client hello, adding alpn extension" \
2370 -S "found alpn extension" \
2371 -C "got an alert message, type: \\[2:120]" \
2372 -S "server hello, adding alpn extension" \
2373 -C "found alpn extension " \
2374 -C "Application Layer Protocol is" \
2375 -S "Application Layer Protocol is"
2376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002377run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002378 "$P_SRV debug_level=3" \
2379 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002380 0 \
2381 -c "client hello, adding alpn extension" \
2382 -s "found alpn extension" \
2383 -C "got an alert message, type: \\[2:120]" \
2384 -S "server hello, adding alpn extension" \
2385 -C "found alpn extension " \
2386 -c "Application Layer Protocol is (none)" \
2387 -S "Application Layer Protocol is"
2388
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002389run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002390 "$P_SRV debug_level=3 alpn=abc,1234" \
2391 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002392 0 \
2393 -C "client hello, adding alpn extension" \
2394 -S "found alpn extension" \
2395 -C "got an alert message, type: \\[2:120]" \
2396 -S "server hello, adding alpn extension" \
2397 -C "found alpn extension " \
2398 -C "Application Layer Protocol is" \
2399 -s "Application Layer Protocol is (none)"
2400
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002401run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002402 "$P_SRV debug_level=3 alpn=abc,1234" \
2403 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002404 0 \
2405 -c "client hello, adding alpn extension" \
2406 -s "found alpn extension" \
2407 -C "got an alert message, type: \\[2:120]" \
2408 -s "server hello, adding alpn extension" \
2409 -c "found alpn extension" \
2410 -c "Application Layer Protocol is abc" \
2411 -s "Application Layer Protocol is abc"
2412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002413run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002414 "$P_SRV debug_level=3 alpn=abc,1234" \
2415 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002416 0 \
2417 -c "client hello, adding alpn extension" \
2418 -s "found alpn extension" \
2419 -C "got an alert message, type: \\[2:120]" \
2420 -s "server hello, adding alpn extension" \
2421 -c "found alpn extension" \
2422 -c "Application Layer Protocol is abc" \
2423 -s "Application Layer Protocol is abc"
2424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002425run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002426 "$P_SRV debug_level=3 alpn=abc,1234" \
2427 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002428 0 \
2429 -c "client hello, adding alpn extension" \
2430 -s "found alpn extension" \
2431 -C "got an alert message, type: \\[2:120]" \
2432 -s "server hello, adding alpn extension" \
2433 -c "found alpn extension" \
2434 -c "Application Layer Protocol is 1234" \
2435 -s "Application Layer Protocol is 1234"
2436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002437run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002438 "$P_SRV debug_level=3 alpn=abc,123" \
2439 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002440 1 \
2441 -c "client hello, adding alpn extension" \
2442 -s "found alpn extension" \
2443 -c "got an alert message, type: \\[2:120]" \
2444 -S "server hello, adding alpn extension" \
2445 -C "found alpn extension" \
2446 -C "Application Layer Protocol is 1234" \
2447 -S "Application Layer Protocol is 1234"
2448
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002449
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002450# Tests for keyUsage in leaf certificates, part 1:
2451# server-side certificate/suite selection
2452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002453run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002454 "$P_SRV key_file=data_files/server2.key \
2455 crt_file=data_files/server2.ku-ds.crt" \
2456 "$P_CLI" \
2457 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002458 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002459
2460
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002461run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002462 "$P_SRV key_file=data_files/server2.key \
2463 crt_file=data_files/server2.ku-ke.crt" \
2464 "$P_CLI" \
2465 0 \
2466 -c "Ciphersuite is TLS-RSA-WITH-"
2467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002468run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002469 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002470 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002471 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002472 1 \
2473 -C "Ciphersuite is "
2474
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002475run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002476 "$P_SRV key_file=data_files/server5.key \
2477 crt_file=data_files/server5.ku-ds.crt" \
2478 "$P_CLI" \
2479 0 \
2480 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2481
2482
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002483run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002484 "$P_SRV key_file=data_files/server5.key \
2485 crt_file=data_files/server5.ku-ka.crt" \
2486 "$P_CLI" \
2487 0 \
2488 -c "Ciphersuite is TLS-ECDH-"
2489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002490run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002491 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002492 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002493 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002494 1 \
2495 -C "Ciphersuite is "
2496
2497# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002498# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002499
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002500run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002501 "$O_SRV -key data_files/server2.key \
2502 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002503 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002504 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2505 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002506 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002507 -C "Processing of the Certificate handshake message failed" \
2508 -c "Ciphersuite is TLS-"
2509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002510run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002511 "$O_SRV -key data_files/server2.key \
2512 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002513 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002514 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2515 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002516 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002517 -C "Processing of the Certificate handshake message failed" \
2518 -c "Ciphersuite is TLS-"
2519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002520run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002521 "$O_SRV -key data_files/server2.key \
2522 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002523 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002524 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2525 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002526 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002527 -C "Processing of the Certificate handshake message failed" \
2528 -c "Ciphersuite is TLS-"
2529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002530run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002531 "$O_SRV -key data_files/server2.key \
2532 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002533 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002534 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2535 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002536 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002537 -c "Processing of the Certificate handshake message failed" \
2538 -C "Ciphersuite is TLS-"
2539
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002540run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2541 "$O_SRV -key data_files/server2.key \
2542 -cert data_files/server2.ku-ke.crt" \
2543 "$P_CLI debug_level=1 auth_mode=optional \
2544 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2545 0 \
2546 -c "bad certificate (usage extensions)" \
2547 -C "Processing of the Certificate handshake message failed" \
2548 -c "Ciphersuite is TLS-" \
2549 -c "! Usage does not match the keyUsage extension"
2550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002551run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002552 "$O_SRV -key data_files/server2.key \
2553 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002554 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002555 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2556 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002557 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002558 -C "Processing of the Certificate handshake message failed" \
2559 -c "Ciphersuite is TLS-"
2560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002561run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002562 "$O_SRV -key data_files/server2.key \
2563 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002564 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002565 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2566 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002567 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002568 -c "Processing of the Certificate handshake message failed" \
2569 -C "Ciphersuite is TLS-"
2570
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002571run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2572 "$O_SRV -key data_files/server2.key \
2573 -cert data_files/server2.ku-ds.crt" \
2574 "$P_CLI debug_level=1 auth_mode=optional \
2575 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2576 0 \
2577 -c "bad certificate (usage extensions)" \
2578 -C "Processing of the Certificate handshake message failed" \
2579 -c "Ciphersuite is TLS-" \
2580 -c "! Usage does not match the keyUsage extension"
2581
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002582# Tests for keyUsage in leaf certificates, part 3:
2583# server-side checking of client cert
2584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002585run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002586 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002587 "$O_CLI -key data_files/server2.key \
2588 -cert data_files/server2.ku-ds.crt" \
2589 0 \
2590 -S "bad certificate (usage extensions)" \
2591 -S "Processing of the Certificate handshake message failed"
2592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002593run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002594 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002595 "$O_CLI -key data_files/server2.key \
2596 -cert data_files/server2.ku-ke.crt" \
2597 0 \
2598 -s "bad certificate (usage extensions)" \
2599 -S "Processing of the Certificate handshake message failed"
2600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002601run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002602 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002603 "$O_CLI -key data_files/server2.key \
2604 -cert data_files/server2.ku-ke.crt" \
2605 1 \
2606 -s "bad certificate (usage extensions)" \
2607 -s "Processing of the Certificate handshake message failed"
2608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002609run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002610 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002611 "$O_CLI -key data_files/server5.key \
2612 -cert data_files/server5.ku-ds.crt" \
2613 0 \
2614 -S "bad certificate (usage extensions)" \
2615 -S "Processing of the Certificate handshake message failed"
2616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002617run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002618 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002619 "$O_CLI -key data_files/server5.key \
2620 -cert data_files/server5.ku-ka.crt" \
2621 0 \
2622 -s "bad certificate (usage extensions)" \
2623 -S "Processing of the Certificate handshake message failed"
2624
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002625# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002627run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002628 "$P_SRV key_file=data_files/server5.key \
2629 crt_file=data_files/server5.eku-srv.crt" \
2630 "$P_CLI" \
2631 0
2632
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002633run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002634 "$P_SRV key_file=data_files/server5.key \
2635 crt_file=data_files/server5.eku-srv.crt" \
2636 "$P_CLI" \
2637 0
2638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002639run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002640 "$P_SRV key_file=data_files/server5.key \
2641 crt_file=data_files/server5.eku-cs_any.crt" \
2642 "$P_CLI" \
2643 0
2644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002645run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002646 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002647 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002648 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002649 1
2650
2651# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002653run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002654 "$O_SRV -key data_files/server5.key \
2655 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002656 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002657 0 \
2658 -C "bad certificate (usage extensions)" \
2659 -C "Processing of the Certificate handshake message failed" \
2660 -c "Ciphersuite is TLS-"
2661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002662run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002663 "$O_SRV -key data_files/server5.key \
2664 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002665 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002666 0 \
2667 -C "bad certificate (usage extensions)" \
2668 -C "Processing of the Certificate handshake message failed" \
2669 -c "Ciphersuite is TLS-"
2670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002671run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002672 "$O_SRV -key data_files/server5.key \
2673 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002674 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002675 0 \
2676 -C "bad certificate (usage extensions)" \
2677 -C "Processing of the Certificate handshake message failed" \
2678 -c "Ciphersuite is TLS-"
2679
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002680run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002681 "$O_SRV -key data_files/server5.key \
2682 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002683 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002684 1 \
2685 -c "bad certificate (usage extensions)" \
2686 -c "Processing of the Certificate handshake message failed" \
2687 -C "Ciphersuite is TLS-"
2688
2689# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002691run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002692 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002693 "$O_CLI -key data_files/server5.key \
2694 -cert data_files/server5.eku-cli.crt" \
2695 0 \
2696 -S "bad certificate (usage extensions)" \
2697 -S "Processing of the Certificate handshake message failed"
2698
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002699run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002700 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002701 "$O_CLI -key data_files/server5.key \
2702 -cert data_files/server5.eku-srv_cli.crt" \
2703 0 \
2704 -S "bad certificate (usage extensions)" \
2705 -S "Processing of the Certificate handshake message failed"
2706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002707run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002708 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002709 "$O_CLI -key data_files/server5.key \
2710 -cert data_files/server5.eku-cs_any.crt" \
2711 0 \
2712 -S "bad certificate (usage extensions)" \
2713 -S "Processing of the Certificate handshake message failed"
2714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002715run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002716 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002717 "$O_CLI -key data_files/server5.key \
2718 -cert data_files/server5.eku-cs.crt" \
2719 0 \
2720 -s "bad certificate (usage extensions)" \
2721 -S "Processing of the Certificate handshake message failed"
2722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002723run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002724 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002725 "$O_CLI -key data_files/server5.key \
2726 -cert data_files/server5.eku-cs.crt" \
2727 1 \
2728 -s "bad certificate (usage extensions)" \
2729 -s "Processing of the Certificate handshake message failed"
2730
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002731# Tests for DHM parameters loading
2732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002733run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002734 "$P_SRV" \
2735 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2736 debug_level=3" \
2737 0 \
2738 -c "value of 'DHM: P ' (2048 bits)" \
2739 -c "value of 'DHM: G ' (2048 bits)"
2740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002741run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002742 "$P_SRV dhm_file=data_files/dhparams.pem" \
2743 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2744 debug_level=3" \
2745 0 \
2746 -c "value of 'DHM: P ' (1024 bits)" \
2747 -c "value of 'DHM: G ' (2 bits)"
2748
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002749# Tests for DHM client-side size checking
2750
2751run_test "DHM size: server default, client default, OK" \
2752 "$P_SRV" \
2753 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2754 debug_level=1" \
2755 0 \
2756 -C "DHM prime too short:"
2757
2758run_test "DHM size: server default, client 2048, OK" \
2759 "$P_SRV" \
2760 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2761 debug_level=1 dhmlen=2048" \
2762 0 \
2763 -C "DHM prime too short:"
2764
2765run_test "DHM size: server 1024, client default, OK" \
2766 "$P_SRV dhm_file=data_files/dhparams.pem" \
2767 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2768 debug_level=1" \
2769 0 \
2770 -C "DHM prime too short:"
2771
2772run_test "DHM size: server 1000, client default, rejected" \
2773 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2774 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2775 debug_level=1" \
2776 1 \
2777 -c "DHM prime too short:"
2778
2779run_test "DHM size: server default, client 2049, rejected" \
2780 "$P_SRV" \
2781 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2782 debug_level=1 dhmlen=2049" \
2783 1 \
2784 -c "DHM prime too short:"
2785
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002786# Tests for PSK callback
2787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002788run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002789 "$P_SRV psk=abc123 psk_identity=foo" \
2790 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2791 psk_identity=foo psk=abc123" \
2792 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002793 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002794 -S "SSL - Unknown identity received" \
2795 -S "SSL - Verification of the message MAC failed"
2796
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002797run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002798 "$P_SRV" \
2799 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2800 psk_identity=foo psk=abc123" \
2801 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002802 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002803 -S "SSL - Unknown identity received" \
2804 -S "SSL - Verification of the message MAC failed"
2805
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002806run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002807 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2808 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2809 psk_identity=foo psk=abc123" \
2810 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002811 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002812 -s "SSL - Unknown identity received" \
2813 -S "SSL - Verification of the message MAC failed"
2814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002815run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002816 "$P_SRV psk_list=abc,dead,def,beef" \
2817 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2818 psk_identity=abc psk=dead" \
2819 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002820 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002821 -S "SSL - Unknown identity received" \
2822 -S "SSL - Verification of the message MAC failed"
2823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002824run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002825 "$P_SRV psk_list=abc,dead,def,beef" \
2826 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2827 psk_identity=def psk=beef" \
2828 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002829 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002830 -S "SSL - Unknown identity received" \
2831 -S "SSL - Verification of the message MAC failed"
2832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002833run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002834 "$P_SRV psk_list=abc,dead,def,beef" \
2835 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2836 psk_identity=ghi psk=beef" \
2837 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002838 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002839 -s "SSL - Unknown identity received" \
2840 -S "SSL - Verification of the message MAC failed"
2841
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002842run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002843 "$P_SRV psk_list=abc,dead,def,beef" \
2844 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2845 psk_identity=abc psk=beef" \
2846 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002847 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002848 -S "SSL - Unknown identity received" \
2849 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002850
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002851# Tests for ciphersuites per version
2852
Janos Follath542ee5d2016-03-07 15:57:05 +00002853requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002854run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002855 "$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 +02002856 "$P_CLI force_version=ssl3" \
2857 0 \
2858 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002860run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002861 "$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 +01002862 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002863 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002864 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002866run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002867 "$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 +02002868 "$P_CLI force_version=tls1_1" \
2869 0 \
2870 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002872run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002873 "$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 +02002874 "$P_CLI force_version=tls1_2" \
2875 0 \
2876 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2877
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002878# Test for ClientHello without extensions
2879
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002880requires_gnutls
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002881run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002882 "$P_SRV debug_level=3" \
2883 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2884 0 \
2885 -s "dumping 'client hello extensions' (0 bytes)"
2886
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002887requires_gnutls
2888run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
2889 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
2890 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2891 0 \
2892 -s "dumping 'client hello extensions' (0 bytes)"
2893
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002894# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002895
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002896run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002897 "$P_SRV" \
2898 "$P_CLI request_size=100" \
2899 0 \
2900 -s "Read from client: 100 bytes read$"
2901
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002902run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002903 "$P_SRV" \
2904 "$P_CLI request_size=500" \
2905 0 \
2906 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002907
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002908# Tests for small packets
2909
Janos Follath542ee5d2016-03-07 15:57:05 +00002910requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002911run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002912 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002913 "$P_CLI request_size=1 force_version=ssl3 \
2914 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2915 0 \
2916 -s "Read from client: 1 bytes read"
2917
Janos Follath542ee5d2016-03-07 15:57:05 +00002918requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002919run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002920 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002921 "$P_CLI request_size=1 force_version=ssl3 \
2922 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2923 0 \
2924 -s "Read from client: 1 bytes read"
2925
2926run_test "Small packet TLS 1.0 BlockCipher" \
2927 "$P_SRV" \
2928 "$P_CLI request_size=1 force_version=tls1 \
2929 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2930 0 \
2931 -s "Read from client: 1 bytes read"
2932
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002933run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2934 "$P_SRV" \
2935 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2936 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2937 0 \
2938 -s "Read from client: 1 bytes read"
2939
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002940run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2941 "$P_SRV" \
2942 "$P_CLI request_size=1 force_version=tls1 \
2943 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2944 trunc_hmac=1" \
2945 0 \
2946 -s "Read from client: 1 bytes read"
2947
2948run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002949 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002950 "$P_CLI request_size=1 force_version=tls1 \
2951 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2952 trunc_hmac=1" \
2953 0 \
2954 -s "Read from client: 1 bytes read"
2955
2956run_test "Small packet TLS 1.1 BlockCipher" \
2957 "$P_SRV" \
2958 "$P_CLI request_size=1 force_version=tls1_1 \
2959 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2960 0 \
2961 -s "Read from client: 1 bytes read"
2962
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002963run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2964 "$P_SRV" \
2965 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2966 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2967 0 \
2968 -s "Read from client: 1 bytes read"
2969
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002970run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002971 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002972 "$P_CLI request_size=1 force_version=tls1_1 \
2973 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2974 0 \
2975 -s "Read from client: 1 bytes read"
2976
2977run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2978 "$P_SRV" \
2979 "$P_CLI request_size=1 force_version=tls1_1 \
2980 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2981 trunc_hmac=1" \
2982 0 \
2983 -s "Read from client: 1 bytes read"
2984
2985run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002986 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002987 "$P_CLI request_size=1 force_version=tls1_1 \
2988 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2989 trunc_hmac=1" \
2990 0 \
2991 -s "Read from client: 1 bytes read"
2992
2993run_test "Small packet TLS 1.2 BlockCipher" \
2994 "$P_SRV" \
2995 "$P_CLI request_size=1 force_version=tls1_2 \
2996 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2997 0 \
2998 -s "Read from client: 1 bytes read"
2999
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003000run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3001 "$P_SRV" \
3002 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3003 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3004 0 \
3005 -s "Read from client: 1 bytes read"
3006
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003007run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3008 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003009 "$P_CLI request_size=1 force_version=tls1_2 \
3010 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003011 0 \
3012 -s "Read from client: 1 bytes read"
3013
3014run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3015 "$P_SRV" \
3016 "$P_CLI request_size=1 force_version=tls1_2 \
3017 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3018 trunc_hmac=1" \
3019 0 \
3020 -s "Read from client: 1 bytes read"
3021
3022run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003023 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003024 "$P_CLI request_size=1 force_version=tls1_2 \
3025 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3026 0 \
3027 -s "Read from client: 1 bytes read"
3028
3029run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003030 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003031 "$P_CLI request_size=1 force_version=tls1_2 \
3032 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3033 trunc_hmac=1" \
3034 0 \
3035 -s "Read from client: 1 bytes read"
3036
3037run_test "Small packet TLS 1.2 AEAD" \
3038 "$P_SRV" \
3039 "$P_CLI request_size=1 force_version=tls1_2 \
3040 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3041 0 \
3042 -s "Read from client: 1 bytes read"
3043
3044run_test "Small packet TLS 1.2 AEAD shorter tag" \
3045 "$P_SRV" \
3046 "$P_CLI request_size=1 force_version=tls1_2 \
3047 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3048 0 \
3049 -s "Read from client: 1 bytes read"
3050
Janos Follathb700c462016-05-06 13:48:23 +01003051# A test for extensions in SSLv3
3052
3053requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3054run_test "SSLv3 with extensions, server side" \
3055 "$P_SRV min_version=ssl3 debug_level=3" \
3056 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3057 0 \
3058 -S "dumping 'client hello extensions'" \
3059 -S "server hello, total extension length:"
3060
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003061# Test for large packets
3062
Janos Follath542ee5d2016-03-07 15:57:05 +00003063requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003064run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003065 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003066 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003067 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3068 0 \
3069 -s "Read from client: 16384 bytes read"
3070
Janos Follath542ee5d2016-03-07 15:57:05 +00003071requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003072run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003073 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003074 "$P_CLI request_size=16384 force_version=ssl3 \
3075 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3076 0 \
3077 -s "Read from client: 16384 bytes read"
3078
3079run_test "Large packet TLS 1.0 BlockCipher" \
3080 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003081 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003082 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3083 0 \
3084 -s "Read from client: 16384 bytes read"
3085
3086run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3087 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003088 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003089 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3090 trunc_hmac=1" \
3091 0 \
3092 -s "Read from client: 16384 bytes read"
3093
3094run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003095 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003096 "$P_CLI request_size=16384 force_version=tls1 \
3097 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3098 trunc_hmac=1" \
3099 0 \
3100 -s "Read from client: 16384 bytes read"
3101
3102run_test "Large packet TLS 1.1 BlockCipher" \
3103 "$P_SRV" \
3104 "$P_CLI request_size=16384 force_version=tls1_1 \
3105 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3106 0 \
3107 -s "Read from client: 16384 bytes read"
3108
3109run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003110 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003111 "$P_CLI request_size=16384 force_version=tls1_1 \
3112 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3113 0 \
3114 -s "Read from client: 16384 bytes read"
3115
3116run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3117 "$P_SRV" \
3118 "$P_CLI request_size=16384 force_version=tls1_1 \
3119 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3120 trunc_hmac=1" \
3121 0 \
3122 -s "Read from client: 16384 bytes read"
3123
3124run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003125 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003126 "$P_CLI request_size=16384 force_version=tls1_1 \
3127 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3128 trunc_hmac=1" \
3129 0 \
3130 -s "Read from client: 16384 bytes read"
3131
3132run_test "Large packet TLS 1.2 BlockCipher" \
3133 "$P_SRV" \
3134 "$P_CLI request_size=16384 force_version=tls1_2 \
3135 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3136 0 \
3137 -s "Read from client: 16384 bytes read"
3138
3139run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3140 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003141 "$P_CLI request_size=16384 force_version=tls1_2 \
3142 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003143 0 \
3144 -s "Read from client: 16384 bytes read"
3145
3146run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3147 "$P_SRV" \
3148 "$P_CLI request_size=16384 force_version=tls1_2 \
3149 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3150 trunc_hmac=1" \
3151 0 \
3152 -s "Read from client: 16384 bytes read"
3153
3154run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003155 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003156 "$P_CLI request_size=16384 force_version=tls1_2 \
3157 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3158 0 \
3159 -s "Read from client: 16384 bytes read"
3160
3161run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003162 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003163 "$P_CLI request_size=16384 force_version=tls1_2 \
3164 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3165 trunc_hmac=1" \
3166 0 \
3167 -s "Read from client: 16384 bytes read"
3168
3169run_test "Large packet TLS 1.2 AEAD" \
3170 "$P_SRV" \
3171 "$P_CLI request_size=16384 force_version=tls1_2 \
3172 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3173 0 \
3174 -s "Read from client: 16384 bytes read"
3175
3176run_test "Large packet TLS 1.2 AEAD shorter tag" \
3177 "$P_SRV" \
3178 "$P_CLI request_size=16384 force_version=tls1_2 \
3179 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3180 0 \
3181 -s "Read from client: 16384 bytes read"
3182
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003183# Tests for DTLS HelloVerifyRequest
3184
3185run_test "DTLS cookie: enabled" \
3186 "$P_SRV dtls=1 debug_level=2" \
3187 "$P_CLI dtls=1 debug_level=2" \
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
3196run_test "DTLS cookie: disabled" \
3197 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3198 "$P_CLI dtls=1 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é-Gonnard0eb6cab2014-07-23 20:17:47 +02003205 -S "SSL - The requested feature is not available"
3206
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003207run_test "DTLS cookie: default (failing)" \
3208 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3209 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3210 1 \
3211 -s "cookie verification failed" \
3212 -S "cookie verification passed" \
3213 -S "cookie verification skipped" \
3214 -C "received hello verify request" \
3215 -S "hello verification requested" \
3216 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003217
3218requires_ipv6
3219run_test "DTLS cookie: enabled, IPv6" \
3220 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3221 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3222 0 \
3223 -s "cookie verification failed" \
3224 -s "cookie verification passed" \
3225 -S "cookie verification skipped" \
3226 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003227 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003228 -S "SSL - The requested feature is not available"
3229
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003230run_test "DTLS cookie: enabled, nbio" \
3231 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3232 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3233 0 \
3234 -s "cookie verification failed" \
3235 -s "cookie verification passed" \
3236 -S "cookie verification skipped" \
3237 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003238 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003239 -S "SSL - The requested feature is not available"
3240
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003241# Tests for client reconnecting from the same port with DTLS
3242
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003243not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003244run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003245 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3246 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003247 0 \
3248 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003249 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003250 -S "Client initiated reconnection from same port"
3251
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003252not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003253run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003254 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3255 "$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 +02003256 0 \
3257 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003258 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003259 -s "Client initiated reconnection from same port"
3260
Paul Bakker3b224ff2016-05-13 10:33:25 +01003261not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3262run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003263 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3264 "$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 +02003265 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003266 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003267 -s "Client initiated reconnection from same port"
3268
Paul Bakker3b224ff2016-05-13 10:33:25 +01003269only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3270run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3271 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3272 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3273 0 \
3274 -S "The operation timed out" \
3275 -s "Client initiated reconnection from same port"
3276
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003277run_test "DTLS client reconnect from same port: no cookies" \
3278 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003279 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3280 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003281 -s "The operation timed out" \
3282 -S "Client initiated reconnection from same port"
3283
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003284# Tests for various cases of client authentication with DTLS
3285# (focused on handshake flows and message parsing)
3286
3287run_test "DTLS client auth: required" \
3288 "$P_SRV dtls=1 auth_mode=required" \
3289 "$P_CLI dtls=1" \
3290 0 \
3291 -s "Verifying peer X.509 certificate... ok"
3292
3293run_test "DTLS client auth: optional, client has no cert" \
3294 "$P_SRV dtls=1 auth_mode=optional" \
3295 "$P_CLI dtls=1 crt_file=none key_file=none" \
3296 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003297 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003298
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003299run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003300 "$P_SRV dtls=1 auth_mode=none" \
3301 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3302 0 \
3303 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003304 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003305
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003306run_test "DTLS wrong PSK: badmac alert" \
3307 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3308 "$P_CLI dtls=1 psk=abc124" \
3309 1 \
3310 -s "SSL - Verification of the message MAC failed" \
3311 -c "SSL - A fatal alert message was received from our peer"
3312
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003313# Tests for receiving fragmented handshake messages with DTLS
3314
3315requires_gnutls
3316run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3317 "$G_SRV -u --mtu 2048 -a" \
3318 "$P_CLI dtls=1 debug_level=2" \
3319 0 \
3320 -C "found fragmented DTLS handshake message" \
3321 -C "error"
3322
3323requires_gnutls
3324run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3325 "$G_SRV -u --mtu 512" \
3326 "$P_CLI dtls=1 debug_level=2" \
3327 0 \
3328 -c "found fragmented DTLS handshake message" \
3329 -C "error"
3330
3331requires_gnutls
3332run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3333 "$G_SRV -u --mtu 128" \
3334 "$P_CLI dtls=1 debug_level=2" \
3335 0 \
3336 -c "found fragmented DTLS handshake message" \
3337 -C "error"
3338
3339requires_gnutls
3340run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3341 "$G_SRV -u --mtu 128" \
3342 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3343 0 \
3344 -c "found fragmented DTLS handshake message" \
3345 -C "error"
3346
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003347requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003348run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3349 "$G_SRV -u --mtu 256" \
3350 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3351 0 \
3352 -c "found fragmented DTLS handshake message" \
3353 -c "client hello, adding renegotiation extension" \
3354 -c "found renegotiation extension" \
3355 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003356 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003357 -C "error" \
3358 -s "Extra-header:"
3359
3360requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003361run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3362 "$G_SRV -u --mtu 256" \
3363 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3364 0 \
3365 -c "found fragmented DTLS handshake message" \
3366 -c "client hello, adding renegotiation extension" \
3367 -c "found renegotiation extension" \
3368 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003369 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003370 -C "error" \
3371 -s "Extra-header:"
3372
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003373run_test "DTLS reassembly: no fragmentation (openssl server)" \
3374 "$O_SRV -dtls1 -mtu 2048" \
3375 "$P_CLI dtls=1 debug_level=2" \
3376 0 \
3377 -C "found fragmented DTLS handshake message" \
3378 -C "error"
3379
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003380run_test "DTLS reassembly: some fragmentation (openssl server)" \
3381 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003382 "$P_CLI dtls=1 debug_level=2" \
3383 0 \
3384 -c "found fragmented DTLS handshake message" \
3385 -C "error"
3386
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003387run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003388 "$O_SRV -dtls1 -mtu 256" \
3389 "$P_CLI dtls=1 debug_level=2" \
3390 0 \
3391 -c "found fragmented DTLS handshake message" \
3392 -C "error"
3393
3394run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3395 "$O_SRV -dtls1 -mtu 256" \
3396 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3397 0 \
3398 -c "found fragmented DTLS handshake message" \
3399 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003400
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003401# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003402
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003403not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003404run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003405 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003406 "$P_SRV dtls=1 debug_level=2" \
3407 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003408 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003409 -C "replayed record" \
3410 -S "replayed record" \
3411 -C "record from another epoch" \
3412 -S "record from another epoch" \
3413 -C "discarding invalid record" \
3414 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003415 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003416 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003417 -c "HTTP/1.0 200 OK"
3418
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003419not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003420run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003421 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003422 "$P_SRV dtls=1 debug_level=2" \
3423 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003424 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003425 -c "replayed record" \
3426 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003427 -c "discarding invalid record" \
3428 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003429 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003430 -s "Extra-header:" \
3431 -c "HTTP/1.0 200 OK"
3432
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003433run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3434 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003435 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3436 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003437 0 \
3438 -c "replayed record" \
3439 -S "replayed record" \
3440 -c "discarding invalid record" \
3441 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003442 -c "resend" \
3443 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003444 -s "Extra-header:" \
3445 -c "HTTP/1.0 200 OK"
3446
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003447run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003448 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003449 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003450 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003451 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003452 -c "discarding invalid record (mac)" \
3453 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003454 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003455 -c "HTTP/1.0 200 OK" \
3456 -S "too many records with bad MAC" \
3457 -S "Verification of the message MAC failed"
3458
3459run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3460 -p "$P_PXY bad_ad=1" \
3461 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3462 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3463 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003464 -C "discarding invalid record (mac)" \
3465 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003466 -S "Extra-header:" \
3467 -C "HTTP/1.0 200 OK" \
3468 -s "too many records with bad MAC" \
3469 -s "Verification of the message MAC failed"
3470
3471run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3472 -p "$P_PXY bad_ad=1" \
3473 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3474 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3475 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003476 -c "discarding invalid record (mac)" \
3477 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003478 -s "Extra-header:" \
3479 -c "HTTP/1.0 200 OK" \
3480 -S "too many records with bad MAC" \
3481 -S "Verification of the message MAC failed"
3482
3483run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3484 -p "$P_PXY bad_ad=1" \
3485 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3486 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3487 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003488 -c "discarding invalid record (mac)" \
3489 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003490 -s "Extra-header:" \
3491 -c "HTTP/1.0 200 OK" \
3492 -s "too many records with bad MAC" \
3493 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003494
3495run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003496 -p "$P_PXY delay_ccs=1" \
3497 "$P_SRV dtls=1 debug_level=1" \
3498 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003499 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003500 -c "record from another epoch" \
3501 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003502 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003503 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003504 -s "Extra-header:" \
3505 -c "HTTP/1.0 200 OK"
3506
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003507# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003508
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003509needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003510run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003511 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003512 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3513 psk=abc123" \
3514 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003515 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3516 0 \
3517 -s "Extra-header:" \
3518 -c "HTTP/1.0 200 OK"
3519
3520needs_more_time 2
3521run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3522 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003523 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3524 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003525 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3526 0 \
3527 -s "Extra-header:" \
3528 -c "HTTP/1.0 200 OK"
3529
3530needs_more_time 2
3531run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3532 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003533 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3534 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003535 0 \
3536 -s "Extra-header:" \
3537 -c "HTTP/1.0 200 OK"
3538
3539needs_more_time 2
3540run_test "DTLS proxy: 3d, FS, client auth" \
3541 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003542 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3543 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003544 0 \
3545 -s "Extra-header:" \
3546 -c "HTTP/1.0 200 OK"
3547
3548needs_more_time 2
3549run_test "DTLS proxy: 3d, FS, ticket" \
3550 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003551 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3552 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003553 0 \
3554 -s "Extra-header:" \
3555 -c "HTTP/1.0 200 OK"
3556
3557needs_more_time 2
3558run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3559 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003560 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3561 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003562 0 \
3563 -s "Extra-header:" \
3564 -c "HTTP/1.0 200 OK"
3565
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003566needs_more_time 2
3567run_test "DTLS proxy: 3d, max handshake, nbio" \
3568 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003569 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3570 auth_mode=required" \
3571 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003572 0 \
3573 -s "Extra-header:" \
3574 -c "HTTP/1.0 200 OK"
3575
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003576needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003577run_test "DTLS proxy: 3d, min handshake, resumption" \
3578 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3579 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3580 psk=abc123 debug_level=3" \
3581 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3582 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3583 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3584 0 \
3585 -s "a session has been resumed" \
3586 -c "a session has been resumed" \
3587 -s "Extra-header:" \
3588 -c "HTTP/1.0 200 OK"
3589
3590needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003591run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3592 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3593 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3594 psk=abc123 debug_level=3 nbio=2" \
3595 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3596 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3597 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3598 0 \
3599 -s "a session has been resumed" \
3600 -c "a session has been resumed" \
3601 -s "Extra-header:" \
3602 -c "HTTP/1.0 200 OK"
3603
3604needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003605run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003606 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003607 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3608 psk=abc123 renegotiation=1 debug_level=2" \
3609 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3610 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003611 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3612 0 \
3613 -c "=> renegotiate" \
3614 -s "=> renegotiate" \
3615 -s "Extra-header:" \
3616 -c "HTTP/1.0 200 OK"
3617
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003618needs_more_time 4
3619run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3620 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003621 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3622 psk=abc123 renegotiation=1 debug_level=2" \
3623 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3624 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003625 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3626 0 \
3627 -c "=> renegotiate" \
3628 -s "=> renegotiate" \
3629 -s "Extra-header:" \
3630 -c "HTTP/1.0 200 OK"
3631
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003632needs_more_time 4
3633run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003634 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003635 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003636 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003637 debug_level=2" \
3638 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003639 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003640 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3641 0 \
3642 -c "=> renegotiate" \
3643 -s "=> renegotiate" \
3644 -s "Extra-header:" \
3645 -c "HTTP/1.0 200 OK"
3646
3647needs_more_time 4
3648run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003649 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003650 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003651 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003652 debug_level=2 nbio=2" \
3653 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003654 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003655 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3656 0 \
3657 -c "=> renegotiate" \
3658 -s "=> renegotiate" \
3659 -s "Extra-header:" \
3660 -c "HTTP/1.0 200 OK"
3661
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003662needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003663not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003664run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003665 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3666 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003667 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003668 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003669 -c "HTTP/1.0 200 OK"
3670
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003671needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003672not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003673run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3674 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3675 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003676 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003677 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003678 -c "HTTP/1.0 200 OK"
3679
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003680needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003681not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003682run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3683 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3684 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003685 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003686 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003687 -c "HTTP/1.0 200 OK"
3688
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003689requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003690needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003691not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003692run_test "DTLS proxy: 3d, gnutls server" \
3693 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3694 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003695 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003696 0 \
3697 -s "Extra-header:" \
3698 -c "Extra-header:"
3699
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003700requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003701needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003702not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003703run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3704 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3705 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003706 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003707 0 \
3708 -s "Extra-header:" \
3709 -c "Extra-header:"
3710
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003711requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003712needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003713not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003714run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3715 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3716 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003717 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003718 0 \
3719 -s "Extra-header:" \
3720 -c "Extra-header:"
3721
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003722# Final report
3723
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003724echo "------------------------------------------------------------------------"
3725
3726if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003727 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003728else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003729 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003730fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003731PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003732echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003733
3734exit $FAILS