blob: ca0a1f1ffb4ba3412a93f2adbb34bd07916924d4 [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}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010020
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020021O_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 +010022O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020023G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010024G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010025
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010026TESTS=0
27FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020028SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010029
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000030CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020031
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010032MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010033FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020034EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010035
36print_usage() {
37 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010038 printf " -h|--help\tPrint this help.\n"
39 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
40 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
41 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010042}
43
44get_options() {
45 while [ $# -gt 0 ]; do
46 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010047 -f|--filter)
48 shift; FILTER=$1
49 ;;
50 -e|--exclude)
51 shift; EXCLUDE=$1
52 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010053 -m|--memcheck)
54 MEMCHECK=1
55 ;;
56 -h|--help)
57 print_usage
58 exit 0
59 ;;
60 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020061 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 print_usage
63 exit 1
64 ;;
65 esac
66 shift
67 done
68}
69
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010070# skip next test if the flag is not enabled in config.h
71requires_config_enabled() {
72 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
73 SKIP_NEXT="YES"
74 fi
75}
76
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020077# skip next test if OpenSSL doesn't support FALLBACK_SCSV
78requires_openssl_with_fallback_scsv() {
79 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
80 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
81 then
82 OPENSSL_HAS_FBSCSV="YES"
83 else
84 OPENSSL_HAS_FBSCSV="NO"
85 fi
86 fi
87 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
88 SKIP_NEXT="YES"
89 fi
90}
91
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020092# skip next test if GnuTLS isn't available
93requires_gnutls() {
94 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +020095 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020096 GNUTLS_AVAILABLE="YES"
97 else
98 GNUTLS_AVAILABLE="NO"
99 fi
100 fi
101 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
102 SKIP_NEXT="YES"
103 fi
104}
105
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200106# skip next test if IPv6 isn't available on this host
107requires_ipv6() {
108 if [ -z "${HAS_IPV6:-}" ]; then
109 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
110 SRV_PID=$!
111 sleep 1
112 kill $SRV_PID >/dev/null 2>&1
113 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
114 HAS_IPV6="NO"
115 else
116 HAS_IPV6="YES"
117 fi
118 rm -r $SRV_OUT
119 fi
120
121 if [ "$HAS_IPV6" = "NO" ]; then
122 SKIP_NEXT="YES"
123 fi
124}
125
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200126# skip the next test if valgrind is in use
127not_with_valgrind() {
128 if [ "$MEMCHECK" -gt 0 ]; then
129 SKIP_NEXT="YES"
130 fi
131}
132
Paul Bakker3b224ff2016-05-13 10:33:25 +0100133# skip the next test if valgrind is NOT in use
134only_with_valgrind() {
135 if [ "$MEMCHECK" -eq 0 ]; then
136 SKIP_NEXT="YES"
137 fi
138}
139
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200140# multiply the client timeout delay by the given factor for the next test
141needs_more_time() {
142 CLI_DELAY_FACTOR=$1
143}
144
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100145# print_name <name>
146print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100147 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200148 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100149 for i in `seq 1 $LEN`; do printf '.'; done
150 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100151
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200152 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100153}
154
155# fail <message>
156fail() {
157 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100158 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100159
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200160 mv $SRV_OUT o-srv-${TESTS}.log
161 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200162 if [ -n "$PXY_CMD" ]; then
163 mv $PXY_OUT o-pxy-${TESTS}.log
164 fi
165 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100166
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200167 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
168 echo " ! server output:"
169 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200170 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200171 echo " ! client output:"
172 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200173 if [ -n "$PXY_CMD" ]; then
174 echo " ! ========================================================"
175 echo " ! proxy output:"
176 cat o-pxy-${TESTS}.log
177 fi
178 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200179 fi
180
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200181 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100182}
183
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100184# is_polar <cmd_line>
185is_polar() {
186 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
187}
188
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200189# openssl s_server doesn't have -www with DTLS
190check_osrv_dtls() {
191 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
192 NEEDS_INPUT=1
193 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
194 else
195 NEEDS_INPUT=0
196 fi
197}
198
199# provide input to commands that need it
200provide_input() {
201 if [ $NEEDS_INPUT -eq 0 ]; then
202 return
203 fi
204
205 while true; do
206 echo "HTTP/1.0 200 OK"
207 sleep 1
208 done
209}
210
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100211# has_mem_err <log_file_name>
212has_mem_err() {
213 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
214 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
215 then
216 return 1 # false: does not have errors
217 else
218 return 0 # true: has errors
219 fi
220}
221
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200222# wait for server to start: two versions depending on lsof availability
223wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200224 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200225 START_TIME=$( date +%s )
226 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200227
228 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200229 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200230 while [ $DONE -eq 0 ]; do
231 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
232 then
233 DONE=1
234 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
235 echo "SERVERSTART TIMEOUT"
236 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
237 DONE=1
238 fi
239 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200240 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200241 while [ $DONE -eq 0 ]; do
242 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
243 then
244 DONE=1
245 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
246 echo "SERVERSTART TIMEOUT"
247 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
248 DONE=1
249 fi
250 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200251 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200252 else
253 sleep "$START_DELAY"
254 fi
255}
256
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200257# wait for client to terminate and set CLI_EXIT
258# must be called right after starting the client
259wait_client_done() {
260 CLI_PID=$!
261
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200262 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
263 CLI_DELAY_FACTOR=1
264
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200265 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200266 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200267
268 wait $CLI_PID
269 CLI_EXIT=$?
270
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200271 kill $DOG_PID >/dev/null 2>&1
272 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200273
274 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
275}
276
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200277# check if the given command uses dtls and sets global variable DTLS
278detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200279 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200280 DTLS=1
281 else
282 DTLS=0
283 fi
284}
285
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200286# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100287# Options: -s pattern pattern that must be present in server output
288# -c pattern pattern that must be present in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100289# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100290# -S pattern pattern that must be absent in server output
291# -C pattern pattern that must be absent in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100292# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100293run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100294 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200295 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100296
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100297 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
298 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200299 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100300 return
301 fi
302
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100303 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100304
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200305 # should we skip?
306 if [ "X$SKIP_NEXT" = "XYES" ]; then
307 SKIP_NEXT="NO"
308 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200309 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200310 return
311 fi
312
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200313 # does this test use a proxy?
314 if [ "X$1" = "X-p" ]; then
315 PXY_CMD="$2"
316 shift 2
317 else
318 PXY_CMD=""
319 fi
320
321 # get commands and client output
322 SRV_CMD="$1"
323 CLI_CMD="$2"
324 CLI_EXPECT="$3"
325 shift 3
326
327 # fix client port
328 if [ -n "$PXY_CMD" ]; then
329 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
330 else
331 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
332 fi
333
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200334 # update DTLS variable
335 detect_dtls "$SRV_CMD"
336
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100337 # prepend valgrind to our commands if active
338 if [ "$MEMCHECK" -gt 0 ]; then
339 if is_polar "$SRV_CMD"; then
340 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
341 fi
342 if is_polar "$CLI_CMD"; then
343 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
344 fi
345 fi
346
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200347 TIMES_LEFT=2
348 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200349 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200350
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200351 # run the commands
352 if [ -n "$PXY_CMD" ]; then
353 echo "$PXY_CMD" > $PXY_OUT
354 $PXY_CMD >> $PXY_OUT 2>&1 &
355 PXY_PID=$!
356 # assume proxy starts faster than server
357 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200358
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200359 check_osrv_dtls
360 echo "$SRV_CMD" > $SRV_OUT
361 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
362 SRV_PID=$!
363 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200364
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200365 echo "$CLI_CMD" > $CLI_OUT
366 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
367 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100368
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200369 # terminate the server (and the proxy)
370 kill $SRV_PID
371 wait $SRV_PID
372 if [ -n "$PXY_CMD" ]; then
373 kill $PXY_PID >/dev/null 2>&1
374 wait $PXY_PID
375 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100376
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200377 # retry only on timeouts
378 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
379 printf "RETRY "
380 else
381 TIMES_LEFT=0
382 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200383 done
384
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100385 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200386 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100387 # expected client exit to incorrectly succeed in case of catastrophic
388 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100389 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200390 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100391 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100392 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100393 return
394 fi
395 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100396 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200397 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100398 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100399 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100400 return
401 fi
402 fi
403
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100404 # check server exit code
405 if [ $? != 0 ]; then
406 fail "server fail"
407 return
408 fi
409
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100410 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100411 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
412 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100413 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200414 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100415 return
416 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100417
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100418 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200419 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100420 while [ $# -gt 0 ]
421 do
422 case $1 in
423 "-s")
Janos Follath6d3e3382016-09-07 15:48:48 +0100424 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
425 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426 return
427 fi
428 ;;
429
430 "-c")
Janos Follath6d3e3382016-09-07 15:48:48 +0100431 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
432 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100433 return
434 fi
435 ;;
436
437 "-S")
Janos Follath6d3e3382016-09-07 15:48:48 +0100438 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
439 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100440 return
441 fi
442 ;;
443
444 "-C")
Janos Follath6d3e3382016-09-07 15:48:48 +0100445 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
446 fail "pattern '$2' MUST NOT be present in the Client output"
447 return
448 fi
449 ;;
450
451 # The filtering in the following two options (-u and -U) do the following
452 # - ignore valgrind output
453 # - filter out everything but lines right after the pattern occurances
454 # - keep one of each non-unique line
455 # - count how many lines remain
456 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
457 # if there were no duplicates.
458 "-U")
459 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
460 fail "lines following pattern '$2' must be unique in Server output"
461 return
462 fi
463 ;;
464
465 "-u")
466 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
467 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100468 return
469 fi
470 ;;
471
472 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200473 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100474 exit 1
475 esac
476 shift 2
477 done
478
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100479 # check valgrind's results
480 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200481 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100482 fail "Server has memory errors"
483 return
484 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200485 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100486 fail "Client has memory errors"
487 return
488 fi
489 fi
490
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100491 # if we're here, everything is ok
492 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200493 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100494}
495
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100496cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200497 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200498 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
499 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
500 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
501 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100502 exit 1
503}
504
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100505#
506# MAIN
507#
508
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000509if cd $( dirname $0 ); then :; else
510 echo "cd $( dirname $0 ) failed" >&2
511 exit 1
512fi
513
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100514get_options "$@"
515
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100516# sanity checks, avoid an avalanche of errors
517if [ ! -x "$P_SRV" ]; then
518 echo "Command '$P_SRV' is not an executable file"
519 exit 1
520fi
521if [ ! -x "$P_CLI" ]; then
522 echo "Command '$P_CLI' is not an executable file"
523 exit 1
524fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200525if [ ! -x "$P_PXY" ]; then
526 echo "Command '$P_PXY' is not an executable file"
527 exit 1
528fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100529if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
530 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100531 exit 1
532fi
533
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200534# used by watchdog
535MAIN_PID="$$"
536
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200537# be more patient with valgrind
538if [ "$MEMCHECK" -gt 0 ]; then
539 START_DELAY=3
540 DOG_DELAY=30
541else
542 START_DELAY=1
543 DOG_DELAY=10
544fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200545CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200546
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200547# Pick a "unique" server port in the range 10000-19999, and a proxy port
548PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000549PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200550SRV_PORT="1$PORT_BASE"
551PXY_PORT="2$PORT_BASE"
552unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200553
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200554# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000555# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200556P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
557P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
558P_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 +0200559O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200560O_CLI="$O_CLI -connect localhost:+SRV_PORT"
561G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000562G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200563
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200564# Also pick a unique name for intermediate files
565SRV_OUT="srv_out.$$"
566CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200567PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200568SESSION="session.$$"
569
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200570SKIP_NEXT="NO"
571
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100572trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100573
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200574# Basic test
575
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200576# Checks that:
577# - things work with all ciphersuites active (used with config-full in all.sh)
578# - the expected (highest security) parameters are selected
579# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200580run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200581 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200582 "$P_CLI" \
583 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200584 -s "Protocol is TLSv1.2" \
585 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
586 -s "client hello v3, signature_algorithm ext: 6" \
587 -s "ECDHE curve: secp521r1" \
588 -S "error" \
589 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200590
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000591run_test "Default, DTLS" \
592 "$P_SRV dtls=1" \
593 "$P_CLI dtls=1" \
594 0 \
595 -s "Protocol is DTLSv1.2" \
596 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
597
Janos Follath6d3e3382016-09-07 15:48:48 +0100598# Test for uniqueness of IVs in AEAD ciphersuites
599run_test "Unique IV in GCM" \
600 "$P_SRV exchanges=20 debug_level=4" \
601 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
602 0 \
603 -u "IV used" \
604 -U "IV used"
605
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100606# Tests for rc4 option
607
Simon Butcher6eb066e2016-05-19 22:12:18 +0100608requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100609run_test "RC4: server disabled, client enabled" \
610 "$P_SRV" \
611 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
612 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100613 -s "SSL - The server has no ciphersuites in common"
614
Simon Butcher6eb066e2016-05-19 22:12:18 +0100615requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100616run_test "RC4: server half, client enabled" \
617 "$P_SRV arc4=1" \
618 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
619 1 \
620 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100621
622run_test "RC4: server enabled, client disabled" \
623 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
624 "$P_CLI" \
625 1 \
626 -s "SSL - The server has no ciphersuites in common"
627
628run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100629 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100630 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
631 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100632 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100633 -S "SSL - The server has no ciphersuites in common"
634
Gilles Peskineae765992017-05-09 15:59:24 +0200635# Tests for SHA-1 support
636
637run_test "SHA-1 forbidden by default in server certificate" \
638 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
639 "$P_CLI debug_level=2 allow_sha1=0" \
640 1 \
641 -c "The certificate is signed with an unacceptable hash"
642
643run_test "SHA-1 explicitly allowed in server certificate" \
644 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
645 "$P_CLI allow_sha1=1" \
646 0
647
648run_test "SHA-256 allowed by default in server certificate" \
649 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
650 "$P_CLI allow_sha1=0" \
651 0
652
653run_test "SHA-1 forbidden by default in client certificate" \
654 "$P_SRV auth_mode=required allow_sha1=0" \
655 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
656 1 \
657 -s "The certificate is signed with an unacceptable hash"
658
659run_test "SHA-1 explicitly allowed in client certificate" \
660 "$P_SRV auth_mode=required allow_sha1=1" \
661 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
662 0
663
664run_test "SHA-256 allowed by default in client certificate" \
665 "$P_SRV auth_mode=required allow_sha1=0" \
666 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
667 0
668
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100669# Tests for Truncated HMAC extension
670
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100671run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200672 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100673 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100674 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100675 -s "dumping 'computed mac' (20 bytes)" \
676 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100677
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100678run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200679 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100680 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
681 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100682 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100683 -s "dumping 'computed mac' (20 bytes)" \
684 -S "dumping 'computed mac' (10 bytes)"
685
686run_test "Truncated HMAC: client enabled, server default" \
687 "$P_SRV debug_level=4" \
688 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
689 trunc_hmac=1" \
690 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100691 -s "dumping 'computed mac' (20 bytes)" \
692 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100693
694run_test "Truncated HMAC: client enabled, server disabled" \
695 "$P_SRV debug_level=4 trunc_hmac=0" \
696 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
697 trunc_hmac=1" \
698 0 \
699 -s "dumping 'computed mac' (20 bytes)" \
700 -S "dumping 'computed mac' (10 bytes)"
701
702run_test "Truncated HMAC: client enabled, server enabled" \
703 "$P_SRV debug_level=4 trunc_hmac=1" \
704 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
705 trunc_hmac=1" \
706 0 \
707 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100708 -s "dumping 'computed mac' (10 bytes)"
709
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100710# Tests for Encrypt-then-MAC extension
711
712run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100713 "$P_SRV debug_level=3 \
714 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100715 "$P_CLI debug_level=3" \
716 0 \
717 -c "client hello, adding encrypt_then_mac extension" \
718 -s "found encrypt then mac extension" \
719 -s "server hello, adding encrypt then mac extension" \
720 -c "found encrypt_then_mac extension" \
721 -c "using encrypt then mac" \
722 -s "using encrypt then mac"
723
724run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100725 "$P_SRV debug_level=3 etm=0 \
726 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100727 "$P_CLI debug_level=3 etm=1" \
728 0 \
729 -c "client hello, adding encrypt_then_mac extension" \
730 -s "found encrypt then mac extension" \
731 -S "server hello, adding encrypt then mac extension" \
732 -C "found encrypt_then_mac extension" \
733 -C "using encrypt then mac" \
734 -S "using encrypt then mac"
735
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100736run_test "Encrypt then MAC: client enabled, aead cipher" \
737 "$P_SRV debug_level=3 etm=1 \
738 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
739 "$P_CLI debug_level=3 etm=1" \
740 0 \
741 -c "client hello, adding encrypt_then_mac extension" \
742 -s "found encrypt then mac extension" \
743 -S "server hello, adding encrypt then mac extension" \
744 -C "found encrypt_then_mac extension" \
745 -C "using encrypt then mac" \
746 -S "using encrypt then mac"
747
748run_test "Encrypt then MAC: client enabled, stream cipher" \
749 "$P_SRV debug_level=3 etm=1 \
750 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100751 "$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 +0100752 0 \
753 -c "client hello, adding encrypt_then_mac extension" \
754 -s "found encrypt then mac extension" \
755 -S "server hello, adding encrypt then mac extension" \
756 -C "found encrypt_then_mac extension" \
757 -C "using encrypt then mac" \
758 -S "using encrypt then mac"
759
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100760run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100761 "$P_SRV debug_level=3 etm=1 \
762 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100763 "$P_CLI debug_level=3 etm=0" \
764 0 \
765 -C "client hello, adding encrypt_then_mac extension" \
766 -S "found encrypt then mac extension" \
767 -S "server hello, adding encrypt then mac extension" \
768 -C "found encrypt_then_mac extension" \
769 -C "using encrypt then mac" \
770 -S "using encrypt then mac"
771
Janos Follath542ee5d2016-03-07 15:57:05 +0000772requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100773run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100774 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100775 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100776 "$P_CLI debug_level=3 force_version=ssl3" \
777 0 \
778 -C "client hello, adding encrypt_then_mac extension" \
779 -S "found encrypt then mac extension" \
780 -S "server hello, adding encrypt then mac extension" \
781 -C "found encrypt_then_mac extension" \
782 -C "using encrypt then mac" \
783 -S "using encrypt then mac"
784
Janos Follath542ee5d2016-03-07 15:57:05 +0000785requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100786run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100787 "$P_SRV debug_level=3 force_version=ssl3 \
788 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100789 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100790 0 \
791 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100792 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100793 -S "server hello, adding encrypt then mac extension" \
794 -C "found encrypt_then_mac extension" \
795 -C "using encrypt then mac" \
796 -S "using encrypt then mac"
797
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200798# Tests for Extended Master Secret extension
799
800run_test "Extended Master Secret: default" \
801 "$P_SRV debug_level=3" \
802 "$P_CLI debug_level=3" \
803 0 \
804 -c "client hello, adding extended_master_secret extension" \
805 -s "found extended master secret extension" \
806 -s "server hello, adding extended master secret extension" \
807 -c "found extended_master_secret extension" \
808 -c "using extended master secret" \
809 -s "using extended master secret"
810
811run_test "Extended Master Secret: client enabled, server disabled" \
812 "$P_SRV debug_level=3 extended_ms=0" \
813 "$P_CLI debug_level=3 extended_ms=1" \
814 0 \
815 -c "client hello, adding extended_master_secret extension" \
816 -s "found extended master secret extension" \
817 -S "server hello, adding extended master secret extension" \
818 -C "found extended_master_secret extension" \
819 -C "using extended master secret" \
820 -S "using extended master secret"
821
822run_test "Extended Master Secret: client disabled, server enabled" \
823 "$P_SRV debug_level=3 extended_ms=1" \
824 "$P_CLI debug_level=3 extended_ms=0" \
825 0 \
826 -C "client hello, adding extended_master_secret extension" \
827 -S "found extended master secret extension" \
828 -S "server hello, adding extended master secret extension" \
829 -C "found extended_master_secret extension" \
830 -C "using extended master secret" \
831 -S "using extended master secret"
832
Janos Follath542ee5d2016-03-07 15:57:05 +0000833requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200834run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100835 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200836 "$P_CLI debug_level=3 force_version=ssl3" \
837 0 \
838 -C "client hello, adding extended_master_secret extension" \
839 -S "found extended master secret extension" \
840 -S "server hello, adding extended master secret extension" \
841 -C "found extended_master_secret extension" \
842 -C "using extended master secret" \
843 -S "using extended master secret"
844
Janos Follath542ee5d2016-03-07 15:57:05 +0000845requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200846run_test "Extended Master Secret: client enabled, server SSLv3" \
847 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100848 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200849 0 \
850 -c "client hello, adding extended_master_secret extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100851 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200852 -S "server hello, adding extended master secret extension" \
853 -C "found extended_master_secret extension" \
854 -C "using extended master secret" \
855 -S "using extended master secret"
856
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200857# Tests for FALLBACK_SCSV
858
859run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200860 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200861 "$P_CLI debug_level=3 force_version=tls1_1" \
862 0 \
863 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200864 -S "received FALLBACK_SCSV" \
865 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200866 -C "is a fatal alert message (msg 86)"
867
868run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200869 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200870 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
871 0 \
872 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200873 -S "received FALLBACK_SCSV" \
874 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200875 -C "is a fatal alert message (msg 86)"
876
877run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200878 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200879 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200880 1 \
881 -c "adding FALLBACK_SCSV" \
882 -s "received FALLBACK_SCSV" \
883 -s "inapropriate fallback" \
884 -c "is a fatal alert message (msg 86)"
885
886run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200887 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200888 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200889 0 \
890 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200891 -s "received FALLBACK_SCSV" \
892 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200893 -C "is a fatal alert message (msg 86)"
894
895requires_openssl_with_fallback_scsv
896run_test "Fallback SCSV: default, openssl server" \
897 "$O_SRV" \
898 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
899 0 \
900 -C "adding FALLBACK_SCSV" \
901 -C "is a fatal alert message (msg 86)"
902
903requires_openssl_with_fallback_scsv
904run_test "Fallback SCSV: enabled, openssl server" \
905 "$O_SRV" \
906 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
907 1 \
908 -c "adding FALLBACK_SCSV" \
909 -c "is a fatal alert message (msg 86)"
910
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200911requires_openssl_with_fallback_scsv
912run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200913 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200914 "$O_CLI -tls1_1" \
915 0 \
916 -S "received FALLBACK_SCSV" \
917 -S "inapropriate fallback"
918
919requires_openssl_with_fallback_scsv
920run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200921 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200922 "$O_CLI -tls1_1 -fallback_scsv" \
923 1 \
924 -s "received FALLBACK_SCSV" \
925 -s "inapropriate fallback"
926
927requires_openssl_with_fallback_scsv
928run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200929 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200930 "$O_CLI -fallback_scsv" \
931 0 \
932 -s "received FALLBACK_SCSV" \
933 -S "inapropriate fallback"
934
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100935# Tests for CBC 1/n-1 record splitting
936
937run_test "CBC Record splitting: TLS 1.2, no splitting" \
938 "$P_SRV" \
939 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
940 request_size=123 force_version=tls1_2" \
941 0 \
942 -s "Read from client: 123 bytes read" \
943 -S "Read from client: 1 bytes read" \
944 -S "122 bytes read"
945
946run_test "CBC Record splitting: TLS 1.1, no splitting" \
947 "$P_SRV" \
948 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
949 request_size=123 force_version=tls1_1" \
950 0 \
951 -s "Read from client: 123 bytes read" \
952 -S "Read from client: 1 bytes read" \
953 -S "122 bytes read"
954
955run_test "CBC Record splitting: TLS 1.0, splitting" \
956 "$P_SRV" \
957 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
958 request_size=123 force_version=tls1" \
959 0 \
960 -S "Read from client: 123 bytes read" \
961 -s "Read from client: 1 bytes read" \
962 -s "122 bytes read"
963
Janos Follath542ee5d2016-03-07 15:57:05 +0000964requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100965run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100966 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100967 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
968 request_size=123 force_version=ssl3" \
969 0 \
970 -S "Read from client: 123 bytes read" \
971 -s "Read from client: 1 bytes read" \
972 -s "122 bytes read"
973
974run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100975 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100976 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
977 request_size=123 force_version=tls1" \
978 0 \
979 -s "Read from client: 123 bytes read" \
980 -S "Read from client: 1 bytes read" \
981 -S "122 bytes read"
982
983run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
984 "$P_SRV" \
985 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
986 request_size=123 force_version=tls1 recsplit=0" \
987 0 \
988 -s "Read from client: 123 bytes read" \
989 -S "Read from client: 1 bytes read" \
990 -S "122 bytes read"
991
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100992run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
993 "$P_SRV nbio=2" \
994 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
995 request_size=123 force_version=tls1" \
996 0 \
997 -S "Read from client: 123 bytes read" \
998 -s "Read from client: 1 bytes read" \
999 -s "122 bytes read"
1000
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001001# Tests for Session Tickets
1002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001003run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001004 "$P_SRV debug_level=3 tickets=1" \
1005 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001006 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001007 -c "client hello, adding session ticket extension" \
1008 -s "found session ticket extension" \
1009 -s "server hello, adding session ticket extension" \
1010 -c "found session_ticket extension" \
1011 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001012 -S "session successfully restored from cache" \
1013 -s "session successfully restored from ticket" \
1014 -s "a session has been resumed" \
1015 -c "a session has been resumed"
1016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001017run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001018 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1019 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001020 0 \
1021 -c "client hello, adding session ticket extension" \
1022 -s "found session ticket extension" \
1023 -s "server hello, adding session ticket extension" \
1024 -c "found session_ticket extension" \
1025 -c "parse new session ticket" \
1026 -S "session successfully restored from cache" \
1027 -s "session successfully restored from ticket" \
1028 -s "a session has been resumed" \
1029 -c "a session has been resumed"
1030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001031run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001032 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1033 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001034 0 \
1035 -c "client hello, adding session ticket extension" \
1036 -s "found session ticket extension" \
1037 -s "server hello, adding session ticket extension" \
1038 -c "found session_ticket extension" \
1039 -c "parse new session ticket" \
1040 -S "session successfully restored from cache" \
1041 -S "session successfully restored from ticket" \
1042 -S "a session has been resumed" \
1043 -C "a session has been resumed"
1044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001045run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001046 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001047 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001048 0 \
1049 -c "client hello, adding session ticket extension" \
1050 -c "found session_ticket extension" \
1051 -c "parse new session ticket" \
1052 -c "a session has been resumed"
1053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001054run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001055 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001056 "( $O_CLI -sess_out $SESSION; \
1057 $O_CLI -sess_in $SESSION; \
1058 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001059 0 \
1060 -s "found session ticket extension" \
1061 -s "server hello, adding session ticket extension" \
1062 -S "session successfully restored from cache" \
1063 -s "session successfully restored from ticket" \
1064 -s "a session has been resumed"
1065
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001066# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001068run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001069 "$P_SRV debug_level=3 tickets=0" \
1070 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001071 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001072 -c "client hello, adding session ticket extension" \
1073 -s "found session ticket extension" \
1074 -S "server hello, adding session ticket extension" \
1075 -C "found session_ticket extension" \
1076 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001077 -s "session successfully restored from cache" \
1078 -S "session successfully restored from ticket" \
1079 -s "a session has been resumed" \
1080 -c "a session has been resumed"
1081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001082run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001083 "$P_SRV debug_level=3 tickets=1" \
1084 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001085 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001086 -C "client hello, adding session ticket extension" \
1087 -S "found session ticket extension" \
1088 -S "server hello, adding session ticket extension" \
1089 -C "found session_ticket extension" \
1090 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001091 -s "session successfully restored from cache" \
1092 -S "session successfully restored from ticket" \
1093 -s "a session has been resumed" \
1094 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001095
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001096run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001097 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1098 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001099 0 \
1100 -S "session successfully restored from cache" \
1101 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001102 -S "a session has been resumed" \
1103 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001104
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001105run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001106 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1107 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001108 0 \
1109 -s "session successfully restored from cache" \
1110 -S "session successfully restored from ticket" \
1111 -s "a session has been resumed" \
1112 -c "a session has been resumed"
1113
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001114run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001115 "$P_SRV debug_level=3 tickets=0" \
1116 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001117 0 \
1118 -s "session successfully restored from cache" \
1119 -S "session successfully restored from ticket" \
1120 -s "a session has been resumed" \
1121 -c "a session has been resumed"
1122
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001123run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001124 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1125 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001126 0 \
1127 -S "session successfully restored from cache" \
1128 -S "session successfully restored from ticket" \
1129 -S "a session has been resumed" \
1130 -C "a session has been resumed"
1131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001132run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001133 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1134 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001135 0 \
1136 -s "session successfully restored from cache" \
1137 -S "session successfully restored from ticket" \
1138 -s "a session has been resumed" \
1139 -c "a session has been resumed"
1140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001141run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001142 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001143 "( $O_CLI -sess_out $SESSION; \
1144 $O_CLI -sess_in $SESSION; \
1145 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001146 0 \
1147 -s "found session ticket extension" \
1148 -S "server hello, adding session ticket extension" \
1149 -s "session successfully restored from cache" \
1150 -S "session successfully restored from ticket" \
1151 -s "a session has been resumed"
1152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001153run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001154 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001155 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001156 0 \
1157 -C "found session_ticket extension" \
1158 -C "parse new session ticket" \
1159 -c "a session has been resumed"
1160
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001161# Tests for Max Fragment Length extension
1162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001163run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001164 "$P_SRV debug_level=3" \
1165 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001166 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001167 -c "Maximum fragment length is 16384" \
1168 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001169 -C "client hello, adding max_fragment_length extension" \
1170 -S "found max fragment length extension" \
1171 -S "server hello, max_fragment_length extension" \
1172 -C "found max_fragment_length extension"
1173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001174run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001175 "$P_SRV debug_level=3" \
1176 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001177 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001178 -c "Maximum fragment length is 4096" \
1179 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001180 -c "client hello, adding max_fragment_length extension" \
1181 -s "found max fragment length extension" \
1182 -s "server hello, max_fragment_length extension" \
1183 -c "found max_fragment_length extension"
1184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001185run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001186 "$P_SRV debug_level=3 max_frag_len=4096" \
1187 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001188 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001189 -c "Maximum fragment length is 16384" \
1190 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001191 -C "client hello, adding max_fragment_length extension" \
1192 -S "found max fragment length extension" \
1193 -S "server hello, max_fragment_length extension" \
1194 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001196requires_gnutls
1197run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001198 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001199 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001200 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001201 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001202 -c "client hello, adding max_fragment_length extension" \
1203 -c "found max_fragment_length extension"
1204
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001205run_test "Max fragment length: client, message just fits" \
1206 "$P_SRV debug_level=3" \
1207 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1208 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001209 -c "Maximum fragment length is 2048" \
1210 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001211 -c "client hello, adding max_fragment_length extension" \
1212 -s "found max fragment length extension" \
1213 -s "server hello, max_fragment_length extension" \
1214 -c "found max_fragment_length extension" \
1215 -c "2048 bytes written in 1 fragments" \
1216 -s "2048 bytes read"
1217
1218run_test "Max fragment length: client, larger message" \
1219 "$P_SRV debug_level=3" \
1220 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1221 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001222 -c "Maximum fragment length is 2048" \
1223 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001224 -c "client hello, adding max_fragment_length extension" \
1225 -s "found max fragment length extension" \
1226 -s "server hello, max_fragment_length extension" \
1227 -c "found max_fragment_length extension" \
1228 -c "2345 bytes written in 2 fragments" \
1229 -s "2048 bytes read" \
1230 -s "297 bytes read"
1231
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001232run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001233 "$P_SRV debug_level=3 dtls=1" \
1234 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1235 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001236 -c "Maximum fragment length is 2048" \
1237 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001238 -c "client hello, adding max_fragment_length extension" \
1239 -s "found max fragment length extension" \
1240 -s "server hello, max_fragment_length extension" \
1241 -c "found max_fragment_length extension" \
1242 -c "fragment larger than.*maximum"
1243
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001244# Tests for renegotiation
1245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001246run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001247 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001248 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001249 0 \
1250 -C "client hello, adding renegotiation extension" \
1251 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1252 -S "found renegotiation extension" \
1253 -s "server hello, secure renegotiation extension" \
1254 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001255 -C "=> renegotiate" \
1256 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001257 -S "write hello request"
1258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001259run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001260 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001261 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001262 0 \
1263 -c "client hello, adding renegotiation extension" \
1264 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1265 -s "found renegotiation extension" \
1266 -s "server hello, secure renegotiation extension" \
1267 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001268 -c "=> renegotiate" \
1269 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001270 -S "write hello request"
1271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001272run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001273 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001274 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001275 0 \
1276 -c "client hello, adding renegotiation extension" \
1277 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1278 -s "found renegotiation extension" \
1279 -s "server hello, secure renegotiation extension" \
1280 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001281 -c "=> renegotiate" \
1282 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001283 -s "write hello request"
1284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001285run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001286 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001287 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001288 0 \
1289 -c "client hello, adding renegotiation extension" \
1290 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1291 -s "found renegotiation extension" \
1292 -s "server hello, secure renegotiation extension" \
1293 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001294 -c "=> renegotiate" \
1295 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001296 -s "write hello request"
1297
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001298run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001299 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001300 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001301 1 \
1302 -c "client hello, adding renegotiation extension" \
1303 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1304 -S "found renegotiation extension" \
1305 -s "server hello, secure renegotiation extension" \
1306 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001307 -c "=> renegotiate" \
1308 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001309 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001310 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001311 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001313run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001314 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001315 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001316 0 \
1317 -C "client hello, adding renegotiation extension" \
1318 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1319 -S "found renegotiation extension" \
1320 -s "server hello, secure renegotiation extension" \
1321 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001322 -C "=> renegotiate" \
1323 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001324 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001325 -S "SSL - An unexpected message was received from our peer" \
1326 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001328run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001329 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001330 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001331 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001332 0 \
1333 -C "client hello, adding renegotiation extension" \
1334 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1335 -S "found renegotiation extension" \
1336 -s "server hello, secure renegotiation extension" \
1337 -c "found renegotiation extension" \
1338 -C "=> renegotiate" \
1339 -S "=> renegotiate" \
1340 -s "write hello request" \
1341 -S "SSL - An unexpected message was received from our peer" \
1342 -S "failed"
1343
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001344# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001345run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001346 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001347 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001348 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001349 0 \
1350 -C "client hello, adding renegotiation extension" \
1351 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1352 -S "found renegotiation extension" \
1353 -s "server hello, secure renegotiation extension" \
1354 -c "found renegotiation extension" \
1355 -C "=> renegotiate" \
1356 -S "=> renegotiate" \
1357 -s "write hello request" \
1358 -S "SSL - An unexpected message was received from our peer" \
1359 -S "failed"
1360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001361run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001362 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001363 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001365 0 \
1366 -C "client hello, adding renegotiation extension" \
1367 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1368 -S "found renegotiation extension" \
1369 -s "server hello, secure renegotiation extension" \
1370 -c "found renegotiation extension" \
1371 -C "=> renegotiate" \
1372 -S "=> renegotiate" \
1373 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001374 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001375
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001376run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001377 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001378 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001379 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001380 0 \
1381 -c "client hello, adding renegotiation extension" \
1382 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1383 -s "found renegotiation extension" \
1384 -s "server hello, secure renegotiation extension" \
1385 -c "found renegotiation extension" \
1386 -c "=> renegotiate" \
1387 -s "=> renegotiate" \
1388 -s "write hello request" \
1389 -S "SSL - An unexpected message was received from our peer" \
1390 -S "failed"
1391
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001392run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001393 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001394 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1395 0 \
1396 -C "client hello, adding renegotiation extension" \
1397 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1398 -S "found renegotiation extension" \
1399 -s "server hello, secure renegotiation extension" \
1400 -c "found renegotiation extension" \
1401 -S "record counter limit reached: renegotiate" \
1402 -C "=> renegotiate" \
1403 -S "=> renegotiate" \
1404 -S "write hello request" \
1405 -S "SSL - An unexpected message was received from our peer" \
1406 -S "failed"
1407
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001408# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001409run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001410 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001411 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001412 0 \
1413 -c "client hello, adding renegotiation extension" \
1414 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1415 -s "found renegotiation extension" \
1416 -s "server hello, secure renegotiation extension" \
1417 -c "found renegotiation extension" \
1418 -s "record counter limit reached: renegotiate" \
1419 -c "=> renegotiate" \
1420 -s "=> renegotiate" \
1421 -s "write hello request" \
1422 -S "SSL - An unexpected message was received from our peer" \
1423 -S "failed"
1424
1425run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001426 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001427 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001428 0 \
1429 -c "client hello, adding renegotiation extension" \
1430 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1431 -s "found renegotiation extension" \
1432 -s "server hello, secure renegotiation extension" \
1433 -c "found renegotiation extension" \
1434 -s "record counter limit reached: renegotiate" \
1435 -c "=> renegotiate" \
1436 -s "=> renegotiate" \
1437 -s "write hello request" \
1438 -S "SSL - An unexpected message was received from our peer" \
1439 -S "failed"
1440
1441run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001442 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001443 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1444 0 \
1445 -C "client hello, adding renegotiation extension" \
1446 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1447 -S "found renegotiation extension" \
1448 -s "server hello, secure renegotiation extension" \
1449 -c "found renegotiation extension" \
1450 -S "record counter limit reached: renegotiate" \
1451 -C "=> renegotiate" \
1452 -S "=> renegotiate" \
1453 -S "write hello request" \
1454 -S "SSL - An unexpected message was received from our peer" \
1455 -S "failed"
1456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001457run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001458 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001459 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001460 0 \
1461 -c "client hello, adding renegotiation extension" \
1462 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1463 -s "found renegotiation extension" \
1464 -s "server hello, secure renegotiation extension" \
1465 -c "found renegotiation extension" \
1466 -c "=> renegotiate" \
1467 -s "=> renegotiate" \
1468 -S "write hello request"
1469
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001470run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001471 "$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 +02001472 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001473 0 \
1474 -c "client hello, adding renegotiation extension" \
1475 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1476 -s "found renegotiation extension" \
1477 -s "server hello, secure renegotiation extension" \
1478 -c "found renegotiation extension" \
1479 -c "=> renegotiate" \
1480 -s "=> renegotiate" \
1481 -s "write hello request"
1482
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001483run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001484 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001485 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001486 0 \
1487 -c "client hello, adding renegotiation extension" \
1488 -c "found renegotiation extension" \
1489 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001490 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001491 -C "error" \
1492 -c "HTTP/1.0 200 [Oo][Kk]"
1493
Paul Bakker539d9722015-02-08 16:18:35 +01001494requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001495run_test "Renegotiation: gnutls server strict, client-initiated" \
1496 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001497 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001498 0 \
1499 -c "client hello, adding renegotiation extension" \
1500 -c "found renegotiation extension" \
1501 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001502 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001503 -C "error" \
1504 -c "HTTP/1.0 200 [Oo][Kk]"
1505
Paul Bakker539d9722015-02-08 16:18:35 +01001506requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001507run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1508 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1509 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1510 1 \
1511 -c "client hello, adding renegotiation extension" \
1512 -C "found renegotiation extension" \
1513 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001514 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001515 -c "error" \
1516 -C "HTTP/1.0 200 [Oo][Kk]"
1517
Paul Bakker539d9722015-02-08 16:18:35 +01001518requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001519run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1520 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1521 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1522 allow_legacy=0" \
1523 1 \
1524 -c "client hello, adding renegotiation extension" \
1525 -C "found renegotiation extension" \
1526 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001527 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001528 -c "error" \
1529 -C "HTTP/1.0 200 [Oo][Kk]"
1530
Paul Bakker539d9722015-02-08 16:18:35 +01001531requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001532run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1533 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1534 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1535 allow_legacy=1" \
1536 0 \
1537 -c "client hello, adding renegotiation extension" \
1538 -C "found renegotiation extension" \
1539 -c "=> renegotiate" \
1540 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001541 -C "error" \
1542 -c "HTTP/1.0 200 [Oo][Kk]"
1543
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001544run_test "Renegotiation: DTLS, client-initiated" \
1545 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1546 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1547 0 \
1548 -c "client hello, adding renegotiation extension" \
1549 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1550 -s "found renegotiation extension" \
1551 -s "server hello, secure renegotiation extension" \
1552 -c "found renegotiation extension" \
1553 -c "=> renegotiate" \
1554 -s "=> renegotiate" \
1555 -S "write hello request"
1556
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001557run_test "Renegotiation: DTLS, server-initiated" \
1558 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001559 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1560 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001561 0 \
1562 -c "client hello, adding renegotiation extension" \
1563 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1564 -s "found renegotiation extension" \
1565 -s "server hello, secure renegotiation extension" \
1566 -c "found renegotiation extension" \
1567 -c "=> renegotiate" \
1568 -s "=> renegotiate" \
1569 -s "write hello request"
1570
Andres AG9b1927b2017-01-19 16:30:57 +00001571run_test "Renegotiation: DTLS, renego_period overflow" \
1572 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1573 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1574 0 \
1575 -c "client hello, adding renegotiation extension" \
1576 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1577 -s "found renegotiation extension" \
1578 -s "server hello, secure renegotiation extension" \
1579 -s "record counter limit reached: renegotiate" \
1580 -c "=> renegotiate" \
1581 -s "=> renegotiate" \
1582 -s "write hello request" \
1583
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001584requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001585run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1586 "$G_SRV -u --mtu 4096" \
1587 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1588 0 \
1589 -c "client hello, adding renegotiation extension" \
1590 -c "found renegotiation extension" \
1591 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001592 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001593 -C "error" \
1594 -s "Extra-header:"
1595
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001596# Test for the "secure renegotation" extension only (no actual renegotiation)
1597
Paul Bakker539d9722015-02-08 16:18:35 +01001598requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001599run_test "Renego ext: gnutls server strict, client default" \
1600 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1601 "$P_CLI debug_level=3" \
1602 0 \
1603 -c "found renegotiation extension" \
1604 -C "error" \
1605 -c "HTTP/1.0 200 [Oo][Kk]"
1606
Paul Bakker539d9722015-02-08 16:18:35 +01001607requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001608run_test "Renego ext: gnutls server unsafe, client default" \
1609 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1610 "$P_CLI debug_level=3" \
1611 0 \
1612 -C "found renegotiation extension" \
1613 -C "error" \
1614 -c "HTTP/1.0 200 [Oo][Kk]"
1615
Paul Bakker539d9722015-02-08 16:18:35 +01001616requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001617run_test "Renego ext: gnutls server unsafe, client break legacy" \
1618 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1619 "$P_CLI debug_level=3 allow_legacy=-1" \
1620 1 \
1621 -C "found renegotiation extension" \
1622 -c "error" \
1623 -C "HTTP/1.0 200 [Oo][Kk]"
1624
Paul Bakker539d9722015-02-08 16:18:35 +01001625requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001626run_test "Renego ext: gnutls client strict, server default" \
1627 "$P_SRV debug_level=3" \
1628 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1629 0 \
1630 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1631 -s "server hello, secure renegotiation extension"
1632
Paul Bakker539d9722015-02-08 16:18:35 +01001633requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001634run_test "Renego ext: gnutls client unsafe, server default" \
1635 "$P_SRV debug_level=3" \
1636 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1637 0 \
1638 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1639 -S "server hello, secure renegotiation extension"
1640
Paul Bakker539d9722015-02-08 16:18:35 +01001641requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001642run_test "Renego ext: gnutls client unsafe, server break legacy" \
1643 "$P_SRV debug_level=3 allow_legacy=-1" \
1644 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1645 1 \
1646 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1647 -S "server hello, secure renegotiation extension"
1648
Janos Follath365b2262016-02-17 10:11:21 +00001649# Tests for silently dropping trailing extra bytes in .der certificates
1650
1651requires_gnutls
1652run_test "DER format: no trailing bytes" \
1653 "$P_SRV crt_file=data_files/server5-der0.crt \
1654 key_file=data_files/server5.key" \
1655 "$G_CLI " \
1656 0 \
1657 -c "Handshake was completed" \
1658
1659requires_gnutls
1660run_test "DER format: with a trailing zero byte" \
1661 "$P_SRV crt_file=data_files/server5-der1a.crt \
1662 key_file=data_files/server5.key" \
1663 "$G_CLI " \
1664 0 \
1665 -c "Handshake was completed" \
1666
1667requires_gnutls
1668run_test "DER format: with a trailing random byte" \
1669 "$P_SRV crt_file=data_files/server5-der1b.crt \
1670 key_file=data_files/server5.key" \
1671 "$G_CLI " \
1672 0 \
1673 -c "Handshake was completed" \
1674
1675requires_gnutls
1676run_test "DER format: with 2 trailing random bytes" \
1677 "$P_SRV crt_file=data_files/server5-der2.crt \
1678 key_file=data_files/server5.key" \
1679 "$G_CLI " \
1680 0 \
1681 -c "Handshake was completed" \
1682
1683requires_gnutls
1684run_test "DER format: with 4 trailing random bytes" \
1685 "$P_SRV crt_file=data_files/server5-der4.crt \
1686 key_file=data_files/server5.key" \
1687 "$G_CLI " \
1688 0 \
1689 -c "Handshake was completed" \
1690
1691requires_gnutls
1692run_test "DER format: with 8 trailing random bytes" \
1693 "$P_SRV crt_file=data_files/server5-der8.crt \
1694 key_file=data_files/server5.key" \
1695 "$G_CLI " \
1696 0 \
1697 -c "Handshake was completed" \
1698
1699requires_gnutls
1700run_test "DER format: with 9 trailing random bytes" \
1701 "$P_SRV crt_file=data_files/server5-der9.crt \
1702 key_file=data_files/server5.key" \
1703 "$G_CLI " \
1704 0 \
1705 -c "Handshake was completed" \
1706
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001707# Tests for auth_mode
1708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001709run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001710 "$P_SRV crt_file=data_files/server5-badsign.crt \
1711 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001712 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001713 1 \
1714 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001715 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001716 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001717 -c "X509 - Certificate verification failed"
1718
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001719run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001720 "$P_SRV crt_file=data_files/server5-badsign.crt \
1721 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001722 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001723 0 \
1724 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001725 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001726 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001727 -C "X509 - Certificate verification failed"
1728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001729run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001730 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001731 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001732 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001733 0 \
1734 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001735 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001736 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001737 -C "X509 - Certificate verification failed"
1738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001739run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001740 "$P_SRV debug_level=3 auth_mode=required" \
1741 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001742 key_file=data_files/server5.key" \
1743 1 \
1744 -S "skip write certificate request" \
1745 -C "skip parse certificate request" \
1746 -c "got a certificate request" \
1747 -C "skip write certificate" \
1748 -C "skip write certificate verify" \
1749 -S "skip parse certificate verify" \
1750 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001751 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001752 -s "! mbedtls_ssl_handshake returned" \
1753 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001754 -s "X509 - Certificate verification failed"
1755
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001756run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001757 "$P_SRV debug_level=3 auth_mode=optional" \
1758 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001759 key_file=data_files/server5.key" \
1760 0 \
1761 -S "skip write certificate request" \
1762 -C "skip parse certificate request" \
1763 -c "got a certificate request" \
1764 -C "skip write certificate" \
1765 -C "skip write certificate verify" \
1766 -S "skip parse certificate verify" \
1767 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001768 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001769 -S "! mbedtls_ssl_handshake returned" \
1770 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001771 -S "X509 - Certificate verification failed"
1772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001773run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001774 "$P_SRV debug_level=3 auth_mode=none" \
1775 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001776 key_file=data_files/server5.key" \
1777 0 \
1778 -s "skip write certificate request" \
1779 -C "skip parse certificate request" \
1780 -c "got no certificate request" \
1781 -c "skip write certificate" \
1782 -c "skip write certificate verify" \
1783 -s "skip parse certificate verify" \
1784 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001785 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001786 -S "! mbedtls_ssl_handshake returned" \
1787 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001788 -S "X509 - Certificate verification failed"
1789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001790run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001791 "$P_SRV debug_level=3 auth_mode=optional" \
1792 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001793 0 \
1794 -S "skip write certificate request" \
1795 -C "skip parse certificate request" \
1796 -c "got a certificate request" \
1797 -C "skip write certificate$" \
1798 -C "got no certificate to send" \
1799 -S "SSLv3 client has no certificate" \
1800 -c "skip write certificate verify" \
1801 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001802 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001803 -S "! mbedtls_ssl_handshake returned" \
1804 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001805 -S "X509 - Certificate verification failed"
1806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001807run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001808 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001809 "$O_CLI" \
1810 0 \
1811 -S "skip write certificate request" \
1812 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001813 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001814 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001815 -S "X509 - Certificate verification failed"
1816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001817run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001818 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001819 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001820 0 \
1821 -C "skip parse certificate request" \
1822 -c "got a certificate request" \
1823 -C "skip write certificate$" \
1824 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001825 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001826
Janos Follath542ee5d2016-03-07 15:57:05 +00001827requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001828run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001829 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001830 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001831 0 \
1832 -S "skip write certificate request" \
1833 -C "skip parse certificate request" \
1834 -c "got a certificate request" \
1835 -C "skip write certificate$" \
1836 -c "skip write certificate verify" \
1837 -c "got no certificate to send" \
1838 -s "SSLv3 client has no certificate" \
1839 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001840 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001841 -S "! mbedtls_ssl_handshake returned" \
1842 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001843 -S "X509 - Certificate verification failed"
1844
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001845# Tests for certificate selection based on SHA verson
1846
1847run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1848 "$P_SRV crt_file=data_files/server5.crt \
1849 key_file=data_files/server5.key \
1850 crt_file2=data_files/server5-sha1.crt \
1851 key_file2=data_files/server5.key" \
1852 "$P_CLI force_version=tls1_2" \
1853 0 \
1854 -c "signed using.*ECDSA with SHA256" \
1855 -C "signed using.*ECDSA with SHA1"
1856
1857run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1858 "$P_SRV crt_file=data_files/server5.crt \
1859 key_file=data_files/server5.key \
1860 crt_file2=data_files/server5-sha1.crt \
1861 key_file2=data_files/server5.key" \
1862 "$P_CLI force_version=tls1_1" \
1863 0 \
1864 -C "signed using.*ECDSA with SHA256" \
1865 -c "signed using.*ECDSA with SHA1"
1866
1867run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1868 "$P_SRV crt_file=data_files/server5.crt \
1869 key_file=data_files/server5.key \
1870 crt_file2=data_files/server5-sha1.crt \
1871 key_file2=data_files/server5.key" \
1872 "$P_CLI force_version=tls1" \
1873 0 \
1874 -C "signed using.*ECDSA with SHA256" \
1875 -c "signed using.*ECDSA with SHA1"
1876
1877run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1878 "$P_SRV crt_file=data_files/server5.crt \
1879 key_file=data_files/server5.key \
1880 crt_file2=data_files/server6.crt \
1881 key_file2=data_files/server6.key" \
1882 "$P_CLI force_version=tls1_1" \
1883 0 \
1884 -c "serial number.*09" \
1885 -c "signed using.*ECDSA with SHA256" \
1886 -C "signed using.*ECDSA with SHA1"
1887
1888run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1889 "$P_SRV crt_file=data_files/server6.crt \
1890 key_file=data_files/server6.key \
1891 crt_file2=data_files/server5.crt \
1892 key_file2=data_files/server5.key" \
1893 "$P_CLI force_version=tls1_1" \
1894 0 \
1895 -c "serial number.*0A" \
1896 -c "signed using.*ECDSA with SHA256" \
1897 -C "signed using.*ECDSA with SHA1"
1898
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001899# tests for SNI
1900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001901run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001902 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001903 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001904 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001905 0 \
1906 -S "parse ServerName extension" \
1907 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1908 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001909
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001910run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001911 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001912 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001913 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 +02001914 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001915 0 \
1916 -s "parse ServerName extension" \
1917 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1918 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001919
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001920run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001921 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001922 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001923 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 +02001924 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001925 0 \
1926 -s "parse ServerName extension" \
1927 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1928 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001930run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001931 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001932 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001933 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 +02001934 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001935 1 \
1936 -s "parse ServerName extension" \
1937 -s "ssl_sni_wrapper() returned" \
1938 -s "mbedtls_ssl_handshake returned" \
1939 -c "mbedtls_ssl_handshake returned" \
1940 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001941
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001942run_test "SNI: client auth no override: optional" \
1943 "$P_SRV debug_level=3 auth_mode=optional \
1944 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1945 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1946 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001947 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001948 -S "skip write certificate request" \
1949 -C "skip parse certificate request" \
1950 -c "got a certificate request" \
1951 -C "skip write certificate" \
1952 -C "skip write certificate verify" \
1953 -S "skip parse certificate verify"
1954
1955run_test "SNI: client auth override: none -> optional" \
1956 "$P_SRV debug_level=3 auth_mode=none \
1957 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1958 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1959 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001960 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001961 -S "skip write certificate request" \
1962 -C "skip parse certificate request" \
1963 -c "got a certificate request" \
1964 -C "skip write certificate" \
1965 -C "skip write certificate verify" \
1966 -S "skip parse certificate verify"
1967
1968run_test "SNI: client auth override: optional -> none" \
1969 "$P_SRV debug_level=3 auth_mode=optional \
1970 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1971 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1972 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001973 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001974 -s "skip write certificate request" \
1975 -C "skip parse certificate request" \
1976 -c "got no certificate request" \
1977 -c "skip write certificate" \
1978 -c "skip write certificate verify" \
1979 -s "skip parse certificate verify"
1980
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001981run_test "SNI: CA no override" \
1982 "$P_SRV debug_level=3 auth_mode=optional \
1983 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1984 ca_file=data_files/test-ca.crt \
1985 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1986 "$P_CLI debug_level=3 server_name=localhost \
1987 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1988 1 \
1989 -S "skip write certificate request" \
1990 -C "skip parse certificate request" \
1991 -c "got a certificate request" \
1992 -C "skip write certificate" \
1993 -C "skip write certificate verify" \
1994 -S "skip parse certificate verify" \
1995 -s "x509_verify_cert() returned" \
1996 -s "! The certificate is not correctly signed by the trusted CA" \
1997 -S "The certificate has been revoked (is on a CRL)"
1998
1999run_test "SNI: CA override" \
2000 "$P_SRV debug_level=3 auth_mode=optional \
2001 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2002 ca_file=data_files/test-ca.crt \
2003 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2004 "$P_CLI debug_level=3 server_name=localhost \
2005 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2006 0 \
2007 -S "skip write certificate request" \
2008 -C "skip parse certificate request" \
2009 -c "got a certificate request" \
2010 -C "skip write certificate" \
2011 -C "skip write certificate verify" \
2012 -S "skip parse certificate verify" \
2013 -S "x509_verify_cert() returned" \
2014 -S "! The certificate is not correctly signed by the trusted CA" \
2015 -S "The certificate has been revoked (is on a CRL)"
2016
2017run_test "SNI: CA override with CRL" \
2018 "$P_SRV debug_level=3 auth_mode=optional \
2019 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2020 ca_file=data_files/test-ca.crt \
2021 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2022 "$P_CLI debug_level=3 server_name=localhost \
2023 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2024 1 \
2025 -S "skip write certificate request" \
2026 -C "skip parse certificate request" \
2027 -c "got a certificate request" \
2028 -C "skip write certificate" \
2029 -C "skip write certificate verify" \
2030 -S "skip parse certificate verify" \
2031 -s "x509_verify_cert() returned" \
2032 -S "! The certificate is not correctly signed by the trusted CA" \
2033 -s "The certificate has been revoked (is on a CRL)"
2034
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002035# Tests for non-blocking I/O: exercise a variety of handshake flows
2036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002037run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002038 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2039 "$P_CLI nbio=2 tickets=0" \
2040 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002041 -S "mbedtls_ssl_handshake returned" \
2042 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002043 -c "Read from server: .* bytes read"
2044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002045run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002046 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2047 "$P_CLI nbio=2 tickets=0" \
2048 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002049 -S "mbedtls_ssl_handshake returned" \
2050 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002051 -c "Read from server: .* bytes read"
2052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002053run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002054 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2055 "$P_CLI nbio=2 tickets=1" \
2056 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002057 -S "mbedtls_ssl_handshake returned" \
2058 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002059 -c "Read from server: .* bytes read"
2060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002061run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002062 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2063 "$P_CLI nbio=2 tickets=1" \
2064 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002065 -S "mbedtls_ssl_handshake returned" \
2066 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002067 -c "Read from server: .* bytes read"
2068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002069run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002070 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2071 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2072 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002073 -S "mbedtls_ssl_handshake returned" \
2074 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002075 -c "Read from server: .* bytes read"
2076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002077run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002078 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2079 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2080 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002081 -S "mbedtls_ssl_handshake returned" \
2082 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002083 -c "Read from server: .* bytes read"
2084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002085run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002086 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2087 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2088 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002089 -S "mbedtls_ssl_handshake returned" \
2090 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002091 -c "Read from server: .* bytes read"
2092
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002093# Tests for version negotiation
2094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002095run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002096 "$P_SRV" \
2097 "$P_CLI" \
2098 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002099 -S "mbedtls_ssl_handshake returned" \
2100 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002101 -s "Protocol is TLSv1.2" \
2102 -c "Protocol is TLSv1.2"
2103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002104run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002105 "$P_SRV" \
2106 "$P_CLI max_version=tls1_1" \
2107 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002108 -S "mbedtls_ssl_handshake returned" \
2109 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002110 -s "Protocol is TLSv1.1" \
2111 -c "Protocol is TLSv1.1"
2112
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002113run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002114 "$P_SRV max_version=tls1_1" \
2115 "$P_CLI" \
2116 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002117 -S "mbedtls_ssl_handshake returned" \
2118 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002119 -s "Protocol is TLSv1.1" \
2120 -c "Protocol is TLSv1.1"
2121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002122run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002123 "$P_SRV max_version=tls1_1" \
2124 "$P_CLI max_version=tls1_1" \
2125 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002126 -S "mbedtls_ssl_handshake returned" \
2127 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002128 -s "Protocol is TLSv1.1" \
2129 -c "Protocol is TLSv1.1"
2130
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002131run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002132 "$P_SRV min_version=tls1_1" \
2133 "$P_CLI max_version=tls1_1" \
2134 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002135 -S "mbedtls_ssl_handshake returned" \
2136 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002137 -s "Protocol is TLSv1.1" \
2138 -c "Protocol is TLSv1.1"
2139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002140run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002141 "$P_SRV max_version=tls1_1" \
2142 "$P_CLI min_version=tls1_1" \
2143 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002144 -S "mbedtls_ssl_handshake returned" \
2145 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002146 -s "Protocol is TLSv1.1" \
2147 -c "Protocol is TLSv1.1"
2148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002149run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002150 "$P_SRV max_version=tls1_1" \
2151 "$P_CLI min_version=tls1_2" \
2152 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002153 -s "mbedtls_ssl_handshake returned" \
2154 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002155 -c "SSL - Handshake protocol not within min/max boundaries"
2156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002157run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002158 "$P_SRV min_version=tls1_2" \
2159 "$P_CLI max_version=tls1_1" \
2160 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002161 -s "mbedtls_ssl_handshake returned" \
2162 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002163 -s "SSL - Handshake protocol not within min/max boundaries"
2164
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002165# Tests for ALPN extension
2166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002167run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002168 "$P_SRV debug_level=3" \
2169 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002170 0 \
2171 -C "client hello, adding alpn extension" \
2172 -S "found alpn extension" \
2173 -C "got an alert message, type: \\[2:120]" \
2174 -S "server hello, adding alpn extension" \
2175 -C "found alpn extension " \
2176 -C "Application Layer Protocol is" \
2177 -S "Application Layer Protocol is"
2178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002179run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002180 "$P_SRV debug_level=3" \
2181 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002182 0 \
2183 -c "client hello, adding alpn extension" \
2184 -s "found alpn extension" \
2185 -C "got an alert message, type: \\[2:120]" \
2186 -S "server hello, adding alpn extension" \
2187 -C "found alpn extension " \
2188 -c "Application Layer Protocol is (none)" \
2189 -S "Application Layer Protocol is"
2190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002191run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002192 "$P_SRV debug_level=3 alpn=abc,1234" \
2193 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002194 0 \
2195 -C "client hello, adding alpn extension" \
2196 -S "found alpn extension" \
2197 -C "got an alert message, type: \\[2:120]" \
2198 -S "server hello, adding alpn extension" \
2199 -C "found alpn extension " \
2200 -C "Application Layer Protocol is" \
2201 -s "Application Layer Protocol is (none)"
2202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002203run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002204 "$P_SRV debug_level=3 alpn=abc,1234" \
2205 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002206 0 \
2207 -c "client hello, adding alpn extension" \
2208 -s "found alpn extension" \
2209 -C "got an alert message, type: \\[2:120]" \
2210 -s "server hello, adding alpn extension" \
2211 -c "found alpn extension" \
2212 -c "Application Layer Protocol is abc" \
2213 -s "Application Layer Protocol is abc"
2214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002215run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002216 "$P_SRV debug_level=3 alpn=abc,1234" \
2217 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002218 0 \
2219 -c "client hello, adding alpn extension" \
2220 -s "found alpn extension" \
2221 -C "got an alert message, type: \\[2:120]" \
2222 -s "server hello, adding alpn extension" \
2223 -c "found alpn extension" \
2224 -c "Application Layer Protocol is abc" \
2225 -s "Application Layer Protocol is abc"
2226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002227run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002228 "$P_SRV debug_level=3 alpn=abc,1234" \
2229 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002230 0 \
2231 -c "client hello, adding alpn extension" \
2232 -s "found alpn extension" \
2233 -C "got an alert message, type: \\[2:120]" \
2234 -s "server hello, adding alpn extension" \
2235 -c "found alpn extension" \
2236 -c "Application Layer Protocol is 1234" \
2237 -s "Application Layer Protocol is 1234"
2238
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002239run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002240 "$P_SRV debug_level=3 alpn=abc,123" \
2241 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002242 1 \
2243 -c "client hello, adding alpn extension" \
2244 -s "found alpn extension" \
2245 -c "got an alert message, type: \\[2:120]" \
2246 -S "server hello, adding alpn extension" \
2247 -C "found alpn extension" \
2248 -C "Application Layer Protocol is 1234" \
2249 -S "Application Layer Protocol is 1234"
2250
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002251
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002252# Tests for keyUsage in leaf certificates, part 1:
2253# server-side certificate/suite selection
2254
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002255run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002256 "$P_SRV key_file=data_files/server2.key \
2257 crt_file=data_files/server2.ku-ds.crt" \
2258 "$P_CLI" \
2259 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002260 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002261
2262
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002263run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002264 "$P_SRV key_file=data_files/server2.key \
2265 crt_file=data_files/server2.ku-ke.crt" \
2266 "$P_CLI" \
2267 0 \
2268 -c "Ciphersuite is TLS-RSA-WITH-"
2269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002270run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002271 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002272 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002273 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002274 1 \
2275 -C "Ciphersuite is "
2276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002277run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002278 "$P_SRV key_file=data_files/server5.key \
2279 crt_file=data_files/server5.ku-ds.crt" \
2280 "$P_CLI" \
2281 0 \
2282 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2283
2284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002285run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002286 "$P_SRV key_file=data_files/server5.key \
2287 crt_file=data_files/server5.ku-ka.crt" \
2288 "$P_CLI" \
2289 0 \
2290 -c "Ciphersuite is TLS-ECDH-"
2291
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002292run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002293 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002294 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002295 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002296 1 \
2297 -C "Ciphersuite is "
2298
2299# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002300# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002302run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002303 "$O_SRV -key data_files/server2.key \
2304 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002305 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002306 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2307 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002308 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002309 -C "Processing of the Certificate handshake message failed" \
2310 -c "Ciphersuite is TLS-"
2311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002312run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002313 "$O_SRV -key data_files/server2.key \
2314 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002315 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002316 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2317 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002318 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002319 -C "Processing of the Certificate handshake message failed" \
2320 -c "Ciphersuite is TLS-"
2321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002322run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002323 "$O_SRV -key data_files/server2.key \
2324 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002325 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002326 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2327 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002328 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002329 -C "Processing of the Certificate handshake message failed" \
2330 -c "Ciphersuite is TLS-"
2331
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002332run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002333 "$O_SRV -key data_files/server2.key \
2334 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002335 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002336 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2337 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002338 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002339 -c "Processing of the Certificate handshake message failed" \
2340 -C "Ciphersuite is TLS-"
2341
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002342run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2343 "$O_SRV -key data_files/server2.key \
2344 -cert data_files/server2.ku-ke.crt" \
2345 "$P_CLI debug_level=1 auth_mode=optional \
2346 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2347 0 \
2348 -c "bad certificate (usage extensions)" \
2349 -C "Processing of the Certificate handshake message failed" \
2350 -c "Ciphersuite is TLS-" \
2351 -c "! Usage does not match the keyUsage extension"
2352
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002353run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002354 "$O_SRV -key data_files/server2.key \
2355 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002356 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002357 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2358 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002359 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002360 -C "Processing of the Certificate handshake message failed" \
2361 -c "Ciphersuite is TLS-"
2362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002363run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002364 "$O_SRV -key data_files/server2.key \
2365 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002366 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002367 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2368 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002369 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002370 -c "Processing of the Certificate handshake message failed" \
2371 -C "Ciphersuite is TLS-"
2372
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002373run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2374 "$O_SRV -key data_files/server2.key \
2375 -cert data_files/server2.ku-ds.crt" \
2376 "$P_CLI debug_level=1 auth_mode=optional \
2377 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2378 0 \
2379 -c "bad certificate (usage extensions)" \
2380 -C "Processing of the Certificate handshake message failed" \
2381 -c "Ciphersuite is TLS-" \
2382 -c "! Usage does not match the keyUsage extension"
2383
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002384# Tests for keyUsage in leaf certificates, part 3:
2385# server-side checking of client cert
2386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002387run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002388 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002389 "$O_CLI -key data_files/server2.key \
2390 -cert data_files/server2.ku-ds.crt" \
2391 0 \
2392 -S "bad certificate (usage extensions)" \
2393 -S "Processing of the Certificate handshake message failed"
2394
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002395run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002396 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002397 "$O_CLI -key data_files/server2.key \
2398 -cert data_files/server2.ku-ke.crt" \
2399 0 \
2400 -s "bad certificate (usage extensions)" \
2401 -S "Processing of the Certificate handshake message failed"
2402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002403run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002404 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002405 "$O_CLI -key data_files/server2.key \
2406 -cert data_files/server2.ku-ke.crt" \
2407 1 \
2408 -s "bad certificate (usage extensions)" \
2409 -s "Processing of the Certificate handshake message failed"
2410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002411run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002412 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002413 "$O_CLI -key data_files/server5.key \
2414 -cert data_files/server5.ku-ds.crt" \
2415 0 \
2416 -S "bad certificate (usage extensions)" \
2417 -S "Processing of the Certificate handshake message failed"
2418
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002419run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002420 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002421 "$O_CLI -key data_files/server5.key \
2422 -cert data_files/server5.ku-ka.crt" \
2423 0 \
2424 -s "bad certificate (usage extensions)" \
2425 -S "Processing of the Certificate handshake message failed"
2426
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002427# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002429run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002430 "$P_SRV key_file=data_files/server5.key \
2431 crt_file=data_files/server5.eku-srv.crt" \
2432 "$P_CLI" \
2433 0
2434
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002435run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002436 "$P_SRV key_file=data_files/server5.key \
2437 crt_file=data_files/server5.eku-srv.crt" \
2438 "$P_CLI" \
2439 0
2440
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002441run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002442 "$P_SRV key_file=data_files/server5.key \
2443 crt_file=data_files/server5.eku-cs_any.crt" \
2444 "$P_CLI" \
2445 0
2446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002447run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002448 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002449 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002450 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002451 1
2452
2453# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002455run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002456 "$O_SRV -key data_files/server5.key \
2457 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002458 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002459 0 \
2460 -C "bad certificate (usage extensions)" \
2461 -C "Processing of the Certificate handshake message failed" \
2462 -c "Ciphersuite is TLS-"
2463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002464run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002465 "$O_SRV -key data_files/server5.key \
2466 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002467 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002468 0 \
2469 -C "bad certificate (usage extensions)" \
2470 -C "Processing of the Certificate handshake message failed" \
2471 -c "Ciphersuite is TLS-"
2472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002473run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002474 "$O_SRV -key data_files/server5.key \
2475 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002476 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002477 0 \
2478 -C "bad certificate (usage extensions)" \
2479 -C "Processing of the Certificate handshake message failed" \
2480 -c "Ciphersuite is TLS-"
2481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002482run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002483 "$O_SRV -key data_files/server5.key \
2484 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002485 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002486 1 \
2487 -c "bad certificate (usage extensions)" \
2488 -c "Processing of the Certificate handshake message failed" \
2489 -C "Ciphersuite is TLS-"
2490
2491# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002493run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002494 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002495 "$O_CLI -key data_files/server5.key \
2496 -cert data_files/server5.eku-cli.crt" \
2497 0 \
2498 -S "bad certificate (usage extensions)" \
2499 -S "Processing of the Certificate handshake message failed"
2500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002501run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002502 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002503 "$O_CLI -key data_files/server5.key \
2504 -cert data_files/server5.eku-srv_cli.crt" \
2505 0 \
2506 -S "bad certificate (usage extensions)" \
2507 -S "Processing of the Certificate handshake message failed"
2508
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002509run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002510 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002511 "$O_CLI -key data_files/server5.key \
2512 -cert data_files/server5.eku-cs_any.crt" \
2513 0 \
2514 -S "bad certificate (usage extensions)" \
2515 -S "Processing of the Certificate handshake message failed"
2516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002517run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002518 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002519 "$O_CLI -key data_files/server5.key \
2520 -cert data_files/server5.eku-cs.crt" \
2521 0 \
2522 -s "bad certificate (usage extensions)" \
2523 -S "Processing of the Certificate handshake message failed"
2524
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002525run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002526 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002527 "$O_CLI -key data_files/server5.key \
2528 -cert data_files/server5.eku-cs.crt" \
2529 1 \
2530 -s "bad certificate (usage extensions)" \
2531 -s "Processing of the Certificate handshake message failed"
2532
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002533# Tests for DHM parameters loading
2534
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002535run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002536 "$P_SRV" \
2537 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2538 debug_level=3" \
2539 0 \
2540 -c "value of 'DHM: P ' (2048 bits)" \
2541 -c "value of 'DHM: G ' (2048 bits)"
2542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002543run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002544 "$P_SRV dhm_file=data_files/dhparams.pem" \
2545 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2546 debug_level=3" \
2547 0 \
2548 -c "value of 'DHM: P ' (1024 bits)" \
2549 -c "value of 'DHM: G ' (2 bits)"
2550
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002551# Tests for DHM client-side size checking
2552
2553run_test "DHM size: server default, client default, OK" \
2554 "$P_SRV" \
2555 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2556 debug_level=1" \
2557 0 \
2558 -C "DHM prime too short:"
2559
2560run_test "DHM size: server default, client 2048, OK" \
2561 "$P_SRV" \
2562 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2563 debug_level=1 dhmlen=2048" \
2564 0 \
2565 -C "DHM prime too short:"
2566
2567run_test "DHM size: server 1024, client default, OK" \
2568 "$P_SRV dhm_file=data_files/dhparams.pem" \
2569 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2570 debug_level=1" \
2571 0 \
2572 -C "DHM prime too short:"
2573
2574run_test "DHM size: server 1000, client default, rejected" \
2575 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2576 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2577 debug_level=1" \
2578 1 \
2579 -c "DHM prime too short:"
2580
2581run_test "DHM size: server default, client 2049, rejected" \
2582 "$P_SRV" \
2583 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2584 debug_level=1 dhmlen=2049" \
2585 1 \
2586 -c "DHM prime too short:"
2587
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002588# Tests for PSK callback
2589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002590run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002591 "$P_SRV psk=abc123 psk_identity=foo" \
2592 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2593 psk_identity=foo psk=abc123" \
2594 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002595 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002596 -S "SSL - Unknown identity received" \
2597 -S "SSL - Verification of the message MAC failed"
2598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002599run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002600 "$P_SRV" \
2601 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2602 psk_identity=foo psk=abc123" \
2603 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002604 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002605 -S "SSL - Unknown identity received" \
2606 -S "SSL - Verification of the message MAC failed"
2607
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002608run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002609 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2610 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2611 psk_identity=foo psk=abc123" \
2612 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002613 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002614 -s "SSL - Unknown identity received" \
2615 -S "SSL - Verification of the message MAC failed"
2616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002617run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002618 "$P_SRV psk_list=abc,dead,def,beef" \
2619 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2620 psk_identity=abc psk=dead" \
2621 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002622 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002623 -S "SSL - Unknown identity received" \
2624 -S "SSL - Verification of the message MAC failed"
2625
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002626run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002627 "$P_SRV psk_list=abc,dead,def,beef" \
2628 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2629 psk_identity=def psk=beef" \
2630 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002631 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002632 -S "SSL - Unknown identity received" \
2633 -S "SSL - Verification of the message MAC failed"
2634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002635run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002636 "$P_SRV psk_list=abc,dead,def,beef" \
2637 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2638 psk_identity=ghi psk=beef" \
2639 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002640 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002641 -s "SSL - Unknown identity received" \
2642 -S "SSL - Verification of the message MAC failed"
2643
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002644run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002645 "$P_SRV psk_list=abc,dead,def,beef" \
2646 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2647 psk_identity=abc psk=beef" \
2648 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002649 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002650 -S "SSL - Unknown identity received" \
2651 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002652
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002653# Tests for ciphersuites per version
2654
Janos Follath542ee5d2016-03-07 15:57:05 +00002655requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002656run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002657 "$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 +02002658 "$P_CLI force_version=ssl3" \
2659 0 \
2660 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002662run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002663 "$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 +01002664 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002665 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002666 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002667
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002668run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002669 "$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 +02002670 "$P_CLI force_version=tls1_1" \
2671 0 \
2672 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002674run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002675 "$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 +02002676 "$P_CLI force_version=tls1_2" \
2677 0 \
2678 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2679
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002680# Test for ClientHello without extensions
2681
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002682requires_gnutls
2683run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002684 "$P_SRV debug_level=3" \
2685 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2686 0 \
2687 -s "dumping 'client hello extensions' (0 bytes)"
2688
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002689# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002690
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002691run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002692 "$P_SRV" \
2693 "$P_CLI request_size=100" \
2694 0 \
2695 -s "Read from client: 100 bytes read$"
2696
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002697run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002698 "$P_SRV" \
2699 "$P_CLI request_size=500" \
2700 0 \
2701 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002702
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002703# Tests for small packets
2704
Janos Follath542ee5d2016-03-07 15:57:05 +00002705requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002706run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002707 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002708 "$P_CLI request_size=1 force_version=ssl3 \
2709 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2710 0 \
2711 -s "Read from client: 1 bytes read"
2712
Janos Follath542ee5d2016-03-07 15:57:05 +00002713requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002714run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002715 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002716 "$P_CLI request_size=1 force_version=ssl3 \
2717 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2718 0 \
2719 -s "Read from client: 1 bytes read"
2720
2721run_test "Small packet TLS 1.0 BlockCipher" \
2722 "$P_SRV" \
2723 "$P_CLI request_size=1 force_version=tls1 \
2724 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2725 0 \
2726 -s "Read from client: 1 bytes read"
2727
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002728run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2729 "$P_SRV" \
2730 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2731 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2732 0 \
2733 -s "Read from client: 1 bytes read"
2734
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002735run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2736 "$P_SRV" \
2737 "$P_CLI request_size=1 force_version=tls1 \
2738 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2739 trunc_hmac=1" \
2740 0 \
2741 -s "Read from client: 1 bytes read"
2742
2743run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002744 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002745 "$P_CLI request_size=1 force_version=tls1 \
2746 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2747 trunc_hmac=1" \
2748 0 \
2749 -s "Read from client: 1 bytes read"
2750
2751run_test "Small packet TLS 1.1 BlockCipher" \
2752 "$P_SRV" \
2753 "$P_CLI request_size=1 force_version=tls1_1 \
2754 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2755 0 \
2756 -s "Read from client: 1 bytes read"
2757
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002758run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2759 "$P_SRV" \
2760 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2761 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2762 0 \
2763 -s "Read from client: 1 bytes read"
2764
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002765run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002766 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002767 "$P_CLI request_size=1 force_version=tls1_1 \
2768 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2769 0 \
2770 -s "Read from client: 1 bytes read"
2771
2772run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2773 "$P_SRV" \
2774 "$P_CLI request_size=1 force_version=tls1_1 \
2775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2776 trunc_hmac=1" \
2777 0 \
2778 -s "Read from client: 1 bytes read"
2779
2780run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002781 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002782 "$P_CLI request_size=1 force_version=tls1_1 \
2783 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2784 trunc_hmac=1" \
2785 0 \
2786 -s "Read from client: 1 bytes read"
2787
2788run_test "Small packet TLS 1.2 BlockCipher" \
2789 "$P_SRV" \
2790 "$P_CLI request_size=1 force_version=tls1_2 \
2791 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2792 0 \
2793 -s "Read from client: 1 bytes read"
2794
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002795run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2796 "$P_SRV" \
2797 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2798 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2799 0 \
2800 -s "Read from client: 1 bytes read"
2801
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002802run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2803 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002804 "$P_CLI request_size=1 force_version=tls1_2 \
2805 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002806 0 \
2807 -s "Read from client: 1 bytes read"
2808
2809run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2810 "$P_SRV" \
2811 "$P_CLI request_size=1 force_version=tls1_2 \
2812 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2813 trunc_hmac=1" \
2814 0 \
2815 -s "Read from client: 1 bytes read"
2816
2817run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002818 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002819 "$P_CLI request_size=1 force_version=tls1_2 \
2820 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2821 0 \
2822 -s "Read from client: 1 bytes read"
2823
2824run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002825 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002826 "$P_CLI request_size=1 force_version=tls1_2 \
2827 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2828 trunc_hmac=1" \
2829 0 \
2830 -s "Read from client: 1 bytes read"
2831
2832run_test "Small packet TLS 1.2 AEAD" \
2833 "$P_SRV" \
2834 "$P_CLI request_size=1 force_version=tls1_2 \
2835 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2836 0 \
2837 -s "Read from client: 1 bytes read"
2838
2839run_test "Small packet TLS 1.2 AEAD shorter tag" \
2840 "$P_SRV" \
2841 "$P_CLI request_size=1 force_version=tls1_2 \
2842 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2843 0 \
2844 -s "Read from client: 1 bytes read"
2845
Janos Follathb700c462016-05-06 13:48:23 +01002846# A test for extensions in SSLv3
2847
2848requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2849run_test "SSLv3 with extensions, server side" \
2850 "$P_SRV min_version=ssl3 debug_level=3" \
2851 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2852 0 \
2853 -S "dumping 'client hello extensions'" \
2854 -S "server hello, total extension length:"
2855
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002856# Test for large packets
2857
Janos Follath542ee5d2016-03-07 15:57:05 +00002858requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002859run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002860 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002861 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002862 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2863 0 \
2864 -s "Read from client: 16384 bytes read"
2865
Janos Follath542ee5d2016-03-07 15:57:05 +00002866requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002867run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002868 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002869 "$P_CLI request_size=16384 force_version=ssl3 \
2870 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2871 0 \
2872 -s "Read from client: 16384 bytes read"
2873
2874run_test "Large packet TLS 1.0 BlockCipher" \
2875 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002876 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002877 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2878 0 \
2879 -s "Read from client: 16384 bytes read"
2880
2881run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2882 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002883 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002884 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2885 trunc_hmac=1" \
2886 0 \
2887 -s "Read from client: 16384 bytes read"
2888
2889run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002890 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002891 "$P_CLI request_size=16384 force_version=tls1 \
2892 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2893 trunc_hmac=1" \
2894 0 \
2895 -s "Read from client: 16384 bytes read"
2896
2897run_test "Large packet TLS 1.1 BlockCipher" \
2898 "$P_SRV" \
2899 "$P_CLI request_size=16384 force_version=tls1_1 \
2900 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2901 0 \
2902 -s "Read from client: 16384 bytes read"
2903
2904run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002905 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002906 "$P_CLI request_size=16384 force_version=tls1_1 \
2907 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2908 0 \
2909 -s "Read from client: 16384 bytes read"
2910
2911run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2912 "$P_SRV" \
2913 "$P_CLI request_size=16384 force_version=tls1_1 \
2914 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2915 trunc_hmac=1" \
2916 0 \
2917 -s "Read from client: 16384 bytes read"
2918
2919run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002920 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002921 "$P_CLI request_size=16384 force_version=tls1_1 \
2922 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2923 trunc_hmac=1" \
2924 0 \
2925 -s "Read from client: 16384 bytes read"
2926
2927run_test "Large packet TLS 1.2 BlockCipher" \
2928 "$P_SRV" \
2929 "$P_CLI request_size=16384 force_version=tls1_2 \
2930 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2931 0 \
2932 -s "Read from client: 16384 bytes read"
2933
2934run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2935 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002936 "$P_CLI request_size=16384 force_version=tls1_2 \
2937 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002938 0 \
2939 -s "Read from client: 16384 bytes read"
2940
2941run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2942 "$P_SRV" \
2943 "$P_CLI request_size=16384 force_version=tls1_2 \
2944 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2945 trunc_hmac=1" \
2946 0 \
2947 -s "Read from client: 16384 bytes read"
2948
2949run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002950 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002951 "$P_CLI request_size=16384 force_version=tls1_2 \
2952 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2953 0 \
2954 -s "Read from client: 16384 bytes read"
2955
2956run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002957 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002958 "$P_CLI request_size=16384 force_version=tls1_2 \
2959 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2960 trunc_hmac=1" \
2961 0 \
2962 -s "Read from client: 16384 bytes read"
2963
2964run_test "Large packet TLS 1.2 AEAD" \
2965 "$P_SRV" \
2966 "$P_CLI request_size=16384 force_version=tls1_2 \
2967 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2968 0 \
2969 -s "Read from client: 16384 bytes read"
2970
2971run_test "Large packet TLS 1.2 AEAD shorter tag" \
2972 "$P_SRV" \
2973 "$P_CLI request_size=16384 force_version=tls1_2 \
2974 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2975 0 \
2976 -s "Read from client: 16384 bytes read"
2977
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002978# Tests for DTLS HelloVerifyRequest
2979
2980run_test "DTLS cookie: enabled" \
2981 "$P_SRV dtls=1 debug_level=2" \
2982 "$P_CLI dtls=1 debug_level=2" \
2983 0 \
2984 -s "cookie verification failed" \
2985 -s "cookie verification passed" \
2986 -S "cookie verification skipped" \
2987 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002988 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002989 -S "SSL - The requested feature is not available"
2990
2991run_test "DTLS cookie: disabled" \
2992 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2993 "$P_CLI dtls=1 debug_level=2" \
2994 0 \
2995 -S "cookie verification failed" \
2996 -S "cookie verification passed" \
2997 -s "cookie verification skipped" \
2998 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002999 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003000 -S "SSL - The requested feature is not available"
3001
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003002run_test "DTLS cookie: default (failing)" \
3003 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3004 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3005 1 \
3006 -s "cookie verification failed" \
3007 -S "cookie verification passed" \
3008 -S "cookie verification skipped" \
3009 -C "received hello verify request" \
3010 -S "hello verification requested" \
3011 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003012
3013requires_ipv6
3014run_test "DTLS cookie: enabled, IPv6" \
3015 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3016 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3017 0 \
3018 -s "cookie verification failed" \
3019 -s "cookie verification passed" \
3020 -S "cookie verification skipped" \
3021 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003022 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003023 -S "SSL - The requested feature is not available"
3024
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003025run_test "DTLS cookie: enabled, nbio" \
3026 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3027 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3028 0 \
3029 -s "cookie verification failed" \
3030 -s "cookie verification passed" \
3031 -S "cookie verification skipped" \
3032 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003033 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003034 -S "SSL - The requested feature is not available"
3035
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003036# Tests for client reconnecting from the same port with DTLS
3037
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003038not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003039run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003040 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3041 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003042 0 \
3043 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003044 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003045 -S "Client initiated reconnection from same port"
3046
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003047not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003048run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003049 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3050 "$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 +02003051 0 \
3052 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003053 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003054 -s "Client initiated reconnection from same port"
3055
Paul Bakker3b224ff2016-05-13 10:33:25 +01003056not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3057run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003058 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3059 "$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 +02003060 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003061 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003062 -s "Client initiated reconnection from same port"
3063
Paul Bakker3b224ff2016-05-13 10:33:25 +01003064only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3065run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3066 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3067 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3068 0 \
3069 -S "The operation timed out" \
3070 -s "Client initiated reconnection from same port"
3071
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003072run_test "DTLS client reconnect from same port: no cookies" \
3073 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003074 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3075 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003076 -s "The operation timed out" \
3077 -S "Client initiated reconnection from same port"
3078
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003079# Tests for various cases of client authentication with DTLS
3080# (focused on handshake flows and message parsing)
3081
3082run_test "DTLS client auth: required" \
3083 "$P_SRV dtls=1 auth_mode=required" \
3084 "$P_CLI dtls=1" \
3085 0 \
3086 -s "Verifying peer X.509 certificate... ok"
3087
3088run_test "DTLS client auth: optional, client has no cert" \
3089 "$P_SRV dtls=1 auth_mode=optional" \
3090 "$P_CLI dtls=1 crt_file=none key_file=none" \
3091 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003092 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003093
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003094run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003095 "$P_SRV dtls=1 auth_mode=none" \
3096 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3097 0 \
3098 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003099 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003100
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003101run_test "DTLS wrong PSK: badmac alert" \
3102 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3103 "$P_CLI dtls=1 psk=abc124" \
3104 1 \
3105 -s "SSL - Verification of the message MAC failed" \
3106 -c "SSL - A fatal alert message was received from our peer"
3107
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003108# Tests for receiving fragmented handshake messages with DTLS
3109
3110requires_gnutls
3111run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3112 "$G_SRV -u --mtu 2048 -a" \
3113 "$P_CLI dtls=1 debug_level=2" \
3114 0 \
3115 -C "found fragmented DTLS handshake message" \
3116 -C "error"
3117
3118requires_gnutls
3119run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3120 "$G_SRV -u --mtu 512" \
3121 "$P_CLI dtls=1 debug_level=2" \
3122 0 \
3123 -c "found fragmented DTLS handshake message" \
3124 -C "error"
3125
3126requires_gnutls
3127run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3128 "$G_SRV -u --mtu 128" \
3129 "$P_CLI dtls=1 debug_level=2" \
3130 0 \
3131 -c "found fragmented DTLS handshake message" \
3132 -C "error"
3133
3134requires_gnutls
3135run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3136 "$G_SRV -u --mtu 128" \
3137 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3138 0 \
3139 -c "found fragmented DTLS handshake message" \
3140 -C "error"
3141
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003142requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003143run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3144 "$G_SRV -u --mtu 256" \
3145 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3146 0 \
3147 -c "found fragmented DTLS handshake message" \
3148 -c "client hello, adding renegotiation extension" \
3149 -c "found renegotiation extension" \
3150 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003151 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003152 -C "error" \
3153 -s "Extra-header:"
3154
3155requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003156run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3157 "$G_SRV -u --mtu 256" \
3158 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3159 0 \
3160 -c "found fragmented DTLS handshake message" \
3161 -c "client hello, adding renegotiation extension" \
3162 -c "found renegotiation extension" \
3163 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003164 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003165 -C "error" \
3166 -s "Extra-header:"
3167
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003168run_test "DTLS reassembly: no fragmentation (openssl server)" \
3169 "$O_SRV -dtls1 -mtu 2048" \
3170 "$P_CLI dtls=1 debug_level=2" \
3171 0 \
3172 -C "found fragmented DTLS handshake message" \
3173 -C "error"
3174
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003175run_test "DTLS reassembly: some fragmentation (openssl server)" \
3176 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003177 "$P_CLI dtls=1 debug_level=2" \
3178 0 \
3179 -c "found fragmented DTLS handshake message" \
3180 -C "error"
3181
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003182run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003183 "$O_SRV -dtls1 -mtu 256" \
3184 "$P_CLI dtls=1 debug_level=2" \
3185 0 \
3186 -c "found fragmented DTLS handshake message" \
3187 -C "error"
3188
3189run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3190 "$O_SRV -dtls1 -mtu 256" \
3191 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3192 0 \
3193 -c "found fragmented DTLS handshake message" \
3194 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003195
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003196# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003197
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003198not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003199run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003200 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003201 "$P_SRV dtls=1 debug_level=2" \
3202 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003203 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003204 -C "replayed record" \
3205 -S "replayed record" \
3206 -C "record from another epoch" \
3207 -S "record from another epoch" \
3208 -C "discarding invalid record" \
3209 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003210 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003211 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003212 -c "HTTP/1.0 200 OK"
3213
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003214not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003215run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003216 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003217 "$P_SRV dtls=1 debug_level=2" \
3218 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003219 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003220 -c "replayed record" \
3221 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003222 -c "discarding invalid record" \
3223 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003224 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003225 -s "Extra-header:" \
3226 -c "HTTP/1.0 200 OK"
3227
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003228run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3229 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003230 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3231 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003232 0 \
3233 -c "replayed record" \
3234 -S "replayed record" \
3235 -c "discarding invalid record" \
3236 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003237 -c "resend" \
3238 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003239 -s "Extra-header:" \
3240 -c "HTTP/1.0 200 OK"
3241
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003242run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003243 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003244 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003245 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003246 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003247 -c "discarding invalid record (mac)" \
3248 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003249 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003250 -c "HTTP/1.0 200 OK" \
3251 -S "too many records with bad MAC" \
3252 -S "Verification of the message MAC failed"
3253
3254run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3255 -p "$P_PXY bad_ad=1" \
3256 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3257 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3258 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003259 -C "discarding invalid record (mac)" \
3260 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003261 -S "Extra-header:" \
3262 -C "HTTP/1.0 200 OK" \
3263 -s "too many records with bad MAC" \
3264 -s "Verification of the message MAC failed"
3265
3266run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3267 -p "$P_PXY bad_ad=1" \
3268 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3269 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3270 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003271 -c "discarding invalid record (mac)" \
3272 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003273 -s "Extra-header:" \
3274 -c "HTTP/1.0 200 OK" \
3275 -S "too many records with bad MAC" \
3276 -S "Verification of the message MAC failed"
3277
3278run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3279 -p "$P_PXY bad_ad=1" \
3280 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3281 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3282 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003283 -c "discarding invalid record (mac)" \
3284 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003285 -s "Extra-header:" \
3286 -c "HTTP/1.0 200 OK" \
3287 -s "too many records with bad MAC" \
3288 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003289
3290run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003291 -p "$P_PXY delay_ccs=1" \
3292 "$P_SRV dtls=1 debug_level=1" \
3293 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003294 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003295 -c "record from another epoch" \
3296 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003297 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003298 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003299 -s "Extra-header:" \
3300 -c "HTTP/1.0 200 OK"
3301
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003302# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003303
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003304needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003305run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003306 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003307 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3308 psk=abc123" \
3309 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003310 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3311 0 \
3312 -s "Extra-header:" \
3313 -c "HTTP/1.0 200 OK"
3314
3315needs_more_time 2
3316run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3317 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003318 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3319 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003320 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3321 0 \
3322 -s "Extra-header:" \
3323 -c "HTTP/1.0 200 OK"
3324
3325needs_more_time 2
3326run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3327 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003328 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3329 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003330 0 \
3331 -s "Extra-header:" \
3332 -c "HTTP/1.0 200 OK"
3333
3334needs_more_time 2
3335run_test "DTLS proxy: 3d, FS, client auth" \
3336 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003337 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3338 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003339 0 \
3340 -s "Extra-header:" \
3341 -c "HTTP/1.0 200 OK"
3342
3343needs_more_time 2
3344run_test "DTLS proxy: 3d, FS, ticket" \
3345 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003346 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3347 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003348 0 \
3349 -s "Extra-header:" \
3350 -c "HTTP/1.0 200 OK"
3351
3352needs_more_time 2
3353run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3354 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003355 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3356 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003357 0 \
3358 -s "Extra-header:" \
3359 -c "HTTP/1.0 200 OK"
3360
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003361needs_more_time 2
3362run_test "DTLS proxy: 3d, max handshake, nbio" \
3363 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003364 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3365 auth_mode=required" \
3366 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003367 0 \
3368 -s "Extra-header:" \
3369 -c "HTTP/1.0 200 OK"
3370
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003371needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003372run_test "DTLS proxy: 3d, min handshake, resumption" \
3373 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3374 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3375 psk=abc123 debug_level=3" \
3376 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3377 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3378 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3379 0 \
3380 -s "a session has been resumed" \
3381 -c "a session has been resumed" \
3382 -s "Extra-header:" \
3383 -c "HTTP/1.0 200 OK"
3384
3385needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003386run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3387 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3388 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3389 psk=abc123 debug_level=3 nbio=2" \
3390 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3391 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3392 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3393 0 \
3394 -s "a session has been resumed" \
3395 -c "a session has been resumed" \
3396 -s "Extra-header:" \
3397 -c "HTTP/1.0 200 OK"
3398
3399needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003400run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003401 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003402 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3403 psk=abc123 renegotiation=1 debug_level=2" \
3404 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3405 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003406 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3407 0 \
3408 -c "=> renegotiate" \
3409 -s "=> renegotiate" \
3410 -s "Extra-header:" \
3411 -c "HTTP/1.0 200 OK"
3412
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003413needs_more_time 4
3414run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3415 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003416 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3417 psk=abc123 renegotiation=1 debug_level=2" \
3418 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3419 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003420 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3421 0 \
3422 -c "=> renegotiate" \
3423 -s "=> renegotiate" \
3424 -s "Extra-header:" \
3425 -c "HTTP/1.0 200 OK"
3426
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003427needs_more_time 4
3428run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003429 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003430 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003431 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003432 debug_level=2" \
3433 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003434 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003435 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3436 0 \
3437 -c "=> renegotiate" \
3438 -s "=> renegotiate" \
3439 -s "Extra-header:" \
3440 -c "HTTP/1.0 200 OK"
3441
3442needs_more_time 4
3443run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003444 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003445 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003446 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003447 debug_level=2 nbio=2" \
3448 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003449 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003450 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3451 0 \
3452 -c "=> renegotiate" \
3453 -s "=> renegotiate" \
3454 -s "Extra-header:" \
3455 -c "HTTP/1.0 200 OK"
3456
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003457needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003458not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003459run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003460 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3461 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003462 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003463 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003464 -c "HTTP/1.0 200 OK"
3465
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003466needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003467not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003468run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3469 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3470 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003471 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003472 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003473 -c "HTTP/1.0 200 OK"
3474
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003475needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003476not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003477run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3478 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3479 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003480 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003481 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003482 -c "HTTP/1.0 200 OK"
3483
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003484requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003485needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003486not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003487run_test "DTLS proxy: 3d, gnutls server" \
3488 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3489 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003490 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003491 0 \
3492 -s "Extra-header:" \
3493 -c "Extra-header:"
3494
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003495requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003496needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003497not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003498run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3499 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3500 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003501 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003502 0 \
3503 -s "Extra-header:" \
3504 -c "Extra-header:"
3505
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003506requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003507needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003508not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003509run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3510 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3511 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003512 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003513 0 \
3514 -s "Extra-header:" \
3515 -c "Extra-header:"
3516
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003517# Final report
3518
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003519echo "------------------------------------------------------------------------"
3520
3521if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003522 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003523else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003524 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003525fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003526PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003527echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003528
3529exit $FAILS