blob: 2ca1490ee01f848b633cdd7e0757b8c716fce35e [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é-Gonnard1cbd39d2014-10-20 13:34:59 +020079# skip next test if OpenSSL doesn't support FALLBACK_SCSV
80requires_openssl_with_fallback_scsv() {
81 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
82 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
83 then
84 OPENSSL_HAS_FBSCSV="YES"
85 else
86 OPENSSL_HAS_FBSCSV="NO"
87 fi
88 fi
89 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
90 SKIP_NEXT="YES"
91 fi
92}
93
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020094# skip next test if GnuTLS isn't available
95requires_gnutls() {
96 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +020097 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020098 GNUTLS_AVAILABLE="YES"
99 else
100 GNUTLS_AVAILABLE="NO"
101 fi
102 fi
103 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
104 SKIP_NEXT="YES"
105 fi
106}
107
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200108# skip next test if IPv6 isn't available on this host
109requires_ipv6() {
110 if [ -z "${HAS_IPV6:-}" ]; then
111 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
112 SRV_PID=$!
113 sleep 1
114 kill $SRV_PID >/dev/null 2>&1
115 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
116 HAS_IPV6="NO"
117 else
118 HAS_IPV6="YES"
119 fi
120 rm -r $SRV_OUT
121 fi
122
123 if [ "$HAS_IPV6" = "NO" ]; then
124 SKIP_NEXT="YES"
125 fi
126}
127
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200128# skip the next test if valgrind is in use
129not_with_valgrind() {
130 if [ "$MEMCHECK" -gt 0 ]; then
131 SKIP_NEXT="YES"
132 fi
133}
134
Paul Bakker3b224ff2016-05-13 10:33:25 +0100135# skip the next test if valgrind is NOT in use
136only_with_valgrind() {
137 if [ "$MEMCHECK" -eq 0 ]; then
138 SKIP_NEXT="YES"
139 fi
140}
141
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200142# multiply the client timeout delay by the given factor for the next test
143needs_more_time() {
144 CLI_DELAY_FACTOR=$1
145}
146
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100147# print_name <name>
148print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100149 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200150 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100151 for i in `seq 1 $LEN`; do printf '.'; done
152 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100153
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200154 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100155}
156
157# fail <message>
158fail() {
159 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100160 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100161
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200162 mv $SRV_OUT o-srv-${TESTS}.log
163 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200164 if [ -n "$PXY_CMD" ]; then
165 mv $PXY_OUT o-pxy-${TESTS}.log
166 fi
167 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100168
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200169 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
170 echo " ! server output:"
171 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200172 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200173 echo " ! client output:"
174 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200175 if [ -n "$PXY_CMD" ]; then
176 echo " ! ========================================================"
177 echo " ! proxy output:"
178 cat o-pxy-${TESTS}.log
179 fi
180 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200181 fi
182
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200183 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100184}
185
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100186# is_polar <cmd_line>
187is_polar() {
188 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
189}
190
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200191# openssl s_server doesn't have -www with DTLS
192check_osrv_dtls() {
193 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
194 NEEDS_INPUT=1
195 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
196 else
197 NEEDS_INPUT=0
198 fi
199}
200
201# provide input to commands that need it
202provide_input() {
203 if [ $NEEDS_INPUT -eq 0 ]; then
204 return
205 fi
206
207 while true; do
208 echo "HTTP/1.0 200 OK"
209 sleep 1
210 done
211}
212
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100213# has_mem_err <log_file_name>
214has_mem_err() {
215 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
216 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
217 then
218 return 1 # false: does not have errors
219 else
220 return 0 # true: has errors
221 fi
222}
223
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200224# wait for server to start: two versions depending on lsof availability
225wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200226 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200227 START_TIME=$( date +%s )
228 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200229
230 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200231 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200232 while [ $DONE -eq 0 ]; do
233 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
234 then
235 DONE=1
236 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
237 echo "SERVERSTART TIMEOUT"
238 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
239 DONE=1
240 fi
241 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200242 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200243 while [ $DONE -eq 0 ]; do
244 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
245 then
246 DONE=1
247 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
248 echo "SERVERSTART TIMEOUT"
249 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
250 DONE=1
251 fi
252 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200253 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200254 else
255 sleep "$START_DELAY"
256 fi
257}
258
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200259# wait for client to terminate and set CLI_EXIT
260# must be called right after starting the client
261wait_client_done() {
262 CLI_PID=$!
263
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200264 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
265 CLI_DELAY_FACTOR=1
266
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200267 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200268 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200269
270 wait $CLI_PID
271 CLI_EXIT=$?
272
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200273 kill $DOG_PID >/dev/null 2>&1
274 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200275
276 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
277}
278
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200279# check if the given command uses dtls and sets global variable DTLS
280detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200281 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200282 DTLS=1
283 else
284 DTLS=0
285 fi
286}
287
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200288# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100289# Options: -s pattern pattern that must be present in server output
290# -c pattern pattern that must be present in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100291# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100292# -S pattern pattern that must be absent in server output
293# -C pattern pattern that must be absent in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100294# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100295run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100296 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200297 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100298
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100299 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
300 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200301 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100302 return
303 fi
304
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100305 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100306
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200307 # should we skip?
308 if [ "X$SKIP_NEXT" = "XYES" ]; then
309 SKIP_NEXT="NO"
310 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200311 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200312 return
313 fi
314
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200315 # does this test use a proxy?
316 if [ "X$1" = "X-p" ]; then
317 PXY_CMD="$2"
318 shift 2
319 else
320 PXY_CMD=""
321 fi
322
323 # get commands and client output
324 SRV_CMD="$1"
325 CLI_CMD="$2"
326 CLI_EXPECT="$3"
327 shift 3
328
329 # fix client port
330 if [ -n "$PXY_CMD" ]; then
331 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
332 else
333 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
334 fi
335
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200336 # update DTLS variable
337 detect_dtls "$SRV_CMD"
338
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100339 # prepend valgrind to our commands if active
340 if [ "$MEMCHECK" -gt 0 ]; then
341 if is_polar "$SRV_CMD"; then
342 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
343 fi
344 if is_polar "$CLI_CMD"; then
345 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
346 fi
347 fi
348
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200349 TIMES_LEFT=2
350 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200351 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200352
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200353 # run the commands
354 if [ -n "$PXY_CMD" ]; then
355 echo "$PXY_CMD" > $PXY_OUT
356 $PXY_CMD >> $PXY_OUT 2>&1 &
357 PXY_PID=$!
358 # assume proxy starts faster than server
359 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200360
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200361 check_osrv_dtls
362 echo "$SRV_CMD" > $SRV_OUT
363 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
364 SRV_PID=$!
365 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200366
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200367 echo "$CLI_CMD" > $CLI_OUT
368 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
369 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100370
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200371 # terminate the server (and the proxy)
372 kill $SRV_PID
373 wait $SRV_PID
374 if [ -n "$PXY_CMD" ]; then
375 kill $PXY_PID >/dev/null 2>&1
376 wait $PXY_PID
377 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100378
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200379 # retry only on timeouts
380 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
381 printf "RETRY "
382 else
383 TIMES_LEFT=0
384 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200385 done
386
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100387 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200388 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100389 # expected client exit to incorrectly succeed in case of catastrophic
390 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100391 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200392 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100393 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100394 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100395 return
396 fi
397 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100398 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200399 if grep "Performing the SSL/TLS handshake" $CLI_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
405
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100406 # check server exit code
407 if [ $? != 0 ]; then
408 fail "server fail"
409 return
410 fi
411
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100412 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100413 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
414 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100415 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200416 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100417 return
418 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100419
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100420 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200421 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100422 while [ $# -gt 0 ]
423 do
424 case $1 in
425 "-s")
Janos Follath6d3e3382016-09-07 15:48:48 +0100426 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
427 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100428 return
429 fi
430 ;;
431
432 "-c")
Janos Follath6d3e3382016-09-07 15:48:48 +0100433 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
434 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100435 return
436 fi
437 ;;
438
439 "-S")
Janos Follath6d3e3382016-09-07 15:48:48 +0100440 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
441 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100442 return
443 fi
444 ;;
445
446 "-C")
Janos Follath6d3e3382016-09-07 15:48:48 +0100447 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
448 fail "pattern '$2' MUST NOT be present in the Client output"
449 return
450 fi
451 ;;
452
453 # The filtering in the following two options (-u and -U) do the following
454 # - ignore valgrind output
455 # - filter out everything but lines right after the pattern occurances
456 # - keep one of each non-unique line
457 # - count how many lines remain
458 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
459 # if there were no duplicates.
460 "-U")
461 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
462 fail "lines following pattern '$2' must be unique in Server output"
463 return
464 fi
465 ;;
466
467 "-u")
468 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
469 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100470 return
471 fi
472 ;;
473
474 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200475 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100476 exit 1
477 esac
478 shift 2
479 done
480
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100481 # check valgrind's results
482 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200483 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100484 fail "Server has memory errors"
485 return
486 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200487 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100488 fail "Client has memory errors"
489 return
490 fi
491 fi
492
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100493 # if we're here, everything is ok
494 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200495 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100496}
497
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100498cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200499 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200500 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
501 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
502 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
503 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100504 exit 1
505}
506
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100507#
508# MAIN
509#
510
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000511if cd $( dirname $0 ); then :; else
512 echo "cd $( dirname $0 ) failed" >&2
513 exit 1
514fi
515
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100516get_options "$@"
517
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100518# sanity checks, avoid an avalanche of errors
519if [ ! -x "$P_SRV" ]; then
520 echo "Command '$P_SRV' is not an executable file"
521 exit 1
522fi
523if [ ! -x "$P_CLI" ]; then
524 echo "Command '$P_CLI' is not an executable file"
525 exit 1
526fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200527if [ ! -x "$P_PXY" ]; then
528 echo "Command '$P_PXY' is not an executable file"
529 exit 1
530fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100531if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
532 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100533 exit 1
534fi
535
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200536# used by watchdog
537MAIN_PID="$$"
538
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200539# be more patient with valgrind
540if [ "$MEMCHECK" -gt 0 ]; then
541 START_DELAY=3
542 DOG_DELAY=30
543else
544 START_DELAY=1
545 DOG_DELAY=10
546fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200547CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200548
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200549# Pick a "unique" server port in the range 10000-19999, and a proxy port
550PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000551PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200552SRV_PORT="1$PORT_BASE"
553PXY_PORT="2$PORT_BASE"
554unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200555
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200556# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000557# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200558P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
559P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
560P_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 +0200561O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200562O_CLI="$O_CLI -connect localhost:+SRV_PORT"
563G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000564G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200565
Gilles Peskine35db5ba2017-05-10 10:13:59 +0200566# Allow SHA-1, because many of our test certificates use it
567P_SRV="$P_SRV allow_sha1=1"
568P_CLI="$P_CLI allow_sha1=1"
569
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200570# Also pick a unique name for intermediate files
571SRV_OUT="srv_out.$$"
572CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200573PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200574SESSION="session.$$"
575
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200576SKIP_NEXT="NO"
577
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100578trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100579
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200580# Basic test
581
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200582# Checks that:
583# - things work with all ciphersuites active (used with config-full in all.sh)
584# - the expected (highest security) parameters are selected
585# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200586run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200587 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200588 "$P_CLI" \
589 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200590 -s "Protocol is TLSv1.2" \
591 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
592 -s "client hello v3, signature_algorithm ext: 6" \
593 -s "ECDHE curve: secp521r1" \
594 -S "error" \
595 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200596
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000597run_test "Default, DTLS" \
598 "$P_SRV dtls=1" \
599 "$P_CLI dtls=1" \
600 0 \
601 -s "Protocol is DTLSv1.2" \
602 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
603
Janos Follath6d3e3382016-09-07 15:48:48 +0100604# Test for uniqueness of IVs in AEAD ciphersuites
605run_test "Unique IV in GCM" \
606 "$P_SRV exchanges=20 debug_level=4" \
607 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
608 0 \
609 -u "IV used" \
610 -U "IV used"
611
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100612# Tests for rc4 option
613
Simon Butcher6eb066e2016-05-19 22:12:18 +0100614requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100615run_test "RC4: server disabled, client enabled" \
616 "$P_SRV" \
617 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
618 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100619 -s "SSL - The server has no ciphersuites in common"
620
Simon Butcher6eb066e2016-05-19 22:12:18 +0100621requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100622run_test "RC4: server half, client enabled" \
623 "$P_SRV arc4=1" \
624 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
625 1 \
626 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100627
628run_test "RC4: server enabled, client disabled" \
629 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
630 "$P_CLI" \
631 1 \
632 -s "SSL - The server has no ciphersuites in common"
633
634run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100635 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100636 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
637 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100638 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100639 -S "SSL - The server has no ciphersuites in common"
640
Gilles Peskineae765992017-05-09 15:59:24 +0200641# Tests for SHA-1 support
642
643run_test "SHA-1 forbidden by default in server certificate" \
644 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
645 "$P_CLI debug_level=2 allow_sha1=0" \
646 1 \
647 -c "The certificate is signed with an unacceptable hash"
648
649run_test "SHA-1 explicitly allowed in server certificate" \
650 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
651 "$P_CLI allow_sha1=1" \
652 0
653
654run_test "SHA-256 allowed by default in server certificate" \
655 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
656 "$P_CLI allow_sha1=0" \
657 0
658
659run_test "SHA-1 forbidden by default in client certificate" \
660 "$P_SRV auth_mode=required allow_sha1=0" \
661 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
662 1 \
663 -s "The certificate is signed with an unacceptable hash"
664
665run_test "SHA-1 explicitly allowed in client certificate" \
666 "$P_SRV auth_mode=required allow_sha1=1" \
667 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
668 0
669
670run_test "SHA-256 allowed by default in client certificate" \
671 "$P_SRV auth_mode=required allow_sha1=0" \
672 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
673 0
674
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100675# Tests for Truncated HMAC extension
676
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100677run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200678 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100679 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100680 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100681 -s "dumping 'computed mac' (20 bytes)" \
682 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100683
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100684run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200685 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100686 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
687 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100688 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100689 -s "dumping 'computed mac' (20 bytes)" \
690 -S "dumping 'computed mac' (10 bytes)"
691
692run_test "Truncated HMAC: client enabled, server default" \
693 "$P_SRV debug_level=4" \
694 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
695 trunc_hmac=1" \
696 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100697 -s "dumping 'computed mac' (20 bytes)" \
698 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100699
700run_test "Truncated HMAC: client enabled, server disabled" \
701 "$P_SRV debug_level=4 trunc_hmac=0" \
702 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
703 trunc_hmac=1" \
704 0 \
705 -s "dumping 'computed mac' (20 bytes)" \
706 -S "dumping 'computed mac' (10 bytes)"
707
708run_test "Truncated HMAC: client enabled, server enabled" \
709 "$P_SRV debug_level=4 trunc_hmac=1" \
710 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
711 trunc_hmac=1" \
712 0 \
713 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100714 -s "dumping 'computed mac' (10 bytes)"
715
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100716# Tests for Encrypt-then-MAC extension
717
718run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100719 "$P_SRV debug_level=3 \
720 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100721 "$P_CLI debug_level=3" \
722 0 \
723 -c "client hello, adding encrypt_then_mac extension" \
724 -s "found encrypt then mac extension" \
725 -s "server hello, adding encrypt then mac extension" \
726 -c "found encrypt_then_mac extension" \
727 -c "using encrypt then mac" \
728 -s "using encrypt then mac"
729
730run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100731 "$P_SRV debug_level=3 etm=0 \
732 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100733 "$P_CLI debug_level=3 etm=1" \
734 0 \
735 -c "client hello, adding encrypt_then_mac extension" \
736 -s "found encrypt then mac extension" \
737 -S "server hello, adding encrypt then mac extension" \
738 -C "found encrypt_then_mac extension" \
739 -C "using encrypt then mac" \
740 -S "using encrypt then mac"
741
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100742run_test "Encrypt then MAC: client enabled, aead cipher" \
743 "$P_SRV debug_level=3 etm=1 \
744 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
745 "$P_CLI debug_level=3 etm=1" \
746 0 \
747 -c "client hello, adding encrypt_then_mac extension" \
748 -s "found encrypt then mac extension" \
749 -S "server hello, adding encrypt then mac extension" \
750 -C "found encrypt_then_mac extension" \
751 -C "using encrypt then mac" \
752 -S "using encrypt then mac"
753
754run_test "Encrypt then MAC: client enabled, stream cipher" \
755 "$P_SRV debug_level=3 etm=1 \
756 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100757 "$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 +0100758 0 \
759 -c "client hello, adding encrypt_then_mac extension" \
760 -s "found encrypt then mac extension" \
761 -S "server hello, adding encrypt then mac extension" \
762 -C "found encrypt_then_mac extension" \
763 -C "using encrypt then mac" \
764 -S "using encrypt then mac"
765
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100766run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100767 "$P_SRV debug_level=3 etm=1 \
768 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100769 "$P_CLI debug_level=3 etm=0" \
770 0 \
771 -C "client hello, adding encrypt_then_mac extension" \
772 -S "found encrypt then mac extension" \
773 -S "server hello, adding encrypt then mac extension" \
774 -C "found encrypt_then_mac extension" \
775 -C "using encrypt then mac" \
776 -S "using encrypt then mac"
777
Janos Follath542ee5d2016-03-07 15:57:05 +0000778requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100779run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100780 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100781 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100782 "$P_CLI debug_level=3 force_version=ssl3" \
783 0 \
784 -C "client hello, adding encrypt_then_mac extension" \
785 -S "found encrypt then mac extension" \
786 -S "server hello, adding encrypt then mac extension" \
787 -C "found encrypt_then_mac extension" \
788 -C "using encrypt then mac" \
789 -S "using encrypt then mac"
790
Janos Follath542ee5d2016-03-07 15:57:05 +0000791requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100792run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100793 "$P_SRV debug_level=3 force_version=ssl3 \
794 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100795 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100796 0 \
797 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100798 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100799 -S "server hello, adding encrypt then mac extension" \
800 -C "found encrypt_then_mac extension" \
801 -C "using encrypt then mac" \
802 -S "using encrypt then mac"
803
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200804# Tests for Extended Master Secret extension
805
806run_test "Extended Master Secret: default" \
807 "$P_SRV debug_level=3" \
808 "$P_CLI debug_level=3" \
809 0 \
810 -c "client hello, adding extended_master_secret extension" \
811 -s "found extended master secret extension" \
812 -s "server hello, adding extended master secret extension" \
813 -c "found extended_master_secret extension" \
814 -c "using extended master secret" \
815 -s "using extended master secret"
816
817run_test "Extended Master Secret: client enabled, server disabled" \
818 "$P_SRV debug_level=3 extended_ms=0" \
819 "$P_CLI debug_level=3 extended_ms=1" \
820 0 \
821 -c "client hello, adding extended_master_secret extension" \
822 -s "found extended master secret extension" \
823 -S "server hello, adding extended master secret extension" \
824 -C "found extended_master_secret extension" \
825 -C "using extended master secret" \
826 -S "using extended master secret"
827
828run_test "Extended Master Secret: client disabled, server enabled" \
829 "$P_SRV debug_level=3 extended_ms=1" \
830 "$P_CLI debug_level=3 extended_ms=0" \
831 0 \
832 -C "client hello, adding extended_master_secret extension" \
833 -S "found extended master secret extension" \
834 -S "server hello, adding extended master secret extension" \
835 -C "found extended_master_secret extension" \
836 -C "using extended master secret" \
837 -S "using extended master secret"
838
Janos Follath542ee5d2016-03-07 15:57:05 +0000839requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200840run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100841 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200842 "$P_CLI debug_level=3 force_version=ssl3" \
843 0 \
844 -C "client hello, adding extended_master_secret extension" \
845 -S "found extended master secret extension" \
846 -S "server hello, adding extended master secret extension" \
847 -C "found extended_master_secret extension" \
848 -C "using extended master secret" \
849 -S "using extended master secret"
850
Janos Follath542ee5d2016-03-07 15:57:05 +0000851requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200852run_test "Extended Master Secret: client enabled, server SSLv3" \
853 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100854 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200855 0 \
856 -c "client hello, adding extended_master_secret extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100857 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200858 -S "server hello, adding extended master secret extension" \
859 -C "found extended_master_secret extension" \
860 -C "using extended master secret" \
861 -S "using extended master secret"
862
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200863# Tests for FALLBACK_SCSV
864
865run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200866 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200867 "$P_CLI debug_level=3 force_version=tls1_1" \
868 0 \
869 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200870 -S "received FALLBACK_SCSV" \
871 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200872 -C "is a fatal alert message (msg 86)"
873
874run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200875 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200876 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
877 0 \
878 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200879 -S "received FALLBACK_SCSV" \
880 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200881 -C "is a fatal alert message (msg 86)"
882
883run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200884 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200885 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200886 1 \
887 -c "adding FALLBACK_SCSV" \
888 -s "received FALLBACK_SCSV" \
889 -s "inapropriate fallback" \
890 -c "is a fatal alert message (msg 86)"
891
892run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200893 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200894 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200895 0 \
896 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200897 -s "received FALLBACK_SCSV" \
898 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200899 -C "is a fatal alert message (msg 86)"
900
901requires_openssl_with_fallback_scsv
902run_test "Fallback SCSV: default, openssl server" \
903 "$O_SRV" \
904 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
905 0 \
906 -C "adding FALLBACK_SCSV" \
907 -C "is a fatal alert message (msg 86)"
908
909requires_openssl_with_fallback_scsv
910run_test "Fallback SCSV: enabled, openssl server" \
911 "$O_SRV" \
912 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
913 1 \
914 -c "adding FALLBACK_SCSV" \
915 -c "is a fatal alert message (msg 86)"
916
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200917requires_openssl_with_fallback_scsv
918run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200919 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200920 "$O_CLI -tls1_1" \
921 0 \
922 -S "received FALLBACK_SCSV" \
923 -S "inapropriate fallback"
924
925requires_openssl_with_fallback_scsv
926run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200927 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200928 "$O_CLI -tls1_1 -fallback_scsv" \
929 1 \
930 -s "received FALLBACK_SCSV" \
931 -s "inapropriate fallback"
932
933requires_openssl_with_fallback_scsv
934run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200935 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200936 "$O_CLI -fallback_scsv" \
937 0 \
938 -s "received FALLBACK_SCSV" \
939 -S "inapropriate fallback"
940
Gilles Peskine39e29812017-05-16 17:53:03 +0200941## ClientHello generated with
942## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
943## then manually twiddling the ciphersuite list.
944## The ClientHello content is spelled out below as a hex string as
945## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
946## The expected response is an inappropriate_fallback alert.
947requires_openssl_with_fallback_scsv
948run_test "Fallback SCSV: beginning of list" \
949 "$P_SRV debug_level=2" \
950 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
951 0 \
952 -s "received FALLBACK_SCSV" \
953 -s "inapropriate fallback"
954
955requires_openssl_with_fallback_scsv
956run_test "Fallback SCSV: end of list" \
957 "$P_SRV debug_level=2" \
958 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
959 0 \
960 -s "received FALLBACK_SCSV" \
961 -s "inapropriate fallback"
962
963## Here the expected response is a valid ServerHello prefix, up to the random.
964requires_openssl_with_fallback_scsv
965run_test "Fallback SCSV: not in list" \
966 "$P_SRV debug_level=2" \
967 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
968 0 \
969 -S "received FALLBACK_SCSV" \
970 -S "inapropriate fallback"
971
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100972# Tests for CBC 1/n-1 record splitting
973
974run_test "CBC Record splitting: TLS 1.2, no splitting" \
975 "$P_SRV" \
976 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
977 request_size=123 force_version=tls1_2" \
978 0 \
979 -s "Read from client: 123 bytes read" \
980 -S "Read from client: 1 bytes read" \
981 -S "122 bytes read"
982
983run_test "CBC Record splitting: TLS 1.1, no splitting" \
984 "$P_SRV" \
985 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
986 request_size=123 force_version=tls1_1" \
987 0 \
988 -s "Read from client: 123 bytes read" \
989 -S "Read from client: 1 bytes read" \
990 -S "122 bytes read"
991
992run_test "CBC Record splitting: TLS 1.0, splitting" \
993 "$P_SRV" \
994 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
995 request_size=123 force_version=tls1" \
996 0 \
997 -S "Read from client: 123 bytes read" \
998 -s "Read from client: 1 bytes read" \
999 -s "122 bytes read"
1000
Janos Follath542ee5d2016-03-07 15:57:05 +00001001requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001002run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001003 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001004 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1005 request_size=123 force_version=ssl3" \
1006 0 \
1007 -S "Read from client: 123 bytes read" \
1008 -s "Read from client: 1 bytes read" \
1009 -s "122 bytes read"
1010
1011run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001012 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001013 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1014 request_size=123 force_version=tls1" \
1015 0 \
1016 -s "Read from client: 123 bytes read" \
1017 -S "Read from client: 1 bytes read" \
1018 -S "122 bytes read"
1019
1020run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1021 "$P_SRV" \
1022 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1023 request_size=123 force_version=tls1 recsplit=0" \
1024 0 \
1025 -s "Read from client: 123 bytes read" \
1026 -S "Read from client: 1 bytes read" \
1027 -S "122 bytes read"
1028
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001029run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1030 "$P_SRV nbio=2" \
1031 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1032 request_size=123 force_version=tls1" \
1033 0 \
1034 -S "Read from client: 123 bytes read" \
1035 -s "Read from client: 1 bytes read" \
1036 -s "122 bytes read"
1037
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001038# Tests for Session Tickets
1039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001040run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001041 "$P_SRV debug_level=3 tickets=1" \
1042 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001043 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001044 -c "client hello, adding session ticket extension" \
1045 -s "found session ticket extension" \
1046 -s "server hello, adding session ticket extension" \
1047 -c "found session_ticket extension" \
1048 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001049 -S "session successfully restored from cache" \
1050 -s "session successfully restored from ticket" \
1051 -s "a session has been resumed" \
1052 -c "a session has been resumed"
1053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001054run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001055 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1056 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001057 0 \
1058 -c "client hello, adding session ticket extension" \
1059 -s "found session ticket extension" \
1060 -s "server hello, adding session ticket extension" \
1061 -c "found session_ticket extension" \
1062 -c "parse new session ticket" \
1063 -S "session successfully restored from cache" \
1064 -s "session successfully restored from ticket" \
1065 -s "a session has been resumed" \
1066 -c "a session has been resumed"
1067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001068run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001069 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1070 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001071 0 \
1072 -c "client hello, adding session ticket extension" \
1073 -s "found session ticket extension" \
1074 -s "server hello, adding session ticket extension" \
1075 -c "found session_ticket extension" \
1076 -c "parse new session ticket" \
1077 -S "session successfully restored from cache" \
1078 -S "session successfully restored from ticket" \
1079 -S "a session has been resumed" \
1080 -C "a session has been resumed"
1081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001082run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001083 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001084 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001085 0 \
1086 -c "client hello, adding session ticket extension" \
1087 -c "found session_ticket extension" \
1088 -c "parse new session ticket" \
1089 -c "a session has been resumed"
1090
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001091run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001092 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001093 "( $O_CLI -sess_out $SESSION; \
1094 $O_CLI -sess_in $SESSION; \
1095 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001096 0 \
1097 -s "found session ticket extension" \
1098 -s "server hello, adding session ticket extension" \
1099 -S "session successfully restored from cache" \
1100 -s "session successfully restored from ticket" \
1101 -s "a session has been resumed"
1102
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001103# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001104
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001105run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001106 "$P_SRV debug_level=3 tickets=0" \
1107 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001108 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001109 -c "client hello, adding session ticket extension" \
1110 -s "found session ticket extension" \
1111 -S "server hello, adding session ticket extension" \
1112 -C "found session_ticket extension" \
1113 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001114 -s "session successfully restored from cache" \
1115 -S "session successfully restored from ticket" \
1116 -s "a session has been resumed" \
1117 -c "a session has been resumed"
1118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001119run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001120 "$P_SRV debug_level=3 tickets=1" \
1121 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001122 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001123 -C "client hello, adding session ticket extension" \
1124 -S "found session ticket extension" \
1125 -S "server hello, adding session ticket extension" \
1126 -C "found session_ticket extension" \
1127 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001128 -s "session successfully restored from cache" \
1129 -S "session successfully restored from ticket" \
1130 -s "a session has been resumed" \
1131 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001133run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001134 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1135 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001136 0 \
1137 -S "session successfully restored from cache" \
1138 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001139 -S "a session has been resumed" \
1140 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001142run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001143 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1144 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001145 0 \
1146 -s "session successfully restored from cache" \
1147 -S "session successfully restored from ticket" \
1148 -s "a session has been resumed" \
1149 -c "a session has been resumed"
1150
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001151run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001152 "$P_SRV debug_level=3 tickets=0" \
1153 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001154 0 \
1155 -s "session successfully restored from cache" \
1156 -S "session successfully restored from ticket" \
1157 -s "a session has been resumed" \
1158 -c "a session has been resumed"
1159
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001160run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001161 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1162 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001163 0 \
1164 -S "session successfully restored from cache" \
1165 -S "session successfully restored from ticket" \
1166 -S "a session has been resumed" \
1167 -C "a session has been resumed"
1168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001169run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001170 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1171 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001172 0 \
1173 -s "session successfully restored from cache" \
1174 -S "session successfully restored from ticket" \
1175 -s "a session has been resumed" \
1176 -c "a session has been resumed"
1177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001178run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001179 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001180 "( $O_CLI -sess_out $SESSION; \
1181 $O_CLI -sess_in $SESSION; \
1182 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001183 0 \
1184 -s "found session ticket extension" \
1185 -S "server hello, adding session ticket extension" \
1186 -s "session successfully restored from cache" \
1187 -S "session successfully restored from ticket" \
1188 -s "a session has been resumed"
1189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001190run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001191 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001192 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001193 0 \
1194 -C "found session_ticket extension" \
1195 -C "parse new session ticket" \
1196 -c "a session has been resumed"
1197
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001198# Tests for Max Fragment Length extension
1199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001200run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001201 "$P_SRV debug_level=3" \
1202 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001203 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001204 -c "Maximum fragment length is 16384" \
1205 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001206 -C "client hello, adding max_fragment_length extension" \
1207 -S "found max fragment length extension" \
1208 -S "server hello, max_fragment_length extension" \
1209 -C "found max_fragment_length extension"
1210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001211run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001212 "$P_SRV debug_level=3" \
1213 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001214 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001215 -c "Maximum fragment length is 4096" \
1216 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001217 -c "client hello, adding max_fragment_length extension" \
1218 -s "found max fragment length extension" \
1219 -s "server hello, max_fragment_length extension" \
1220 -c "found max_fragment_length extension"
1221
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001222run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001223 "$P_SRV debug_level=3 max_frag_len=4096" \
1224 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001225 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001226 -c "Maximum fragment length is 16384" \
1227 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001228 -C "client hello, adding max_fragment_length extension" \
1229 -S "found max fragment length extension" \
1230 -S "server hello, max_fragment_length extension" \
1231 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001233requires_gnutls
1234run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001235 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001236 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001237 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001238 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001239 -c "client hello, adding max_fragment_length extension" \
1240 -c "found max_fragment_length extension"
1241
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001242run_test "Max fragment length: client, message just fits" \
1243 "$P_SRV debug_level=3" \
1244 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1245 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001246 -c "Maximum fragment length is 2048" \
1247 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001248 -c "client hello, adding max_fragment_length extension" \
1249 -s "found max fragment length extension" \
1250 -s "server hello, max_fragment_length extension" \
1251 -c "found max_fragment_length extension" \
1252 -c "2048 bytes written in 1 fragments" \
1253 -s "2048 bytes read"
1254
1255run_test "Max fragment length: client, larger message" \
1256 "$P_SRV debug_level=3" \
1257 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1258 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001259 -c "Maximum fragment length is 2048" \
1260 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001261 -c "client hello, adding max_fragment_length extension" \
1262 -s "found max fragment length extension" \
1263 -s "server hello, max_fragment_length extension" \
1264 -c "found max_fragment_length extension" \
1265 -c "2345 bytes written in 2 fragments" \
1266 -s "2048 bytes read" \
1267 -s "297 bytes read"
1268
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001269run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001270 "$P_SRV debug_level=3 dtls=1" \
1271 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1272 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001273 -c "Maximum fragment length is 2048" \
1274 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001275 -c "client hello, adding max_fragment_length extension" \
1276 -s "found max fragment length extension" \
1277 -s "server hello, max_fragment_length extension" \
1278 -c "found max_fragment_length extension" \
1279 -c "fragment larger than.*maximum"
1280
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001281# Tests for renegotiation
1282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001283run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001284 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001285 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001286 0 \
1287 -C "client hello, adding renegotiation extension" \
1288 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1289 -S "found renegotiation extension" \
1290 -s "server hello, secure renegotiation extension" \
1291 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001292 -C "=> renegotiate" \
1293 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001294 -S "write hello request"
1295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001296run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001297 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001298 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001299 0 \
1300 -c "client hello, adding renegotiation extension" \
1301 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1302 -s "found renegotiation extension" \
1303 -s "server hello, secure renegotiation extension" \
1304 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001305 -c "=> renegotiate" \
1306 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001307 -S "write hello request"
1308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001309run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001310 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001311 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001312 0 \
1313 -c "client hello, adding renegotiation extension" \
1314 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1315 -s "found renegotiation extension" \
1316 -s "server hello, secure renegotiation extension" \
1317 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001318 -c "=> renegotiate" \
1319 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001320 -s "write hello request"
1321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001322run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001323 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001324 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001325 0 \
1326 -c "client hello, adding renegotiation extension" \
1327 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1328 -s "found renegotiation extension" \
1329 -s "server hello, secure renegotiation extension" \
1330 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001331 -c "=> renegotiate" \
1332 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001333 -s "write hello request"
1334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001335run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001336 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001337 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001338 1 \
1339 -c "client hello, adding renegotiation extension" \
1340 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1341 -S "found renegotiation extension" \
1342 -s "server hello, secure renegotiation extension" \
1343 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001344 -c "=> renegotiate" \
1345 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001346 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001347 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001348 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001350run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001351 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001352 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001353 0 \
1354 -C "client hello, adding renegotiation extension" \
1355 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1356 -S "found renegotiation extension" \
1357 -s "server hello, secure renegotiation extension" \
1358 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001359 -C "=> renegotiate" \
1360 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001361 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001362 -S "SSL - An unexpected message was received from our peer" \
1363 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001365run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001366 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001367 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001368 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001369 0 \
1370 -C "client hello, adding renegotiation extension" \
1371 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1372 -S "found renegotiation extension" \
1373 -s "server hello, secure renegotiation extension" \
1374 -c "found renegotiation extension" \
1375 -C "=> renegotiate" \
1376 -S "=> renegotiate" \
1377 -s "write hello request" \
1378 -S "SSL - An unexpected message was received from our peer" \
1379 -S "failed"
1380
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001381# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001382run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001383 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001384 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001385 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001386 0 \
1387 -C "client hello, adding renegotiation extension" \
1388 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1389 -S "found renegotiation extension" \
1390 -s "server hello, secure renegotiation extension" \
1391 -c "found renegotiation extension" \
1392 -C "=> renegotiate" \
1393 -S "=> renegotiate" \
1394 -s "write hello request" \
1395 -S "SSL - An unexpected message was received from our peer" \
1396 -S "failed"
1397
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001398run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001399 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001400 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001401 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001402 0 \
1403 -C "client hello, adding renegotiation extension" \
1404 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1405 -S "found renegotiation extension" \
1406 -s "server hello, secure renegotiation extension" \
1407 -c "found renegotiation extension" \
1408 -C "=> renegotiate" \
1409 -S "=> renegotiate" \
1410 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001411 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001413run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001414 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001415 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001416 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001417 0 \
1418 -c "client hello, adding renegotiation extension" \
1419 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1420 -s "found renegotiation extension" \
1421 -s "server hello, secure renegotiation extension" \
1422 -c "found renegotiation extension" \
1423 -c "=> renegotiate" \
1424 -s "=> renegotiate" \
1425 -s "write hello request" \
1426 -S "SSL - An unexpected message was received from our peer" \
1427 -S "failed"
1428
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001429run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001430 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001431 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1432 0 \
1433 -C "client hello, adding renegotiation extension" \
1434 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1435 -S "found renegotiation extension" \
1436 -s "server hello, secure renegotiation extension" \
1437 -c "found renegotiation extension" \
1438 -S "record counter limit reached: renegotiate" \
1439 -C "=> renegotiate" \
1440 -S "=> renegotiate" \
1441 -S "write hello request" \
1442 -S "SSL - An unexpected message was received from our peer" \
1443 -S "failed"
1444
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001445# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001446run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001447 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001448 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001449 0 \
1450 -c "client hello, adding renegotiation extension" \
1451 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1452 -s "found renegotiation extension" \
1453 -s "server hello, secure renegotiation extension" \
1454 -c "found renegotiation extension" \
1455 -s "record counter limit reached: renegotiate" \
1456 -c "=> renegotiate" \
1457 -s "=> renegotiate" \
1458 -s "write hello request" \
1459 -S "SSL - An unexpected message was received from our peer" \
1460 -S "failed"
1461
1462run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001463 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001464 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001465 0 \
1466 -c "client hello, adding renegotiation extension" \
1467 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1468 -s "found renegotiation extension" \
1469 -s "server hello, secure renegotiation extension" \
1470 -c "found renegotiation extension" \
1471 -s "record counter limit reached: renegotiate" \
1472 -c "=> renegotiate" \
1473 -s "=> renegotiate" \
1474 -s "write hello request" \
1475 -S "SSL - An unexpected message was received from our peer" \
1476 -S "failed"
1477
1478run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001479 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001480 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1481 0 \
1482 -C "client hello, adding renegotiation extension" \
1483 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1484 -S "found renegotiation extension" \
1485 -s "server hello, secure renegotiation extension" \
1486 -c "found renegotiation extension" \
1487 -S "record counter limit reached: renegotiate" \
1488 -C "=> renegotiate" \
1489 -S "=> renegotiate" \
1490 -S "write hello request" \
1491 -S "SSL - An unexpected message was received from our peer" \
1492 -S "failed"
1493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001494run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001495 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001496 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001497 0 \
1498 -c "client hello, adding renegotiation extension" \
1499 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1500 -s "found renegotiation extension" \
1501 -s "server hello, secure renegotiation extension" \
1502 -c "found renegotiation extension" \
1503 -c "=> renegotiate" \
1504 -s "=> renegotiate" \
1505 -S "write hello request"
1506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001508 "$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 +02001509 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001510 0 \
1511 -c "client hello, adding renegotiation extension" \
1512 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1513 -s "found renegotiation extension" \
1514 -s "server hello, secure renegotiation extension" \
1515 -c "found renegotiation extension" \
1516 -c "=> renegotiate" \
1517 -s "=> renegotiate" \
1518 -s "write hello request"
1519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001520run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001521 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001522 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001523 0 \
1524 -c "client hello, adding renegotiation extension" \
1525 -c "found renegotiation extension" \
1526 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001527 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001528 -C "error" \
1529 -c "HTTP/1.0 200 [Oo][Kk]"
1530
Paul Bakker539d9722015-02-08 16:18:35 +01001531requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001532run_test "Renegotiation: gnutls server strict, client-initiated" \
1533 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001534 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001535 0 \
1536 -c "client hello, adding renegotiation extension" \
1537 -c "found renegotiation extension" \
1538 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001539 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001540 -C "error" \
1541 -c "HTTP/1.0 200 [Oo][Kk]"
1542
Paul Bakker539d9722015-02-08 16:18:35 +01001543requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001544run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1545 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1546 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1547 1 \
1548 -c "client hello, adding renegotiation extension" \
1549 -C "found renegotiation extension" \
1550 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001551 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001552 -c "error" \
1553 -C "HTTP/1.0 200 [Oo][Kk]"
1554
Paul Bakker539d9722015-02-08 16:18:35 +01001555requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001556run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1557 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1558 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1559 allow_legacy=0" \
1560 1 \
1561 -c "client hello, adding renegotiation extension" \
1562 -C "found renegotiation extension" \
1563 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001564 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001565 -c "error" \
1566 -C "HTTP/1.0 200 [Oo][Kk]"
1567
Paul Bakker539d9722015-02-08 16:18:35 +01001568requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001569run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1570 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1571 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1572 allow_legacy=1" \
1573 0 \
1574 -c "client hello, adding renegotiation extension" \
1575 -C "found renegotiation extension" \
1576 -c "=> renegotiate" \
1577 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001578 -C "error" \
1579 -c "HTTP/1.0 200 [Oo][Kk]"
1580
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001581run_test "Renegotiation: DTLS, client-initiated" \
1582 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1583 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1584 0 \
1585 -c "client hello, adding renegotiation extension" \
1586 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1587 -s "found renegotiation extension" \
1588 -s "server hello, secure renegotiation extension" \
1589 -c "found renegotiation extension" \
1590 -c "=> renegotiate" \
1591 -s "=> renegotiate" \
1592 -S "write hello request"
1593
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001594run_test "Renegotiation: DTLS, server-initiated" \
1595 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001596 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1597 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001598 0 \
1599 -c "client hello, adding renegotiation extension" \
1600 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1601 -s "found renegotiation extension" \
1602 -s "server hello, secure renegotiation extension" \
1603 -c "found renegotiation extension" \
1604 -c "=> renegotiate" \
1605 -s "=> renegotiate" \
1606 -s "write hello request"
1607
Andres AG9b1927b2017-01-19 16:30:57 +00001608run_test "Renegotiation: DTLS, renego_period overflow" \
1609 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1610 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1611 0 \
1612 -c "client hello, adding renegotiation extension" \
1613 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1614 -s "found renegotiation extension" \
1615 -s "server hello, secure renegotiation extension" \
1616 -s "record counter limit reached: renegotiate" \
1617 -c "=> renegotiate" \
1618 -s "=> renegotiate" \
1619 -s "write hello request" \
1620
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001621requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001622run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1623 "$G_SRV -u --mtu 4096" \
1624 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1625 0 \
1626 -c "client hello, adding renegotiation extension" \
1627 -c "found renegotiation extension" \
1628 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001629 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001630 -C "error" \
1631 -s "Extra-header:"
1632
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001633# Test for the "secure renegotation" extension only (no actual renegotiation)
1634
Paul Bakker539d9722015-02-08 16:18:35 +01001635requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001636run_test "Renego ext: gnutls server strict, client default" \
1637 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1638 "$P_CLI debug_level=3" \
1639 0 \
1640 -c "found renegotiation extension" \
1641 -C "error" \
1642 -c "HTTP/1.0 200 [Oo][Kk]"
1643
Paul Bakker539d9722015-02-08 16:18:35 +01001644requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001645run_test "Renego ext: gnutls server unsafe, client default" \
1646 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1647 "$P_CLI debug_level=3" \
1648 0 \
1649 -C "found renegotiation extension" \
1650 -C "error" \
1651 -c "HTTP/1.0 200 [Oo][Kk]"
1652
Paul Bakker539d9722015-02-08 16:18:35 +01001653requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001654run_test "Renego ext: gnutls server unsafe, client break legacy" \
1655 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1656 "$P_CLI debug_level=3 allow_legacy=-1" \
1657 1 \
1658 -C "found renegotiation extension" \
1659 -c "error" \
1660 -C "HTTP/1.0 200 [Oo][Kk]"
1661
Paul Bakker539d9722015-02-08 16:18:35 +01001662requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001663run_test "Renego ext: gnutls client strict, server default" \
1664 "$P_SRV debug_level=3" \
1665 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1666 0 \
1667 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1668 -s "server hello, secure renegotiation extension"
1669
Paul Bakker539d9722015-02-08 16:18:35 +01001670requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001671run_test "Renego ext: gnutls client unsafe, server default" \
1672 "$P_SRV debug_level=3" \
1673 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1674 0 \
1675 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1676 -S "server hello, secure renegotiation extension"
1677
Paul Bakker539d9722015-02-08 16:18:35 +01001678requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001679run_test "Renego ext: gnutls client unsafe, server break legacy" \
1680 "$P_SRV debug_level=3 allow_legacy=-1" \
1681 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1682 1 \
1683 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1684 -S "server hello, secure renegotiation extension"
1685
Janos Follath365b2262016-02-17 10:11:21 +00001686# Tests for silently dropping trailing extra bytes in .der certificates
1687
1688requires_gnutls
1689run_test "DER format: no trailing bytes" \
1690 "$P_SRV crt_file=data_files/server5-der0.crt \
1691 key_file=data_files/server5.key" \
1692 "$G_CLI " \
1693 0 \
1694 -c "Handshake was completed" \
1695
1696requires_gnutls
1697run_test "DER format: with a trailing zero byte" \
1698 "$P_SRV crt_file=data_files/server5-der1a.crt \
1699 key_file=data_files/server5.key" \
1700 "$G_CLI " \
1701 0 \
1702 -c "Handshake was completed" \
1703
1704requires_gnutls
1705run_test "DER format: with a trailing random byte" \
1706 "$P_SRV crt_file=data_files/server5-der1b.crt \
1707 key_file=data_files/server5.key" \
1708 "$G_CLI " \
1709 0 \
1710 -c "Handshake was completed" \
1711
1712requires_gnutls
1713run_test "DER format: with 2 trailing random bytes" \
1714 "$P_SRV crt_file=data_files/server5-der2.crt \
1715 key_file=data_files/server5.key" \
1716 "$G_CLI " \
1717 0 \
1718 -c "Handshake was completed" \
1719
1720requires_gnutls
1721run_test "DER format: with 4 trailing random bytes" \
1722 "$P_SRV crt_file=data_files/server5-der4.crt \
1723 key_file=data_files/server5.key" \
1724 "$G_CLI " \
1725 0 \
1726 -c "Handshake was completed" \
1727
1728requires_gnutls
1729run_test "DER format: with 8 trailing random bytes" \
1730 "$P_SRV crt_file=data_files/server5-der8.crt \
1731 key_file=data_files/server5.key" \
1732 "$G_CLI " \
1733 0 \
1734 -c "Handshake was completed" \
1735
1736requires_gnutls
1737run_test "DER format: with 9 trailing random bytes" \
1738 "$P_SRV crt_file=data_files/server5-der9.crt \
1739 key_file=data_files/server5.key" \
1740 "$G_CLI " \
1741 0 \
1742 -c "Handshake was completed" \
1743
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001744# Tests for auth_mode
1745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001746run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001747 "$P_SRV crt_file=data_files/server5-badsign.crt \
1748 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001749 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001750 1 \
1751 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001752 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001753 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001754 -c "X509 - Certificate verification failed"
1755
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001756run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001757 "$P_SRV crt_file=data_files/server5-badsign.crt \
1758 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001759 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001760 0 \
1761 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001762 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001763 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001764 -C "X509 - Certificate verification failed"
1765
Hanno Becker61c0c702017-05-15 16:05:15 +01001766run_test "Authentication: server goodcert, client optional, no trusted CA" \
1767 "$P_SRV" \
1768 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1769 0 \
1770 -c "x509_verify_cert() returned" \
1771 -c "! The certificate is not correctly signed by the trusted CA" \
1772 -c "! Certificate verification flags"\
1773 -C "! mbedtls_ssl_handshake returned" \
1774 -C "X509 - Certificate verification failed" \
1775 -C "SSL - No CA Chain is set, but required to operate"
1776
1777run_test "Authentication: server goodcert, client required, no trusted CA" \
1778 "$P_SRV" \
1779 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1780 1 \
1781 -c "x509_verify_cert() returned" \
1782 -c "! The certificate is not correctly signed by the trusted CA" \
1783 -c "! Certificate verification flags"\
1784 -c "! mbedtls_ssl_handshake returned" \
1785 -c "SSL - No CA Chain is set, but required to operate"
1786
1787# The purpose of the next two tests is to test the client's behaviour when receiving a server
1788# certificate with an unsupported elliptic curve. This should usually not happen because
1789# the client informs the server about the supported curves - it does, though, in the
1790# corner case of a static ECDH suite, because the server doesn't check the curve on that
1791# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1792# different means to have the server ignoring the client's supported curve list.
1793
1794requires_config_enabled MBEDTLS_ECP_C
1795run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1796 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1797 crt_file=data_files/server5.ku-ka.crt" \
1798 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1799 1 \
1800 -c "bad certificate (EC key curve)"\
1801 -c "! Certificate verification flags"\
1802 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1803
1804requires_config_enabled MBEDTLS_ECP_C
1805run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1806 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1807 crt_file=data_files/server5.ku-ka.crt" \
1808 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1809 1 \
1810 -c "bad certificate (EC key curve)"\
1811 -c "! Certificate verification flags"\
1812 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001814run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001815 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001816 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001817 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001818 0 \
1819 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001820 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001821 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001822 -C "X509 - Certificate verification failed"
1823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001824run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001825 "$P_SRV debug_level=3 auth_mode=required" \
1826 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001827 key_file=data_files/server5.key" \
1828 1 \
1829 -S "skip write certificate request" \
1830 -C "skip parse certificate request" \
1831 -c "got a certificate request" \
1832 -C "skip write certificate" \
1833 -C "skip write certificate verify" \
1834 -S "skip parse certificate verify" \
1835 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001836 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001837 -s "! mbedtls_ssl_handshake returned" \
1838 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001839 -s "X509 - Certificate verification failed"
1840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001841run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001842 "$P_SRV debug_level=3 auth_mode=optional" \
1843 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001844 key_file=data_files/server5.key" \
1845 0 \
1846 -S "skip write certificate request" \
1847 -C "skip parse certificate request" \
1848 -c "got a certificate request" \
1849 -C "skip write certificate" \
1850 -C "skip write certificate verify" \
1851 -S "skip parse certificate verify" \
1852 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001853 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001854 -S "! mbedtls_ssl_handshake returned" \
1855 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001856 -S "X509 - Certificate verification failed"
1857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001858run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001859 "$P_SRV debug_level=3 auth_mode=none" \
1860 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001861 key_file=data_files/server5.key" \
1862 0 \
1863 -s "skip write certificate request" \
1864 -C "skip parse certificate request" \
1865 -c "got no certificate request" \
1866 -c "skip write certificate" \
1867 -c "skip write certificate verify" \
1868 -s "skip parse certificate verify" \
1869 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001870 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001871 -S "! mbedtls_ssl_handshake returned" \
1872 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001873 -S "X509 - Certificate verification failed"
1874
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001875run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001876 "$P_SRV debug_level=3 auth_mode=optional" \
1877 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001878 0 \
1879 -S "skip write certificate request" \
1880 -C "skip parse certificate request" \
1881 -c "got a certificate request" \
1882 -C "skip write certificate$" \
1883 -C "got no certificate to send" \
1884 -S "SSLv3 client has no certificate" \
1885 -c "skip write certificate verify" \
1886 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001887 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001888 -S "! mbedtls_ssl_handshake returned" \
1889 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001890 -S "X509 - Certificate verification failed"
1891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001892run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001893 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001894 "$O_CLI" \
1895 0 \
1896 -S "skip write certificate request" \
1897 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001898 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001899 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001900 -S "X509 - Certificate verification failed"
1901
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001902run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001903 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001904 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001905 0 \
1906 -C "skip parse certificate request" \
1907 -c "got a certificate request" \
1908 -C "skip write certificate$" \
1909 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001910 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001911
Janos Follath542ee5d2016-03-07 15:57:05 +00001912requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001913run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001914 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001915 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001916 0 \
1917 -S "skip write certificate request" \
1918 -C "skip parse certificate request" \
1919 -c "got a certificate request" \
1920 -C "skip write certificate$" \
1921 -c "skip write certificate verify" \
1922 -c "got no certificate to send" \
1923 -s "SSLv3 client has no certificate" \
1924 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001925 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001926 -S "! mbedtls_ssl_handshake returned" \
1927 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001928 -S "X509 - Certificate verification failed"
1929
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001930# Tests for certificate selection based on SHA verson
1931
1932run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1933 "$P_SRV crt_file=data_files/server5.crt \
1934 key_file=data_files/server5.key \
1935 crt_file2=data_files/server5-sha1.crt \
1936 key_file2=data_files/server5.key" \
1937 "$P_CLI force_version=tls1_2" \
1938 0 \
1939 -c "signed using.*ECDSA with SHA256" \
1940 -C "signed using.*ECDSA with SHA1"
1941
1942run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1943 "$P_SRV crt_file=data_files/server5.crt \
1944 key_file=data_files/server5.key \
1945 crt_file2=data_files/server5-sha1.crt \
1946 key_file2=data_files/server5.key" \
1947 "$P_CLI force_version=tls1_1" \
1948 0 \
1949 -C "signed using.*ECDSA with SHA256" \
1950 -c "signed using.*ECDSA with SHA1"
1951
1952run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1953 "$P_SRV crt_file=data_files/server5.crt \
1954 key_file=data_files/server5.key \
1955 crt_file2=data_files/server5-sha1.crt \
1956 key_file2=data_files/server5.key" \
1957 "$P_CLI force_version=tls1" \
1958 0 \
1959 -C "signed using.*ECDSA with SHA256" \
1960 -c "signed using.*ECDSA with SHA1"
1961
1962run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1963 "$P_SRV crt_file=data_files/server5.crt \
1964 key_file=data_files/server5.key \
1965 crt_file2=data_files/server6.crt \
1966 key_file2=data_files/server6.key" \
1967 "$P_CLI force_version=tls1_1" \
1968 0 \
1969 -c "serial number.*09" \
1970 -c "signed using.*ECDSA with SHA256" \
1971 -C "signed using.*ECDSA with SHA1"
1972
1973run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1974 "$P_SRV crt_file=data_files/server6.crt \
1975 key_file=data_files/server6.key \
1976 crt_file2=data_files/server5.crt \
1977 key_file2=data_files/server5.key" \
1978 "$P_CLI force_version=tls1_1" \
1979 0 \
1980 -c "serial number.*0A" \
1981 -c "signed using.*ECDSA with SHA256" \
1982 -C "signed using.*ECDSA with SHA1"
1983
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001984# tests for SNI
1985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001986run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001987 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001988 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001989 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001990 0 \
1991 -S "parse ServerName extension" \
1992 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1993 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001995run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001996 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001997 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001998 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 +02001999 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002000 0 \
2001 -s "parse ServerName extension" \
2002 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2003 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002005run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002006 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002007 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002008 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 +02002009 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002010 0 \
2011 -s "parse ServerName extension" \
2012 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2013 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002015run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002016 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002017 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002018 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 +02002019 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002020 1 \
2021 -s "parse ServerName extension" \
2022 -s "ssl_sni_wrapper() returned" \
2023 -s "mbedtls_ssl_handshake returned" \
2024 -c "mbedtls_ssl_handshake returned" \
2025 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002026
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002027run_test "SNI: client auth no override: optional" \
2028 "$P_SRV debug_level=3 auth_mode=optional \
2029 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2030 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2031 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002032 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002033 -S "skip write certificate request" \
2034 -C "skip parse certificate request" \
2035 -c "got a certificate request" \
2036 -C "skip write certificate" \
2037 -C "skip write certificate verify" \
2038 -S "skip parse certificate verify"
2039
2040run_test "SNI: client auth override: none -> optional" \
2041 "$P_SRV debug_level=3 auth_mode=none \
2042 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2043 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2044 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002045 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002046 -S "skip write certificate request" \
2047 -C "skip parse certificate request" \
2048 -c "got a certificate request" \
2049 -C "skip write certificate" \
2050 -C "skip write certificate verify" \
2051 -S "skip parse certificate verify"
2052
2053run_test "SNI: client auth override: optional -> none" \
2054 "$P_SRV debug_level=3 auth_mode=optional \
2055 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2056 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2057 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002058 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002059 -s "skip write certificate request" \
2060 -C "skip parse certificate request" \
2061 -c "got no certificate request" \
2062 -c "skip write certificate" \
2063 -c "skip write certificate verify" \
2064 -s "skip parse certificate verify"
2065
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002066run_test "SNI: CA no override" \
2067 "$P_SRV debug_level=3 auth_mode=optional \
2068 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2069 ca_file=data_files/test-ca.crt \
2070 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2071 "$P_CLI debug_level=3 server_name=localhost \
2072 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2073 1 \
2074 -S "skip write certificate request" \
2075 -C "skip parse certificate request" \
2076 -c "got a certificate request" \
2077 -C "skip write certificate" \
2078 -C "skip write certificate verify" \
2079 -S "skip parse certificate verify" \
2080 -s "x509_verify_cert() returned" \
2081 -s "! The certificate is not correctly signed by the trusted CA" \
2082 -S "The certificate has been revoked (is on a CRL)"
2083
2084run_test "SNI: CA override" \
2085 "$P_SRV debug_level=3 auth_mode=optional \
2086 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2087 ca_file=data_files/test-ca.crt \
2088 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2089 "$P_CLI debug_level=3 server_name=localhost \
2090 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2091 0 \
2092 -S "skip write certificate request" \
2093 -C "skip parse certificate request" \
2094 -c "got a certificate request" \
2095 -C "skip write certificate" \
2096 -C "skip write certificate verify" \
2097 -S "skip parse certificate verify" \
2098 -S "x509_verify_cert() returned" \
2099 -S "! The certificate is not correctly signed by the trusted CA" \
2100 -S "The certificate has been revoked (is on a CRL)"
2101
2102run_test "SNI: CA override with CRL" \
2103 "$P_SRV debug_level=3 auth_mode=optional \
2104 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2105 ca_file=data_files/test-ca.crt \
2106 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2107 "$P_CLI debug_level=3 server_name=localhost \
2108 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2109 1 \
2110 -S "skip write certificate request" \
2111 -C "skip parse certificate request" \
2112 -c "got a certificate request" \
2113 -C "skip write certificate" \
2114 -C "skip write certificate verify" \
2115 -S "skip parse certificate verify" \
2116 -s "x509_verify_cert() returned" \
2117 -S "! The certificate is not correctly signed by the trusted CA" \
2118 -s "The certificate has been revoked (is on a CRL)"
2119
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002120# Tests for non-blocking I/O: exercise a variety of handshake flows
2121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002122run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002123 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2124 "$P_CLI nbio=2 tickets=0" \
2125 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002126 -S "mbedtls_ssl_handshake returned" \
2127 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002128 -c "Read from server: .* bytes read"
2129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002130run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002131 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2132 "$P_CLI nbio=2 tickets=0" \
2133 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002134 -S "mbedtls_ssl_handshake returned" \
2135 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002136 -c "Read from server: .* bytes read"
2137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002138run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002139 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2140 "$P_CLI nbio=2 tickets=1" \
2141 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002142 -S "mbedtls_ssl_handshake returned" \
2143 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002144 -c "Read from server: .* bytes read"
2145
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002146run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002147 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2148 "$P_CLI nbio=2 tickets=1" \
2149 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002150 -S "mbedtls_ssl_handshake returned" \
2151 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002152 -c "Read from server: .* bytes read"
2153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002154run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002155 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2156 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2157 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002158 -S "mbedtls_ssl_handshake returned" \
2159 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002160 -c "Read from server: .* bytes read"
2161
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002162run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002163 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2164 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2165 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002166 -S "mbedtls_ssl_handshake returned" \
2167 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002168 -c "Read from server: .* bytes read"
2169
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002170run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002171 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2172 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2173 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002174 -S "mbedtls_ssl_handshake returned" \
2175 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002176 -c "Read from server: .* bytes read"
2177
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002178# Tests for version negotiation
2179
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002180run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002181 "$P_SRV" \
2182 "$P_CLI" \
2183 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002184 -S "mbedtls_ssl_handshake returned" \
2185 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002186 -s "Protocol is TLSv1.2" \
2187 -c "Protocol is TLSv1.2"
2188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002189run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002190 "$P_SRV" \
2191 "$P_CLI max_version=tls1_1" \
2192 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002193 -S "mbedtls_ssl_handshake returned" \
2194 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002195 -s "Protocol is TLSv1.1" \
2196 -c "Protocol is TLSv1.1"
2197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002198run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002199 "$P_SRV max_version=tls1_1" \
2200 "$P_CLI" \
2201 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002202 -S "mbedtls_ssl_handshake returned" \
2203 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002204 -s "Protocol is TLSv1.1" \
2205 -c "Protocol is TLSv1.1"
2206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002207run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002208 "$P_SRV max_version=tls1_1" \
2209 "$P_CLI max_version=tls1_1" \
2210 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002211 -S "mbedtls_ssl_handshake returned" \
2212 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002213 -s "Protocol is TLSv1.1" \
2214 -c "Protocol is TLSv1.1"
2215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002216run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002217 "$P_SRV min_version=tls1_1" \
2218 "$P_CLI max_version=tls1_1" \
2219 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002220 -S "mbedtls_ssl_handshake returned" \
2221 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002222 -s "Protocol is TLSv1.1" \
2223 -c "Protocol is TLSv1.1"
2224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002225run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002226 "$P_SRV max_version=tls1_1" \
2227 "$P_CLI min_version=tls1_1" \
2228 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002229 -S "mbedtls_ssl_handshake returned" \
2230 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002231 -s "Protocol is TLSv1.1" \
2232 -c "Protocol is TLSv1.1"
2233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002234run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002235 "$P_SRV max_version=tls1_1" \
2236 "$P_CLI min_version=tls1_2" \
2237 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002238 -s "mbedtls_ssl_handshake returned" \
2239 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002240 -c "SSL - Handshake protocol not within min/max boundaries"
2241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002242run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002243 "$P_SRV min_version=tls1_2" \
2244 "$P_CLI max_version=tls1_1" \
2245 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002246 -s "mbedtls_ssl_handshake returned" \
2247 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002248 -s "SSL - Handshake protocol not within min/max boundaries"
2249
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002250# Tests for ALPN extension
2251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002252run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002253 "$P_SRV debug_level=3" \
2254 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002255 0 \
2256 -C "client hello, adding alpn extension" \
2257 -S "found alpn extension" \
2258 -C "got an alert message, type: \\[2:120]" \
2259 -S "server hello, adding alpn extension" \
2260 -C "found alpn extension " \
2261 -C "Application Layer Protocol is" \
2262 -S "Application Layer Protocol is"
2263
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002264run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002265 "$P_SRV debug_level=3" \
2266 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002267 0 \
2268 -c "client hello, adding alpn extension" \
2269 -s "found alpn extension" \
2270 -C "got an alert message, type: \\[2:120]" \
2271 -S "server hello, adding alpn extension" \
2272 -C "found alpn extension " \
2273 -c "Application Layer Protocol is (none)" \
2274 -S "Application Layer Protocol is"
2275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002276run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002277 "$P_SRV debug_level=3 alpn=abc,1234" \
2278 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002279 0 \
2280 -C "client hello, adding alpn extension" \
2281 -S "found alpn extension" \
2282 -C "got an alert message, type: \\[2:120]" \
2283 -S "server hello, adding alpn extension" \
2284 -C "found alpn extension " \
2285 -C "Application Layer Protocol is" \
2286 -s "Application Layer Protocol is (none)"
2287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002288run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002289 "$P_SRV debug_level=3 alpn=abc,1234" \
2290 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002291 0 \
2292 -c "client hello, adding alpn extension" \
2293 -s "found alpn extension" \
2294 -C "got an alert message, type: \\[2:120]" \
2295 -s "server hello, adding alpn extension" \
2296 -c "found alpn extension" \
2297 -c "Application Layer Protocol is abc" \
2298 -s "Application Layer Protocol is abc"
2299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002300run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002301 "$P_SRV debug_level=3 alpn=abc,1234" \
2302 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002303 0 \
2304 -c "client hello, adding alpn extension" \
2305 -s "found alpn extension" \
2306 -C "got an alert message, type: \\[2:120]" \
2307 -s "server hello, adding alpn extension" \
2308 -c "found alpn extension" \
2309 -c "Application Layer Protocol is abc" \
2310 -s "Application Layer Protocol is abc"
2311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002312run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002313 "$P_SRV debug_level=3 alpn=abc,1234" \
2314 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002315 0 \
2316 -c "client hello, adding alpn extension" \
2317 -s "found alpn extension" \
2318 -C "got an alert message, type: \\[2:120]" \
2319 -s "server hello, adding alpn extension" \
2320 -c "found alpn extension" \
2321 -c "Application Layer Protocol is 1234" \
2322 -s "Application Layer Protocol is 1234"
2323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002324run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002325 "$P_SRV debug_level=3 alpn=abc,123" \
2326 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002327 1 \
2328 -c "client hello, adding alpn extension" \
2329 -s "found alpn extension" \
2330 -c "got an alert message, type: \\[2:120]" \
2331 -S "server hello, adding alpn extension" \
2332 -C "found alpn extension" \
2333 -C "Application Layer Protocol is 1234" \
2334 -S "Application Layer Protocol is 1234"
2335
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002336
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002337# Tests for keyUsage in leaf certificates, part 1:
2338# server-side certificate/suite selection
2339
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002340run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002341 "$P_SRV key_file=data_files/server2.key \
2342 crt_file=data_files/server2.ku-ds.crt" \
2343 "$P_CLI" \
2344 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002345 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002346
2347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002348run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002349 "$P_SRV key_file=data_files/server2.key \
2350 crt_file=data_files/server2.ku-ke.crt" \
2351 "$P_CLI" \
2352 0 \
2353 -c "Ciphersuite is TLS-RSA-WITH-"
2354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002355run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002356 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002357 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002358 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002359 1 \
2360 -C "Ciphersuite is "
2361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002362run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002363 "$P_SRV key_file=data_files/server5.key \
2364 crt_file=data_files/server5.ku-ds.crt" \
2365 "$P_CLI" \
2366 0 \
2367 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2368
2369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002370run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002371 "$P_SRV key_file=data_files/server5.key \
2372 crt_file=data_files/server5.ku-ka.crt" \
2373 "$P_CLI" \
2374 0 \
2375 -c "Ciphersuite is TLS-ECDH-"
2376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002377run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002378 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002379 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002380 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002381 1 \
2382 -C "Ciphersuite is "
2383
2384# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002385# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002387run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002388 "$O_SRV -key data_files/server2.key \
2389 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002390 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002391 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2392 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002393 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002394 -C "Processing of the Certificate handshake message failed" \
2395 -c "Ciphersuite is TLS-"
2396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002397run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002398 "$O_SRV -key data_files/server2.key \
2399 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002400 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002401 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2402 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002403 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002404 -C "Processing of the Certificate handshake message failed" \
2405 -c "Ciphersuite is TLS-"
2406
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002407run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002408 "$O_SRV -key data_files/server2.key \
2409 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002410 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002411 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2412 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002413 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002414 -C "Processing of the Certificate handshake message failed" \
2415 -c "Ciphersuite is TLS-"
2416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002417run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002418 "$O_SRV -key data_files/server2.key \
2419 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002420 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002421 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2422 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002423 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002424 -c "Processing of the Certificate handshake message failed" \
2425 -C "Ciphersuite is TLS-"
2426
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002427run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2428 "$O_SRV -key data_files/server2.key \
2429 -cert data_files/server2.ku-ke.crt" \
2430 "$P_CLI debug_level=1 auth_mode=optional \
2431 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2432 0 \
2433 -c "bad certificate (usage extensions)" \
2434 -C "Processing of the Certificate handshake message failed" \
2435 -c "Ciphersuite is TLS-" \
2436 -c "! Usage does not match the keyUsage extension"
2437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002438run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002439 "$O_SRV -key data_files/server2.key \
2440 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002441 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002442 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2443 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002444 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002445 -C "Processing of the Certificate handshake message failed" \
2446 -c "Ciphersuite is TLS-"
2447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002448run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002449 "$O_SRV -key data_files/server2.key \
2450 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002451 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002452 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2453 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002454 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002455 -c "Processing of the Certificate handshake message failed" \
2456 -C "Ciphersuite is TLS-"
2457
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002458run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2459 "$O_SRV -key data_files/server2.key \
2460 -cert data_files/server2.ku-ds.crt" \
2461 "$P_CLI debug_level=1 auth_mode=optional \
2462 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2463 0 \
2464 -c "bad certificate (usage extensions)" \
2465 -C "Processing of the Certificate handshake message failed" \
2466 -c "Ciphersuite is TLS-" \
2467 -c "! Usage does not match the keyUsage extension"
2468
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002469# Tests for keyUsage in leaf certificates, part 3:
2470# server-side checking of client cert
2471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002472run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002473 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002474 "$O_CLI -key data_files/server2.key \
2475 -cert data_files/server2.ku-ds.crt" \
2476 0 \
2477 -S "bad certificate (usage extensions)" \
2478 -S "Processing of the Certificate handshake message failed"
2479
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002480run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002481 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002482 "$O_CLI -key data_files/server2.key \
2483 -cert data_files/server2.ku-ke.crt" \
2484 0 \
2485 -s "bad certificate (usage extensions)" \
2486 -S "Processing of the Certificate handshake message failed"
2487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002488run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002489 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002490 "$O_CLI -key data_files/server2.key \
2491 -cert data_files/server2.ku-ke.crt" \
2492 1 \
2493 -s "bad certificate (usage extensions)" \
2494 -s "Processing of the Certificate handshake message failed"
2495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002496run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002497 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002498 "$O_CLI -key data_files/server5.key \
2499 -cert data_files/server5.ku-ds.crt" \
2500 0 \
2501 -S "bad certificate (usage extensions)" \
2502 -S "Processing of the Certificate handshake message failed"
2503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002504run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002505 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002506 "$O_CLI -key data_files/server5.key \
2507 -cert data_files/server5.ku-ka.crt" \
2508 0 \
2509 -s "bad certificate (usage extensions)" \
2510 -S "Processing of the Certificate handshake message failed"
2511
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002512# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002514run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002515 "$P_SRV key_file=data_files/server5.key \
2516 crt_file=data_files/server5.eku-srv.crt" \
2517 "$P_CLI" \
2518 0
2519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002520run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002521 "$P_SRV key_file=data_files/server5.key \
2522 crt_file=data_files/server5.eku-srv.crt" \
2523 "$P_CLI" \
2524 0
2525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002526run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002527 "$P_SRV key_file=data_files/server5.key \
2528 crt_file=data_files/server5.eku-cs_any.crt" \
2529 "$P_CLI" \
2530 0
2531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002532run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002533 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002534 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002535 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002536 1
2537
2538# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002540run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002541 "$O_SRV -key data_files/server5.key \
2542 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002543 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002544 0 \
2545 -C "bad certificate (usage extensions)" \
2546 -C "Processing of the Certificate handshake message failed" \
2547 -c "Ciphersuite is TLS-"
2548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002549run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002550 "$O_SRV -key data_files/server5.key \
2551 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002552 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002553 0 \
2554 -C "bad certificate (usage extensions)" \
2555 -C "Processing of the Certificate handshake message failed" \
2556 -c "Ciphersuite is TLS-"
2557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002558run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002559 "$O_SRV -key data_files/server5.key \
2560 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002561 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002562 0 \
2563 -C "bad certificate (usage extensions)" \
2564 -C "Processing of the Certificate handshake message failed" \
2565 -c "Ciphersuite is TLS-"
2566
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002567run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002568 "$O_SRV -key data_files/server5.key \
2569 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002570 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002571 1 \
2572 -c "bad certificate (usage extensions)" \
2573 -c "Processing of the Certificate handshake message failed" \
2574 -C "Ciphersuite is TLS-"
2575
2576# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2577
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002578run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002579 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002580 "$O_CLI -key data_files/server5.key \
2581 -cert data_files/server5.eku-cli.crt" \
2582 0 \
2583 -S "bad certificate (usage extensions)" \
2584 -S "Processing of the Certificate handshake message failed"
2585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002586run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002587 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002588 "$O_CLI -key data_files/server5.key \
2589 -cert data_files/server5.eku-srv_cli.crt" \
2590 0 \
2591 -S "bad certificate (usage extensions)" \
2592 -S "Processing of the Certificate handshake message failed"
2593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002594run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002595 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002596 "$O_CLI -key data_files/server5.key \
2597 -cert data_files/server5.eku-cs_any.crt" \
2598 0 \
2599 -S "bad certificate (usage extensions)" \
2600 -S "Processing of the Certificate handshake message failed"
2601
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002602run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002603 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002604 "$O_CLI -key data_files/server5.key \
2605 -cert data_files/server5.eku-cs.crt" \
2606 0 \
2607 -s "bad certificate (usage extensions)" \
2608 -S "Processing of the Certificate handshake message failed"
2609
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002610run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002611 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002612 "$O_CLI -key data_files/server5.key \
2613 -cert data_files/server5.eku-cs.crt" \
2614 1 \
2615 -s "bad certificate (usage extensions)" \
2616 -s "Processing of the Certificate handshake message failed"
2617
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002618# Tests for DHM parameters loading
2619
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002620run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002621 "$P_SRV" \
2622 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2623 debug_level=3" \
2624 0 \
2625 -c "value of 'DHM: P ' (2048 bits)" \
2626 -c "value of 'DHM: G ' (2048 bits)"
2627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002628run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002629 "$P_SRV dhm_file=data_files/dhparams.pem" \
2630 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2631 debug_level=3" \
2632 0 \
2633 -c "value of 'DHM: P ' (1024 bits)" \
2634 -c "value of 'DHM: G ' (2 bits)"
2635
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002636# Tests for DHM client-side size checking
2637
2638run_test "DHM size: server default, client default, OK" \
2639 "$P_SRV" \
2640 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2641 debug_level=1" \
2642 0 \
2643 -C "DHM prime too short:"
2644
2645run_test "DHM size: server default, client 2048, OK" \
2646 "$P_SRV" \
2647 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2648 debug_level=1 dhmlen=2048" \
2649 0 \
2650 -C "DHM prime too short:"
2651
2652run_test "DHM size: server 1024, client default, OK" \
2653 "$P_SRV dhm_file=data_files/dhparams.pem" \
2654 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2655 debug_level=1" \
2656 0 \
2657 -C "DHM prime too short:"
2658
2659run_test "DHM size: server 1000, client default, rejected" \
2660 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2661 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2662 debug_level=1" \
2663 1 \
2664 -c "DHM prime too short:"
2665
2666run_test "DHM size: server default, client 2049, rejected" \
2667 "$P_SRV" \
2668 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2669 debug_level=1 dhmlen=2049" \
2670 1 \
2671 -c "DHM prime too short:"
2672
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002673# Tests for PSK callback
2674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002675run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002676 "$P_SRV psk=abc123 psk_identity=foo" \
2677 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2678 psk_identity=foo psk=abc123" \
2679 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002680 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002681 -S "SSL - Unknown identity received" \
2682 -S "SSL - Verification of the message MAC failed"
2683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002684run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002685 "$P_SRV" \
2686 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2687 psk_identity=foo psk=abc123" \
2688 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002689 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002690 -S "SSL - Unknown identity received" \
2691 -S "SSL - Verification of the message MAC failed"
2692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002693run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002694 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2695 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2696 psk_identity=foo psk=abc123" \
2697 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002698 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002699 -s "SSL - Unknown identity received" \
2700 -S "SSL - Verification of the message MAC failed"
2701
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002702run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002703 "$P_SRV psk_list=abc,dead,def,beef" \
2704 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2705 psk_identity=abc psk=dead" \
2706 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002707 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002708 -S "SSL - Unknown identity received" \
2709 -S "SSL - Verification of the message MAC failed"
2710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002711run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002712 "$P_SRV psk_list=abc,dead,def,beef" \
2713 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2714 psk_identity=def psk=beef" \
2715 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002716 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002717 -S "SSL - Unknown identity received" \
2718 -S "SSL - Verification of the message MAC failed"
2719
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002720run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002721 "$P_SRV psk_list=abc,dead,def,beef" \
2722 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2723 psk_identity=ghi psk=beef" \
2724 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002725 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002726 -s "SSL - Unknown identity received" \
2727 -S "SSL - Verification of the message MAC failed"
2728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002729run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002730 "$P_SRV psk_list=abc,dead,def,beef" \
2731 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2732 psk_identity=abc psk=beef" \
2733 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002734 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002735 -S "SSL - Unknown identity received" \
2736 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002737
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002738# Tests for ciphersuites per version
2739
Janos Follath542ee5d2016-03-07 15:57:05 +00002740requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002741run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002742 "$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 +02002743 "$P_CLI force_version=ssl3" \
2744 0 \
2745 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002747run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002748 "$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 +01002749 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002750 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002751 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002753run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002754 "$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 +02002755 "$P_CLI force_version=tls1_1" \
2756 0 \
2757 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002759run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002760 "$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 +02002761 "$P_CLI force_version=tls1_2" \
2762 0 \
2763 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2764
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002765# Test for ClientHello without extensions
2766
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002767requires_gnutls
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002768run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002769 "$P_SRV debug_level=3" \
2770 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2771 0 \
2772 -s "dumping 'client hello extensions' (0 bytes)"
2773
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002774requires_gnutls
2775run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
2776 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
2777 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2778 0 \
2779 -s "dumping 'client hello extensions' (0 bytes)"
2780
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002781# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002782
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002783run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002784 "$P_SRV" \
2785 "$P_CLI request_size=100" \
2786 0 \
2787 -s "Read from client: 100 bytes read$"
2788
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002789run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002790 "$P_SRV" \
2791 "$P_CLI request_size=500" \
2792 0 \
2793 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002794
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002795# Tests for small packets
2796
Janos Follath542ee5d2016-03-07 15:57:05 +00002797requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002798run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002799 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002800 "$P_CLI request_size=1 force_version=ssl3 \
2801 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2802 0 \
2803 -s "Read from client: 1 bytes read"
2804
Janos Follath542ee5d2016-03-07 15:57:05 +00002805requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002806run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002807 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002808 "$P_CLI request_size=1 force_version=ssl3 \
2809 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2810 0 \
2811 -s "Read from client: 1 bytes read"
2812
2813run_test "Small packet TLS 1.0 BlockCipher" \
2814 "$P_SRV" \
2815 "$P_CLI request_size=1 force_version=tls1 \
2816 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2817 0 \
2818 -s "Read from client: 1 bytes read"
2819
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002820run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2821 "$P_SRV" \
2822 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2823 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2824 0 \
2825 -s "Read from client: 1 bytes read"
2826
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002827run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2828 "$P_SRV" \
2829 "$P_CLI request_size=1 force_version=tls1 \
2830 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2831 trunc_hmac=1" \
2832 0 \
2833 -s "Read from client: 1 bytes read"
2834
2835run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002836 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002837 "$P_CLI request_size=1 force_version=tls1 \
2838 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2839 trunc_hmac=1" \
2840 0 \
2841 -s "Read from client: 1 bytes read"
2842
2843run_test "Small packet TLS 1.1 BlockCipher" \
2844 "$P_SRV" \
2845 "$P_CLI request_size=1 force_version=tls1_1 \
2846 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2847 0 \
2848 -s "Read from client: 1 bytes read"
2849
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002850run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2851 "$P_SRV" \
2852 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2853 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2854 0 \
2855 -s "Read from client: 1 bytes read"
2856
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002857run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002858 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002859 "$P_CLI request_size=1 force_version=tls1_1 \
2860 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2861 0 \
2862 -s "Read from client: 1 bytes read"
2863
2864run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2865 "$P_SRV" \
2866 "$P_CLI request_size=1 force_version=tls1_1 \
2867 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2868 trunc_hmac=1" \
2869 0 \
2870 -s "Read from client: 1 bytes read"
2871
2872run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002873 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002874 "$P_CLI request_size=1 force_version=tls1_1 \
2875 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2876 trunc_hmac=1" \
2877 0 \
2878 -s "Read from client: 1 bytes read"
2879
2880run_test "Small packet TLS 1.2 BlockCipher" \
2881 "$P_SRV" \
2882 "$P_CLI request_size=1 force_version=tls1_2 \
2883 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2884 0 \
2885 -s "Read from client: 1 bytes read"
2886
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002887run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2888 "$P_SRV" \
2889 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2890 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2891 0 \
2892 -s "Read from client: 1 bytes read"
2893
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002894run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2895 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002896 "$P_CLI request_size=1 force_version=tls1_2 \
2897 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002898 0 \
2899 -s "Read from client: 1 bytes read"
2900
2901run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2902 "$P_SRV" \
2903 "$P_CLI request_size=1 force_version=tls1_2 \
2904 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2905 trunc_hmac=1" \
2906 0 \
2907 -s "Read from client: 1 bytes read"
2908
2909run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002910 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002911 "$P_CLI request_size=1 force_version=tls1_2 \
2912 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2913 0 \
2914 -s "Read from client: 1 bytes read"
2915
2916run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002917 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002918 "$P_CLI request_size=1 force_version=tls1_2 \
2919 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2920 trunc_hmac=1" \
2921 0 \
2922 -s "Read from client: 1 bytes read"
2923
2924run_test "Small packet TLS 1.2 AEAD" \
2925 "$P_SRV" \
2926 "$P_CLI request_size=1 force_version=tls1_2 \
2927 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2928 0 \
2929 -s "Read from client: 1 bytes read"
2930
2931run_test "Small packet TLS 1.2 AEAD shorter tag" \
2932 "$P_SRV" \
2933 "$P_CLI request_size=1 force_version=tls1_2 \
2934 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2935 0 \
2936 -s "Read from client: 1 bytes read"
2937
Janos Follathb700c462016-05-06 13:48:23 +01002938# A test for extensions in SSLv3
2939
2940requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2941run_test "SSLv3 with extensions, server side" \
2942 "$P_SRV min_version=ssl3 debug_level=3" \
2943 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2944 0 \
2945 -S "dumping 'client hello extensions'" \
2946 -S "server hello, total extension length:"
2947
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002948# Test for large packets
2949
Janos Follath542ee5d2016-03-07 15:57:05 +00002950requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002951run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002952 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002953 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002954 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2955 0 \
2956 -s "Read from client: 16384 bytes read"
2957
Janos Follath542ee5d2016-03-07 15:57:05 +00002958requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002959run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002960 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002961 "$P_CLI request_size=16384 force_version=ssl3 \
2962 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2963 0 \
2964 -s "Read from client: 16384 bytes read"
2965
2966run_test "Large packet TLS 1.0 BlockCipher" \
2967 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002968 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002969 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2970 0 \
2971 -s "Read from client: 16384 bytes read"
2972
2973run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2974 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002975 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002976 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2977 trunc_hmac=1" \
2978 0 \
2979 -s "Read from client: 16384 bytes read"
2980
2981run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002982 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002983 "$P_CLI request_size=16384 force_version=tls1 \
2984 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2985 trunc_hmac=1" \
2986 0 \
2987 -s "Read from client: 16384 bytes read"
2988
2989run_test "Large packet TLS 1.1 BlockCipher" \
2990 "$P_SRV" \
2991 "$P_CLI request_size=16384 force_version=tls1_1 \
2992 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2993 0 \
2994 -s "Read from client: 16384 bytes read"
2995
2996run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002997 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002998 "$P_CLI request_size=16384 force_version=tls1_1 \
2999 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3000 0 \
3001 -s "Read from client: 16384 bytes read"
3002
3003run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3004 "$P_SRV" \
3005 "$P_CLI request_size=16384 force_version=tls1_1 \
3006 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3007 trunc_hmac=1" \
3008 0 \
3009 -s "Read from client: 16384 bytes read"
3010
3011run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003012 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003013 "$P_CLI request_size=16384 force_version=tls1_1 \
3014 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3015 trunc_hmac=1" \
3016 0 \
3017 -s "Read from client: 16384 bytes read"
3018
3019run_test "Large packet TLS 1.2 BlockCipher" \
3020 "$P_SRV" \
3021 "$P_CLI request_size=16384 force_version=tls1_2 \
3022 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3023 0 \
3024 -s "Read from client: 16384 bytes read"
3025
3026run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3027 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003028 "$P_CLI request_size=16384 force_version=tls1_2 \
3029 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003030 0 \
3031 -s "Read from client: 16384 bytes read"
3032
3033run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3034 "$P_SRV" \
3035 "$P_CLI request_size=16384 force_version=tls1_2 \
3036 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3037 trunc_hmac=1" \
3038 0 \
3039 -s "Read from client: 16384 bytes read"
3040
3041run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003042 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003043 "$P_CLI request_size=16384 force_version=tls1_2 \
3044 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3045 0 \
3046 -s "Read from client: 16384 bytes read"
3047
3048run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003049 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003050 "$P_CLI request_size=16384 force_version=tls1_2 \
3051 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3052 trunc_hmac=1" \
3053 0 \
3054 -s "Read from client: 16384 bytes read"
3055
3056run_test "Large packet TLS 1.2 AEAD" \
3057 "$P_SRV" \
3058 "$P_CLI request_size=16384 force_version=tls1_2 \
3059 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3060 0 \
3061 -s "Read from client: 16384 bytes read"
3062
3063run_test "Large packet TLS 1.2 AEAD shorter tag" \
3064 "$P_SRV" \
3065 "$P_CLI request_size=16384 force_version=tls1_2 \
3066 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3067 0 \
3068 -s "Read from client: 16384 bytes read"
3069
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003070# Tests for DTLS HelloVerifyRequest
3071
3072run_test "DTLS cookie: enabled" \
3073 "$P_SRV dtls=1 debug_level=2" \
3074 "$P_CLI dtls=1 debug_level=2" \
3075 0 \
3076 -s "cookie verification failed" \
3077 -s "cookie verification passed" \
3078 -S "cookie verification skipped" \
3079 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003080 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003081 -S "SSL - The requested feature is not available"
3082
3083run_test "DTLS cookie: disabled" \
3084 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3085 "$P_CLI dtls=1 debug_level=2" \
3086 0 \
3087 -S "cookie verification failed" \
3088 -S "cookie verification passed" \
3089 -s "cookie verification skipped" \
3090 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003091 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003092 -S "SSL - The requested feature is not available"
3093
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003094run_test "DTLS cookie: default (failing)" \
3095 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3096 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3097 1 \
3098 -s "cookie verification failed" \
3099 -S "cookie verification passed" \
3100 -S "cookie verification skipped" \
3101 -C "received hello verify request" \
3102 -S "hello verification requested" \
3103 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003104
3105requires_ipv6
3106run_test "DTLS cookie: enabled, IPv6" \
3107 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3108 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3109 0 \
3110 -s "cookie verification failed" \
3111 -s "cookie verification passed" \
3112 -S "cookie verification skipped" \
3113 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003114 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003115 -S "SSL - The requested feature is not available"
3116
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003117run_test "DTLS cookie: enabled, nbio" \
3118 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3119 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3120 0 \
3121 -s "cookie verification failed" \
3122 -s "cookie verification passed" \
3123 -S "cookie verification skipped" \
3124 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003125 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003126 -S "SSL - The requested feature is not available"
3127
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003128# Tests for client reconnecting from the same port with DTLS
3129
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003130not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003131run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003132 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3133 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003134 0 \
3135 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003136 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003137 -S "Client initiated reconnection from same port"
3138
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003139not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003140run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003141 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3142 "$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 +02003143 0 \
3144 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003145 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003146 -s "Client initiated reconnection from same port"
3147
Paul Bakker3b224ff2016-05-13 10:33:25 +01003148not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3149run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003150 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3151 "$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 +02003152 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003153 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003154 -s "Client initiated reconnection from same port"
3155
Paul Bakker3b224ff2016-05-13 10:33:25 +01003156only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3157run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3158 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3159 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3160 0 \
3161 -S "The operation timed out" \
3162 -s "Client initiated reconnection from same port"
3163
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003164run_test "DTLS client reconnect from same port: no cookies" \
3165 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003166 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3167 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003168 -s "The operation timed out" \
3169 -S "Client initiated reconnection from same port"
3170
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003171# Tests for various cases of client authentication with DTLS
3172# (focused on handshake flows and message parsing)
3173
3174run_test "DTLS client auth: required" \
3175 "$P_SRV dtls=1 auth_mode=required" \
3176 "$P_CLI dtls=1" \
3177 0 \
3178 -s "Verifying peer X.509 certificate... ok"
3179
3180run_test "DTLS client auth: optional, client has no cert" \
3181 "$P_SRV dtls=1 auth_mode=optional" \
3182 "$P_CLI dtls=1 crt_file=none key_file=none" \
3183 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003184 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003185
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003186run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003187 "$P_SRV dtls=1 auth_mode=none" \
3188 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3189 0 \
3190 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003191 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003192
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003193run_test "DTLS wrong PSK: badmac alert" \
3194 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3195 "$P_CLI dtls=1 psk=abc124" \
3196 1 \
3197 -s "SSL - Verification of the message MAC failed" \
3198 -c "SSL - A fatal alert message was received from our peer"
3199
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003200# Tests for receiving fragmented handshake messages with DTLS
3201
3202requires_gnutls
3203run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3204 "$G_SRV -u --mtu 2048 -a" \
3205 "$P_CLI dtls=1 debug_level=2" \
3206 0 \
3207 -C "found fragmented DTLS handshake message" \
3208 -C "error"
3209
3210requires_gnutls
3211run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3212 "$G_SRV -u --mtu 512" \
3213 "$P_CLI dtls=1 debug_level=2" \
3214 0 \
3215 -c "found fragmented DTLS handshake message" \
3216 -C "error"
3217
3218requires_gnutls
3219run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3220 "$G_SRV -u --mtu 128" \
3221 "$P_CLI dtls=1 debug_level=2" \
3222 0 \
3223 -c "found fragmented DTLS handshake message" \
3224 -C "error"
3225
3226requires_gnutls
3227run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3228 "$G_SRV -u --mtu 128" \
3229 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3230 0 \
3231 -c "found fragmented DTLS handshake message" \
3232 -C "error"
3233
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003234requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003235run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3236 "$G_SRV -u --mtu 256" \
3237 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3238 0 \
3239 -c "found fragmented DTLS handshake message" \
3240 -c "client hello, adding renegotiation extension" \
3241 -c "found renegotiation extension" \
3242 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003243 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003244 -C "error" \
3245 -s "Extra-header:"
3246
3247requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003248run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3249 "$G_SRV -u --mtu 256" \
3250 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3251 0 \
3252 -c "found fragmented DTLS handshake message" \
3253 -c "client hello, adding renegotiation extension" \
3254 -c "found renegotiation extension" \
3255 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003256 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003257 -C "error" \
3258 -s "Extra-header:"
3259
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003260run_test "DTLS reassembly: no fragmentation (openssl server)" \
3261 "$O_SRV -dtls1 -mtu 2048" \
3262 "$P_CLI dtls=1 debug_level=2" \
3263 0 \
3264 -C "found fragmented DTLS handshake message" \
3265 -C "error"
3266
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003267run_test "DTLS reassembly: some fragmentation (openssl server)" \
3268 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003269 "$P_CLI dtls=1 debug_level=2" \
3270 0 \
3271 -c "found fragmented DTLS handshake message" \
3272 -C "error"
3273
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003274run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003275 "$O_SRV -dtls1 -mtu 256" \
3276 "$P_CLI dtls=1 debug_level=2" \
3277 0 \
3278 -c "found fragmented DTLS handshake message" \
3279 -C "error"
3280
3281run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3282 "$O_SRV -dtls1 -mtu 256" \
3283 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3284 0 \
3285 -c "found fragmented DTLS handshake message" \
3286 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003287
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003288# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003289
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003290not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003291run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003292 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003293 "$P_SRV dtls=1 debug_level=2" \
3294 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003295 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003296 -C "replayed record" \
3297 -S "replayed record" \
3298 -C "record from another epoch" \
3299 -S "record from another epoch" \
3300 -C "discarding invalid record" \
3301 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003302 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003303 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003304 -c "HTTP/1.0 200 OK"
3305
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003306not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003307run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003308 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003309 "$P_SRV dtls=1 debug_level=2" \
3310 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003311 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003312 -c "replayed record" \
3313 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003314 -c "discarding invalid record" \
3315 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003316 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003317 -s "Extra-header:" \
3318 -c "HTTP/1.0 200 OK"
3319
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003320run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3321 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003322 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3323 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003324 0 \
3325 -c "replayed record" \
3326 -S "replayed record" \
3327 -c "discarding invalid record" \
3328 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003329 -c "resend" \
3330 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003331 -s "Extra-header:" \
3332 -c "HTTP/1.0 200 OK"
3333
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003334run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003335 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003336 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003337 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003338 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003339 -c "discarding invalid record (mac)" \
3340 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003341 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003342 -c "HTTP/1.0 200 OK" \
3343 -S "too many records with bad MAC" \
3344 -S "Verification of the message MAC failed"
3345
3346run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3347 -p "$P_PXY bad_ad=1" \
3348 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3349 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3350 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003351 -C "discarding invalid record (mac)" \
3352 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003353 -S "Extra-header:" \
3354 -C "HTTP/1.0 200 OK" \
3355 -s "too many records with bad MAC" \
3356 -s "Verification of the message MAC failed"
3357
3358run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3359 -p "$P_PXY bad_ad=1" \
3360 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3361 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3362 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003363 -c "discarding invalid record (mac)" \
3364 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003365 -s "Extra-header:" \
3366 -c "HTTP/1.0 200 OK" \
3367 -S "too many records with bad MAC" \
3368 -S "Verification of the message MAC failed"
3369
3370run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3371 -p "$P_PXY bad_ad=1" \
3372 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3373 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3374 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003375 -c "discarding invalid record (mac)" \
3376 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003377 -s "Extra-header:" \
3378 -c "HTTP/1.0 200 OK" \
3379 -s "too many records with bad MAC" \
3380 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003381
3382run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003383 -p "$P_PXY delay_ccs=1" \
3384 "$P_SRV dtls=1 debug_level=1" \
3385 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003386 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003387 -c "record from another epoch" \
3388 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003389 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003390 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003391 -s "Extra-header:" \
3392 -c "HTTP/1.0 200 OK"
3393
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003394# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003395
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003396needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003397run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003398 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003399 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3400 psk=abc123" \
3401 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003402 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3403 0 \
3404 -s "Extra-header:" \
3405 -c "HTTP/1.0 200 OK"
3406
3407needs_more_time 2
3408run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3409 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003410 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3411 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003412 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3413 0 \
3414 -s "Extra-header:" \
3415 -c "HTTP/1.0 200 OK"
3416
3417needs_more_time 2
3418run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3419 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003420 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3421 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003422 0 \
3423 -s "Extra-header:" \
3424 -c "HTTP/1.0 200 OK"
3425
3426needs_more_time 2
3427run_test "DTLS proxy: 3d, FS, client auth" \
3428 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003429 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3430 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003431 0 \
3432 -s "Extra-header:" \
3433 -c "HTTP/1.0 200 OK"
3434
3435needs_more_time 2
3436run_test "DTLS proxy: 3d, FS, ticket" \
3437 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003438 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3439 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003440 0 \
3441 -s "Extra-header:" \
3442 -c "HTTP/1.0 200 OK"
3443
3444needs_more_time 2
3445run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3446 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003447 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3448 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003449 0 \
3450 -s "Extra-header:" \
3451 -c "HTTP/1.0 200 OK"
3452
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003453needs_more_time 2
3454run_test "DTLS proxy: 3d, max handshake, nbio" \
3455 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003456 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3457 auth_mode=required" \
3458 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003459 0 \
3460 -s "Extra-header:" \
3461 -c "HTTP/1.0 200 OK"
3462
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003463needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003464run_test "DTLS proxy: 3d, min handshake, resumption" \
3465 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3466 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3467 psk=abc123 debug_level=3" \
3468 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3469 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3470 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3471 0 \
3472 -s "a session has been resumed" \
3473 -c "a session has been resumed" \
3474 -s "Extra-header:" \
3475 -c "HTTP/1.0 200 OK"
3476
3477needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003478run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3479 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3480 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3481 psk=abc123 debug_level=3 nbio=2" \
3482 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3483 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3484 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3485 0 \
3486 -s "a session has been resumed" \
3487 -c "a session has been resumed" \
3488 -s "Extra-header:" \
3489 -c "HTTP/1.0 200 OK"
3490
3491needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003492run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003493 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003494 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3495 psk=abc123 renegotiation=1 debug_level=2" \
3496 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3497 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003498 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3499 0 \
3500 -c "=> renegotiate" \
3501 -s "=> renegotiate" \
3502 -s "Extra-header:" \
3503 -c "HTTP/1.0 200 OK"
3504
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003505needs_more_time 4
3506run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3507 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003508 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3509 psk=abc123 renegotiation=1 debug_level=2" \
3510 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3511 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003512 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3513 0 \
3514 -c "=> renegotiate" \
3515 -s "=> renegotiate" \
3516 -s "Extra-header:" \
3517 -c "HTTP/1.0 200 OK"
3518
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003519needs_more_time 4
3520run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003521 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003522 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003523 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003524 debug_level=2" \
3525 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003526 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003527 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3528 0 \
3529 -c "=> renegotiate" \
3530 -s "=> renegotiate" \
3531 -s "Extra-header:" \
3532 -c "HTTP/1.0 200 OK"
3533
3534needs_more_time 4
3535run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003536 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003537 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003538 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003539 debug_level=2 nbio=2" \
3540 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003541 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003542 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3543 0 \
3544 -c "=> renegotiate" \
3545 -s "=> renegotiate" \
3546 -s "Extra-header:" \
3547 -c "HTTP/1.0 200 OK"
3548
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003549needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003550not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003551run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003552 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3553 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003554 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003555 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003556 -c "HTTP/1.0 200 OK"
3557
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003558needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003559not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003560run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3561 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3562 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003563 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003564 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003565 -c "HTTP/1.0 200 OK"
3566
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003567needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003568not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003569run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3570 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3571 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003572 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003573 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003574 -c "HTTP/1.0 200 OK"
3575
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003576requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003577needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003578not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003579run_test "DTLS proxy: 3d, gnutls server" \
3580 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3581 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003582 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003583 0 \
3584 -s "Extra-header:" \
3585 -c "Extra-header:"
3586
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003587requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003588needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003589not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003590run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3591 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3592 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003593 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003594 0 \
3595 -s "Extra-header:" \
3596 -c "Extra-header:"
3597
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003598requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003599needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003600not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003601run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3602 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3603 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003604 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003605 0 \
3606 -s "Extra-header:" \
3607 -c "Extra-header:"
3608
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003609# Final report
3610
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003611echo "------------------------------------------------------------------------"
3612
3613if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003614 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003615else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003616 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003617fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003618PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003619echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003620
3621exit $FAILS