blob: 21a4ab7e85fc068cf0a195704d7d3aeefd8eff9a [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
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200566# Also pick a unique name for intermediate files
567SRV_OUT="srv_out.$$"
568CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200569PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200570SESSION="session.$$"
571
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200572SKIP_NEXT="NO"
573
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100574trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100575
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200576# Basic test
577
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200578# Checks that:
579# - things work with all ciphersuites active (used with config-full in all.sh)
580# - the expected (highest security) parameters are selected
581# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200582run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200583 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200584 "$P_CLI" \
585 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200586 -s "Protocol is TLSv1.2" \
587 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
588 -s "client hello v3, signature_algorithm ext: 6" \
589 -s "ECDHE curve: secp521r1" \
590 -S "error" \
591 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200592
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000593run_test "Default, DTLS" \
594 "$P_SRV dtls=1" \
595 "$P_CLI dtls=1" \
596 0 \
597 -s "Protocol is DTLSv1.2" \
598 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
599
Janos Follath6d3e3382016-09-07 15:48:48 +0100600# Test for uniqueness of IVs in AEAD ciphersuites
601run_test "Unique IV in GCM" \
602 "$P_SRV exchanges=20 debug_level=4" \
603 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
604 0 \
605 -u "IV used" \
606 -U "IV used"
607
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100608# Tests for rc4 option
609
Simon Butcher6eb066e2016-05-19 22:12:18 +0100610requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100611run_test "RC4: server disabled, client enabled" \
612 "$P_SRV" \
613 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
614 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100615 -s "SSL - The server has no ciphersuites in common"
616
Simon Butcher6eb066e2016-05-19 22:12:18 +0100617requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100618run_test "RC4: server half, client enabled" \
619 "$P_SRV arc4=1" \
620 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
621 1 \
622 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100623
624run_test "RC4: server enabled, client disabled" \
625 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
626 "$P_CLI" \
627 1 \
628 -s "SSL - The server has no ciphersuites in common"
629
630run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100631 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100632 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
633 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100634 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100635 -S "SSL - The server has no ciphersuites in common"
636
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100637# Tests for Truncated HMAC extension
638
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100639run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200640 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100641 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100642 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100643 -s "dumping 'computed mac' (20 bytes)" \
644 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100645
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100646run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200647 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100648 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
649 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100650 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100651 -s "dumping 'computed mac' (20 bytes)" \
652 -S "dumping 'computed mac' (10 bytes)"
653
654run_test "Truncated HMAC: client enabled, server default" \
655 "$P_SRV debug_level=4" \
656 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
657 trunc_hmac=1" \
658 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100659 -s "dumping 'computed mac' (20 bytes)" \
660 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100661
662run_test "Truncated HMAC: client enabled, server disabled" \
663 "$P_SRV debug_level=4 trunc_hmac=0" \
664 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
665 trunc_hmac=1" \
666 0 \
667 -s "dumping 'computed mac' (20 bytes)" \
668 -S "dumping 'computed mac' (10 bytes)"
669
670run_test "Truncated HMAC: client enabled, server enabled" \
671 "$P_SRV debug_level=4 trunc_hmac=1" \
672 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
673 trunc_hmac=1" \
674 0 \
675 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100676 -s "dumping 'computed mac' (10 bytes)"
677
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100678# Tests for Encrypt-then-MAC extension
679
680run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100681 "$P_SRV debug_level=3 \
682 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100683 "$P_CLI debug_level=3" \
684 0 \
685 -c "client hello, adding encrypt_then_mac extension" \
686 -s "found encrypt then mac extension" \
687 -s "server hello, adding encrypt then mac extension" \
688 -c "found encrypt_then_mac extension" \
689 -c "using encrypt then mac" \
690 -s "using encrypt then mac"
691
692run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100693 "$P_SRV debug_level=3 etm=0 \
694 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100695 "$P_CLI debug_level=3 etm=1" \
696 0 \
697 -c "client hello, adding encrypt_then_mac extension" \
698 -s "found encrypt then mac extension" \
699 -S "server hello, adding encrypt then mac extension" \
700 -C "found encrypt_then_mac extension" \
701 -C "using encrypt then mac" \
702 -S "using encrypt then mac"
703
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100704run_test "Encrypt then MAC: client enabled, aead cipher" \
705 "$P_SRV debug_level=3 etm=1 \
706 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
707 "$P_CLI debug_level=3 etm=1" \
708 0 \
709 -c "client hello, adding encrypt_then_mac extension" \
710 -s "found encrypt then mac extension" \
711 -S "server hello, adding encrypt then mac extension" \
712 -C "found encrypt_then_mac extension" \
713 -C "using encrypt then mac" \
714 -S "using encrypt then mac"
715
716run_test "Encrypt then MAC: client enabled, stream cipher" \
717 "$P_SRV debug_level=3 etm=1 \
718 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100719 "$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 +0100720 0 \
721 -c "client hello, adding encrypt_then_mac extension" \
722 -s "found encrypt then mac extension" \
723 -S "server hello, adding encrypt then mac extension" \
724 -C "found encrypt_then_mac extension" \
725 -C "using encrypt then mac" \
726 -S "using encrypt then mac"
727
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100728run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100729 "$P_SRV debug_level=3 etm=1 \
730 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100731 "$P_CLI debug_level=3 etm=0" \
732 0 \
733 -C "client hello, adding encrypt_then_mac extension" \
734 -S "found encrypt then mac extension" \
735 -S "server hello, adding encrypt then mac extension" \
736 -C "found encrypt_then_mac extension" \
737 -C "using encrypt then mac" \
738 -S "using encrypt then mac"
739
Janos Follath542ee5d2016-03-07 15:57:05 +0000740requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100741run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100742 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100743 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100744 "$P_CLI debug_level=3 force_version=ssl3" \
745 0 \
746 -C "client hello, adding encrypt_then_mac extension" \
747 -S "found encrypt then mac extension" \
748 -S "server hello, adding encrypt then mac extension" \
749 -C "found encrypt_then_mac extension" \
750 -C "using encrypt then mac" \
751 -S "using encrypt then mac"
752
Janos Follath542ee5d2016-03-07 15:57:05 +0000753requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100754run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100755 "$P_SRV debug_level=3 force_version=ssl3 \
756 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100757 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100758 0 \
759 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100760 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100761 -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é-Gonnard367381f2014-10-20 18:40:56 +0200766# Tests for Extended Master Secret extension
767
768run_test "Extended Master Secret: default" \
769 "$P_SRV debug_level=3" \
770 "$P_CLI debug_level=3" \
771 0 \
772 -c "client hello, adding extended_master_secret extension" \
773 -s "found extended master secret extension" \
774 -s "server hello, adding extended master secret extension" \
775 -c "found extended_master_secret extension" \
776 -c "using extended master secret" \
777 -s "using extended master secret"
778
779run_test "Extended Master Secret: client enabled, server disabled" \
780 "$P_SRV debug_level=3 extended_ms=0" \
781 "$P_CLI debug_level=3 extended_ms=1" \
782 0 \
783 -c "client hello, adding extended_master_secret extension" \
784 -s "found extended master secret extension" \
785 -S "server hello, adding extended master secret extension" \
786 -C "found extended_master_secret extension" \
787 -C "using extended master secret" \
788 -S "using extended master secret"
789
790run_test "Extended Master Secret: client disabled, server enabled" \
791 "$P_SRV debug_level=3 extended_ms=1" \
792 "$P_CLI debug_level=3 extended_ms=0" \
793 0 \
794 -C "client hello, adding extended_master_secret extension" \
795 -S "found extended master secret extension" \
796 -S "server hello, adding extended master secret extension" \
797 -C "found extended_master_secret extension" \
798 -C "using extended master secret" \
799 -S "using extended master secret"
800
Janos Follath542ee5d2016-03-07 15:57:05 +0000801requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200802run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100803 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200804 "$P_CLI debug_level=3 force_version=ssl3" \
805 0 \
806 -C "client hello, adding extended_master_secret extension" \
807 -S "found extended master secret extension" \
808 -S "server hello, adding extended master secret extension" \
809 -C "found extended_master_secret extension" \
810 -C "using extended master secret" \
811 -S "using extended master secret"
812
Janos Follath542ee5d2016-03-07 15:57:05 +0000813requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200814run_test "Extended Master Secret: client enabled, server SSLv3" \
815 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100816 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200817 0 \
818 -c "client hello, adding extended_master_secret extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100819 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200820 -S "server hello, adding extended master secret extension" \
821 -C "found extended_master_secret extension" \
822 -C "using extended master secret" \
823 -S "using extended master secret"
824
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200825# Tests for FALLBACK_SCSV
826
827run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200828 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200829 "$P_CLI debug_level=3 force_version=tls1_1" \
830 0 \
831 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200832 -S "received FALLBACK_SCSV" \
833 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200834 -C "is a fatal alert message (msg 86)"
835
836run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200837 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200838 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
839 0 \
840 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200841 -S "received FALLBACK_SCSV" \
842 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200843 -C "is a fatal alert message (msg 86)"
844
845run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200846 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200847 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200848 1 \
849 -c "adding FALLBACK_SCSV" \
850 -s "received FALLBACK_SCSV" \
851 -s "inapropriate fallback" \
852 -c "is a fatal alert message (msg 86)"
853
854run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200855 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200856 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200857 0 \
858 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200859 -s "received FALLBACK_SCSV" \
860 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200861 -C "is a fatal alert message (msg 86)"
862
863requires_openssl_with_fallback_scsv
864run_test "Fallback SCSV: default, openssl server" \
865 "$O_SRV" \
866 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
867 0 \
868 -C "adding FALLBACK_SCSV" \
869 -C "is a fatal alert message (msg 86)"
870
871requires_openssl_with_fallback_scsv
872run_test "Fallback SCSV: enabled, openssl server" \
873 "$O_SRV" \
874 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
875 1 \
876 -c "adding FALLBACK_SCSV" \
877 -c "is a fatal alert message (msg 86)"
878
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200879requires_openssl_with_fallback_scsv
880run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200881 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200882 "$O_CLI -tls1_1" \
883 0 \
884 -S "received FALLBACK_SCSV" \
885 -S "inapropriate fallback"
886
887requires_openssl_with_fallback_scsv
888run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200889 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200890 "$O_CLI -tls1_1 -fallback_scsv" \
891 1 \
892 -s "received FALLBACK_SCSV" \
893 -s "inapropriate fallback"
894
895requires_openssl_with_fallback_scsv
896run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200897 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200898 "$O_CLI -fallback_scsv" \
899 0 \
900 -s "received FALLBACK_SCSV" \
901 -S "inapropriate fallback"
902
Gilles Peskine39e29812017-05-16 17:53:03 +0200903## ClientHello generated with
904## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
905## then manually twiddling the ciphersuite list.
906## The ClientHello content is spelled out below as a hex string as
907## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
908## The expected response is an inappropriate_fallback alert.
909requires_openssl_with_fallback_scsv
910run_test "Fallback SCSV: beginning of list" \
911 "$P_SRV debug_level=2" \
912 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
913 0 \
914 -s "received FALLBACK_SCSV" \
915 -s "inapropriate fallback"
916
917requires_openssl_with_fallback_scsv
918run_test "Fallback SCSV: end of list" \
919 "$P_SRV debug_level=2" \
920 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
921 0 \
922 -s "received FALLBACK_SCSV" \
923 -s "inapropriate fallback"
924
925## Here the expected response is a valid ServerHello prefix, up to the random.
926requires_openssl_with_fallback_scsv
927run_test "Fallback SCSV: not in list" \
928 "$P_SRV debug_level=2" \
929 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
930 0 \
931 -S "received FALLBACK_SCSV" \
932 -S "inapropriate fallback"
933
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100934# Tests for CBC 1/n-1 record splitting
935
936run_test "CBC Record splitting: TLS 1.2, no splitting" \
937 "$P_SRV" \
938 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
939 request_size=123 force_version=tls1_2" \
940 0 \
941 -s "Read from client: 123 bytes read" \
942 -S "Read from client: 1 bytes read" \
943 -S "122 bytes read"
944
945run_test "CBC Record splitting: TLS 1.1, no splitting" \
946 "$P_SRV" \
947 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
948 request_size=123 force_version=tls1_1" \
949 0 \
950 -s "Read from client: 123 bytes read" \
951 -S "Read from client: 1 bytes read" \
952 -S "122 bytes read"
953
954run_test "CBC Record splitting: TLS 1.0, splitting" \
955 "$P_SRV" \
956 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
957 request_size=123 force_version=tls1" \
958 0 \
959 -S "Read from client: 123 bytes read" \
960 -s "Read from client: 1 bytes read" \
961 -s "122 bytes read"
962
Janos Follath542ee5d2016-03-07 15:57:05 +0000963requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100964run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100965 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100966 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
967 request_size=123 force_version=ssl3" \
968 0 \
969 -S "Read from client: 123 bytes read" \
970 -s "Read from client: 1 bytes read" \
971 -s "122 bytes read"
972
973run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100974 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100975 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
976 request_size=123 force_version=tls1" \
977 0 \
978 -s "Read from client: 123 bytes read" \
979 -S "Read from client: 1 bytes read" \
980 -S "122 bytes read"
981
982run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
983 "$P_SRV" \
984 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
985 request_size=123 force_version=tls1 recsplit=0" \
986 0 \
987 -s "Read from client: 123 bytes read" \
988 -S "Read from client: 1 bytes read" \
989 -S "122 bytes read"
990
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100991run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
992 "$P_SRV nbio=2" \
993 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
994 request_size=123 force_version=tls1" \
995 0 \
996 -S "Read from client: 123 bytes read" \
997 -s "Read from client: 1 bytes read" \
998 -s "122 bytes read"
999
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001000# Tests for Session Tickets
1001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001002run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001003 "$P_SRV debug_level=3 tickets=1" \
1004 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001005 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001006 -c "client hello, adding session ticket extension" \
1007 -s "found session ticket extension" \
1008 -s "server hello, adding session ticket extension" \
1009 -c "found session_ticket extension" \
1010 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001011 -S "session successfully restored from cache" \
1012 -s "session successfully restored from ticket" \
1013 -s "a session has been resumed" \
1014 -c "a session has been resumed"
1015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001016run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001017 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1018 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001019 0 \
1020 -c "client hello, adding session ticket extension" \
1021 -s "found session ticket extension" \
1022 -s "server hello, adding session ticket extension" \
1023 -c "found session_ticket extension" \
1024 -c "parse new session ticket" \
1025 -S "session successfully restored from cache" \
1026 -s "session successfully restored from ticket" \
1027 -s "a session has been resumed" \
1028 -c "a session has been resumed"
1029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001030run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001031 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1032 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001033 0 \
1034 -c "client hello, adding session ticket extension" \
1035 -s "found session ticket extension" \
1036 -s "server hello, adding session ticket extension" \
1037 -c "found session_ticket extension" \
1038 -c "parse new session ticket" \
1039 -S "session successfully restored from cache" \
1040 -S "session successfully restored from ticket" \
1041 -S "a session has been resumed" \
1042 -C "a session has been resumed"
1043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001044run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001045 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001046 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001047 0 \
1048 -c "client hello, adding session ticket extension" \
1049 -c "found session_ticket extension" \
1050 -c "parse new session ticket" \
1051 -c "a session has been resumed"
1052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001053run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001054 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001055 "( $O_CLI -sess_out $SESSION; \
1056 $O_CLI -sess_in $SESSION; \
1057 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001058 0 \
1059 -s "found session ticket extension" \
1060 -s "server hello, adding session ticket extension" \
1061 -S "session successfully restored from cache" \
1062 -s "session successfully restored from ticket" \
1063 -s "a session has been resumed"
1064
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001065# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001067run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001068 "$P_SRV debug_level=3 tickets=0" \
1069 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001070 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001071 -c "client hello, adding session ticket extension" \
1072 -s "found session ticket extension" \
1073 -S "server hello, adding session ticket extension" \
1074 -C "found session_ticket extension" \
1075 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001076 -s "session successfully restored from cache" \
1077 -S "session successfully restored from ticket" \
1078 -s "a session has been resumed" \
1079 -c "a session has been resumed"
1080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001081run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001082 "$P_SRV debug_level=3 tickets=1" \
1083 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001084 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001085 -C "client hello, adding session ticket extension" \
1086 -S "found session ticket extension" \
1087 -S "server hello, adding session ticket extension" \
1088 -C "found session_ticket extension" \
1089 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001090 -s "session successfully restored from cache" \
1091 -S "session successfully restored from ticket" \
1092 -s "a session has been resumed" \
1093 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001095run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001096 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1097 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001098 0 \
1099 -S "session successfully restored from cache" \
1100 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001101 -S "a session has been resumed" \
1102 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001104run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001105 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1106 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001107 0 \
1108 -s "session successfully restored from cache" \
1109 -S "session successfully restored from ticket" \
1110 -s "a session has been resumed" \
1111 -c "a session has been resumed"
1112
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001113run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001114 "$P_SRV debug_level=3 tickets=0" \
1115 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001116 0 \
1117 -s "session successfully restored from cache" \
1118 -S "session successfully restored from ticket" \
1119 -s "a session has been resumed" \
1120 -c "a session has been resumed"
1121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001122run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001123 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1124 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001125 0 \
1126 -S "session successfully restored from cache" \
1127 -S "session successfully restored from ticket" \
1128 -S "a session has been resumed" \
1129 -C "a session has been resumed"
1130
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001131run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001132 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1133 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001134 0 \
1135 -s "session successfully restored from cache" \
1136 -S "session successfully restored from ticket" \
1137 -s "a session has been resumed" \
1138 -c "a session has been resumed"
1139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001140run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001141 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001142 "( $O_CLI -sess_out $SESSION; \
1143 $O_CLI -sess_in $SESSION; \
1144 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001145 0 \
1146 -s "found session ticket extension" \
1147 -S "server hello, adding session ticket extension" \
1148 -s "session successfully restored from cache" \
1149 -S "session successfully restored from ticket" \
1150 -s "a session has been resumed"
1151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001152run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001153 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001154 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001155 0 \
1156 -C "found session_ticket extension" \
1157 -C "parse new session ticket" \
1158 -c "a session has been resumed"
1159
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001160# Tests for Max Fragment Length extension
1161
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001162run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001163 "$P_SRV debug_level=3" \
1164 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001165 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001166 -c "Maximum fragment length is 16384" \
1167 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001168 -C "client hello, adding max_fragment_length extension" \
1169 -S "found max fragment length extension" \
1170 -S "server hello, max_fragment_length extension" \
1171 -C "found max_fragment_length extension"
1172
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001173run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001174 "$P_SRV debug_level=3" \
1175 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001176 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001177 -c "Maximum fragment length is 4096" \
1178 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001179 -c "client hello, adding max_fragment_length extension" \
1180 -s "found max fragment length extension" \
1181 -s "server hello, max_fragment_length extension" \
1182 -c "found max_fragment_length extension"
1183
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001184run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001185 "$P_SRV debug_level=3 max_frag_len=4096" \
1186 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001187 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001188 -c "Maximum fragment length is 16384" \
1189 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001190 -C "client hello, adding max_fragment_length extension" \
1191 -S "found max fragment length extension" \
1192 -S "server hello, max_fragment_length extension" \
1193 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001194
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001195requires_gnutls
1196run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001197 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001198 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001199 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001200 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001201 -c "client hello, adding max_fragment_length extension" \
1202 -c "found max_fragment_length extension"
1203
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001204run_test "Max fragment length: client, message just fits" \
1205 "$P_SRV debug_level=3" \
1206 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1207 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001208 -c "Maximum fragment length is 2048" \
1209 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001210 -c "client hello, adding max_fragment_length extension" \
1211 -s "found max fragment length extension" \
1212 -s "server hello, max_fragment_length extension" \
1213 -c "found max_fragment_length extension" \
1214 -c "2048 bytes written in 1 fragments" \
1215 -s "2048 bytes read"
1216
1217run_test "Max fragment length: client, larger message" \
1218 "$P_SRV debug_level=3" \
1219 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1220 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001221 -c "Maximum fragment length is 2048" \
1222 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001223 -c "client hello, adding max_fragment_length extension" \
1224 -s "found max fragment length extension" \
1225 -s "server hello, max_fragment_length extension" \
1226 -c "found max_fragment_length extension" \
1227 -c "2345 bytes written in 2 fragments" \
1228 -s "2048 bytes read" \
1229 -s "297 bytes read"
1230
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001231run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001232 "$P_SRV debug_level=3 dtls=1" \
1233 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1234 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001235 -c "Maximum fragment length is 2048" \
1236 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001237 -c "client hello, adding max_fragment_length extension" \
1238 -s "found max fragment length extension" \
1239 -s "server hello, max_fragment_length extension" \
1240 -c "found max_fragment_length extension" \
1241 -c "fragment larger than.*maximum"
1242
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001243# Tests for renegotiation
1244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001245run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001246 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001247 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001248 0 \
1249 -C "client hello, adding renegotiation extension" \
1250 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1251 -S "found renegotiation extension" \
1252 -s "server hello, secure renegotiation extension" \
1253 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001254 -C "=> renegotiate" \
1255 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001256 -S "write hello request"
1257
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001258run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001259 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001260 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001261 0 \
1262 -c "client hello, adding renegotiation extension" \
1263 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1264 -s "found renegotiation extension" \
1265 -s "server hello, secure renegotiation extension" \
1266 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001267 -c "=> renegotiate" \
1268 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001269 -S "write hello request"
1270
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001271run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001272 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001273 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001274 0 \
1275 -c "client hello, adding renegotiation extension" \
1276 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1277 -s "found renegotiation extension" \
1278 -s "server hello, secure renegotiation extension" \
1279 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001280 -c "=> renegotiate" \
1281 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001282 -s "write hello request"
1283
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001284run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001285 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001286 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001287 0 \
1288 -c "client hello, adding renegotiation extension" \
1289 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1290 -s "found renegotiation extension" \
1291 -s "server hello, secure renegotiation extension" \
1292 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001293 -c "=> renegotiate" \
1294 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001295 -s "write hello request"
1296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001297run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001298 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001299 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001300 1 \
1301 -c "client hello, adding renegotiation extension" \
1302 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1303 -S "found renegotiation extension" \
1304 -s "server hello, secure renegotiation extension" \
1305 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001306 -c "=> renegotiate" \
1307 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001308 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001309 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001310 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001312run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001313 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001314 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001315 0 \
1316 -C "client hello, adding renegotiation extension" \
1317 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1318 -S "found renegotiation extension" \
1319 -s "server hello, secure renegotiation extension" \
1320 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001321 -C "=> renegotiate" \
1322 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001323 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001324 -S "SSL - An unexpected message was received from our peer" \
1325 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001326
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001327run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001328 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001329 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001330 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001331 0 \
1332 -C "client hello, adding renegotiation extension" \
1333 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1334 -S "found renegotiation extension" \
1335 -s "server hello, secure renegotiation extension" \
1336 -c "found renegotiation extension" \
1337 -C "=> renegotiate" \
1338 -S "=> renegotiate" \
1339 -s "write hello request" \
1340 -S "SSL - An unexpected message was received from our peer" \
1341 -S "failed"
1342
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001343# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001344run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001345 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001346 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001348 0 \
1349 -C "client hello, adding renegotiation extension" \
1350 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1351 -S "found renegotiation extension" \
1352 -s "server hello, secure renegotiation extension" \
1353 -c "found renegotiation extension" \
1354 -C "=> renegotiate" \
1355 -S "=> renegotiate" \
1356 -s "write hello request" \
1357 -S "SSL - An unexpected message was received from our peer" \
1358 -S "failed"
1359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001360run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001361 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001362 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001363 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001364 0 \
1365 -C "client hello, adding renegotiation extension" \
1366 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1367 -S "found renegotiation extension" \
1368 -s "server hello, secure renegotiation extension" \
1369 -c "found renegotiation extension" \
1370 -C "=> renegotiate" \
1371 -S "=> renegotiate" \
1372 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001373 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001375run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001376 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001377 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001378 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001379 0 \
1380 -c "client hello, adding renegotiation extension" \
1381 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1382 -s "found renegotiation extension" \
1383 -s "server hello, secure renegotiation extension" \
1384 -c "found renegotiation extension" \
1385 -c "=> renegotiate" \
1386 -s "=> renegotiate" \
1387 -s "write hello request" \
1388 -S "SSL - An unexpected message was received from our peer" \
1389 -S "failed"
1390
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001391run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001392 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001393 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1394 0 \
1395 -C "client hello, adding renegotiation extension" \
1396 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1397 -S "found renegotiation extension" \
1398 -s "server hello, secure renegotiation extension" \
1399 -c "found renegotiation extension" \
1400 -S "record counter limit reached: renegotiate" \
1401 -C "=> renegotiate" \
1402 -S "=> renegotiate" \
1403 -S "write hello request" \
1404 -S "SSL - An unexpected message was received from our peer" \
1405 -S "failed"
1406
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001407# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001408run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001409 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001410 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001411 0 \
1412 -c "client hello, adding renegotiation extension" \
1413 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1414 -s "found renegotiation extension" \
1415 -s "server hello, secure renegotiation extension" \
1416 -c "found renegotiation extension" \
1417 -s "record counter limit reached: renegotiate" \
1418 -c "=> renegotiate" \
1419 -s "=> renegotiate" \
1420 -s "write hello request" \
1421 -S "SSL - An unexpected message was received from our peer" \
1422 -S "failed"
1423
1424run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001425 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001426 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001427 0 \
1428 -c "client hello, adding renegotiation extension" \
1429 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1430 -s "found renegotiation extension" \
1431 -s "server hello, secure renegotiation extension" \
1432 -c "found renegotiation extension" \
1433 -s "record counter limit reached: renegotiate" \
1434 -c "=> renegotiate" \
1435 -s "=> renegotiate" \
1436 -s "write hello request" \
1437 -S "SSL - An unexpected message was received from our peer" \
1438 -S "failed"
1439
1440run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001441 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001442 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1443 0 \
1444 -C "client hello, adding renegotiation extension" \
1445 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1446 -S "found renegotiation extension" \
1447 -s "server hello, secure renegotiation extension" \
1448 -c "found renegotiation extension" \
1449 -S "record counter limit reached: renegotiate" \
1450 -C "=> renegotiate" \
1451 -S "=> renegotiate" \
1452 -S "write hello request" \
1453 -S "SSL - An unexpected message was received from our peer" \
1454 -S "failed"
1455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001456run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001457 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001458 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001459 0 \
1460 -c "client hello, adding renegotiation extension" \
1461 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1462 -s "found renegotiation extension" \
1463 -s "server hello, secure renegotiation extension" \
1464 -c "found renegotiation extension" \
1465 -c "=> renegotiate" \
1466 -s "=> renegotiate" \
1467 -S "write hello request"
1468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001469run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001470 "$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 +02001471 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001472 0 \
1473 -c "client hello, adding renegotiation extension" \
1474 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1475 -s "found renegotiation extension" \
1476 -s "server hello, secure renegotiation extension" \
1477 -c "found renegotiation extension" \
1478 -c "=> renegotiate" \
1479 -s "=> renegotiate" \
1480 -s "write hello request"
1481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001482run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001483 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001484 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001485 0 \
1486 -c "client hello, adding renegotiation extension" \
1487 -c "found renegotiation extension" \
1488 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001489 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001490 -C "error" \
1491 -c "HTTP/1.0 200 [Oo][Kk]"
1492
Paul Bakker539d9722015-02-08 16:18:35 +01001493requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001494run_test "Renegotiation: gnutls server strict, client-initiated" \
1495 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001496 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001497 0 \
1498 -c "client hello, adding renegotiation extension" \
1499 -c "found renegotiation extension" \
1500 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001501 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001502 -C "error" \
1503 -c "HTTP/1.0 200 [Oo][Kk]"
1504
Paul Bakker539d9722015-02-08 16:18:35 +01001505requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001506run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1507 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1508 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1509 1 \
1510 -c "client hello, adding renegotiation extension" \
1511 -C "found renegotiation extension" \
1512 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001513 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001514 -c "error" \
1515 -C "HTTP/1.0 200 [Oo][Kk]"
1516
Paul Bakker539d9722015-02-08 16:18:35 +01001517requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001518run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1519 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1520 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1521 allow_legacy=0" \
1522 1 \
1523 -c "client hello, adding renegotiation extension" \
1524 -C "found renegotiation extension" \
1525 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001526 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001527 -c "error" \
1528 -C "HTTP/1.0 200 [Oo][Kk]"
1529
Paul Bakker539d9722015-02-08 16:18:35 +01001530requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001531run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1532 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1533 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1534 allow_legacy=1" \
1535 0 \
1536 -c "client hello, adding renegotiation extension" \
1537 -C "found renegotiation extension" \
1538 -c "=> renegotiate" \
1539 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001540 -C "error" \
1541 -c "HTTP/1.0 200 [Oo][Kk]"
1542
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001543run_test "Renegotiation: DTLS, client-initiated" \
1544 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1545 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1546 0 \
1547 -c "client hello, adding renegotiation extension" \
1548 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1549 -s "found renegotiation extension" \
1550 -s "server hello, secure renegotiation extension" \
1551 -c "found renegotiation extension" \
1552 -c "=> renegotiate" \
1553 -s "=> renegotiate" \
1554 -S "write hello request"
1555
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001556run_test "Renegotiation: DTLS, server-initiated" \
1557 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001558 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1559 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001560 0 \
1561 -c "client hello, adding renegotiation extension" \
1562 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1563 -s "found renegotiation extension" \
1564 -s "server hello, secure renegotiation extension" \
1565 -c "found renegotiation extension" \
1566 -c "=> renegotiate" \
1567 -s "=> renegotiate" \
1568 -s "write hello request"
1569
Andres AG9b1927b2017-01-19 16:30:57 +00001570run_test "Renegotiation: DTLS, renego_period overflow" \
1571 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1572 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1573 0 \
1574 -c "client hello, adding renegotiation extension" \
1575 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1576 -s "found renegotiation extension" \
1577 -s "server hello, secure renegotiation extension" \
1578 -s "record counter limit reached: renegotiate" \
1579 -c "=> renegotiate" \
1580 -s "=> renegotiate" \
1581 -s "write hello request" \
1582
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001583requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001584run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1585 "$G_SRV -u --mtu 4096" \
1586 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1587 0 \
1588 -c "client hello, adding renegotiation extension" \
1589 -c "found renegotiation extension" \
1590 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001591 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001592 -C "error" \
1593 -s "Extra-header:"
1594
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001595# Test for the "secure renegotation" extension only (no actual renegotiation)
1596
Paul Bakker539d9722015-02-08 16:18:35 +01001597requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001598run_test "Renego ext: gnutls server strict, client default" \
1599 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1600 "$P_CLI debug_level=3" \
1601 0 \
1602 -c "found renegotiation extension" \
1603 -C "error" \
1604 -c "HTTP/1.0 200 [Oo][Kk]"
1605
Paul Bakker539d9722015-02-08 16:18:35 +01001606requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001607run_test "Renego ext: gnutls server unsafe, client default" \
1608 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1609 "$P_CLI debug_level=3" \
1610 0 \
1611 -C "found renegotiation extension" \
1612 -C "error" \
1613 -c "HTTP/1.0 200 [Oo][Kk]"
1614
Paul Bakker539d9722015-02-08 16:18:35 +01001615requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001616run_test "Renego ext: gnutls server unsafe, client break legacy" \
1617 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1618 "$P_CLI debug_level=3 allow_legacy=-1" \
1619 1 \
1620 -C "found renegotiation extension" \
1621 -c "error" \
1622 -C "HTTP/1.0 200 [Oo][Kk]"
1623
Paul Bakker539d9722015-02-08 16:18:35 +01001624requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001625run_test "Renego ext: gnutls client strict, server default" \
1626 "$P_SRV debug_level=3" \
1627 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1628 0 \
1629 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1630 -s "server hello, secure renegotiation extension"
1631
Paul Bakker539d9722015-02-08 16:18:35 +01001632requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001633run_test "Renego ext: gnutls client unsafe, server default" \
1634 "$P_SRV debug_level=3" \
1635 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1636 0 \
1637 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1638 -S "server hello, secure renegotiation extension"
1639
Paul Bakker539d9722015-02-08 16:18:35 +01001640requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001641run_test "Renego ext: gnutls client unsafe, server break legacy" \
1642 "$P_SRV debug_level=3 allow_legacy=-1" \
1643 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1644 1 \
1645 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1646 -S "server hello, secure renegotiation extension"
1647
Janos Follath365b2262016-02-17 10:11:21 +00001648# Tests for silently dropping trailing extra bytes in .der certificates
1649
1650requires_gnutls
1651run_test "DER format: no trailing bytes" \
1652 "$P_SRV crt_file=data_files/server5-der0.crt \
1653 key_file=data_files/server5.key" \
1654 "$G_CLI " \
1655 0 \
1656 -c "Handshake was completed" \
1657
1658requires_gnutls
1659run_test "DER format: with a trailing zero byte" \
1660 "$P_SRV crt_file=data_files/server5-der1a.crt \
1661 key_file=data_files/server5.key" \
1662 "$G_CLI " \
1663 0 \
1664 -c "Handshake was completed" \
1665
1666requires_gnutls
1667run_test "DER format: with a trailing random byte" \
1668 "$P_SRV crt_file=data_files/server5-der1b.crt \
1669 key_file=data_files/server5.key" \
1670 "$G_CLI " \
1671 0 \
1672 -c "Handshake was completed" \
1673
1674requires_gnutls
1675run_test "DER format: with 2 trailing random bytes" \
1676 "$P_SRV crt_file=data_files/server5-der2.crt \
1677 key_file=data_files/server5.key" \
1678 "$G_CLI " \
1679 0 \
1680 -c "Handshake was completed" \
1681
1682requires_gnutls
1683run_test "DER format: with 4 trailing random bytes" \
1684 "$P_SRV crt_file=data_files/server5-der4.crt \
1685 key_file=data_files/server5.key" \
1686 "$G_CLI " \
1687 0 \
1688 -c "Handshake was completed" \
1689
1690requires_gnutls
1691run_test "DER format: with 8 trailing random bytes" \
1692 "$P_SRV crt_file=data_files/server5-der8.crt \
1693 key_file=data_files/server5.key" \
1694 "$G_CLI " \
1695 0 \
1696 -c "Handshake was completed" \
1697
1698requires_gnutls
1699run_test "DER format: with 9 trailing random bytes" \
1700 "$P_SRV crt_file=data_files/server5-der9.crt \
1701 key_file=data_files/server5.key" \
1702 "$G_CLI " \
1703 0 \
1704 -c "Handshake was completed" \
1705
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001706# Tests for auth_mode
1707
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001708run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001709 "$P_SRV crt_file=data_files/server5-badsign.crt \
1710 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001711 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001712 1 \
1713 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001714 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001715 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001716 -c "X509 - Certificate verification failed"
1717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001718run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001719 "$P_SRV crt_file=data_files/server5-badsign.crt \
1720 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001721 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001722 0 \
1723 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001724 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001725 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001726 -C "X509 - Certificate verification failed"
1727
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001728run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001729 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001730 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001731 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001732 0 \
1733 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001734 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001735 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001736 -C "X509 - Certificate verification failed"
1737
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001738run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001739 "$P_SRV debug_level=3 auth_mode=required" \
1740 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001741 key_file=data_files/server5.key" \
1742 1 \
1743 -S "skip write certificate request" \
1744 -C "skip parse certificate request" \
1745 -c "got a certificate request" \
1746 -C "skip write certificate" \
1747 -C "skip write certificate verify" \
1748 -S "skip parse certificate verify" \
1749 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001750 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001751 -s "! mbedtls_ssl_handshake returned" \
1752 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001753 -s "X509 - Certificate verification failed"
1754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001755run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001756 "$P_SRV debug_level=3 auth_mode=optional" \
1757 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001758 key_file=data_files/server5.key" \
1759 0 \
1760 -S "skip write certificate request" \
1761 -C "skip parse certificate request" \
1762 -c "got a certificate request" \
1763 -C "skip write certificate" \
1764 -C "skip write certificate verify" \
1765 -S "skip parse certificate verify" \
1766 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001767 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001768 -S "! mbedtls_ssl_handshake returned" \
1769 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001770 -S "X509 - Certificate verification failed"
1771
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001772run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001773 "$P_SRV debug_level=3 auth_mode=none" \
1774 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001775 key_file=data_files/server5.key" \
1776 0 \
1777 -s "skip write certificate request" \
1778 -C "skip parse certificate request" \
1779 -c "got no certificate request" \
1780 -c "skip write certificate" \
1781 -c "skip write certificate verify" \
1782 -s "skip parse certificate verify" \
1783 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001784 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001785 -S "! mbedtls_ssl_handshake returned" \
1786 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001787 -S "X509 - Certificate verification failed"
1788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001789run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001790 "$P_SRV debug_level=3 auth_mode=optional" \
1791 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001792 0 \
1793 -S "skip write certificate request" \
1794 -C "skip parse certificate request" \
1795 -c "got a certificate request" \
1796 -C "skip write certificate$" \
1797 -C "got no certificate to send" \
1798 -S "SSLv3 client has no certificate" \
1799 -c "skip write certificate verify" \
1800 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001801 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001802 -S "! mbedtls_ssl_handshake returned" \
1803 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001804 -S "X509 - Certificate verification failed"
1805
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001806run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001807 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001808 "$O_CLI" \
1809 0 \
1810 -S "skip write certificate request" \
1811 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001812 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001813 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001814 -S "X509 - Certificate verification failed"
1815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001816run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001817 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001818 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001819 0 \
1820 -C "skip parse certificate request" \
1821 -c "got a certificate request" \
1822 -C "skip write certificate$" \
1823 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001824 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001825
Janos Follath542ee5d2016-03-07 15:57:05 +00001826requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001827run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001828 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001829 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
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 "skip write certificate verify" \
1836 -c "got no certificate to send" \
1837 -s "SSLv3 client has no certificate" \
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é-Gonnarddf331a52015-01-08 16:43:07 +01001844# Tests for certificate selection based on SHA verson
1845
1846run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1847 "$P_SRV crt_file=data_files/server5.crt \
1848 key_file=data_files/server5.key \
1849 crt_file2=data_files/server5-sha1.crt \
1850 key_file2=data_files/server5.key" \
1851 "$P_CLI force_version=tls1_2" \
1852 0 \
1853 -c "signed using.*ECDSA with SHA256" \
1854 -C "signed using.*ECDSA with SHA1"
1855
1856run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1857 "$P_SRV crt_file=data_files/server5.crt \
1858 key_file=data_files/server5.key \
1859 crt_file2=data_files/server5-sha1.crt \
1860 key_file2=data_files/server5.key" \
1861 "$P_CLI force_version=tls1_1" \
1862 0 \
1863 -C "signed using.*ECDSA with SHA256" \
1864 -c "signed using.*ECDSA with SHA1"
1865
1866run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1867 "$P_SRV crt_file=data_files/server5.crt \
1868 key_file=data_files/server5.key \
1869 crt_file2=data_files/server5-sha1.crt \
1870 key_file2=data_files/server5.key" \
1871 "$P_CLI force_version=tls1" \
1872 0 \
1873 -C "signed using.*ECDSA with SHA256" \
1874 -c "signed using.*ECDSA with SHA1"
1875
1876run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1877 "$P_SRV crt_file=data_files/server5.crt \
1878 key_file=data_files/server5.key \
1879 crt_file2=data_files/server6.crt \
1880 key_file2=data_files/server6.key" \
1881 "$P_CLI force_version=tls1_1" \
1882 0 \
1883 -c "serial number.*09" \
1884 -c "signed using.*ECDSA with SHA256" \
1885 -C "signed using.*ECDSA with SHA1"
1886
1887run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1888 "$P_SRV crt_file=data_files/server6.crt \
1889 key_file=data_files/server6.key \
1890 crt_file2=data_files/server5.crt \
1891 key_file2=data_files/server5.key" \
1892 "$P_CLI force_version=tls1_1" \
1893 0 \
1894 -c "serial number.*0A" \
1895 -c "signed using.*ECDSA with SHA256" \
1896 -C "signed using.*ECDSA with SHA1"
1897
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001898# tests for SNI
1899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001900run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001901 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001902 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001903 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001904 0 \
1905 -S "parse ServerName extension" \
1906 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1907 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001909run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001910 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001911 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001912 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 +02001913 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001914 0 \
1915 -s "parse ServerName extension" \
1916 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1917 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001919run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001920 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001921 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001922 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 +02001923 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001924 0 \
1925 -s "parse ServerName extension" \
1926 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1927 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001928
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001929run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001930 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001931 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001932 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 +02001933 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001934 1 \
1935 -s "parse ServerName extension" \
1936 -s "ssl_sni_wrapper() returned" \
1937 -s "mbedtls_ssl_handshake returned" \
1938 -c "mbedtls_ssl_handshake returned" \
1939 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001940
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001941run_test "SNI: client auth no override: optional" \
1942 "$P_SRV debug_level=3 auth_mode=optional \
1943 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1944 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1945 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001946 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001947 -S "skip write certificate request" \
1948 -C "skip parse certificate request" \
1949 -c "got a certificate request" \
1950 -C "skip write certificate" \
1951 -C "skip write certificate verify" \
1952 -S "skip parse certificate verify"
1953
1954run_test "SNI: client auth override: none -> optional" \
1955 "$P_SRV debug_level=3 auth_mode=none \
1956 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1957 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1958 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001959 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001960 -S "skip write certificate request" \
1961 -C "skip parse certificate request" \
1962 -c "got a certificate request" \
1963 -C "skip write certificate" \
1964 -C "skip write certificate verify" \
1965 -S "skip parse certificate verify"
1966
1967run_test "SNI: client auth override: optional -> none" \
1968 "$P_SRV debug_level=3 auth_mode=optional \
1969 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1970 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1971 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001972 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001973 -s "skip write certificate request" \
1974 -C "skip parse certificate request" \
1975 -c "got no certificate request" \
1976 -c "skip write certificate" \
1977 -c "skip write certificate verify" \
1978 -s "skip parse certificate verify"
1979
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001980run_test "SNI: CA no override" \
1981 "$P_SRV debug_level=3 auth_mode=optional \
1982 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1983 ca_file=data_files/test-ca.crt \
1984 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1985 "$P_CLI debug_level=3 server_name=localhost \
1986 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1987 1 \
1988 -S "skip write certificate request" \
1989 -C "skip parse certificate request" \
1990 -c "got a certificate request" \
1991 -C "skip write certificate" \
1992 -C "skip write certificate verify" \
1993 -S "skip parse certificate verify" \
1994 -s "x509_verify_cert() returned" \
1995 -s "! The certificate is not correctly signed by the trusted CA" \
1996 -S "The certificate has been revoked (is on a CRL)"
1997
1998run_test "SNI: CA override" \
1999 "$P_SRV debug_level=3 auth_mode=optional \
2000 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2001 ca_file=data_files/test-ca.crt \
2002 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2003 "$P_CLI debug_level=3 server_name=localhost \
2004 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2005 0 \
2006 -S "skip write certificate request" \
2007 -C "skip parse certificate request" \
2008 -c "got a certificate request" \
2009 -C "skip write certificate" \
2010 -C "skip write certificate verify" \
2011 -S "skip parse certificate verify" \
2012 -S "x509_verify_cert() returned" \
2013 -S "! The certificate is not correctly signed by the trusted CA" \
2014 -S "The certificate has been revoked (is on a CRL)"
2015
2016run_test "SNI: CA override with CRL" \
2017 "$P_SRV debug_level=3 auth_mode=optional \
2018 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2019 ca_file=data_files/test-ca.crt \
2020 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2021 "$P_CLI debug_level=3 server_name=localhost \
2022 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2023 1 \
2024 -S "skip write certificate request" \
2025 -C "skip parse certificate request" \
2026 -c "got a certificate request" \
2027 -C "skip write certificate" \
2028 -C "skip write certificate verify" \
2029 -S "skip parse certificate verify" \
2030 -s "x509_verify_cert() returned" \
2031 -S "! The certificate is not correctly signed by the trusted CA" \
2032 -s "The certificate has been revoked (is on a CRL)"
2033
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002034# Tests for non-blocking I/O: exercise a variety of handshake flows
2035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002036run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002037 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2038 "$P_CLI nbio=2 tickets=0" \
2039 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002040 -S "mbedtls_ssl_handshake returned" \
2041 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002042 -c "Read from server: .* bytes read"
2043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002044run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002045 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2046 "$P_CLI nbio=2 tickets=0" \
2047 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002048 -S "mbedtls_ssl_handshake returned" \
2049 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002050 -c "Read from server: .* bytes read"
2051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002052run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002053 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2054 "$P_CLI nbio=2 tickets=1" \
2055 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002056 -S "mbedtls_ssl_handshake returned" \
2057 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002058 -c "Read from server: .* bytes read"
2059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002060run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002061 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2062 "$P_CLI nbio=2 tickets=1" \
2063 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002064 -S "mbedtls_ssl_handshake returned" \
2065 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002066 -c "Read from server: .* bytes read"
2067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002068run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002069 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2070 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2071 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002072 -S "mbedtls_ssl_handshake returned" \
2073 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002074 -c "Read from server: .* bytes read"
2075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002076run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002077 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2078 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2079 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002080 -S "mbedtls_ssl_handshake returned" \
2081 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002082 -c "Read from server: .* bytes read"
2083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002084run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002085 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2086 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2087 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002088 -S "mbedtls_ssl_handshake returned" \
2089 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002090 -c "Read from server: .* bytes read"
2091
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002092# Tests for version negotiation
2093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002094run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002095 "$P_SRV" \
2096 "$P_CLI" \
2097 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002098 -S "mbedtls_ssl_handshake returned" \
2099 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002100 -s "Protocol is TLSv1.2" \
2101 -c "Protocol is TLSv1.2"
2102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002103run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002104 "$P_SRV" \
2105 "$P_CLI max_version=tls1_1" \
2106 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002107 -S "mbedtls_ssl_handshake returned" \
2108 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002109 -s "Protocol is TLSv1.1" \
2110 -c "Protocol is TLSv1.1"
2111
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002112run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002113 "$P_SRV max_version=tls1_1" \
2114 "$P_CLI" \
2115 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002116 -S "mbedtls_ssl_handshake returned" \
2117 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002118 -s "Protocol is TLSv1.1" \
2119 -c "Protocol is TLSv1.1"
2120
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002121run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002122 "$P_SRV max_version=tls1_1" \
2123 "$P_CLI max_version=tls1_1" \
2124 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002125 -S "mbedtls_ssl_handshake returned" \
2126 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002127 -s "Protocol is TLSv1.1" \
2128 -c "Protocol is TLSv1.1"
2129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002130run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002131 "$P_SRV min_version=tls1_1" \
2132 "$P_CLI max_version=tls1_1" \
2133 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002134 -S "mbedtls_ssl_handshake returned" \
2135 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002136 -s "Protocol is TLSv1.1" \
2137 -c "Protocol is TLSv1.1"
2138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002139run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002140 "$P_SRV max_version=tls1_1" \
2141 "$P_CLI min_version=tls1_1" \
2142 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002143 -S "mbedtls_ssl_handshake returned" \
2144 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002145 -s "Protocol is TLSv1.1" \
2146 -c "Protocol is TLSv1.1"
2147
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002148run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002149 "$P_SRV max_version=tls1_1" \
2150 "$P_CLI min_version=tls1_2" \
2151 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002152 -s "mbedtls_ssl_handshake returned" \
2153 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002154 -c "SSL - Handshake protocol not within min/max boundaries"
2155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002156run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002157 "$P_SRV min_version=tls1_2" \
2158 "$P_CLI max_version=tls1_1" \
2159 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002160 -s "mbedtls_ssl_handshake returned" \
2161 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002162 -s "SSL - Handshake protocol not within min/max boundaries"
2163
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002164# Tests for ALPN extension
2165
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002166run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002167 "$P_SRV debug_level=3" \
2168 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002169 0 \
2170 -C "client hello, adding alpn extension" \
2171 -S "found alpn extension" \
2172 -C "got an alert message, type: \\[2:120]" \
2173 -S "server hello, adding alpn extension" \
2174 -C "found alpn extension " \
2175 -C "Application Layer Protocol is" \
2176 -S "Application Layer Protocol is"
2177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002178run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002179 "$P_SRV debug_level=3" \
2180 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002181 0 \
2182 -c "client hello, adding alpn extension" \
2183 -s "found alpn extension" \
2184 -C "got an alert message, type: \\[2:120]" \
2185 -S "server hello, adding alpn extension" \
2186 -C "found alpn extension " \
2187 -c "Application Layer Protocol is (none)" \
2188 -S "Application Layer Protocol is"
2189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002190run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002191 "$P_SRV debug_level=3 alpn=abc,1234" \
2192 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002193 0 \
2194 -C "client hello, adding alpn extension" \
2195 -S "found alpn extension" \
2196 -C "got an alert message, type: \\[2:120]" \
2197 -S "server hello, adding alpn extension" \
2198 -C "found alpn extension " \
2199 -C "Application Layer Protocol is" \
2200 -s "Application Layer Protocol is (none)"
2201
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002202run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002203 "$P_SRV debug_level=3 alpn=abc,1234" \
2204 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002205 0 \
2206 -c "client hello, adding alpn extension" \
2207 -s "found alpn extension" \
2208 -C "got an alert message, type: \\[2:120]" \
2209 -s "server hello, adding alpn extension" \
2210 -c "found alpn extension" \
2211 -c "Application Layer Protocol is abc" \
2212 -s "Application Layer Protocol is abc"
2213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002214run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002215 "$P_SRV debug_level=3 alpn=abc,1234" \
2216 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002217 0 \
2218 -c "client hello, adding alpn extension" \
2219 -s "found alpn extension" \
2220 -C "got an alert message, type: \\[2:120]" \
2221 -s "server hello, adding alpn extension" \
2222 -c "found alpn extension" \
2223 -c "Application Layer Protocol is abc" \
2224 -s "Application Layer Protocol is abc"
2225
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002226run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002227 "$P_SRV debug_level=3 alpn=abc,1234" \
2228 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002229 0 \
2230 -c "client hello, adding alpn extension" \
2231 -s "found alpn extension" \
2232 -C "got an alert message, type: \\[2:120]" \
2233 -s "server hello, adding alpn extension" \
2234 -c "found alpn extension" \
2235 -c "Application Layer Protocol is 1234" \
2236 -s "Application Layer Protocol is 1234"
2237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002238run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002239 "$P_SRV debug_level=3 alpn=abc,123" \
2240 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002241 1 \
2242 -c "client hello, adding alpn extension" \
2243 -s "found alpn extension" \
2244 -c "got an alert message, type: \\[2:120]" \
2245 -S "server hello, adding alpn extension" \
2246 -C "found alpn extension" \
2247 -C "Application Layer Protocol is 1234" \
2248 -S "Application Layer Protocol is 1234"
2249
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002250
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002251# Tests for keyUsage in leaf certificates, part 1:
2252# server-side certificate/suite selection
2253
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002254run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002255 "$P_SRV key_file=data_files/server2.key \
2256 crt_file=data_files/server2.ku-ds.crt" \
2257 "$P_CLI" \
2258 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002259 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002260
2261
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002262run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002263 "$P_SRV key_file=data_files/server2.key \
2264 crt_file=data_files/server2.ku-ke.crt" \
2265 "$P_CLI" \
2266 0 \
2267 -c "Ciphersuite is TLS-RSA-WITH-"
2268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002269run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002270 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002271 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002272 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002273 1 \
2274 -C "Ciphersuite is "
2275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002276run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002277 "$P_SRV key_file=data_files/server5.key \
2278 crt_file=data_files/server5.ku-ds.crt" \
2279 "$P_CLI" \
2280 0 \
2281 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2282
2283
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002284run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002285 "$P_SRV key_file=data_files/server5.key \
2286 crt_file=data_files/server5.ku-ka.crt" \
2287 "$P_CLI" \
2288 0 \
2289 -c "Ciphersuite is TLS-ECDH-"
2290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002291run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002292 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002293 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002294 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002295 1 \
2296 -C "Ciphersuite is "
2297
2298# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002299# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002301run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002302 "$O_SRV -key data_files/server2.key \
2303 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002304 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002305 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2306 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002307 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002308 -C "Processing of the Certificate handshake message failed" \
2309 -c "Ciphersuite is TLS-"
2310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002311run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002312 "$O_SRV -key data_files/server2.key \
2313 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002314 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002315 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2316 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002317 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002318 -C "Processing of the Certificate handshake message failed" \
2319 -c "Ciphersuite is TLS-"
2320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002321run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002322 "$O_SRV -key data_files/server2.key \
2323 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002324 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002325 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2326 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002327 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002328 -C "Processing of the Certificate handshake message failed" \
2329 -c "Ciphersuite is TLS-"
2330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002331run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002332 "$O_SRV -key data_files/server2.key \
2333 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002334 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002335 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2336 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002337 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002338 -c "Processing of the Certificate handshake message failed" \
2339 -C "Ciphersuite is TLS-"
2340
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002341run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2342 "$O_SRV -key data_files/server2.key \
2343 -cert data_files/server2.ku-ke.crt" \
2344 "$P_CLI debug_level=1 auth_mode=optional \
2345 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2346 0 \
2347 -c "bad certificate (usage extensions)" \
2348 -C "Processing of the Certificate handshake message failed" \
2349 -c "Ciphersuite is TLS-" \
2350 -c "! Usage does not match the keyUsage extension"
2351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002352run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002353 "$O_SRV -key data_files/server2.key \
2354 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002355 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002356 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2357 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002358 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002359 -C "Processing of the Certificate handshake message failed" \
2360 -c "Ciphersuite is TLS-"
2361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002362run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002363 "$O_SRV -key data_files/server2.key \
2364 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002365 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002366 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2367 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002368 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002369 -c "Processing of the Certificate handshake message failed" \
2370 -C "Ciphersuite is TLS-"
2371
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002372run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2373 "$O_SRV -key data_files/server2.key \
2374 -cert data_files/server2.ku-ds.crt" \
2375 "$P_CLI debug_level=1 auth_mode=optional \
2376 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2377 0 \
2378 -c "bad certificate (usage extensions)" \
2379 -C "Processing of the Certificate handshake message failed" \
2380 -c "Ciphersuite is TLS-" \
2381 -c "! Usage does not match the keyUsage extension"
2382
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002383# Tests for keyUsage in leaf certificates, part 3:
2384# server-side checking of client cert
2385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002386run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002387 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002388 "$O_CLI -key data_files/server2.key \
2389 -cert data_files/server2.ku-ds.crt" \
2390 0 \
2391 -S "bad certificate (usage extensions)" \
2392 -S "Processing of the Certificate handshake message failed"
2393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002394run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002395 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002396 "$O_CLI -key data_files/server2.key \
2397 -cert data_files/server2.ku-ke.crt" \
2398 0 \
2399 -s "bad certificate (usage extensions)" \
2400 -S "Processing of the Certificate handshake message failed"
2401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002402run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002403 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002404 "$O_CLI -key data_files/server2.key \
2405 -cert data_files/server2.ku-ke.crt" \
2406 1 \
2407 -s "bad certificate (usage extensions)" \
2408 -s "Processing of the Certificate handshake message failed"
2409
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002410run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002411 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002412 "$O_CLI -key data_files/server5.key \
2413 -cert data_files/server5.ku-ds.crt" \
2414 0 \
2415 -S "bad certificate (usage extensions)" \
2416 -S "Processing of the Certificate handshake message failed"
2417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002418run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002419 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002420 "$O_CLI -key data_files/server5.key \
2421 -cert data_files/server5.ku-ka.crt" \
2422 0 \
2423 -s "bad certificate (usage extensions)" \
2424 -S "Processing of the Certificate handshake message failed"
2425
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002426# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2427
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002428run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002429 "$P_SRV key_file=data_files/server5.key \
2430 crt_file=data_files/server5.eku-srv.crt" \
2431 "$P_CLI" \
2432 0
2433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002434run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002435 "$P_SRV key_file=data_files/server5.key \
2436 crt_file=data_files/server5.eku-srv.crt" \
2437 "$P_CLI" \
2438 0
2439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002440run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002441 "$P_SRV key_file=data_files/server5.key \
2442 crt_file=data_files/server5.eku-cs_any.crt" \
2443 "$P_CLI" \
2444 0
2445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002446run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002447 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002448 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002449 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002450 1
2451
2452# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002454run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002455 "$O_SRV -key data_files/server5.key \
2456 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002457 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002458 0 \
2459 -C "bad certificate (usage extensions)" \
2460 -C "Processing of the Certificate handshake message failed" \
2461 -c "Ciphersuite is TLS-"
2462
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002463run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002464 "$O_SRV -key data_files/server5.key \
2465 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002466 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002467 0 \
2468 -C "bad certificate (usage extensions)" \
2469 -C "Processing of the Certificate handshake message failed" \
2470 -c "Ciphersuite is TLS-"
2471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002472run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002473 "$O_SRV -key data_files/server5.key \
2474 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002475 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002476 0 \
2477 -C "bad certificate (usage extensions)" \
2478 -C "Processing of the Certificate handshake message failed" \
2479 -c "Ciphersuite is TLS-"
2480
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002481run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002482 "$O_SRV -key data_files/server5.key \
2483 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002484 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002485 1 \
2486 -c "bad certificate (usage extensions)" \
2487 -c "Processing of the Certificate handshake message failed" \
2488 -C "Ciphersuite is TLS-"
2489
2490# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2491
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002492run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002493 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002494 "$O_CLI -key data_files/server5.key \
2495 -cert data_files/server5.eku-cli.crt" \
2496 0 \
2497 -S "bad certificate (usage extensions)" \
2498 -S "Processing of the Certificate handshake message failed"
2499
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002500run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002501 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002502 "$O_CLI -key data_files/server5.key \
2503 -cert data_files/server5.eku-srv_cli.crt" \
2504 0 \
2505 -S "bad certificate (usage extensions)" \
2506 -S "Processing of the Certificate handshake message failed"
2507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002508run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002509 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002510 "$O_CLI -key data_files/server5.key \
2511 -cert data_files/server5.eku-cs_any.crt" \
2512 0 \
2513 -S "bad certificate (usage extensions)" \
2514 -S "Processing of the Certificate handshake message failed"
2515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002516run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002517 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002518 "$O_CLI -key data_files/server5.key \
2519 -cert data_files/server5.eku-cs.crt" \
2520 0 \
2521 -s "bad certificate (usage extensions)" \
2522 -S "Processing of the Certificate handshake message failed"
2523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002524run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002525 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002526 "$O_CLI -key data_files/server5.key \
2527 -cert data_files/server5.eku-cs.crt" \
2528 1 \
2529 -s "bad certificate (usage extensions)" \
2530 -s "Processing of the Certificate handshake message failed"
2531
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002532# Tests for DHM parameters loading
2533
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002534run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002535 "$P_SRV" \
2536 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2537 debug_level=3" \
2538 0 \
2539 -c "value of 'DHM: P ' (2048 bits)" \
2540 -c "value of 'DHM: G ' (2048 bits)"
2541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002542run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002543 "$P_SRV dhm_file=data_files/dhparams.pem" \
2544 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2545 debug_level=3" \
2546 0 \
2547 -c "value of 'DHM: P ' (1024 bits)" \
2548 -c "value of 'DHM: G ' (2 bits)"
2549
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002550# Tests for DHM client-side size checking
2551
2552run_test "DHM size: server default, client default, OK" \
2553 "$P_SRV" \
2554 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2555 debug_level=1" \
2556 0 \
2557 -C "DHM prime too short:"
2558
2559run_test "DHM size: server default, client 2048, OK" \
2560 "$P_SRV" \
2561 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2562 debug_level=1 dhmlen=2048" \
2563 0 \
2564 -C "DHM prime too short:"
2565
2566run_test "DHM size: server 1024, client default, OK" \
2567 "$P_SRV dhm_file=data_files/dhparams.pem" \
2568 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2569 debug_level=1" \
2570 0 \
2571 -C "DHM prime too short:"
2572
2573run_test "DHM size: server 1000, client default, rejected" \
2574 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2575 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2576 debug_level=1" \
2577 1 \
2578 -c "DHM prime too short:"
2579
2580run_test "DHM size: server default, client 2049, rejected" \
2581 "$P_SRV" \
2582 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2583 debug_level=1 dhmlen=2049" \
2584 1 \
2585 -c "DHM prime too short:"
2586
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002587# Tests for PSK callback
2588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002589run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002590 "$P_SRV psk=abc123 psk_identity=foo" \
2591 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2592 psk_identity=foo psk=abc123" \
2593 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002594 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002595 -S "SSL - Unknown identity received" \
2596 -S "SSL - Verification of the message MAC failed"
2597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002598run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002599 "$P_SRV" \
2600 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2601 psk_identity=foo psk=abc123" \
2602 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002603 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002604 -S "SSL - Unknown identity received" \
2605 -S "SSL - Verification of the message MAC failed"
2606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002607run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002608 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2609 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2610 psk_identity=foo psk=abc123" \
2611 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002612 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002613 -s "SSL - Unknown identity received" \
2614 -S "SSL - Verification of the message MAC failed"
2615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002616run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002617 "$P_SRV psk_list=abc,dead,def,beef" \
2618 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2619 psk_identity=abc psk=dead" \
2620 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002621 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002622 -S "SSL - Unknown identity received" \
2623 -S "SSL - Verification of the message MAC failed"
2624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002625run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002626 "$P_SRV psk_list=abc,dead,def,beef" \
2627 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2628 psk_identity=def psk=beef" \
2629 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002630 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002631 -S "SSL - Unknown identity received" \
2632 -S "SSL - Verification of the message MAC failed"
2633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002634run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002635 "$P_SRV psk_list=abc,dead,def,beef" \
2636 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2637 psk_identity=ghi psk=beef" \
2638 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002639 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002640 -s "SSL - Unknown identity received" \
2641 -S "SSL - Verification of the message MAC failed"
2642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002643run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002644 "$P_SRV psk_list=abc,dead,def,beef" \
2645 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2646 psk_identity=abc psk=beef" \
2647 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002648 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002649 -S "SSL - Unknown identity received" \
2650 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002651
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002652# Tests for ciphersuites per version
2653
Janos Follath542ee5d2016-03-07 15:57:05 +00002654requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002655run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002656 "$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 +02002657 "$P_CLI force_version=ssl3" \
2658 0 \
2659 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2660
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002661run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002662 "$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 +01002663 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002664 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002665 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002667run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002668 "$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 +02002669 "$P_CLI force_version=tls1_1" \
2670 0 \
2671 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2672
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002673run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002674 "$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 +02002675 "$P_CLI force_version=tls1_2" \
2676 0 \
2677 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2678
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002679# Test for ClientHello without extensions
2680
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002681requires_gnutls
2682run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002683 "$P_SRV debug_level=3" \
2684 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2685 0 \
2686 -s "dumping 'client hello extensions' (0 bytes)"
2687
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002688# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002689
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002690run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002691 "$P_SRV" \
2692 "$P_CLI request_size=100" \
2693 0 \
2694 -s "Read from client: 100 bytes read$"
2695
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002696run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002697 "$P_SRV" \
2698 "$P_CLI request_size=500" \
2699 0 \
2700 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002701
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002702# Tests for small packets
2703
Janos Follath542ee5d2016-03-07 15:57:05 +00002704requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002705run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002706 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002707 "$P_CLI request_size=1 force_version=ssl3 \
2708 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2709 0 \
2710 -s "Read from client: 1 bytes read"
2711
Janos Follath542ee5d2016-03-07 15:57:05 +00002712requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002713run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002714 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002715 "$P_CLI request_size=1 force_version=ssl3 \
2716 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2717 0 \
2718 -s "Read from client: 1 bytes read"
2719
2720run_test "Small packet TLS 1.0 BlockCipher" \
2721 "$P_SRV" \
2722 "$P_CLI request_size=1 force_version=tls1 \
2723 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2724 0 \
2725 -s "Read from client: 1 bytes read"
2726
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002727run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2728 "$P_SRV" \
2729 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2730 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2731 0 \
2732 -s "Read from client: 1 bytes read"
2733
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002734run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2735 "$P_SRV" \
2736 "$P_CLI request_size=1 force_version=tls1 \
2737 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2738 trunc_hmac=1" \
2739 0 \
2740 -s "Read from client: 1 bytes read"
2741
2742run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002743 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002744 "$P_CLI request_size=1 force_version=tls1 \
2745 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2746 trunc_hmac=1" \
2747 0 \
2748 -s "Read from client: 1 bytes read"
2749
2750run_test "Small packet TLS 1.1 BlockCipher" \
2751 "$P_SRV" \
2752 "$P_CLI request_size=1 force_version=tls1_1 \
2753 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2754 0 \
2755 -s "Read from client: 1 bytes read"
2756
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002757run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2758 "$P_SRV" \
2759 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2760 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2761 0 \
2762 -s "Read from client: 1 bytes read"
2763
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002764run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002765 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002766 "$P_CLI request_size=1 force_version=tls1_1 \
2767 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2768 0 \
2769 -s "Read from client: 1 bytes read"
2770
2771run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2772 "$P_SRV" \
2773 "$P_CLI request_size=1 force_version=tls1_1 \
2774 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2775 trunc_hmac=1" \
2776 0 \
2777 -s "Read from client: 1 bytes read"
2778
2779run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002780 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002781 "$P_CLI request_size=1 force_version=tls1_1 \
2782 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2783 trunc_hmac=1" \
2784 0 \
2785 -s "Read from client: 1 bytes read"
2786
2787run_test "Small packet TLS 1.2 BlockCipher" \
2788 "$P_SRV" \
2789 "$P_CLI request_size=1 force_version=tls1_2 \
2790 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2791 0 \
2792 -s "Read from client: 1 bytes read"
2793
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002794run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2795 "$P_SRV" \
2796 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2797 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2798 0 \
2799 -s "Read from client: 1 bytes read"
2800
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002801run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2802 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002803 "$P_CLI request_size=1 force_version=tls1_2 \
2804 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002805 0 \
2806 -s "Read from client: 1 bytes read"
2807
2808run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2809 "$P_SRV" \
2810 "$P_CLI request_size=1 force_version=tls1_2 \
2811 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2812 trunc_hmac=1" \
2813 0 \
2814 -s "Read from client: 1 bytes read"
2815
2816run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002817 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002818 "$P_CLI request_size=1 force_version=tls1_2 \
2819 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2820 0 \
2821 -s "Read from client: 1 bytes read"
2822
2823run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002824 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002825 "$P_CLI request_size=1 force_version=tls1_2 \
2826 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2827 trunc_hmac=1" \
2828 0 \
2829 -s "Read from client: 1 bytes read"
2830
2831run_test "Small packet TLS 1.2 AEAD" \
2832 "$P_SRV" \
2833 "$P_CLI request_size=1 force_version=tls1_2 \
2834 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2835 0 \
2836 -s "Read from client: 1 bytes read"
2837
2838run_test "Small packet TLS 1.2 AEAD shorter tag" \
2839 "$P_SRV" \
2840 "$P_CLI request_size=1 force_version=tls1_2 \
2841 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2842 0 \
2843 -s "Read from client: 1 bytes read"
2844
Janos Follathb700c462016-05-06 13:48:23 +01002845# A test for extensions in SSLv3
2846
2847requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2848run_test "SSLv3 with extensions, server side" \
2849 "$P_SRV min_version=ssl3 debug_level=3" \
2850 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2851 0 \
2852 -S "dumping 'client hello extensions'" \
2853 -S "server hello, total extension length:"
2854
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002855# Test for large packets
2856
Janos Follath542ee5d2016-03-07 15:57:05 +00002857requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002858run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002859 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002860 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002861 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2862 0 \
2863 -s "Read from client: 16384 bytes read"
2864
Janos Follath542ee5d2016-03-07 15:57:05 +00002865requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002866run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002867 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002868 "$P_CLI request_size=16384 force_version=ssl3 \
2869 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2870 0 \
2871 -s "Read from client: 16384 bytes read"
2872
2873run_test "Large packet TLS 1.0 BlockCipher" \
2874 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002875 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002876 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2877 0 \
2878 -s "Read from client: 16384 bytes read"
2879
2880run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2881 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002882 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002883 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2884 trunc_hmac=1" \
2885 0 \
2886 -s "Read from client: 16384 bytes read"
2887
2888run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002889 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002890 "$P_CLI request_size=16384 force_version=tls1 \
2891 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2892 trunc_hmac=1" \
2893 0 \
2894 -s "Read from client: 16384 bytes read"
2895
2896run_test "Large packet TLS 1.1 BlockCipher" \
2897 "$P_SRV" \
2898 "$P_CLI request_size=16384 force_version=tls1_1 \
2899 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2900 0 \
2901 -s "Read from client: 16384 bytes read"
2902
2903run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002904 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002905 "$P_CLI request_size=16384 force_version=tls1_1 \
2906 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2907 0 \
2908 -s "Read from client: 16384 bytes read"
2909
2910run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2911 "$P_SRV" \
2912 "$P_CLI request_size=16384 force_version=tls1_1 \
2913 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2914 trunc_hmac=1" \
2915 0 \
2916 -s "Read from client: 16384 bytes read"
2917
2918run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002919 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002920 "$P_CLI request_size=16384 force_version=tls1_1 \
2921 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2922 trunc_hmac=1" \
2923 0 \
2924 -s "Read from client: 16384 bytes read"
2925
2926run_test "Large packet TLS 1.2 BlockCipher" \
2927 "$P_SRV" \
2928 "$P_CLI request_size=16384 force_version=tls1_2 \
2929 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2930 0 \
2931 -s "Read from client: 16384 bytes read"
2932
2933run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2934 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002935 "$P_CLI request_size=16384 force_version=tls1_2 \
2936 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002937 0 \
2938 -s "Read from client: 16384 bytes read"
2939
2940run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2941 "$P_SRV" \
2942 "$P_CLI request_size=16384 force_version=tls1_2 \
2943 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2944 trunc_hmac=1" \
2945 0 \
2946 -s "Read from client: 16384 bytes read"
2947
2948run_test "Large packet TLS 1.2 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_2 \
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.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002956 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002957 "$P_CLI request_size=16384 force_version=tls1_2 \
2958 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2959 trunc_hmac=1" \
2960 0 \
2961 -s "Read from client: 16384 bytes read"
2962
2963run_test "Large packet TLS 1.2 AEAD" \
2964 "$P_SRV" \
2965 "$P_CLI request_size=16384 force_version=tls1_2 \
2966 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2967 0 \
2968 -s "Read from client: 16384 bytes read"
2969
2970run_test "Large packet TLS 1.2 AEAD shorter tag" \
2971 "$P_SRV" \
2972 "$P_CLI request_size=16384 force_version=tls1_2 \
2973 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2974 0 \
2975 -s "Read from client: 16384 bytes read"
2976
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002977# Tests for DTLS HelloVerifyRequest
2978
2979run_test "DTLS cookie: enabled" \
2980 "$P_SRV dtls=1 debug_level=2" \
2981 "$P_CLI dtls=1 debug_level=2" \
2982 0 \
2983 -s "cookie verification failed" \
2984 -s "cookie verification passed" \
2985 -S "cookie verification skipped" \
2986 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002987 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002988 -S "SSL - The requested feature is not available"
2989
2990run_test "DTLS cookie: disabled" \
2991 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2992 "$P_CLI dtls=1 debug_level=2" \
2993 0 \
2994 -S "cookie verification failed" \
2995 -S "cookie verification passed" \
2996 -s "cookie verification skipped" \
2997 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002998 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002999 -S "SSL - The requested feature is not available"
3000
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003001run_test "DTLS cookie: default (failing)" \
3002 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3003 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3004 1 \
3005 -s "cookie verification failed" \
3006 -S "cookie verification passed" \
3007 -S "cookie verification skipped" \
3008 -C "received hello verify request" \
3009 -S "hello verification requested" \
3010 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003011
3012requires_ipv6
3013run_test "DTLS cookie: enabled, IPv6" \
3014 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3015 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3016 0 \
3017 -s "cookie verification failed" \
3018 -s "cookie verification passed" \
3019 -S "cookie verification skipped" \
3020 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003021 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003022 -S "SSL - The requested feature is not available"
3023
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003024run_test "DTLS cookie: enabled, nbio" \
3025 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3026 "$P_CLI dtls=1 nbio=2 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é-Gonnard579950c2014-09-29 17:47:33 +02003033 -S "SSL - The requested feature is not available"
3034
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003035# Tests for client reconnecting from the same port with DTLS
3036
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003037not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003038run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003039 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3040 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003041 0 \
3042 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003043 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003044 -S "Client initiated reconnection from same port"
3045
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003046not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003047run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003048 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3049 "$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 +02003050 0 \
3051 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003052 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003053 -s "Client initiated reconnection from same port"
3054
Paul Bakker3b224ff2016-05-13 10:33:25 +01003055not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3056run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003057 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3058 "$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 +02003059 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003060 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003061 -s "Client initiated reconnection from same port"
3062
Paul Bakker3b224ff2016-05-13 10:33:25 +01003063only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3064run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3065 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3066 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3067 0 \
3068 -S "The operation timed out" \
3069 -s "Client initiated reconnection from same port"
3070
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003071run_test "DTLS client reconnect from same port: no cookies" \
3072 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003073 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3074 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003075 -s "The operation timed out" \
3076 -S "Client initiated reconnection from same port"
3077
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003078# Tests for various cases of client authentication with DTLS
3079# (focused on handshake flows and message parsing)
3080
3081run_test "DTLS client auth: required" \
3082 "$P_SRV dtls=1 auth_mode=required" \
3083 "$P_CLI dtls=1" \
3084 0 \
3085 -s "Verifying peer X.509 certificate... ok"
3086
3087run_test "DTLS client auth: optional, client has no cert" \
3088 "$P_SRV dtls=1 auth_mode=optional" \
3089 "$P_CLI dtls=1 crt_file=none key_file=none" \
3090 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003091 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003092
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003093run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003094 "$P_SRV dtls=1 auth_mode=none" \
3095 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3096 0 \
3097 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003098 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003099
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003100run_test "DTLS wrong PSK: badmac alert" \
3101 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3102 "$P_CLI dtls=1 psk=abc124" \
3103 1 \
3104 -s "SSL - Verification of the message MAC failed" \
3105 -c "SSL - A fatal alert message was received from our peer"
3106
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003107# Tests for receiving fragmented handshake messages with DTLS
3108
3109requires_gnutls
3110run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3111 "$G_SRV -u --mtu 2048 -a" \
3112 "$P_CLI dtls=1 debug_level=2" \
3113 0 \
3114 -C "found fragmented DTLS handshake message" \
3115 -C "error"
3116
3117requires_gnutls
3118run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3119 "$G_SRV -u --mtu 512" \
3120 "$P_CLI dtls=1 debug_level=2" \
3121 0 \
3122 -c "found fragmented DTLS handshake message" \
3123 -C "error"
3124
3125requires_gnutls
3126run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3127 "$G_SRV -u --mtu 128" \
3128 "$P_CLI dtls=1 debug_level=2" \
3129 0 \
3130 -c "found fragmented DTLS handshake message" \
3131 -C "error"
3132
3133requires_gnutls
3134run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3135 "$G_SRV -u --mtu 128" \
3136 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3137 0 \
3138 -c "found fragmented DTLS handshake message" \
3139 -C "error"
3140
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003141requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003142run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3143 "$G_SRV -u --mtu 256" \
3144 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3145 0 \
3146 -c "found fragmented DTLS handshake message" \
3147 -c "client hello, adding renegotiation extension" \
3148 -c "found renegotiation extension" \
3149 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003150 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003151 -C "error" \
3152 -s "Extra-header:"
3153
3154requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003155run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3156 "$G_SRV -u --mtu 256" \
3157 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3158 0 \
3159 -c "found fragmented DTLS handshake message" \
3160 -c "client hello, adding renegotiation extension" \
3161 -c "found renegotiation extension" \
3162 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003163 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003164 -C "error" \
3165 -s "Extra-header:"
3166
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003167run_test "DTLS reassembly: no fragmentation (openssl server)" \
3168 "$O_SRV -dtls1 -mtu 2048" \
3169 "$P_CLI dtls=1 debug_level=2" \
3170 0 \
3171 -C "found fragmented DTLS handshake message" \
3172 -C "error"
3173
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003174run_test "DTLS reassembly: some fragmentation (openssl server)" \
3175 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003176 "$P_CLI dtls=1 debug_level=2" \
3177 0 \
3178 -c "found fragmented DTLS handshake message" \
3179 -C "error"
3180
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003181run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003182 "$O_SRV -dtls1 -mtu 256" \
3183 "$P_CLI dtls=1 debug_level=2" \
3184 0 \
3185 -c "found fragmented DTLS handshake message" \
3186 -C "error"
3187
3188run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3189 "$O_SRV -dtls1 -mtu 256" \
3190 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3191 0 \
3192 -c "found fragmented DTLS handshake message" \
3193 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003194
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003195# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003196
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003197not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003198run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003199 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003200 "$P_SRV dtls=1 debug_level=2" \
3201 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003202 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003203 -C "replayed record" \
3204 -S "replayed record" \
3205 -C "record from another epoch" \
3206 -S "record from another epoch" \
3207 -C "discarding invalid record" \
3208 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003209 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003210 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003211 -c "HTTP/1.0 200 OK"
3212
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003213not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003214run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003215 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003216 "$P_SRV dtls=1 debug_level=2" \
3217 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003218 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003219 -c "replayed record" \
3220 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003221 -c "discarding invalid record" \
3222 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003223 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003224 -s "Extra-header:" \
3225 -c "HTTP/1.0 200 OK"
3226
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003227run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3228 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003229 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3230 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003231 0 \
3232 -c "replayed record" \
3233 -S "replayed record" \
3234 -c "discarding invalid record" \
3235 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003236 -c "resend" \
3237 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003238 -s "Extra-header:" \
3239 -c "HTTP/1.0 200 OK"
3240
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003241run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003242 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003243 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003244 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003245 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003246 -c "discarding invalid record (mac)" \
3247 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003248 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003249 -c "HTTP/1.0 200 OK" \
3250 -S "too many records with bad MAC" \
3251 -S "Verification of the message MAC failed"
3252
3253run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3254 -p "$P_PXY bad_ad=1" \
3255 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3256 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3257 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003258 -C "discarding invalid record (mac)" \
3259 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003260 -S "Extra-header:" \
3261 -C "HTTP/1.0 200 OK" \
3262 -s "too many records with bad MAC" \
3263 -s "Verification of the message MAC failed"
3264
3265run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3266 -p "$P_PXY bad_ad=1" \
3267 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3268 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3269 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003270 -c "discarding invalid record (mac)" \
3271 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003272 -s "Extra-header:" \
3273 -c "HTTP/1.0 200 OK" \
3274 -S "too many records with bad MAC" \
3275 -S "Verification of the message MAC failed"
3276
3277run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3278 -p "$P_PXY bad_ad=1" \
3279 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3280 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3281 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003282 -c "discarding invalid record (mac)" \
3283 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003284 -s "Extra-header:" \
3285 -c "HTTP/1.0 200 OK" \
3286 -s "too many records with bad MAC" \
3287 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003288
3289run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003290 -p "$P_PXY delay_ccs=1" \
3291 "$P_SRV dtls=1 debug_level=1" \
3292 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003293 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003294 -c "record from another epoch" \
3295 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003296 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003297 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003298 -s "Extra-header:" \
3299 -c "HTTP/1.0 200 OK"
3300
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003301# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003302
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003303needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003304run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003305 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003306 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3307 psk=abc123" \
3308 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003309 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3310 0 \
3311 -s "Extra-header:" \
3312 -c "HTTP/1.0 200 OK"
3313
3314needs_more_time 2
3315run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3316 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003317 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3318 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003319 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3320 0 \
3321 -s "Extra-header:" \
3322 -c "HTTP/1.0 200 OK"
3323
3324needs_more_time 2
3325run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3326 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003327 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3328 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003329 0 \
3330 -s "Extra-header:" \
3331 -c "HTTP/1.0 200 OK"
3332
3333needs_more_time 2
3334run_test "DTLS proxy: 3d, FS, client auth" \
3335 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003336 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3337 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003338 0 \
3339 -s "Extra-header:" \
3340 -c "HTTP/1.0 200 OK"
3341
3342needs_more_time 2
3343run_test "DTLS proxy: 3d, FS, ticket" \
3344 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003345 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3346 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003347 0 \
3348 -s "Extra-header:" \
3349 -c "HTTP/1.0 200 OK"
3350
3351needs_more_time 2
3352run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3353 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003354 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3355 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003356 0 \
3357 -s "Extra-header:" \
3358 -c "HTTP/1.0 200 OK"
3359
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003360needs_more_time 2
3361run_test "DTLS proxy: 3d, max handshake, nbio" \
3362 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003363 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3364 auth_mode=required" \
3365 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003366 0 \
3367 -s "Extra-header:" \
3368 -c "HTTP/1.0 200 OK"
3369
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003370needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003371run_test "DTLS proxy: 3d, min handshake, resumption" \
3372 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3373 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3374 psk=abc123 debug_level=3" \
3375 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3376 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3377 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3378 0 \
3379 -s "a session has been resumed" \
3380 -c "a session has been resumed" \
3381 -s "Extra-header:" \
3382 -c "HTTP/1.0 200 OK"
3383
3384needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003385run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3386 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3387 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3388 psk=abc123 debug_level=3 nbio=2" \
3389 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3390 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3391 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3392 0 \
3393 -s "a session has been resumed" \
3394 -c "a session has been resumed" \
3395 -s "Extra-header:" \
3396 -c "HTTP/1.0 200 OK"
3397
3398needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003399run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003400 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003401 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3402 psk=abc123 renegotiation=1 debug_level=2" \
3403 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3404 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003405 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3406 0 \
3407 -c "=> renegotiate" \
3408 -s "=> renegotiate" \
3409 -s "Extra-header:" \
3410 -c "HTTP/1.0 200 OK"
3411
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003412needs_more_time 4
3413run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3414 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003415 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3416 psk=abc123 renegotiation=1 debug_level=2" \
3417 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3418 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003419 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3420 0 \
3421 -c "=> renegotiate" \
3422 -s "=> renegotiate" \
3423 -s "Extra-header:" \
3424 -c "HTTP/1.0 200 OK"
3425
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003426needs_more_time 4
3427run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003428 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003429 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003430 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003431 debug_level=2" \
3432 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003433 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003434 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3435 0 \
3436 -c "=> renegotiate" \
3437 -s "=> renegotiate" \
3438 -s "Extra-header:" \
3439 -c "HTTP/1.0 200 OK"
3440
3441needs_more_time 4
3442run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003443 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003444 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003445 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003446 debug_level=2 nbio=2" \
3447 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003448 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003449 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3450 0 \
3451 -c "=> renegotiate" \
3452 -s "=> renegotiate" \
3453 -s "Extra-header:" \
3454 -c "HTTP/1.0 200 OK"
3455
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003456needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003457not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003458run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003459 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3460 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003461 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003462 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003463 -c "HTTP/1.0 200 OK"
3464
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003465needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003466not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003467run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3468 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3469 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003470 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003471 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003472 -c "HTTP/1.0 200 OK"
3473
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003474needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003475not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003476run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3477 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3478 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003479 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003480 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003481 -c "HTTP/1.0 200 OK"
3482
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003483requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003484needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003485not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003486run_test "DTLS proxy: 3d, gnutls server" \
3487 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3488 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003489 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003490 0 \
3491 -s "Extra-header:" \
3492 -c "Extra-header:"
3493
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003494requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003495needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003496not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003497run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3498 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3499 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003500 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003501 0 \
3502 -s "Extra-header:" \
3503 -c "Extra-header:"
3504
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003505requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003506needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003507not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003508run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3509 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3510 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003511 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003512 0 \
3513 -s "Extra-header:" \
3514 -c "Extra-header:"
3515
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003516# Final report
3517
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003518echo "------------------------------------------------------------------------"
3519
3520if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003521 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003522else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003523 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003524fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003525PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003526echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003527
3528exit $FAILS