blob: 156785ee45c21c3053842a9723ad13437ecf6938 [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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001766run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001767 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001768 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001769 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001770 0 \
1771 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001772 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001773 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001774 -C "X509 - Certificate verification failed"
1775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001776run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001777 "$P_SRV debug_level=3 auth_mode=required" \
1778 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001779 key_file=data_files/server5.key" \
1780 1 \
1781 -S "skip write certificate request" \
1782 -C "skip parse certificate request" \
1783 -c "got a certificate request" \
1784 -C "skip write certificate" \
1785 -C "skip write certificate verify" \
1786 -S "skip parse certificate verify" \
1787 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001788 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001789 -s "! mbedtls_ssl_handshake returned" \
1790 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001791 -s "X509 - Certificate verification failed"
1792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001793run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001794 "$P_SRV debug_level=3 auth_mode=optional" \
1795 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001796 key_file=data_files/server5.key" \
1797 0 \
1798 -S "skip write certificate request" \
1799 -C "skip parse certificate request" \
1800 -c "got a certificate request" \
1801 -C "skip write certificate" \
1802 -C "skip write certificate verify" \
1803 -S "skip parse certificate verify" \
1804 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001805 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001806 -S "! mbedtls_ssl_handshake returned" \
1807 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001808 -S "X509 - Certificate verification failed"
1809
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001810run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001811 "$P_SRV debug_level=3 auth_mode=none" \
1812 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001813 key_file=data_files/server5.key" \
1814 0 \
1815 -s "skip write certificate request" \
1816 -C "skip parse certificate request" \
1817 -c "got no certificate request" \
1818 -c "skip write certificate" \
1819 -c "skip write certificate verify" \
1820 -s "skip parse certificate verify" \
1821 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001822 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001823 -S "! mbedtls_ssl_handshake returned" \
1824 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001825 -S "X509 - Certificate verification failed"
1826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001827run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001828 "$P_SRV debug_level=3 auth_mode=optional" \
1829 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001830 0 \
1831 -S "skip write certificate request" \
1832 -C "skip parse certificate request" \
1833 -c "got a certificate request" \
1834 -C "skip write certificate$" \
1835 -C "got no certificate to send" \
1836 -S "SSLv3 client has no certificate" \
1837 -c "skip write certificate verify" \
1838 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001839 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001840 -S "! mbedtls_ssl_handshake returned" \
1841 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001842 -S "X509 - Certificate verification failed"
1843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001844run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001845 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001846 "$O_CLI" \
1847 0 \
1848 -S "skip write certificate request" \
1849 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001850 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001851 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001852 -S "X509 - Certificate verification failed"
1853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001854run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001855 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001856 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001857 0 \
1858 -C "skip parse certificate request" \
1859 -c "got a certificate request" \
1860 -C "skip write certificate$" \
1861 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001862 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001863
Janos Follath542ee5d2016-03-07 15:57:05 +00001864requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001865run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001866 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001867 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001868 0 \
1869 -S "skip write certificate request" \
1870 -C "skip parse certificate request" \
1871 -c "got a certificate request" \
1872 -C "skip write certificate$" \
1873 -c "skip write certificate verify" \
1874 -c "got no certificate to send" \
1875 -s "SSLv3 client has no certificate" \
1876 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001877 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001878 -S "! mbedtls_ssl_handshake returned" \
1879 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001880 -S "X509 - Certificate verification failed"
1881
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001882# Tests for certificate selection based on SHA verson
1883
1884run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1885 "$P_SRV crt_file=data_files/server5.crt \
1886 key_file=data_files/server5.key \
1887 crt_file2=data_files/server5-sha1.crt \
1888 key_file2=data_files/server5.key" \
1889 "$P_CLI force_version=tls1_2" \
1890 0 \
1891 -c "signed using.*ECDSA with SHA256" \
1892 -C "signed using.*ECDSA with SHA1"
1893
1894run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1895 "$P_SRV crt_file=data_files/server5.crt \
1896 key_file=data_files/server5.key \
1897 crt_file2=data_files/server5-sha1.crt \
1898 key_file2=data_files/server5.key" \
1899 "$P_CLI force_version=tls1_1" \
1900 0 \
1901 -C "signed using.*ECDSA with SHA256" \
1902 -c "signed using.*ECDSA with SHA1"
1903
1904run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1905 "$P_SRV crt_file=data_files/server5.crt \
1906 key_file=data_files/server5.key \
1907 crt_file2=data_files/server5-sha1.crt \
1908 key_file2=data_files/server5.key" \
1909 "$P_CLI force_version=tls1" \
1910 0 \
1911 -C "signed using.*ECDSA with SHA256" \
1912 -c "signed using.*ECDSA with SHA1"
1913
1914run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1915 "$P_SRV crt_file=data_files/server5.crt \
1916 key_file=data_files/server5.key \
1917 crt_file2=data_files/server6.crt \
1918 key_file2=data_files/server6.key" \
1919 "$P_CLI force_version=tls1_1" \
1920 0 \
1921 -c "serial number.*09" \
1922 -c "signed using.*ECDSA with SHA256" \
1923 -C "signed using.*ECDSA with SHA1"
1924
1925run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1926 "$P_SRV crt_file=data_files/server6.crt \
1927 key_file=data_files/server6.key \
1928 crt_file2=data_files/server5.crt \
1929 key_file2=data_files/server5.key" \
1930 "$P_CLI force_version=tls1_1" \
1931 0 \
1932 -c "serial number.*0A" \
1933 -c "signed using.*ECDSA with SHA256" \
1934 -C "signed using.*ECDSA with SHA1"
1935
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001936# tests for SNI
1937
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001938run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001939 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001940 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001941 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001942 0 \
1943 -S "parse ServerName extension" \
1944 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1945 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001947run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001948 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001949 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001950 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 +02001951 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001952 0 \
1953 -s "parse ServerName extension" \
1954 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1955 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001957run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001958 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001959 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001960 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 +02001961 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001962 0 \
1963 -s "parse ServerName extension" \
1964 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1965 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001966
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001967run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001968 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001969 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001970 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 +02001971 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001972 1 \
1973 -s "parse ServerName extension" \
1974 -s "ssl_sni_wrapper() returned" \
1975 -s "mbedtls_ssl_handshake returned" \
1976 -c "mbedtls_ssl_handshake returned" \
1977 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001978
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001979run_test "SNI: client auth no override: optional" \
1980 "$P_SRV debug_level=3 auth_mode=optional \
1981 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1982 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1983 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001984 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001985 -S "skip write certificate request" \
1986 -C "skip parse certificate request" \
1987 -c "got a certificate request" \
1988 -C "skip write certificate" \
1989 -C "skip write certificate verify" \
1990 -S "skip parse certificate verify"
1991
1992run_test "SNI: client auth override: none -> optional" \
1993 "$P_SRV debug_level=3 auth_mode=none \
1994 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1995 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1996 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001997 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001998 -S "skip write certificate request" \
1999 -C "skip parse certificate request" \
2000 -c "got a certificate request" \
2001 -C "skip write certificate" \
2002 -C "skip write certificate verify" \
2003 -S "skip parse certificate verify"
2004
2005run_test "SNI: client auth override: optional -> none" \
2006 "$P_SRV debug_level=3 auth_mode=optional \
2007 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2008 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2009 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002010 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002011 -s "skip write certificate request" \
2012 -C "skip parse certificate request" \
2013 -c "got no certificate request" \
2014 -c "skip write certificate" \
2015 -c "skip write certificate verify" \
2016 -s "skip parse certificate verify"
2017
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002018run_test "SNI: CA no override" \
2019 "$P_SRV debug_level=3 auth_mode=optional \
2020 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2021 ca_file=data_files/test-ca.crt \
2022 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2023 "$P_CLI debug_level=3 server_name=localhost \
2024 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2025 1 \
2026 -S "skip write certificate request" \
2027 -C "skip parse certificate request" \
2028 -c "got a certificate request" \
2029 -C "skip write certificate" \
2030 -C "skip write certificate verify" \
2031 -S "skip parse certificate verify" \
2032 -s "x509_verify_cert() returned" \
2033 -s "! The certificate is not correctly signed by the trusted CA" \
2034 -S "The certificate has been revoked (is on a CRL)"
2035
2036run_test "SNI: CA override" \
2037 "$P_SRV debug_level=3 auth_mode=optional \
2038 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2039 ca_file=data_files/test-ca.crt \
2040 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2041 "$P_CLI debug_level=3 server_name=localhost \
2042 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2043 0 \
2044 -S "skip write certificate request" \
2045 -C "skip parse certificate request" \
2046 -c "got a certificate request" \
2047 -C "skip write certificate" \
2048 -C "skip write certificate verify" \
2049 -S "skip parse certificate verify" \
2050 -S "x509_verify_cert() returned" \
2051 -S "! The certificate is not correctly signed by the trusted CA" \
2052 -S "The certificate has been revoked (is on a CRL)"
2053
2054run_test "SNI: CA override with CRL" \
2055 "$P_SRV debug_level=3 auth_mode=optional \
2056 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2057 ca_file=data_files/test-ca.crt \
2058 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2059 "$P_CLI debug_level=3 server_name=localhost \
2060 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2061 1 \
2062 -S "skip write certificate request" \
2063 -C "skip parse certificate request" \
2064 -c "got a certificate request" \
2065 -C "skip write certificate" \
2066 -C "skip write certificate verify" \
2067 -S "skip parse certificate verify" \
2068 -s "x509_verify_cert() returned" \
2069 -S "! The certificate is not correctly signed by the trusted CA" \
2070 -s "The certificate has been revoked (is on a CRL)"
2071
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002072# Tests for non-blocking I/O: exercise a variety of handshake flows
2073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002074run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002075 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2076 "$P_CLI nbio=2 tickets=0" \
2077 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002078 -S "mbedtls_ssl_handshake returned" \
2079 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002080 -c "Read from server: .* bytes read"
2081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002082run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002083 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2084 "$P_CLI nbio=2 tickets=0" \
2085 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002086 -S "mbedtls_ssl_handshake returned" \
2087 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002088 -c "Read from server: .* bytes read"
2089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002090run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002091 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2092 "$P_CLI nbio=2 tickets=1" \
2093 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002094 -S "mbedtls_ssl_handshake returned" \
2095 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002096 -c "Read from server: .* bytes read"
2097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002098run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002099 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2100 "$P_CLI nbio=2 tickets=1" \
2101 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002102 -S "mbedtls_ssl_handshake returned" \
2103 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002104 -c "Read from server: .* bytes read"
2105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002106run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002107 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2108 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2109 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002110 -S "mbedtls_ssl_handshake returned" \
2111 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002112 -c "Read from server: .* bytes read"
2113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002114run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002115 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2116 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2117 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002118 -S "mbedtls_ssl_handshake returned" \
2119 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002120 -c "Read from server: .* bytes read"
2121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002122run_test "Non-blocking I/O: session-id resume" \
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 reconnect=1" \
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é-Gonnardf6521de2014-04-07 12:42:04 +02002130# Tests for version negotiation
2131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002132run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002133 "$P_SRV" \
2134 "$P_CLI" \
2135 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002136 -S "mbedtls_ssl_handshake returned" \
2137 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002138 -s "Protocol is TLSv1.2" \
2139 -c "Protocol is TLSv1.2"
2140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002141run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002142 "$P_SRV" \
2143 "$P_CLI max_version=tls1_1" \
2144 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002145 -S "mbedtls_ssl_handshake returned" \
2146 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002147 -s "Protocol is TLSv1.1" \
2148 -c "Protocol is TLSv1.1"
2149
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002150run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002151 "$P_SRV max_version=tls1_1" \
2152 "$P_CLI" \
2153 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002154 -S "mbedtls_ssl_handshake returned" \
2155 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002156 -s "Protocol is TLSv1.1" \
2157 -c "Protocol is TLSv1.1"
2158
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002159run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002160 "$P_SRV max_version=tls1_1" \
2161 "$P_CLI max_version=tls1_1" \
2162 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002163 -S "mbedtls_ssl_handshake returned" \
2164 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002165 -s "Protocol is TLSv1.1" \
2166 -c "Protocol is TLSv1.1"
2167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002168run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002169 "$P_SRV min_version=tls1_1" \
2170 "$P_CLI max_version=tls1_1" \
2171 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002172 -S "mbedtls_ssl_handshake returned" \
2173 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002174 -s "Protocol is TLSv1.1" \
2175 -c "Protocol is TLSv1.1"
2176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002177run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002178 "$P_SRV max_version=tls1_1" \
2179 "$P_CLI min_version=tls1_1" \
2180 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002181 -S "mbedtls_ssl_handshake returned" \
2182 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002183 -s "Protocol is TLSv1.1" \
2184 -c "Protocol is TLSv1.1"
2185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002186run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002187 "$P_SRV max_version=tls1_1" \
2188 "$P_CLI min_version=tls1_2" \
2189 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002190 -s "mbedtls_ssl_handshake returned" \
2191 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002192 -c "SSL - Handshake protocol not within min/max boundaries"
2193
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002194run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002195 "$P_SRV min_version=tls1_2" \
2196 "$P_CLI max_version=tls1_1" \
2197 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002198 -s "mbedtls_ssl_handshake returned" \
2199 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002200 -s "SSL - Handshake protocol not within min/max boundaries"
2201
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002202# Tests for ALPN extension
2203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002204run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002205 "$P_SRV debug_level=3" \
2206 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002207 0 \
2208 -C "client hello, adding alpn extension" \
2209 -S "found alpn extension" \
2210 -C "got an alert message, type: \\[2:120]" \
2211 -S "server hello, adding alpn extension" \
2212 -C "found alpn extension " \
2213 -C "Application Layer Protocol is" \
2214 -S "Application Layer Protocol is"
2215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002216run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002217 "$P_SRV debug_level=3" \
2218 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002219 0 \
2220 -c "client hello, adding alpn extension" \
2221 -s "found alpn extension" \
2222 -C "got an alert message, type: \\[2:120]" \
2223 -S "server hello, adding alpn extension" \
2224 -C "found alpn extension " \
2225 -c "Application Layer Protocol is (none)" \
2226 -S "Application Layer Protocol is"
2227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002228run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002229 "$P_SRV debug_level=3 alpn=abc,1234" \
2230 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002231 0 \
2232 -C "client hello, adding alpn extension" \
2233 -S "found alpn extension" \
2234 -C "got an alert message, type: \\[2:120]" \
2235 -S "server hello, adding alpn extension" \
2236 -C "found alpn extension " \
2237 -C "Application Layer Protocol is" \
2238 -s "Application Layer Protocol is (none)"
2239
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002240run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002241 "$P_SRV debug_level=3 alpn=abc,1234" \
2242 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002243 0 \
2244 -c "client hello, adding alpn extension" \
2245 -s "found alpn extension" \
2246 -C "got an alert message, type: \\[2:120]" \
2247 -s "server hello, adding alpn extension" \
2248 -c "found alpn extension" \
2249 -c "Application Layer Protocol is abc" \
2250 -s "Application Layer Protocol is abc"
2251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002252run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002253 "$P_SRV debug_level=3 alpn=abc,1234" \
2254 "$P_CLI debug_level=3 alpn=1234,abc" \
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 abc" \
2262 -s "Application Layer Protocol is abc"
2263
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002264run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002265 "$P_SRV debug_level=3 alpn=abc,1234" \
2266 "$P_CLI debug_level=3 alpn=1234,abcde" \
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 1234" \
2274 -s "Application Layer Protocol is 1234"
2275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002276run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002277 "$P_SRV debug_level=3 alpn=abc,123" \
2278 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002279 1 \
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 1234" \
2286 -S "Application Layer Protocol is 1234"
2287
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002288
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002289# Tests for keyUsage in leaf certificates, part 1:
2290# server-side certificate/suite selection
2291
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002292run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002293 "$P_SRV key_file=data_files/server2.key \
2294 crt_file=data_files/server2.ku-ds.crt" \
2295 "$P_CLI" \
2296 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002297 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002298
2299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002300run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002301 "$P_SRV key_file=data_files/server2.key \
2302 crt_file=data_files/server2.ku-ke.crt" \
2303 "$P_CLI" \
2304 0 \
2305 -c "Ciphersuite is TLS-RSA-WITH-"
2306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002307run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002308 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002309 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002310 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002311 1 \
2312 -C "Ciphersuite is "
2313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002314run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002315 "$P_SRV key_file=data_files/server5.key \
2316 crt_file=data_files/server5.ku-ds.crt" \
2317 "$P_CLI" \
2318 0 \
2319 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2320
2321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002322run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002323 "$P_SRV key_file=data_files/server5.key \
2324 crt_file=data_files/server5.ku-ka.crt" \
2325 "$P_CLI" \
2326 0 \
2327 -c "Ciphersuite is TLS-ECDH-"
2328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002329run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002330 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002331 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002332 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002333 1 \
2334 -C "Ciphersuite is "
2335
2336# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002337# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002339run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002340 "$O_SRV -key data_files/server2.key \
2341 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002342 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002343 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2344 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002345 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002346 -C "Processing of the Certificate handshake message failed" \
2347 -c "Ciphersuite is TLS-"
2348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002349run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002350 "$O_SRV -key data_files/server2.key \
2351 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002352 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002353 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2354 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002355 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002356 -C "Processing of the Certificate handshake message failed" \
2357 -c "Ciphersuite is TLS-"
2358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002359run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002360 "$O_SRV -key data_files/server2.key \
2361 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002362 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002363 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2364 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002365 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002366 -C "Processing of the Certificate handshake message failed" \
2367 -c "Ciphersuite is TLS-"
2368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002369run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002370 "$O_SRV -key data_files/server2.key \
2371 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002372 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002373 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2374 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002375 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002376 -c "Processing of the Certificate handshake message failed" \
2377 -C "Ciphersuite is TLS-"
2378
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002379run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2380 "$O_SRV -key data_files/server2.key \
2381 -cert data_files/server2.ku-ke.crt" \
2382 "$P_CLI debug_level=1 auth_mode=optional \
2383 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2384 0 \
2385 -c "bad certificate (usage extensions)" \
2386 -C "Processing of the Certificate handshake message failed" \
2387 -c "Ciphersuite is TLS-" \
2388 -c "! Usage does not match the keyUsage extension"
2389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002390run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002391 "$O_SRV -key data_files/server2.key \
2392 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002393 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002394 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2395 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002396 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002397 -C "Processing of the Certificate handshake message failed" \
2398 -c "Ciphersuite is TLS-"
2399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002400run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002401 "$O_SRV -key data_files/server2.key \
2402 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002403 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002404 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2405 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002406 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002407 -c "Processing of the Certificate handshake message failed" \
2408 -C "Ciphersuite is TLS-"
2409
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002410run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2411 "$O_SRV -key data_files/server2.key \
2412 -cert data_files/server2.ku-ds.crt" \
2413 "$P_CLI debug_level=1 auth_mode=optional \
2414 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2415 0 \
2416 -c "bad certificate (usage extensions)" \
2417 -C "Processing of the Certificate handshake message failed" \
2418 -c "Ciphersuite is TLS-" \
2419 -c "! Usage does not match the keyUsage extension"
2420
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002421# Tests for keyUsage in leaf certificates, part 3:
2422# server-side checking of client cert
2423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002424run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002425 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002426 "$O_CLI -key data_files/server2.key \
2427 -cert data_files/server2.ku-ds.crt" \
2428 0 \
2429 -S "bad certificate (usage extensions)" \
2430 -S "Processing of the Certificate handshake message failed"
2431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002432run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002433 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002434 "$O_CLI -key data_files/server2.key \
2435 -cert data_files/server2.ku-ke.crt" \
2436 0 \
2437 -s "bad certificate (usage extensions)" \
2438 -S "Processing of the Certificate handshake message failed"
2439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002440run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002441 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002442 "$O_CLI -key data_files/server2.key \
2443 -cert data_files/server2.ku-ke.crt" \
2444 1 \
2445 -s "bad certificate (usage extensions)" \
2446 -s "Processing of the Certificate handshake message failed"
2447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002448run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002449 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002450 "$O_CLI -key data_files/server5.key \
2451 -cert data_files/server5.ku-ds.crt" \
2452 0 \
2453 -S "bad certificate (usage extensions)" \
2454 -S "Processing of the Certificate handshake message failed"
2455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002456run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002457 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002458 "$O_CLI -key data_files/server5.key \
2459 -cert data_files/server5.ku-ka.crt" \
2460 0 \
2461 -s "bad certificate (usage extensions)" \
2462 -S "Processing of the Certificate handshake message failed"
2463
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002464# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002466run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002467 "$P_SRV key_file=data_files/server5.key \
2468 crt_file=data_files/server5.eku-srv.crt" \
2469 "$P_CLI" \
2470 0
2471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002472run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002473 "$P_SRV key_file=data_files/server5.key \
2474 crt_file=data_files/server5.eku-srv.crt" \
2475 "$P_CLI" \
2476 0
2477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002478run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002479 "$P_SRV key_file=data_files/server5.key \
2480 crt_file=data_files/server5.eku-cs_any.crt" \
2481 "$P_CLI" \
2482 0
2483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002484run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002485 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002486 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002487 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002488 1
2489
2490# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2491
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002492run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002493 "$O_SRV -key data_files/server5.key \
2494 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002495 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002496 0 \
2497 -C "bad certificate (usage extensions)" \
2498 -C "Processing of the Certificate handshake message failed" \
2499 -c "Ciphersuite is TLS-"
2500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002501run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002502 "$O_SRV -key data_files/server5.key \
2503 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002504 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002505 0 \
2506 -C "bad certificate (usage extensions)" \
2507 -C "Processing of the Certificate handshake message failed" \
2508 -c "Ciphersuite is TLS-"
2509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002510run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002511 "$O_SRV -key data_files/server5.key \
2512 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002513 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002514 0 \
2515 -C "bad certificate (usage extensions)" \
2516 -C "Processing of the Certificate handshake message failed" \
2517 -c "Ciphersuite is TLS-"
2518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002519run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002520 "$O_SRV -key data_files/server5.key \
2521 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002522 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002523 1 \
2524 -c "bad certificate (usage extensions)" \
2525 -c "Processing of the Certificate handshake message failed" \
2526 -C "Ciphersuite is TLS-"
2527
2528# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002530run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002531 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002532 "$O_CLI -key data_files/server5.key \
2533 -cert data_files/server5.eku-cli.crt" \
2534 0 \
2535 -S "bad certificate (usage extensions)" \
2536 -S "Processing of the Certificate handshake message failed"
2537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002538run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002539 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002540 "$O_CLI -key data_files/server5.key \
2541 -cert data_files/server5.eku-srv_cli.crt" \
2542 0 \
2543 -S "bad certificate (usage extensions)" \
2544 -S "Processing of the Certificate handshake message failed"
2545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002546run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002547 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002548 "$O_CLI -key data_files/server5.key \
2549 -cert data_files/server5.eku-cs_any.crt" \
2550 0 \
2551 -S "bad certificate (usage extensions)" \
2552 -S "Processing of the Certificate handshake message failed"
2553
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002554run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002555 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002556 "$O_CLI -key data_files/server5.key \
2557 -cert data_files/server5.eku-cs.crt" \
2558 0 \
2559 -s "bad certificate (usage extensions)" \
2560 -S "Processing of the Certificate handshake message failed"
2561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002562run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002563 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002564 "$O_CLI -key data_files/server5.key \
2565 -cert data_files/server5.eku-cs.crt" \
2566 1 \
2567 -s "bad certificate (usage extensions)" \
2568 -s "Processing of the Certificate handshake message failed"
2569
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002570# Tests for DHM parameters loading
2571
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002572run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002573 "$P_SRV" \
2574 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2575 debug_level=3" \
2576 0 \
2577 -c "value of 'DHM: P ' (2048 bits)" \
2578 -c "value of 'DHM: G ' (2048 bits)"
2579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002580run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002581 "$P_SRV dhm_file=data_files/dhparams.pem" \
2582 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2583 debug_level=3" \
2584 0 \
2585 -c "value of 'DHM: P ' (1024 bits)" \
2586 -c "value of 'DHM: G ' (2 bits)"
2587
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002588# Tests for DHM client-side size checking
2589
2590run_test "DHM size: server default, client default, OK" \
2591 "$P_SRV" \
2592 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2593 debug_level=1" \
2594 0 \
2595 -C "DHM prime too short:"
2596
2597run_test "DHM size: server default, client 2048, OK" \
2598 "$P_SRV" \
2599 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2600 debug_level=1 dhmlen=2048" \
2601 0 \
2602 -C "DHM prime too short:"
2603
2604run_test "DHM size: server 1024, client default, OK" \
2605 "$P_SRV dhm_file=data_files/dhparams.pem" \
2606 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2607 debug_level=1" \
2608 0 \
2609 -C "DHM prime too short:"
2610
2611run_test "DHM size: server 1000, client default, rejected" \
2612 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2613 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2614 debug_level=1" \
2615 1 \
2616 -c "DHM prime too short:"
2617
2618run_test "DHM size: server default, client 2049, rejected" \
2619 "$P_SRV" \
2620 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2621 debug_level=1 dhmlen=2049" \
2622 1 \
2623 -c "DHM prime too short:"
2624
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002625# Tests for PSK callback
2626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002627run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002628 "$P_SRV psk=abc123 psk_identity=foo" \
2629 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2630 psk_identity=foo psk=abc123" \
2631 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002632 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002633 -S "SSL - Unknown identity received" \
2634 -S "SSL - Verification of the message MAC failed"
2635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002636run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002637 "$P_SRV" \
2638 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2639 psk_identity=foo psk=abc123" \
2640 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002641 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002642 -S "SSL - Unknown identity received" \
2643 -S "SSL - Verification of the message MAC failed"
2644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002645run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002646 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2647 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2648 psk_identity=foo psk=abc123" \
2649 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002650 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002651 -s "SSL - Unknown identity received" \
2652 -S "SSL - Verification of the message MAC failed"
2653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002654run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002655 "$P_SRV psk_list=abc,dead,def,beef" \
2656 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2657 psk_identity=abc psk=dead" \
2658 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002659 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002660 -S "SSL - Unknown identity received" \
2661 -S "SSL - Verification of the message MAC failed"
2662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002663run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002664 "$P_SRV psk_list=abc,dead,def,beef" \
2665 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2666 psk_identity=def psk=beef" \
2667 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002668 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002669 -S "SSL - Unknown identity received" \
2670 -S "SSL - Verification of the message MAC failed"
2671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002672run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002673 "$P_SRV psk_list=abc,dead,def,beef" \
2674 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2675 psk_identity=ghi psk=beef" \
2676 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002677 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002678 -s "SSL - Unknown identity received" \
2679 -S "SSL - Verification of the message MAC failed"
2680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002681run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002682 "$P_SRV psk_list=abc,dead,def,beef" \
2683 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2684 psk_identity=abc psk=beef" \
2685 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002686 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002687 -S "SSL - Unknown identity received" \
2688 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002689
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002690# Tests for ciphersuites per version
2691
Janos Follath542ee5d2016-03-07 15:57:05 +00002692requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002693run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002694 "$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 +02002695 "$P_CLI force_version=ssl3" \
2696 0 \
2697 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2698
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002699run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002700 "$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 +01002701 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002702 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002703 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002705run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002706 "$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 +02002707 "$P_CLI force_version=tls1_1" \
2708 0 \
2709 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002711run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002712 "$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 +02002713 "$P_CLI force_version=tls1_2" \
2714 0 \
2715 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2716
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002717# Test for ClientHello without extensions
2718
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002719requires_gnutls
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002720run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002721 "$P_SRV debug_level=3" \
2722 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2723 0 \
2724 -s "dumping 'client hello extensions' (0 bytes)"
2725
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002726requires_gnutls
2727run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
2728 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
2729 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2730 0 \
2731 -s "dumping 'client hello extensions' (0 bytes)"
2732
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002733# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002734
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002735run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002736 "$P_SRV" \
2737 "$P_CLI request_size=100" \
2738 0 \
2739 -s "Read from client: 100 bytes read$"
2740
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002741run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002742 "$P_SRV" \
2743 "$P_CLI request_size=500" \
2744 0 \
2745 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002746
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002747# Tests for small packets
2748
Janos Follath542ee5d2016-03-07 15:57:05 +00002749requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002750run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002751 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002752 "$P_CLI request_size=1 force_version=ssl3 \
2753 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2754 0 \
2755 -s "Read from client: 1 bytes read"
2756
Janos Follath542ee5d2016-03-07 15:57:05 +00002757requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002758run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002759 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002760 "$P_CLI request_size=1 force_version=ssl3 \
2761 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2762 0 \
2763 -s "Read from client: 1 bytes read"
2764
2765run_test "Small packet TLS 1.0 BlockCipher" \
2766 "$P_SRV" \
2767 "$P_CLI request_size=1 force_version=tls1 \
2768 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2769 0 \
2770 -s "Read from client: 1 bytes read"
2771
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002772run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2773 "$P_SRV" \
2774 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2776 0 \
2777 -s "Read from client: 1 bytes read"
2778
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002779run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2780 "$P_SRV" \
2781 "$P_CLI request_size=1 force_version=tls1 \
2782 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2783 trunc_hmac=1" \
2784 0 \
2785 -s "Read from client: 1 bytes read"
2786
2787run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002788 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002789 "$P_CLI request_size=1 force_version=tls1 \
2790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2791 trunc_hmac=1" \
2792 0 \
2793 -s "Read from client: 1 bytes read"
2794
2795run_test "Small packet TLS 1.1 BlockCipher" \
2796 "$P_SRV" \
2797 "$P_CLI request_size=1 force_version=tls1_1 \
2798 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2799 0 \
2800 -s "Read from client: 1 bytes read"
2801
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002802run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2803 "$P_SRV" \
2804 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2805 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2806 0 \
2807 -s "Read from client: 1 bytes read"
2808
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002809run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002810 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002811 "$P_CLI request_size=1 force_version=tls1_1 \
2812 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2813 0 \
2814 -s "Read from client: 1 bytes read"
2815
2816run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2817 "$P_SRV" \
2818 "$P_CLI request_size=1 force_version=tls1_1 \
2819 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2820 trunc_hmac=1" \
2821 0 \
2822 -s "Read from client: 1 bytes read"
2823
2824run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002825 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002826 "$P_CLI request_size=1 force_version=tls1_1 \
2827 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2828 trunc_hmac=1" \
2829 0 \
2830 -s "Read from client: 1 bytes read"
2831
2832run_test "Small packet TLS 1.2 BlockCipher" \
2833 "$P_SRV" \
2834 "$P_CLI request_size=1 force_version=tls1_2 \
2835 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2836 0 \
2837 -s "Read from client: 1 bytes read"
2838
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002839run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2840 "$P_SRV" \
2841 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2842 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2843 0 \
2844 -s "Read from client: 1 bytes read"
2845
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002846run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2847 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002848 "$P_CLI request_size=1 force_version=tls1_2 \
2849 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002850 0 \
2851 -s "Read from client: 1 bytes read"
2852
2853run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2854 "$P_SRV" \
2855 "$P_CLI request_size=1 force_version=tls1_2 \
2856 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2857 trunc_hmac=1" \
2858 0 \
2859 -s "Read from client: 1 bytes read"
2860
2861run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002862 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002863 "$P_CLI request_size=1 force_version=tls1_2 \
2864 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2865 0 \
2866 -s "Read from client: 1 bytes read"
2867
2868run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002869 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002870 "$P_CLI request_size=1 force_version=tls1_2 \
2871 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2872 trunc_hmac=1" \
2873 0 \
2874 -s "Read from client: 1 bytes read"
2875
2876run_test "Small packet TLS 1.2 AEAD" \
2877 "$P_SRV" \
2878 "$P_CLI request_size=1 force_version=tls1_2 \
2879 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2880 0 \
2881 -s "Read from client: 1 bytes read"
2882
2883run_test "Small packet TLS 1.2 AEAD shorter tag" \
2884 "$P_SRV" \
2885 "$P_CLI request_size=1 force_version=tls1_2 \
2886 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2887 0 \
2888 -s "Read from client: 1 bytes read"
2889
Janos Follathb700c462016-05-06 13:48:23 +01002890# A test for extensions in SSLv3
2891
2892requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2893run_test "SSLv3 with extensions, server side" \
2894 "$P_SRV min_version=ssl3 debug_level=3" \
2895 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2896 0 \
2897 -S "dumping 'client hello extensions'" \
2898 -S "server hello, total extension length:"
2899
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002900# Test for large packets
2901
Janos Follath542ee5d2016-03-07 15:57:05 +00002902requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002903run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002904 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002905 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002906 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2907 0 \
2908 -s "Read from client: 16384 bytes read"
2909
Janos Follath542ee5d2016-03-07 15:57:05 +00002910requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002911run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002912 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002913 "$P_CLI request_size=16384 force_version=ssl3 \
2914 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2915 0 \
2916 -s "Read from client: 16384 bytes read"
2917
2918run_test "Large packet TLS 1.0 BlockCipher" \
2919 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002920 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002921 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2922 0 \
2923 -s "Read from client: 16384 bytes read"
2924
2925run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2926 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002927 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002928 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2929 trunc_hmac=1" \
2930 0 \
2931 -s "Read from client: 16384 bytes read"
2932
2933run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002934 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002935 "$P_CLI request_size=16384 force_version=tls1 \
2936 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2937 trunc_hmac=1" \
2938 0 \
2939 -s "Read from client: 16384 bytes read"
2940
2941run_test "Large packet TLS 1.1 BlockCipher" \
2942 "$P_SRV" \
2943 "$P_CLI request_size=16384 force_version=tls1_1 \
2944 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2945 0 \
2946 -s "Read from client: 16384 bytes read"
2947
2948run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002949 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002950 "$P_CLI request_size=16384 force_version=tls1_1 \
2951 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2952 0 \
2953 -s "Read from client: 16384 bytes read"
2954
2955run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2956 "$P_SRV" \
2957 "$P_CLI request_size=16384 force_version=tls1_1 \
2958 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2959 trunc_hmac=1" \
2960 0 \
2961 -s "Read from client: 16384 bytes read"
2962
2963run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002964 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002965 "$P_CLI request_size=16384 force_version=tls1_1 \
2966 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2967 trunc_hmac=1" \
2968 0 \
2969 -s "Read from client: 16384 bytes read"
2970
2971run_test "Large packet TLS 1.2 BlockCipher" \
2972 "$P_SRV" \
2973 "$P_CLI request_size=16384 force_version=tls1_2 \
2974 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2975 0 \
2976 -s "Read from client: 16384 bytes read"
2977
2978run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2979 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002980 "$P_CLI request_size=16384 force_version=tls1_2 \
2981 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002982 0 \
2983 -s "Read from client: 16384 bytes read"
2984
2985run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2986 "$P_SRV" \
2987 "$P_CLI request_size=16384 force_version=tls1_2 \
2988 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2989 trunc_hmac=1" \
2990 0 \
2991 -s "Read from client: 16384 bytes read"
2992
2993run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002994 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002995 "$P_CLI request_size=16384 force_version=tls1_2 \
2996 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2997 0 \
2998 -s "Read from client: 16384 bytes read"
2999
3000run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003001 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003002 "$P_CLI request_size=16384 force_version=tls1_2 \
3003 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3004 trunc_hmac=1" \
3005 0 \
3006 -s "Read from client: 16384 bytes read"
3007
3008run_test "Large packet TLS 1.2 AEAD" \
3009 "$P_SRV" \
3010 "$P_CLI request_size=16384 force_version=tls1_2 \
3011 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3012 0 \
3013 -s "Read from client: 16384 bytes read"
3014
3015run_test "Large packet TLS 1.2 AEAD shorter tag" \
3016 "$P_SRV" \
3017 "$P_CLI request_size=16384 force_version=tls1_2 \
3018 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3019 0 \
3020 -s "Read from client: 16384 bytes read"
3021
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003022# Tests for DTLS HelloVerifyRequest
3023
3024run_test "DTLS cookie: enabled" \
3025 "$P_SRV dtls=1 debug_level=2" \
3026 "$P_CLI dtls=1 debug_level=2" \
3027 0 \
3028 -s "cookie verification failed" \
3029 -s "cookie verification passed" \
3030 -S "cookie verification skipped" \
3031 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003032 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003033 -S "SSL - The requested feature is not available"
3034
3035run_test "DTLS cookie: disabled" \
3036 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3037 "$P_CLI dtls=1 debug_level=2" \
3038 0 \
3039 -S "cookie verification failed" \
3040 -S "cookie verification passed" \
3041 -s "cookie verification skipped" \
3042 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003043 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003044 -S "SSL - The requested feature is not available"
3045
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003046run_test "DTLS cookie: default (failing)" \
3047 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3048 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3049 1 \
3050 -s "cookie verification failed" \
3051 -S "cookie verification passed" \
3052 -S "cookie verification skipped" \
3053 -C "received hello verify request" \
3054 -S "hello verification requested" \
3055 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003056
3057requires_ipv6
3058run_test "DTLS cookie: enabled, IPv6" \
3059 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3060 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3061 0 \
3062 -s "cookie verification failed" \
3063 -s "cookie verification passed" \
3064 -S "cookie verification skipped" \
3065 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003066 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003067 -S "SSL - The requested feature is not available"
3068
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003069run_test "DTLS cookie: enabled, nbio" \
3070 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3071 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3072 0 \
3073 -s "cookie verification failed" \
3074 -s "cookie verification passed" \
3075 -S "cookie verification skipped" \
3076 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003077 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003078 -S "SSL - The requested feature is not available"
3079
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003080# Tests for client reconnecting from the same port with DTLS
3081
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003082not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003083run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003084 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3085 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003086 0 \
3087 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003088 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003089 -S "Client initiated reconnection from same port"
3090
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003091not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003092run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003093 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3094 "$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 +02003095 0 \
3096 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003097 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003098 -s "Client initiated reconnection from same port"
3099
Paul Bakker3b224ff2016-05-13 10:33:25 +01003100not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3101run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003102 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3103 "$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 +02003104 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003105 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003106 -s "Client initiated reconnection from same port"
3107
Paul Bakker3b224ff2016-05-13 10:33:25 +01003108only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3109run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3110 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3111 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3112 0 \
3113 -S "The operation timed out" \
3114 -s "Client initiated reconnection from same port"
3115
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003116run_test "DTLS client reconnect from same port: no cookies" \
3117 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003118 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3119 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003120 -s "The operation timed out" \
3121 -S "Client initiated reconnection from same port"
3122
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003123# Tests for various cases of client authentication with DTLS
3124# (focused on handshake flows and message parsing)
3125
3126run_test "DTLS client auth: required" \
3127 "$P_SRV dtls=1 auth_mode=required" \
3128 "$P_CLI dtls=1" \
3129 0 \
3130 -s "Verifying peer X.509 certificate... ok"
3131
3132run_test "DTLS client auth: optional, client has no cert" \
3133 "$P_SRV dtls=1 auth_mode=optional" \
3134 "$P_CLI dtls=1 crt_file=none key_file=none" \
3135 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003136 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003137
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003138run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003139 "$P_SRV dtls=1 auth_mode=none" \
3140 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3141 0 \
3142 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003143 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003144
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003145run_test "DTLS wrong PSK: badmac alert" \
3146 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3147 "$P_CLI dtls=1 psk=abc124" \
3148 1 \
3149 -s "SSL - Verification of the message MAC failed" \
3150 -c "SSL - A fatal alert message was received from our peer"
3151
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003152# Tests for receiving fragmented handshake messages with DTLS
3153
3154requires_gnutls
3155run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3156 "$G_SRV -u --mtu 2048 -a" \
3157 "$P_CLI dtls=1 debug_level=2" \
3158 0 \
3159 -C "found fragmented DTLS handshake message" \
3160 -C "error"
3161
3162requires_gnutls
3163run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3164 "$G_SRV -u --mtu 512" \
3165 "$P_CLI dtls=1 debug_level=2" \
3166 0 \
3167 -c "found fragmented DTLS handshake message" \
3168 -C "error"
3169
3170requires_gnutls
3171run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3172 "$G_SRV -u --mtu 128" \
3173 "$P_CLI dtls=1 debug_level=2" \
3174 0 \
3175 -c "found fragmented DTLS handshake message" \
3176 -C "error"
3177
3178requires_gnutls
3179run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3180 "$G_SRV -u --mtu 128" \
3181 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3182 0 \
3183 -c "found fragmented DTLS handshake message" \
3184 -C "error"
3185
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003186requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003187run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3188 "$G_SRV -u --mtu 256" \
3189 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3190 0 \
3191 -c "found fragmented DTLS handshake message" \
3192 -c "client hello, adding renegotiation extension" \
3193 -c "found renegotiation extension" \
3194 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003195 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003196 -C "error" \
3197 -s "Extra-header:"
3198
3199requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003200run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3201 "$G_SRV -u --mtu 256" \
3202 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3203 0 \
3204 -c "found fragmented DTLS handshake message" \
3205 -c "client hello, adding renegotiation extension" \
3206 -c "found renegotiation extension" \
3207 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003208 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003209 -C "error" \
3210 -s "Extra-header:"
3211
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003212run_test "DTLS reassembly: no fragmentation (openssl server)" \
3213 "$O_SRV -dtls1 -mtu 2048" \
3214 "$P_CLI dtls=1 debug_level=2" \
3215 0 \
3216 -C "found fragmented DTLS handshake message" \
3217 -C "error"
3218
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003219run_test "DTLS reassembly: some fragmentation (openssl server)" \
3220 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003221 "$P_CLI dtls=1 debug_level=2" \
3222 0 \
3223 -c "found fragmented DTLS handshake message" \
3224 -C "error"
3225
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003226run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003227 "$O_SRV -dtls1 -mtu 256" \
3228 "$P_CLI dtls=1 debug_level=2" \
3229 0 \
3230 -c "found fragmented DTLS handshake message" \
3231 -C "error"
3232
3233run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3234 "$O_SRV -dtls1 -mtu 256" \
3235 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3236 0 \
3237 -c "found fragmented DTLS handshake message" \
3238 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003239
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003240# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003241
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003242not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003243run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003244 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003245 "$P_SRV dtls=1 debug_level=2" \
3246 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003247 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003248 -C "replayed record" \
3249 -S "replayed record" \
3250 -C "record from another epoch" \
3251 -S "record from another epoch" \
3252 -C "discarding invalid record" \
3253 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003254 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003255 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003256 -c "HTTP/1.0 200 OK"
3257
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003258not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003259run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003260 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003261 "$P_SRV dtls=1 debug_level=2" \
3262 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003263 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003264 -c "replayed record" \
3265 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003266 -c "discarding invalid record" \
3267 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003268 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003269 -s "Extra-header:" \
3270 -c "HTTP/1.0 200 OK"
3271
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003272run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3273 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003274 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3275 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003276 0 \
3277 -c "replayed record" \
3278 -S "replayed record" \
3279 -c "discarding invalid record" \
3280 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003281 -c "resend" \
3282 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003283 -s "Extra-header:" \
3284 -c "HTTP/1.0 200 OK"
3285
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003286run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003287 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003288 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003289 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003290 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003291 -c "discarding invalid record (mac)" \
3292 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003293 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003294 -c "HTTP/1.0 200 OK" \
3295 -S "too many records with bad MAC" \
3296 -S "Verification of the message MAC failed"
3297
3298run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3299 -p "$P_PXY bad_ad=1" \
3300 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3301 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3302 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003303 -C "discarding invalid record (mac)" \
3304 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003305 -S "Extra-header:" \
3306 -C "HTTP/1.0 200 OK" \
3307 -s "too many records with bad MAC" \
3308 -s "Verification of the message MAC failed"
3309
3310run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3311 -p "$P_PXY bad_ad=1" \
3312 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3313 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3314 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003315 -c "discarding invalid record (mac)" \
3316 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003317 -s "Extra-header:" \
3318 -c "HTTP/1.0 200 OK" \
3319 -S "too many records with bad MAC" \
3320 -S "Verification of the message MAC failed"
3321
3322run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3323 -p "$P_PXY bad_ad=1" \
3324 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3325 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3326 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003327 -c "discarding invalid record (mac)" \
3328 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003329 -s "Extra-header:" \
3330 -c "HTTP/1.0 200 OK" \
3331 -s "too many records with bad MAC" \
3332 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003333
3334run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003335 -p "$P_PXY delay_ccs=1" \
3336 "$P_SRV dtls=1 debug_level=1" \
3337 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003338 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003339 -c "record from another epoch" \
3340 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003341 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003342 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003343 -s "Extra-header:" \
3344 -c "HTTP/1.0 200 OK"
3345
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003346# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003347
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003348needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003349run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003350 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003351 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3352 psk=abc123" \
3353 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003354 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3355 0 \
3356 -s "Extra-header:" \
3357 -c "HTTP/1.0 200 OK"
3358
3359needs_more_time 2
3360run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3361 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003362 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3363 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003364 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3365 0 \
3366 -s "Extra-header:" \
3367 -c "HTTP/1.0 200 OK"
3368
3369needs_more_time 2
3370run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3371 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003372 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3373 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003374 0 \
3375 -s "Extra-header:" \
3376 -c "HTTP/1.0 200 OK"
3377
3378needs_more_time 2
3379run_test "DTLS proxy: 3d, FS, client auth" \
3380 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003381 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3382 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003383 0 \
3384 -s "Extra-header:" \
3385 -c "HTTP/1.0 200 OK"
3386
3387needs_more_time 2
3388run_test "DTLS proxy: 3d, FS, ticket" \
3389 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003390 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3391 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003392 0 \
3393 -s "Extra-header:" \
3394 -c "HTTP/1.0 200 OK"
3395
3396needs_more_time 2
3397run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3398 -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=1 auth_mode=required" \
3400 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003401 0 \
3402 -s "Extra-header:" \
3403 -c "HTTP/1.0 200 OK"
3404
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003405needs_more_time 2
3406run_test "DTLS proxy: 3d, max handshake, nbio" \
3407 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003408 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3409 auth_mode=required" \
3410 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003411 0 \
3412 -s "Extra-header:" \
3413 -c "HTTP/1.0 200 OK"
3414
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003415needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003416run_test "DTLS proxy: 3d, min handshake, resumption" \
3417 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3418 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3419 psk=abc123 debug_level=3" \
3420 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3421 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3422 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3423 0 \
3424 -s "a session has been resumed" \
3425 -c "a session has been resumed" \
3426 -s "Extra-header:" \
3427 -c "HTTP/1.0 200 OK"
3428
3429needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003430run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3431 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3432 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3433 psk=abc123 debug_level=3 nbio=2" \
3434 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3435 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3436 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3437 0 \
3438 -s "a session has been resumed" \
3439 -c "a session has been resumed" \
3440 -s "Extra-header:" \
3441 -c "HTTP/1.0 200 OK"
3442
3443needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003444run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003445 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003446 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3447 psk=abc123 renegotiation=1 debug_level=2" \
3448 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3449 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003450 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3451 0 \
3452 -c "=> renegotiate" \
3453 -s "=> renegotiate" \
3454 -s "Extra-header:" \
3455 -c "HTTP/1.0 200 OK"
3456
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003457needs_more_time 4
3458run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3459 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003460 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3461 psk=abc123 renegotiation=1 debug_level=2" \
3462 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3463 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003464 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3465 0 \
3466 -c "=> renegotiate" \
3467 -s "=> renegotiate" \
3468 -s "Extra-header:" \
3469 -c "HTTP/1.0 200 OK"
3470
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003471needs_more_time 4
3472run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003473 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003474 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003475 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003476 debug_level=2" \
3477 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003478 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003479 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3480 0 \
3481 -c "=> renegotiate" \
3482 -s "=> renegotiate" \
3483 -s "Extra-header:" \
3484 -c "HTTP/1.0 200 OK"
3485
3486needs_more_time 4
3487run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003488 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003489 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003490 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003491 debug_level=2 nbio=2" \
3492 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003493 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003494 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3495 0 \
3496 -c "=> renegotiate" \
3497 -s "=> renegotiate" \
3498 -s "Extra-header:" \
3499 -c "HTTP/1.0 200 OK"
3500
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003501needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003502not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003503run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003504 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3505 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003506 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003507 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003508 -c "HTTP/1.0 200 OK"
3509
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003510needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003511not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003512run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3513 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3514 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003515 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003516 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003517 -c "HTTP/1.0 200 OK"
3518
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003519needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003520not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003521run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3522 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3523 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003524 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003525 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003526 -c "HTTP/1.0 200 OK"
3527
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003528requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003529needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003530not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003531run_test "DTLS proxy: 3d, gnutls server" \
3532 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3533 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003534 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003535 0 \
3536 -s "Extra-header:" \
3537 -c "Extra-header:"
3538
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003539requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003540needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003541not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003542run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3543 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3544 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003545 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003546 0 \
3547 -s "Extra-header:" \
3548 -c "Extra-header:"
3549
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003550requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003551needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003552not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003553run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3554 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3555 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003556 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003557 0 \
3558 -s "Extra-header:" \
3559 -c "Extra-header:"
3560
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003561# Final report
3562
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003563echo "------------------------------------------------------------------------"
3564
3565if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003566 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003567else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003568 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003569fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003570PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003571echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003572
3573exit $FAILS