blob: f4987327434ec8d994091f1099c3007d98db561a [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
Gilles Peskine35db5ba2017-05-10 10:13:59 +0200564# Allow SHA-1, because many of our test certificates use it
565P_SRV="$P_SRV allow_sha1=1"
566P_CLI="$P_CLI allow_sha1=1"
567
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200568# Also pick a unique name for intermediate files
569SRV_OUT="srv_out.$$"
570CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200571PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200572SESSION="session.$$"
573
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200574SKIP_NEXT="NO"
575
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100576trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100577
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200578# Basic test
579
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200580# Checks that:
581# - things work with all ciphersuites active (used with config-full in all.sh)
582# - the expected (highest security) parameters are selected
583# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200584run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200585 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200586 "$P_CLI" \
587 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200588 -s "Protocol is TLSv1.2" \
589 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
590 -s "client hello v3, signature_algorithm ext: 6" \
591 -s "ECDHE curve: secp521r1" \
592 -S "error" \
593 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200594
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000595run_test "Default, DTLS" \
596 "$P_SRV dtls=1" \
597 "$P_CLI dtls=1" \
598 0 \
599 -s "Protocol is DTLSv1.2" \
600 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
601
Janos Follath6d3e3382016-09-07 15:48:48 +0100602# Test for uniqueness of IVs in AEAD ciphersuites
603run_test "Unique IV in GCM" \
604 "$P_SRV exchanges=20 debug_level=4" \
605 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
606 0 \
607 -u "IV used" \
608 -U "IV used"
609
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100610# Tests for rc4 option
611
Simon Butcher6eb066e2016-05-19 22:12:18 +0100612requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100613run_test "RC4: server disabled, client enabled" \
614 "$P_SRV" \
615 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
616 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100617 -s "SSL - The server has no ciphersuites in common"
618
Simon Butcher6eb066e2016-05-19 22:12:18 +0100619requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100620run_test "RC4: server half, client enabled" \
621 "$P_SRV arc4=1" \
622 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
623 1 \
624 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100625
626run_test "RC4: server enabled, client disabled" \
627 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
628 "$P_CLI" \
629 1 \
630 -s "SSL - The server has no ciphersuites in common"
631
632run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100633 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100634 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
635 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100636 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100637 -S "SSL - The server has no ciphersuites in common"
638
Gilles Peskineae765992017-05-09 15:59:24 +0200639# Tests for SHA-1 support
640
641run_test "SHA-1 forbidden by default in server certificate" \
642 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
643 "$P_CLI debug_level=2 allow_sha1=0" \
644 1 \
645 -c "The certificate is signed with an unacceptable hash"
646
647run_test "SHA-1 explicitly allowed in server certificate" \
648 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
649 "$P_CLI allow_sha1=1" \
650 0
651
652run_test "SHA-256 allowed by default in server certificate" \
653 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
654 "$P_CLI allow_sha1=0" \
655 0
656
657run_test "SHA-1 forbidden by default in client certificate" \
658 "$P_SRV auth_mode=required allow_sha1=0" \
659 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
660 1 \
661 -s "The certificate is signed with an unacceptable hash"
662
663run_test "SHA-1 explicitly allowed in client certificate" \
664 "$P_SRV auth_mode=required allow_sha1=1" \
665 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
666 0
667
668run_test "SHA-256 allowed by default in client certificate" \
669 "$P_SRV auth_mode=required allow_sha1=0" \
670 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
671 0
672
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100673# Tests for Truncated HMAC extension
674
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100675run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200676 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100677 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100678 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100679 -s "dumping 'computed mac' (20 bytes)" \
680 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100681
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100682run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200683 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100684 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
685 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100686 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100687 -s "dumping 'computed mac' (20 bytes)" \
688 -S "dumping 'computed mac' (10 bytes)"
689
690run_test "Truncated HMAC: client enabled, server default" \
691 "$P_SRV debug_level=4" \
692 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
693 trunc_hmac=1" \
694 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100695 -s "dumping 'computed mac' (20 bytes)" \
696 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100697
698run_test "Truncated HMAC: client enabled, server disabled" \
699 "$P_SRV debug_level=4 trunc_hmac=0" \
700 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
701 trunc_hmac=1" \
702 0 \
703 -s "dumping 'computed mac' (20 bytes)" \
704 -S "dumping 'computed mac' (10 bytes)"
705
706run_test "Truncated HMAC: client enabled, server enabled" \
707 "$P_SRV debug_level=4 trunc_hmac=1" \
708 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
709 trunc_hmac=1" \
710 0 \
711 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100712 -s "dumping 'computed mac' (10 bytes)"
713
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100714# Tests for Encrypt-then-MAC extension
715
716run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100717 "$P_SRV debug_level=3 \
718 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100719 "$P_CLI debug_level=3" \
720 0 \
721 -c "client hello, adding encrypt_then_mac extension" \
722 -s "found encrypt then mac extension" \
723 -s "server hello, adding encrypt then mac extension" \
724 -c "found encrypt_then_mac extension" \
725 -c "using encrypt then mac" \
726 -s "using encrypt then mac"
727
728run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100729 "$P_SRV debug_level=3 etm=0 \
730 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100731 "$P_CLI debug_level=3 etm=1" \
732 0 \
733 -c "client hello, adding encrypt_then_mac extension" \
734 -s "found encrypt then mac extension" \
735 -S "server hello, adding encrypt then mac extension" \
736 -C "found encrypt_then_mac extension" \
737 -C "using encrypt then mac" \
738 -S "using encrypt then mac"
739
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100740run_test "Encrypt then MAC: client enabled, aead cipher" \
741 "$P_SRV debug_level=3 etm=1 \
742 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
743 "$P_CLI debug_level=3 etm=1" \
744 0 \
745 -c "client hello, adding encrypt_then_mac extension" \
746 -s "found encrypt then mac extension" \
747 -S "server hello, adding encrypt then mac extension" \
748 -C "found encrypt_then_mac extension" \
749 -C "using encrypt then mac" \
750 -S "using encrypt then mac"
751
752run_test "Encrypt then MAC: client enabled, stream cipher" \
753 "$P_SRV debug_level=3 etm=1 \
754 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100755 "$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 +0100756 0 \
757 -c "client hello, adding encrypt_then_mac extension" \
758 -s "found encrypt then mac extension" \
759 -S "server hello, adding encrypt then mac extension" \
760 -C "found encrypt_then_mac extension" \
761 -C "using encrypt then mac" \
762 -S "using encrypt then mac"
763
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100764run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100765 "$P_SRV debug_level=3 etm=1 \
766 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100767 "$P_CLI debug_level=3 etm=0" \
768 0 \
769 -C "client hello, adding encrypt_then_mac extension" \
770 -S "found encrypt then mac extension" \
771 -S "server hello, adding encrypt then mac extension" \
772 -C "found encrypt_then_mac extension" \
773 -C "using encrypt then mac" \
774 -S "using encrypt then mac"
775
Janos Follath542ee5d2016-03-07 15:57:05 +0000776requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100777run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100778 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100779 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100780 "$P_CLI debug_level=3 force_version=ssl3" \
781 0 \
782 -C "client hello, adding encrypt_then_mac extension" \
783 -S "found encrypt then mac extension" \
784 -S "server hello, adding encrypt then mac extension" \
785 -C "found encrypt_then_mac extension" \
786 -C "using encrypt then mac" \
787 -S "using encrypt then mac"
788
Janos Follath542ee5d2016-03-07 15:57:05 +0000789requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100790run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100791 "$P_SRV debug_level=3 force_version=ssl3 \
792 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100793 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100794 0 \
795 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100796 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100797 -S "server hello, adding encrypt then mac extension" \
798 -C "found encrypt_then_mac extension" \
799 -C "using encrypt then mac" \
800 -S "using encrypt then mac"
801
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200802# Tests for Extended Master Secret extension
803
804run_test "Extended Master Secret: default" \
805 "$P_SRV debug_level=3" \
806 "$P_CLI debug_level=3" \
807 0 \
808 -c "client hello, adding extended_master_secret extension" \
809 -s "found extended master secret extension" \
810 -s "server hello, adding extended master secret extension" \
811 -c "found extended_master_secret extension" \
812 -c "using extended master secret" \
813 -s "using extended master secret"
814
815run_test "Extended Master Secret: client enabled, server disabled" \
816 "$P_SRV debug_level=3 extended_ms=0" \
817 "$P_CLI debug_level=3 extended_ms=1" \
818 0 \
819 -c "client hello, adding extended_master_secret extension" \
820 -s "found extended master secret extension" \
821 -S "server hello, adding extended master secret extension" \
822 -C "found extended_master_secret extension" \
823 -C "using extended master secret" \
824 -S "using extended master secret"
825
826run_test "Extended Master Secret: client disabled, server enabled" \
827 "$P_SRV debug_level=3 extended_ms=1" \
828 "$P_CLI debug_level=3 extended_ms=0" \
829 0 \
830 -C "client hello, adding extended_master_secret extension" \
831 -S "found extended master secret extension" \
832 -S "server hello, adding extended master secret extension" \
833 -C "found extended_master_secret extension" \
834 -C "using extended master secret" \
835 -S "using extended master secret"
836
Janos Follath542ee5d2016-03-07 15:57:05 +0000837requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200838run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100839 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200840 "$P_CLI debug_level=3 force_version=ssl3" \
841 0 \
842 -C "client hello, adding extended_master_secret extension" \
843 -S "found extended master secret extension" \
844 -S "server hello, adding extended master secret extension" \
845 -C "found extended_master_secret extension" \
846 -C "using extended master secret" \
847 -S "using extended master secret"
848
Janos Follath542ee5d2016-03-07 15:57:05 +0000849requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200850run_test "Extended Master Secret: client enabled, server SSLv3" \
851 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100852 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200853 0 \
854 -c "client hello, adding extended_master_secret extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100855 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200856 -S "server hello, adding extended master secret extension" \
857 -C "found extended_master_secret extension" \
858 -C "using extended master secret" \
859 -S "using extended master secret"
860
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200861# Tests for FALLBACK_SCSV
862
863run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200864 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200865 "$P_CLI debug_level=3 force_version=tls1_1" \
866 0 \
867 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200868 -S "received FALLBACK_SCSV" \
869 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200870 -C "is a fatal alert message (msg 86)"
871
872run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200873 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200874 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
875 0 \
876 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200877 -S "received FALLBACK_SCSV" \
878 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200879 -C "is a fatal alert message (msg 86)"
880
881run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200882 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200883 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200884 1 \
885 -c "adding FALLBACK_SCSV" \
886 -s "received FALLBACK_SCSV" \
887 -s "inapropriate fallback" \
888 -c "is a fatal alert message (msg 86)"
889
890run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200891 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200892 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200893 0 \
894 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200895 -s "received FALLBACK_SCSV" \
896 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200897 -C "is a fatal alert message (msg 86)"
898
899requires_openssl_with_fallback_scsv
900run_test "Fallback SCSV: default, openssl server" \
901 "$O_SRV" \
902 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
903 0 \
904 -C "adding FALLBACK_SCSV" \
905 -C "is a fatal alert message (msg 86)"
906
907requires_openssl_with_fallback_scsv
908run_test "Fallback SCSV: enabled, openssl server" \
909 "$O_SRV" \
910 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
911 1 \
912 -c "adding FALLBACK_SCSV" \
913 -c "is a fatal alert message (msg 86)"
914
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200915requires_openssl_with_fallback_scsv
916run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200917 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200918 "$O_CLI -tls1_1" \
919 0 \
920 -S "received FALLBACK_SCSV" \
921 -S "inapropriate fallback"
922
923requires_openssl_with_fallback_scsv
924run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200925 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200926 "$O_CLI -tls1_1 -fallback_scsv" \
927 1 \
928 -s "received FALLBACK_SCSV" \
929 -s "inapropriate fallback"
930
931requires_openssl_with_fallback_scsv
932run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200933 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200934 "$O_CLI -fallback_scsv" \
935 0 \
936 -s "received FALLBACK_SCSV" \
937 -S "inapropriate fallback"
938
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100939# Tests for CBC 1/n-1 record splitting
940
941run_test "CBC Record splitting: TLS 1.2, no splitting" \
942 "$P_SRV" \
943 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
944 request_size=123 force_version=tls1_2" \
945 0 \
946 -s "Read from client: 123 bytes read" \
947 -S "Read from client: 1 bytes read" \
948 -S "122 bytes read"
949
950run_test "CBC Record splitting: TLS 1.1, no splitting" \
951 "$P_SRV" \
952 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
953 request_size=123 force_version=tls1_1" \
954 0 \
955 -s "Read from client: 123 bytes read" \
956 -S "Read from client: 1 bytes read" \
957 -S "122 bytes read"
958
959run_test "CBC Record splitting: TLS 1.0, splitting" \
960 "$P_SRV" \
961 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
962 request_size=123 force_version=tls1" \
963 0 \
964 -S "Read from client: 123 bytes read" \
965 -s "Read from client: 1 bytes read" \
966 -s "122 bytes read"
967
Janos Follath542ee5d2016-03-07 15:57:05 +0000968requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100969run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100970 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100971 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
972 request_size=123 force_version=ssl3" \
973 0 \
974 -S "Read from client: 123 bytes read" \
975 -s "Read from client: 1 bytes read" \
976 -s "122 bytes read"
977
978run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100979 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100980 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
981 request_size=123 force_version=tls1" \
982 0 \
983 -s "Read from client: 123 bytes read" \
984 -S "Read from client: 1 bytes read" \
985 -S "122 bytes read"
986
987run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
988 "$P_SRV" \
989 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
990 request_size=123 force_version=tls1 recsplit=0" \
991 0 \
992 -s "Read from client: 123 bytes read" \
993 -S "Read from client: 1 bytes read" \
994 -S "122 bytes read"
995
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100996run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
997 "$P_SRV nbio=2" \
998 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
999 request_size=123 force_version=tls1" \
1000 0 \
1001 -S "Read from client: 123 bytes read" \
1002 -s "Read from client: 1 bytes read" \
1003 -s "122 bytes read"
1004
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001005# Tests for Session Tickets
1006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001007run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001008 "$P_SRV debug_level=3 tickets=1" \
1009 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001010 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001011 -c "client hello, adding session ticket extension" \
1012 -s "found session ticket extension" \
1013 -s "server hello, adding session ticket extension" \
1014 -c "found session_ticket extension" \
1015 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001016 -S "session successfully restored from cache" \
1017 -s "session successfully restored from ticket" \
1018 -s "a session has been resumed" \
1019 -c "a session has been resumed"
1020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001021run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001022 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1023 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001024 0 \
1025 -c "client hello, adding session ticket extension" \
1026 -s "found session ticket extension" \
1027 -s "server hello, adding session ticket extension" \
1028 -c "found session_ticket extension" \
1029 -c "parse new session ticket" \
1030 -S "session successfully restored from cache" \
1031 -s "session successfully restored from ticket" \
1032 -s "a session has been resumed" \
1033 -c "a session has been resumed"
1034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001035run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001036 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1037 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001038 0 \
1039 -c "client hello, adding session ticket extension" \
1040 -s "found session ticket extension" \
1041 -s "server hello, adding session ticket extension" \
1042 -c "found session_ticket extension" \
1043 -c "parse new session ticket" \
1044 -S "session successfully restored from cache" \
1045 -S "session successfully restored from ticket" \
1046 -S "a session has been resumed" \
1047 -C "a session has been resumed"
1048
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001049run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001050 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001051 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001052 0 \
1053 -c "client hello, adding session ticket extension" \
1054 -c "found session_ticket extension" \
1055 -c "parse new session ticket" \
1056 -c "a session has been resumed"
1057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001058run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001059 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001060 "( $O_CLI -sess_out $SESSION; \
1061 $O_CLI -sess_in $SESSION; \
1062 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001063 0 \
1064 -s "found session ticket extension" \
1065 -s "server hello, adding session ticket extension" \
1066 -S "session successfully restored from cache" \
1067 -s "session successfully restored from ticket" \
1068 -s "a session has been resumed"
1069
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001070# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001072run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001073 "$P_SRV debug_level=3 tickets=0" \
1074 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001075 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001076 -c "client hello, adding session ticket extension" \
1077 -s "found session ticket extension" \
1078 -S "server hello, adding session ticket extension" \
1079 -C "found session_ticket extension" \
1080 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001081 -s "session successfully restored from cache" \
1082 -S "session successfully restored from ticket" \
1083 -s "a session has been resumed" \
1084 -c "a session has been resumed"
1085
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001086run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001087 "$P_SRV debug_level=3 tickets=1" \
1088 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001089 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001090 -C "client hello, adding session ticket extension" \
1091 -S "found session ticket extension" \
1092 -S "server hello, adding session ticket extension" \
1093 -C "found session_ticket extension" \
1094 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001095 -s "session successfully restored from cache" \
1096 -S "session successfully restored from ticket" \
1097 -s "a session has been resumed" \
1098 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001100run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001101 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1102 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001103 0 \
1104 -S "session successfully restored from cache" \
1105 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001106 -S "a session has been resumed" \
1107 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001108
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001109run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001110 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1111 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001112 0 \
1113 -s "session successfully restored from cache" \
1114 -S "session successfully restored from ticket" \
1115 -s "a session has been resumed" \
1116 -c "a session has been resumed"
1117
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001118run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001119 "$P_SRV debug_level=3 tickets=0" \
1120 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001121 0 \
1122 -s "session successfully restored from cache" \
1123 -S "session successfully restored from ticket" \
1124 -s "a session has been resumed" \
1125 -c "a session has been resumed"
1126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001127run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001128 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1129 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001130 0 \
1131 -S "session successfully restored from cache" \
1132 -S "session successfully restored from ticket" \
1133 -S "a session has been resumed" \
1134 -C "a session has been resumed"
1135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001136run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001137 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1138 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001139 0 \
1140 -s "session successfully restored from cache" \
1141 -S "session successfully restored from ticket" \
1142 -s "a session has been resumed" \
1143 -c "a session has been resumed"
1144
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001145run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001146 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001147 "( $O_CLI -sess_out $SESSION; \
1148 $O_CLI -sess_in $SESSION; \
1149 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001150 0 \
1151 -s "found session ticket extension" \
1152 -S "server hello, adding session ticket extension" \
1153 -s "session successfully restored from cache" \
1154 -S "session successfully restored from ticket" \
1155 -s "a session has been resumed"
1156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001157run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001158 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001159 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001160 0 \
1161 -C "found session_ticket extension" \
1162 -C "parse new session ticket" \
1163 -c "a session has been resumed"
1164
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001165# Tests for Max Fragment Length extension
1166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001167run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001168 "$P_SRV debug_level=3" \
1169 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001170 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001171 -c "Maximum fragment length is 16384" \
1172 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001173 -C "client hello, adding max_fragment_length extension" \
1174 -S "found max fragment length extension" \
1175 -S "server hello, max_fragment_length extension" \
1176 -C "found max_fragment_length extension"
1177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001178run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001179 "$P_SRV debug_level=3" \
1180 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001181 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001182 -c "Maximum fragment length is 4096" \
1183 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001184 -c "client hello, adding max_fragment_length extension" \
1185 -s "found max fragment length extension" \
1186 -s "server hello, max_fragment_length extension" \
1187 -c "found max_fragment_length extension"
1188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001189run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001190 "$P_SRV debug_level=3 max_frag_len=4096" \
1191 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001192 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001193 -c "Maximum fragment length is 16384" \
1194 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001195 -C "client hello, adding max_fragment_length extension" \
1196 -S "found max fragment length extension" \
1197 -S "server hello, max_fragment_length extension" \
1198 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001200requires_gnutls
1201run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001202 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001203 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001204 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001205 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001206 -c "client hello, adding max_fragment_length extension" \
1207 -c "found max_fragment_length extension"
1208
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001209run_test "Max fragment length: client, message just fits" \
1210 "$P_SRV debug_level=3" \
1211 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1212 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001213 -c "Maximum fragment length is 2048" \
1214 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001215 -c "client hello, adding max_fragment_length extension" \
1216 -s "found max fragment length extension" \
1217 -s "server hello, max_fragment_length extension" \
1218 -c "found max_fragment_length extension" \
1219 -c "2048 bytes written in 1 fragments" \
1220 -s "2048 bytes read"
1221
1222run_test "Max fragment length: client, larger message" \
1223 "$P_SRV debug_level=3" \
1224 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1225 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001226 -c "Maximum fragment length is 2048" \
1227 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001228 -c "client hello, adding max_fragment_length extension" \
1229 -s "found max fragment length extension" \
1230 -s "server hello, max_fragment_length extension" \
1231 -c "found max_fragment_length extension" \
1232 -c "2345 bytes written in 2 fragments" \
1233 -s "2048 bytes read" \
1234 -s "297 bytes read"
1235
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001236run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001237 "$P_SRV debug_level=3 dtls=1" \
1238 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1239 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001240 -c "Maximum fragment length is 2048" \
1241 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001242 -c "client hello, adding max_fragment_length extension" \
1243 -s "found max fragment length extension" \
1244 -s "server hello, max_fragment_length extension" \
1245 -c "found max_fragment_length extension" \
1246 -c "fragment larger than.*maximum"
1247
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001248# Tests for renegotiation
1249
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001250run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001251 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001252 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001253 0 \
1254 -C "client hello, adding renegotiation extension" \
1255 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1256 -S "found renegotiation extension" \
1257 -s "server hello, secure renegotiation extension" \
1258 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001259 -C "=> renegotiate" \
1260 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001261 -S "write hello request"
1262
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001263run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001264 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001265 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001266 0 \
1267 -c "client hello, adding renegotiation extension" \
1268 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1269 -s "found renegotiation extension" \
1270 -s "server hello, secure renegotiation extension" \
1271 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001272 -c "=> renegotiate" \
1273 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001274 -S "write hello request"
1275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001276run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001277 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001278 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001279 0 \
1280 -c "client hello, adding renegotiation extension" \
1281 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1282 -s "found renegotiation extension" \
1283 -s "server hello, secure renegotiation extension" \
1284 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001285 -c "=> renegotiate" \
1286 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001287 -s "write hello request"
1288
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001289run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001290 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001291 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001292 0 \
1293 -c "client hello, adding renegotiation extension" \
1294 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1295 -s "found renegotiation extension" \
1296 -s "server hello, secure renegotiation extension" \
1297 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001298 -c "=> renegotiate" \
1299 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001300 -s "write hello request"
1301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001302run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001303 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001304 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001305 1 \
1306 -c "client hello, adding renegotiation extension" \
1307 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1308 -S "found renegotiation extension" \
1309 -s "server hello, secure renegotiation extension" \
1310 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001311 -c "=> renegotiate" \
1312 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001313 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001314 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001315 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001317run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001318 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001319 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001320 0 \
1321 -C "client hello, adding renegotiation extension" \
1322 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1323 -S "found renegotiation extension" \
1324 -s "server hello, secure renegotiation extension" \
1325 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001326 -C "=> renegotiate" \
1327 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001328 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001329 -S "SSL - An unexpected message was received from our peer" \
1330 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001331
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001332run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001333 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001334 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001335 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001336 0 \
1337 -C "client hello, adding renegotiation extension" \
1338 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1339 -S "found renegotiation extension" \
1340 -s "server hello, secure renegotiation extension" \
1341 -c "found renegotiation extension" \
1342 -C "=> renegotiate" \
1343 -S "=> renegotiate" \
1344 -s "write hello request" \
1345 -S "SSL - An unexpected message was received from our peer" \
1346 -S "failed"
1347
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001348# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001349run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001350 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001351 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001352 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001353 0 \
1354 -C "client hello, adding renegotiation extension" \
1355 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1356 -S "found renegotiation extension" \
1357 -s "server hello, secure renegotiation extension" \
1358 -c "found renegotiation extension" \
1359 -C "=> renegotiate" \
1360 -S "=> renegotiate" \
1361 -s "write hello request" \
1362 -S "SSL - An unexpected message was received from our peer" \
1363 -S "failed"
1364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001365run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001366 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001367 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001368 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001369 0 \
1370 -C "client hello, adding renegotiation extension" \
1371 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1372 -S "found renegotiation extension" \
1373 -s "server hello, secure renegotiation extension" \
1374 -c "found renegotiation extension" \
1375 -C "=> renegotiate" \
1376 -S "=> renegotiate" \
1377 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001378 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001380run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001382 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001383 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001384 0 \
1385 -c "client hello, adding renegotiation extension" \
1386 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1387 -s "found renegotiation extension" \
1388 -s "server hello, secure renegotiation extension" \
1389 -c "found renegotiation extension" \
1390 -c "=> renegotiate" \
1391 -s "=> renegotiate" \
1392 -s "write hello request" \
1393 -S "SSL - An unexpected message was received from our peer" \
1394 -S "failed"
1395
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001396run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001397 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001398 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1399 0 \
1400 -C "client hello, adding renegotiation extension" \
1401 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1402 -S "found renegotiation extension" \
1403 -s "server hello, secure renegotiation extension" \
1404 -c "found renegotiation extension" \
1405 -S "record counter limit reached: renegotiate" \
1406 -C "=> renegotiate" \
1407 -S "=> renegotiate" \
1408 -S "write hello request" \
1409 -S "SSL - An unexpected message was received from our peer" \
1410 -S "failed"
1411
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001412# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001413run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001414 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001415 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001416 0 \
1417 -c "client hello, adding renegotiation extension" \
1418 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1419 -s "found renegotiation extension" \
1420 -s "server hello, secure renegotiation extension" \
1421 -c "found renegotiation extension" \
1422 -s "record counter limit reached: renegotiate" \
1423 -c "=> renegotiate" \
1424 -s "=> renegotiate" \
1425 -s "write hello request" \
1426 -S "SSL - An unexpected message was received from our peer" \
1427 -S "failed"
1428
1429run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001430 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001431 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001432 0 \
1433 -c "client hello, adding renegotiation extension" \
1434 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1435 -s "found renegotiation extension" \
1436 -s "server hello, secure renegotiation extension" \
1437 -c "found renegotiation extension" \
1438 -s "record counter limit reached: renegotiate" \
1439 -c "=> renegotiate" \
1440 -s "=> renegotiate" \
1441 -s "write hello request" \
1442 -S "SSL - An unexpected message was received from our peer" \
1443 -S "failed"
1444
1445run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001446 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001447 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1448 0 \
1449 -C "client hello, adding renegotiation extension" \
1450 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1451 -S "found renegotiation extension" \
1452 -s "server hello, secure renegotiation extension" \
1453 -c "found renegotiation extension" \
1454 -S "record counter limit reached: renegotiate" \
1455 -C "=> renegotiate" \
1456 -S "=> renegotiate" \
1457 -S "write hello request" \
1458 -S "SSL - An unexpected message was received from our peer" \
1459 -S "failed"
1460
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001461run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001462 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001463 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001464 0 \
1465 -c "client hello, adding renegotiation extension" \
1466 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1467 -s "found renegotiation extension" \
1468 -s "server hello, secure renegotiation extension" \
1469 -c "found renegotiation extension" \
1470 -c "=> renegotiate" \
1471 -s "=> renegotiate" \
1472 -S "write hello request"
1473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001474run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001475 "$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 +02001476 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001477 0 \
1478 -c "client hello, adding renegotiation extension" \
1479 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1480 -s "found renegotiation extension" \
1481 -s "server hello, secure renegotiation extension" \
1482 -c "found renegotiation extension" \
1483 -c "=> renegotiate" \
1484 -s "=> renegotiate" \
1485 -s "write hello request"
1486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001487run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001488 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001489 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001490 0 \
1491 -c "client hello, adding renegotiation extension" \
1492 -c "found renegotiation extension" \
1493 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001494 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001495 -C "error" \
1496 -c "HTTP/1.0 200 [Oo][Kk]"
1497
Paul Bakker539d9722015-02-08 16:18:35 +01001498requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001499run_test "Renegotiation: gnutls server strict, client-initiated" \
1500 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001501 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001502 0 \
1503 -c "client hello, adding renegotiation extension" \
1504 -c "found renegotiation extension" \
1505 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001506 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001507 -C "error" \
1508 -c "HTTP/1.0 200 [Oo][Kk]"
1509
Paul Bakker539d9722015-02-08 16:18:35 +01001510requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001511run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1512 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1513 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1514 1 \
1515 -c "client hello, adding renegotiation extension" \
1516 -C "found renegotiation extension" \
1517 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001518 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001519 -c "error" \
1520 -C "HTTP/1.0 200 [Oo][Kk]"
1521
Paul Bakker539d9722015-02-08 16:18:35 +01001522requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001523run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1524 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1525 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1526 allow_legacy=0" \
1527 1 \
1528 -c "client hello, adding renegotiation extension" \
1529 -C "found renegotiation extension" \
1530 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001531 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001532 -c "error" \
1533 -C "HTTP/1.0 200 [Oo][Kk]"
1534
Paul Bakker539d9722015-02-08 16:18:35 +01001535requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001536run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1537 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1538 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1539 allow_legacy=1" \
1540 0 \
1541 -c "client hello, adding renegotiation extension" \
1542 -C "found renegotiation extension" \
1543 -c "=> renegotiate" \
1544 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001545 -C "error" \
1546 -c "HTTP/1.0 200 [Oo][Kk]"
1547
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001548run_test "Renegotiation: DTLS, client-initiated" \
1549 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1550 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1551 0 \
1552 -c "client hello, adding renegotiation extension" \
1553 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1554 -s "found renegotiation extension" \
1555 -s "server hello, secure renegotiation extension" \
1556 -c "found renegotiation extension" \
1557 -c "=> renegotiate" \
1558 -s "=> renegotiate" \
1559 -S "write hello request"
1560
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001561run_test "Renegotiation: DTLS, server-initiated" \
1562 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001563 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1564 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001565 0 \
1566 -c "client hello, adding renegotiation extension" \
1567 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1568 -s "found renegotiation extension" \
1569 -s "server hello, secure renegotiation extension" \
1570 -c "found renegotiation extension" \
1571 -c "=> renegotiate" \
1572 -s "=> renegotiate" \
1573 -s "write hello request"
1574
Andres AG9b1927b2017-01-19 16:30:57 +00001575run_test "Renegotiation: DTLS, renego_period overflow" \
1576 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1577 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1578 0 \
1579 -c "client hello, adding renegotiation extension" \
1580 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1581 -s "found renegotiation extension" \
1582 -s "server hello, secure renegotiation extension" \
1583 -s "record counter limit reached: renegotiate" \
1584 -c "=> renegotiate" \
1585 -s "=> renegotiate" \
1586 -s "write hello request" \
1587
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001588requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001589run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1590 "$G_SRV -u --mtu 4096" \
1591 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1592 0 \
1593 -c "client hello, adding renegotiation extension" \
1594 -c "found renegotiation extension" \
1595 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001596 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001597 -C "error" \
1598 -s "Extra-header:"
1599
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001600# Test for the "secure renegotation" extension only (no actual renegotiation)
1601
Paul Bakker539d9722015-02-08 16:18:35 +01001602requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001603run_test "Renego ext: gnutls server strict, client default" \
1604 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1605 "$P_CLI debug_level=3" \
1606 0 \
1607 -c "found renegotiation extension" \
1608 -C "error" \
1609 -c "HTTP/1.0 200 [Oo][Kk]"
1610
Paul Bakker539d9722015-02-08 16:18:35 +01001611requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001612run_test "Renego ext: gnutls server unsafe, client default" \
1613 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1614 "$P_CLI debug_level=3" \
1615 0 \
1616 -C "found renegotiation extension" \
1617 -C "error" \
1618 -c "HTTP/1.0 200 [Oo][Kk]"
1619
Paul Bakker539d9722015-02-08 16:18:35 +01001620requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001621run_test "Renego ext: gnutls server unsafe, client break legacy" \
1622 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1623 "$P_CLI debug_level=3 allow_legacy=-1" \
1624 1 \
1625 -C "found renegotiation extension" \
1626 -c "error" \
1627 -C "HTTP/1.0 200 [Oo][Kk]"
1628
Paul Bakker539d9722015-02-08 16:18:35 +01001629requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001630run_test "Renego ext: gnutls client strict, server default" \
1631 "$P_SRV debug_level=3" \
1632 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1633 0 \
1634 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1635 -s "server hello, secure renegotiation extension"
1636
Paul Bakker539d9722015-02-08 16:18:35 +01001637requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001638run_test "Renego ext: gnutls client unsafe, server default" \
1639 "$P_SRV debug_level=3" \
1640 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1641 0 \
1642 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1643 -S "server hello, secure renegotiation extension"
1644
Paul Bakker539d9722015-02-08 16:18:35 +01001645requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001646run_test "Renego ext: gnutls client unsafe, server break legacy" \
1647 "$P_SRV debug_level=3 allow_legacy=-1" \
1648 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1649 1 \
1650 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1651 -S "server hello, secure renegotiation extension"
1652
Janos Follath365b2262016-02-17 10:11:21 +00001653# Tests for silently dropping trailing extra bytes in .der certificates
1654
1655requires_gnutls
1656run_test "DER format: no trailing bytes" \
1657 "$P_SRV crt_file=data_files/server5-der0.crt \
1658 key_file=data_files/server5.key" \
1659 "$G_CLI " \
1660 0 \
1661 -c "Handshake was completed" \
1662
1663requires_gnutls
1664run_test "DER format: with a trailing zero byte" \
1665 "$P_SRV crt_file=data_files/server5-der1a.crt \
1666 key_file=data_files/server5.key" \
1667 "$G_CLI " \
1668 0 \
1669 -c "Handshake was completed" \
1670
1671requires_gnutls
1672run_test "DER format: with a trailing random byte" \
1673 "$P_SRV crt_file=data_files/server5-der1b.crt \
1674 key_file=data_files/server5.key" \
1675 "$G_CLI " \
1676 0 \
1677 -c "Handshake was completed" \
1678
1679requires_gnutls
1680run_test "DER format: with 2 trailing random bytes" \
1681 "$P_SRV crt_file=data_files/server5-der2.crt \
1682 key_file=data_files/server5.key" \
1683 "$G_CLI " \
1684 0 \
1685 -c "Handshake was completed" \
1686
1687requires_gnutls
1688run_test "DER format: with 4 trailing random bytes" \
1689 "$P_SRV crt_file=data_files/server5-der4.crt \
1690 key_file=data_files/server5.key" \
1691 "$G_CLI " \
1692 0 \
1693 -c "Handshake was completed" \
1694
1695requires_gnutls
1696run_test "DER format: with 8 trailing random bytes" \
1697 "$P_SRV crt_file=data_files/server5-der8.crt \
1698 key_file=data_files/server5.key" \
1699 "$G_CLI " \
1700 0 \
1701 -c "Handshake was completed" \
1702
1703requires_gnutls
1704run_test "DER format: with 9 trailing random bytes" \
1705 "$P_SRV crt_file=data_files/server5-der9.crt \
1706 key_file=data_files/server5.key" \
1707 "$G_CLI " \
1708 0 \
1709 -c "Handshake was completed" \
1710
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001711# Tests for auth_mode
1712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001713run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001714 "$P_SRV crt_file=data_files/server5-badsign.crt \
1715 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001716 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001717 1 \
1718 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001719 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001720 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001721 -c "X509 - Certificate verification failed"
1722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001723run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001724 "$P_SRV crt_file=data_files/server5-badsign.crt \
1725 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001726 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001727 0 \
1728 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001729 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001730 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001731 -C "X509 - Certificate verification failed"
1732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001733run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001734 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001735 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001736 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001737 0 \
1738 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001739 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001740 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001741 -C "X509 - Certificate verification failed"
1742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001743run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001744 "$P_SRV debug_level=3 auth_mode=required" \
1745 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001746 key_file=data_files/server5.key" \
1747 1 \
1748 -S "skip write certificate request" \
1749 -C "skip parse certificate request" \
1750 -c "got a certificate request" \
1751 -C "skip write certificate" \
1752 -C "skip write certificate verify" \
1753 -S "skip parse certificate verify" \
1754 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001755 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001756 -s "! mbedtls_ssl_handshake returned" \
1757 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001758 -s "X509 - Certificate verification failed"
1759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001760run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001761 "$P_SRV debug_level=3 auth_mode=optional" \
1762 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001763 key_file=data_files/server5.key" \
1764 0 \
1765 -S "skip write certificate request" \
1766 -C "skip parse certificate request" \
1767 -c "got a certificate request" \
1768 -C "skip write certificate" \
1769 -C "skip write certificate verify" \
1770 -S "skip parse certificate verify" \
1771 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001772 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001773 -S "! mbedtls_ssl_handshake returned" \
1774 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001775 -S "X509 - Certificate verification failed"
1776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001778 "$P_SRV debug_level=3 auth_mode=none" \
1779 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001780 key_file=data_files/server5.key" \
1781 0 \
1782 -s "skip write certificate request" \
1783 -C "skip parse certificate request" \
1784 -c "got no certificate request" \
1785 -c "skip write certificate" \
1786 -c "skip write certificate verify" \
1787 -s "skip parse certificate verify" \
1788 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001789 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001790 -S "! mbedtls_ssl_handshake returned" \
1791 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001792 -S "X509 - Certificate verification failed"
1793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001794run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001795 "$P_SRV debug_level=3 auth_mode=optional" \
1796 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001797 0 \
1798 -S "skip write certificate request" \
1799 -C "skip parse certificate request" \
1800 -c "got a certificate request" \
1801 -C "skip write certificate$" \
1802 -C "got no certificate to send" \
1803 -S "SSLv3 client has no certificate" \
1804 -c "skip write certificate verify" \
1805 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001806 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001807 -S "! mbedtls_ssl_handshake returned" \
1808 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001809 -S "X509 - Certificate verification failed"
1810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001811run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001812 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001813 "$O_CLI" \
1814 0 \
1815 -S "skip write certificate request" \
1816 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001817 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001818 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001819 -S "X509 - Certificate verification failed"
1820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001821run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001822 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001823 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001824 0 \
1825 -C "skip parse certificate request" \
1826 -c "got a certificate request" \
1827 -C "skip write certificate$" \
1828 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001829 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001830
Janos Follath542ee5d2016-03-07 15:57:05 +00001831requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001832run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001833 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001834 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001835 0 \
1836 -S "skip write certificate request" \
1837 -C "skip parse certificate request" \
1838 -c "got a certificate request" \
1839 -C "skip write certificate$" \
1840 -c "skip write certificate verify" \
1841 -c "got no certificate to send" \
1842 -s "SSLv3 client has no certificate" \
1843 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001844 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001845 -S "! mbedtls_ssl_handshake returned" \
1846 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001847 -S "X509 - Certificate verification failed"
1848
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001849# Tests for certificate selection based on SHA verson
1850
1851run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1852 "$P_SRV crt_file=data_files/server5.crt \
1853 key_file=data_files/server5.key \
1854 crt_file2=data_files/server5-sha1.crt \
1855 key_file2=data_files/server5.key" \
1856 "$P_CLI force_version=tls1_2" \
1857 0 \
1858 -c "signed using.*ECDSA with SHA256" \
1859 -C "signed using.*ECDSA with SHA1"
1860
1861run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1862 "$P_SRV crt_file=data_files/server5.crt \
1863 key_file=data_files/server5.key \
1864 crt_file2=data_files/server5-sha1.crt \
1865 key_file2=data_files/server5.key" \
1866 "$P_CLI force_version=tls1_1" \
1867 0 \
1868 -C "signed using.*ECDSA with SHA256" \
1869 -c "signed using.*ECDSA with SHA1"
1870
1871run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1872 "$P_SRV crt_file=data_files/server5.crt \
1873 key_file=data_files/server5.key \
1874 crt_file2=data_files/server5-sha1.crt \
1875 key_file2=data_files/server5.key" \
1876 "$P_CLI force_version=tls1" \
1877 0 \
1878 -C "signed using.*ECDSA with SHA256" \
1879 -c "signed using.*ECDSA with SHA1"
1880
1881run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1882 "$P_SRV crt_file=data_files/server5.crt \
1883 key_file=data_files/server5.key \
1884 crt_file2=data_files/server6.crt \
1885 key_file2=data_files/server6.key" \
1886 "$P_CLI force_version=tls1_1" \
1887 0 \
1888 -c "serial number.*09" \
1889 -c "signed using.*ECDSA with SHA256" \
1890 -C "signed using.*ECDSA with SHA1"
1891
1892run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1893 "$P_SRV crt_file=data_files/server6.crt \
1894 key_file=data_files/server6.key \
1895 crt_file2=data_files/server5.crt \
1896 key_file2=data_files/server5.key" \
1897 "$P_CLI force_version=tls1_1" \
1898 0 \
1899 -c "serial number.*0A" \
1900 -c "signed using.*ECDSA with SHA256" \
1901 -C "signed using.*ECDSA with SHA1"
1902
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001903# tests for SNI
1904
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001905run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001906 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001907 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001908 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001909 0 \
1910 -S "parse ServerName extension" \
1911 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1912 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001914run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001915 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001916 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001917 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 +02001918 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001919 0 \
1920 -s "parse ServerName extension" \
1921 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1922 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001924run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001925 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001926 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001927 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 +02001928 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001929 0 \
1930 -s "parse ServerName extension" \
1931 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1932 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001934run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001935 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001936 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001937 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 +02001938 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001939 1 \
1940 -s "parse ServerName extension" \
1941 -s "ssl_sni_wrapper() returned" \
1942 -s "mbedtls_ssl_handshake returned" \
1943 -c "mbedtls_ssl_handshake returned" \
1944 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001945
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001946run_test "SNI: client auth no override: optional" \
1947 "$P_SRV debug_level=3 auth_mode=optional \
1948 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1949 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1950 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001951 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001952 -S "skip write certificate request" \
1953 -C "skip parse certificate request" \
1954 -c "got a certificate request" \
1955 -C "skip write certificate" \
1956 -C "skip write certificate verify" \
1957 -S "skip parse certificate verify"
1958
1959run_test "SNI: client auth override: none -> optional" \
1960 "$P_SRV debug_level=3 auth_mode=none \
1961 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1962 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1963 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001964 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001965 -S "skip write certificate request" \
1966 -C "skip parse certificate request" \
1967 -c "got a certificate request" \
1968 -C "skip write certificate" \
1969 -C "skip write certificate verify" \
1970 -S "skip parse certificate verify"
1971
1972run_test "SNI: client auth override: optional -> none" \
1973 "$P_SRV debug_level=3 auth_mode=optional \
1974 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1975 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1976 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001977 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001978 -s "skip write certificate request" \
1979 -C "skip parse certificate request" \
1980 -c "got no certificate request" \
1981 -c "skip write certificate" \
1982 -c "skip write certificate verify" \
1983 -s "skip parse certificate verify"
1984
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001985run_test "SNI: CA no override" \
1986 "$P_SRV debug_level=3 auth_mode=optional \
1987 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1988 ca_file=data_files/test-ca.crt \
1989 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1990 "$P_CLI debug_level=3 server_name=localhost \
1991 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1992 1 \
1993 -S "skip write certificate request" \
1994 -C "skip parse certificate request" \
1995 -c "got a certificate request" \
1996 -C "skip write certificate" \
1997 -C "skip write certificate verify" \
1998 -S "skip parse certificate verify" \
1999 -s "x509_verify_cert() returned" \
2000 -s "! The certificate is not correctly signed by the trusted CA" \
2001 -S "The certificate has been revoked (is on a CRL)"
2002
2003run_test "SNI: CA override" \
2004 "$P_SRV debug_level=3 auth_mode=optional \
2005 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2006 ca_file=data_files/test-ca.crt \
2007 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2008 "$P_CLI debug_level=3 server_name=localhost \
2009 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2010 0 \
2011 -S "skip write certificate request" \
2012 -C "skip parse certificate request" \
2013 -c "got a certificate request" \
2014 -C "skip write certificate" \
2015 -C "skip write certificate verify" \
2016 -S "skip parse certificate verify" \
2017 -S "x509_verify_cert() returned" \
2018 -S "! The certificate is not correctly signed by the trusted CA" \
2019 -S "The certificate has been revoked (is on a CRL)"
2020
2021run_test "SNI: CA override with CRL" \
2022 "$P_SRV debug_level=3 auth_mode=optional \
2023 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2024 ca_file=data_files/test-ca.crt \
2025 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2026 "$P_CLI debug_level=3 server_name=localhost \
2027 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2028 1 \
2029 -S "skip write certificate request" \
2030 -C "skip parse certificate request" \
2031 -c "got a certificate request" \
2032 -C "skip write certificate" \
2033 -C "skip write certificate verify" \
2034 -S "skip parse certificate verify" \
2035 -s "x509_verify_cert() returned" \
2036 -S "! The certificate is not correctly signed by the trusted CA" \
2037 -s "The certificate has been revoked (is on a CRL)"
2038
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002039# Tests for non-blocking I/O: exercise a variety of handshake flows
2040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002041run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002042 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2043 "$P_CLI nbio=2 tickets=0" \
2044 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002045 -S "mbedtls_ssl_handshake returned" \
2046 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002047 -c "Read from server: .* bytes read"
2048
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002049run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002050 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2051 "$P_CLI nbio=2 tickets=0" \
2052 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002053 -S "mbedtls_ssl_handshake returned" \
2054 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002055 -c "Read from server: .* bytes read"
2056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002057run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002058 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2059 "$P_CLI nbio=2 tickets=1" \
2060 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002061 -S "mbedtls_ssl_handshake returned" \
2062 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002063 -c "Read from server: .* bytes read"
2064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002065run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002066 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2067 "$P_CLI nbio=2 tickets=1" \
2068 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002069 -S "mbedtls_ssl_handshake returned" \
2070 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002071 -c "Read from server: .* bytes read"
2072
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002073run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002074 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2075 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2076 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002077 -S "mbedtls_ssl_handshake returned" \
2078 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002079 -c "Read from server: .* bytes read"
2080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002081run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002082 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2083 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2084 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002085 -S "mbedtls_ssl_handshake returned" \
2086 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002087 -c "Read from server: .* bytes read"
2088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002089run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002090 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2091 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2092 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002093 -S "mbedtls_ssl_handshake returned" \
2094 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002095 -c "Read from server: .* bytes read"
2096
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002097# Tests for version negotiation
2098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002099run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002100 "$P_SRV" \
2101 "$P_CLI" \
2102 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002103 -S "mbedtls_ssl_handshake returned" \
2104 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002105 -s "Protocol is TLSv1.2" \
2106 -c "Protocol is TLSv1.2"
2107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002108run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002109 "$P_SRV" \
2110 "$P_CLI max_version=tls1_1" \
2111 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002112 -S "mbedtls_ssl_handshake returned" \
2113 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002114 -s "Protocol is TLSv1.1" \
2115 -c "Protocol is TLSv1.1"
2116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002117run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002118 "$P_SRV max_version=tls1_1" \
2119 "$P_CLI" \
2120 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002121 -S "mbedtls_ssl_handshake returned" \
2122 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002123 -s "Protocol is TLSv1.1" \
2124 -c "Protocol is TLSv1.1"
2125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002126run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002127 "$P_SRV max_version=tls1_1" \
2128 "$P_CLI max_version=tls1_1" \
2129 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002130 -S "mbedtls_ssl_handshake returned" \
2131 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002132 -s "Protocol is TLSv1.1" \
2133 -c "Protocol is TLSv1.1"
2134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002135run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002136 "$P_SRV min_version=tls1_1" \
2137 "$P_CLI max_version=tls1_1" \
2138 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002139 -S "mbedtls_ssl_handshake returned" \
2140 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002141 -s "Protocol is TLSv1.1" \
2142 -c "Protocol is TLSv1.1"
2143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002144run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002145 "$P_SRV max_version=tls1_1" \
2146 "$P_CLI min_version=tls1_1" \
2147 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002148 -S "mbedtls_ssl_handshake returned" \
2149 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002150 -s "Protocol is TLSv1.1" \
2151 -c "Protocol is TLSv1.1"
2152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002153run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002154 "$P_SRV max_version=tls1_1" \
2155 "$P_CLI min_version=tls1_2" \
2156 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002157 -s "mbedtls_ssl_handshake returned" \
2158 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002159 -c "SSL - Handshake protocol not within min/max boundaries"
2160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002161run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002162 "$P_SRV min_version=tls1_2" \
2163 "$P_CLI max_version=tls1_1" \
2164 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002165 -s "mbedtls_ssl_handshake returned" \
2166 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002167 -s "SSL - Handshake protocol not within min/max boundaries"
2168
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002169# Tests for ALPN extension
2170
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002171run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002172 "$P_SRV debug_level=3" \
2173 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002174 0 \
2175 -C "client hello, adding alpn extension" \
2176 -S "found alpn extension" \
2177 -C "got an alert message, type: \\[2:120]" \
2178 -S "server hello, adding alpn extension" \
2179 -C "found alpn extension " \
2180 -C "Application Layer Protocol is" \
2181 -S "Application Layer Protocol is"
2182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002183run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002184 "$P_SRV debug_level=3" \
2185 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002186 0 \
2187 -c "client hello, adding alpn extension" \
2188 -s "found alpn extension" \
2189 -C "got an alert message, type: \\[2:120]" \
2190 -S "server hello, adding alpn extension" \
2191 -C "found alpn extension " \
2192 -c "Application Layer Protocol is (none)" \
2193 -S "Application Layer Protocol is"
2194
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002195run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002196 "$P_SRV debug_level=3 alpn=abc,1234" \
2197 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002198 0 \
2199 -C "client hello, adding alpn extension" \
2200 -S "found alpn extension" \
2201 -C "got an alert message, type: \\[2:120]" \
2202 -S "server hello, adding alpn extension" \
2203 -C "found alpn extension " \
2204 -C "Application Layer Protocol is" \
2205 -s "Application Layer Protocol is (none)"
2206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002207run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002208 "$P_SRV debug_level=3 alpn=abc,1234" \
2209 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002210 0 \
2211 -c "client hello, adding alpn extension" \
2212 -s "found alpn extension" \
2213 -C "got an alert message, type: \\[2:120]" \
2214 -s "server hello, adding alpn extension" \
2215 -c "found alpn extension" \
2216 -c "Application Layer Protocol is abc" \
2217 -s "Application Layer Protocol is abc"
2218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002219run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002220 "$P_SRV debug_level=3 alpn=abc,1234" \
2221 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002222 0 \
2223 -c "client hello, adding alpn extension" \
2224 -s "found alpn extension" \
2225 -C "got an alert message, type: \\[2:120]" \
2226 -s "server hello, adding alpn extension" \
2227 -c "found alpn extension" \
2228 -c "Application Layer Protocol is abc" \
2229 -s "Application Layer Protocol is abc"
2230
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002231run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002232 "$P_SRV debug_level=3 alpn=abc,1234" \
2233 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002234 0 \
2235 -c "client hello, adding alpn extension" \
2236 -s "found alpn extension" \
2237 -C "got an alert message, type: \\[2:120]" \
2238 -s "server hello, adding alpn extension" \
2239 -c "found alpn extension" \
2240 -c "Application Layer Protocol is 1234" \
2241 -s "Application Layer Protocol is 1234"
2242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002243run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002244 "$P_SRV debug_level=3 alpn=abc,123" \
2245 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002246 1 \
2247 -c "client hello, adding alpn extension" \
2248 -s "found alpn extension" \
2249 -c "got an alert message, type: \\[2:120]" \
2250 -S "server hello, adding alpn extension" \
2251 -C "found alpn extension" \
2252 -C "Application Layer Protocol is 1234" \
2253 -S "Application Layer Protocol is 1234"
2254
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002255
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002256# Tests for keyUsage in leaf certificates, part 1:
2257# server-side certificate/suite selection
2258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002259run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002260 "$P_SRV key_file=data_files/server2.key \
2261 crt_file=data_files/server2.ku-ds.crt" \
2262 "$P_CLI" \
2263 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002264 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002265
2266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002267run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002268 "$P_SRV key_file=data_files/server2.key \
2269 crt_file=data_files/server2.ku-ke.crt" \
2270 "$P_CLI" \
2271 0 \
2272 -c "Ciphersuite is TLS-RSA-WITH-"
2273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002274run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002275 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002276 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002277 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002278 1 \
2279 -C "Ciphersuite is "
2280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002281run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002282 "$P_SRV key_file=data_files/server5.key \
2283 crt_file=data_files/server5.ku-ds.crt" \
2284 "$P_CLI" \
2285 0 \
2286 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2287
2288
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002289run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002290 "$P_SRV key_file=data_files/server5.key \
2291 crt_file=data_files/server5.ku-ka.crt" \
2292 "$P_CLI" \
2293 0 \
2294 -c "Ciphersuite is TLS-ECDH-"
2295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002296run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002297 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002298 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002299 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002300 1 \
2301 -C "Ciphersuite is "
2302
2303# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002304# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002306run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002307 "$O_SRV -key data_files/server2.key \
2308 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002309 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002310 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2311 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002312 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002313 -C "Processing of the Certificate handshake message failed" \
2314 -c "Ciphersuite is TLS-"
2315
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002316run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002317 "$O_SRV -key data_files/server2.key \
2318 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002319 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002320 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2321 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002322 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002323 -C "Processing of the Certificate handshake message failed" \
2324 -c "Ciphersuite is TLS-"
2325
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002326run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002327 "$O_SRV -key data_files/server2.key \
2328 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002329 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002330 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2331 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002332 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002333 -C "Processing of the Certificate handshake message failed" \
2334 -c "Ciphersuite is TLS-"
2335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002336run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002337 "$O_SRV -key data_files/server2.key \
2338 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002339 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002340 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2341 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002342 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002343 -c "Processing of the Certificate handshake message failed" \
2344 -C "Ciphersuite is TLS-"
2345
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002346run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2347 "$O_SRV -key data_files/server2.key \
2348 -cert data_files/server2.ku-ke.crt" \
2349 "$P_CLI debug_level=1 auth_mode=optional \
2350 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2351 0 \
2352 -c "bad certificate (usage extensions)" \
2353 -C "Processing of the Certificate handshake message failed" \
2354 -c "Ciphersuite is TLS-" \
2355 -c "! Usage does not match the keyUsage extension"
2356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002357run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002358 "$O_SRV -key data_files/server2.key \
2359 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002360 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002361 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2362 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002363 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002364 -C "Processing of the Certificate handshake message failed" \
2365 -c "Ciphersuite is TLS-"
2366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002367run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002368 "$O_SRV -key data_files/server2.key \
2369 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002370 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002371 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2372 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002373 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002374 -c "Processing of the Certificate handshake message failed" \
2375 -C "Ciphersuite is TLS-"
2376
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002377run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2378 "$O_SRV -key data_files/server2.key \
2379 -cert data_files/server2.ku-ds.crt" \
2380 "$P_CLI debug_level=1 auth_mode=optional \
2381 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2382 0 \
2383 -c "bad certificate (usage extensions)" \
2384 -C "Processing of the Certificate handshake message failed" \
2385 -c "Ciphersuite is TLS-" \
2386 -c "! Usage does not match the keyUsage extension"
2387
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002388# Tests for keyUsage in leaf certificates, part 3:
2389# server-side checking of client cert
2390
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002391run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002392 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002393 "$O_CLI -key data_files/server2.key \
2394 -cert data_files/server2.ku-ds.crt" \
2395 0 \
2396 -S "bad certificate (usage extensions)" \
2397 -S "Processing of the Certificate handshake message failed"
2398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002399run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002400 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002401 "$O_CLI -key data_files/server2.key \
2402 -cert data_files/server2.ku-ke.crt" \
2403 0 \
2404 -s "bad certificate (usage extensions)" \
2405 -S "Processing of the Certificate handshake message failed"
2406
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002407run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002408 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002409 "$O_CLI -key data_files/server2.key \
2410 -cert data_files/server2.ku-ke.crt" \
2411 1 \
2412 -s "bad certificate (usage extensions)" \
2413 -s "Processing of the Certificate handshake message failed"
2414
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002415run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002416 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002417 "$O_CLI -key data_files/server5.key \
2418 -cert data_files/server5.ku-ds.crt" \
2419 0 \
2420 -S "bad certificate (usage extensions)" \
2421 -S "Processing of the Certificate handshake message failed"
2422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002423run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002424 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002425 "$O_CLI -key data_files/server5.key \
2426 -cert data_files/server5.ku-ka.crt" \
2427 0 \
2428 -s "bad certificate (usage extensions)" \
2429 -S "Processing of the Certificate handshake message failed"
2430
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002431# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2432
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002433run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002434 "$P_SRV key_file=data_files/server5.key \
2435 crt_file=data_files/server5.eku-srv.crt" \
2436 "$P_CLI" \
2437 0
2438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002439run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002440 "$P_SRV key_file=data_files/server5.key \
2441 crt_file=data_files/server5.eku-srv.crt" \
2442 "$P_CLI" \
2443 0
2444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002445run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002446 "$P_SRV key_file=data_files/server5.key \
2447 crt_file=data_files/server5.eku-cs_any.crt" \
2448 "$P_CLI" \
2449 0
2450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002451run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002452 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002453 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002454 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002455 1
2456
2457# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002459run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002460 "$O_SRV -key data_files/server5.key \
2461 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002462 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002463 0 \
2464 -C "bad certificate (usage extensions)" \
2465 -C "Processing of the Certificate handshake message failed" \
2466 -c "Ciphersuite is TLS-"
2467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002468run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002469 "$O_SRV -key data_files/server5.key \
2470 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002471 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002472 0 \
2473 -C "bad certificate (usage extensions)" \
2474 -C "Processing of the Certificate handshake message failed" \
2475 -c "Ciphersuite is TLS-"
2476
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002477run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002478 "$O_SRV -key data_files/server5.key \
2479 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002480 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002481 0 \
2482 -C "bad certificate (usage extensions)" \
2483 -C "Processing of the Certificate handshake message failed" \
2484 -c "Ciphersuite is TLS-"
2485
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002486run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002487 "$O_SRV -key data_files/server5.key \
2488 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002489 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002490 1 \
2491 -c "bad certificate (usage extensions)" \
2492 -c "Processing of the Certificate handshake message failed" \
2493 -C "Ciphersuite is TLS-"
2494
2495# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002497run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002498 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002499 "$O_CLI -key data_files/server5.key \
2500 -cert data_files/server5.eku-cli.crt" \
2501 0 \
2502 -S "bad certificate (usage extensions)" \
2503 -S "Processing of the Certificate handshake message failed"
2504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002505run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002506 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002507 "$O_CLI -key data_files/server5.key \
2508 -cert data_files/server5.eku-srv_cli.crt" \
2509 0 \
2510 -S "bad certificate (usage extensions)" \
2511 -S "Processing of the Certificate handshake message failed"
2512
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002513run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002514 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002515 "$O_CLI -key data_files/server5.key \
2516 -cert data_files/server5.eku-cs_any.crt" \
2517 0 \
2518 -S "bad certificate (usage extensions)" \
2519 -S "Processing of the Certificate handshake message failed"
2520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002521run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002522 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002523 "$O_CLI -key data_files/server5.key \
2524 -cert data_files/server5.eku-cs.crt" \
2525 0 \
2526 -s "bad certificate (usage extensions)" \
2527 -S "Processing of the Certificate handshake message failed"
2528
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002529run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002530 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002531 "$O_CLI -key data_files/server5.key \
2532 -cert data_files/server5.eku-cs.crt" \
2533 1 \
2534 -s "bad certificate (usage extensions)" \
2535 -s "Processing of the Certificate handshake message failed"
2536
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002537# Tests for DHM parameters loading
2538
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002539run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002540 "$P_SRV" \
2541 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2542 debug_level=3" \
2543 0 \
2544 -c "value of 'DHM: P ' (2048 bits)" \
2545 -c "value of 'DHM: G ' (2048 bits)"
2546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002547run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002548 "$P_SRV dhm_file=data_files/dhparams.pem" \
2549 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2550 debug_level=3" \
2551 0 \
2552 -c "value of 'DHM: P ' (1024 bits)" \
2553 -c "value of 'DHM: G ' (2 bits)"
2554
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002555# Tests for DHM client-side size checking
2556
2557run_test "DHM size: server default, client default, OK" \
2558 "$P_SRV" \
2559 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2560 debug_level=1" \
2561 0 \
2562 -C "DHM prime too short:"
2563
2564run_test "DHM size: server default, client 2048, OK" \
2565 "$P_SRV" \
2566 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2567 debug_level=1 dhmlen=2048" \
2568 0 \
2569 -C "DHM prime too short:"
2570
2571run_test "DHM size: server 1024, client default, OK" \
2572 "$P_SRV dhm_file=data_files/dhparams.pem" \
2573 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2574 debug_level=1" \
2575 0 \
2576 -C "DHM prime too short:"
2577
2578run_test "DHM size: server 1000, client default, rejected" \
2579 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2580 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2581 debug_level=1" \
2582 1 \
2583 -c "DHM prime too short:"
2584
2585run_test "DHM size: server default, client 2049, rejected" \
2586 "$P_SRV" \
2587 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2588 debug_level=1 dhmlen=2049" \
2589 1 \
2590 -c "DHM prime too short:"
2591
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002592# Tests for PSK callback
2593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002594run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002595 "$P_SRV psk=abc123 psk_identity=foo" \
2596 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2597 psk_identity=foo psk=abc123" \
2598 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002599 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002600 -S "SSL - Unknown identity received" \
2601 -S "SSL - Verification of the message MAC failed"
2602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002603run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002604 "$P_SRV" \
2605 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2606 psk_identity=foo psk=abc123" \
2607 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002608 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002609 -S "SSL - Unknown identity received" \
2610 -S "SSL - Verification of the message MAC failed"
2611
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002612run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002613 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2614 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2615 psk_identity=foo psk=abc123" \
2616 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002617 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002618 -s "SSL - Unknown identity received" \
2619 -S "SSL - Verification of the message MAC failed"
2620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002621run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002622 "$P_SRV psk_list=abc,dead,def,beef" \
2623 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2624 psk_identity=abc psk=dead" \
2625 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002626 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002627 -S "SSL - Unknown identity received" \
2628 -S "SSL - Verification of the message MAC failed"
2629
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002630run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002631 "$P_SRV psk_list=abc,dead,def,beef" \
2632 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2633 psk_identity=def psk=beef" \
2634 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002635 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002636 -S "SSL - Unknown identity received" \
2637 -S "SSL - Verification of the message MAC failed"
2638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002639run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002640 "$P_SRV psk_list=abc,dead,def,beef" \
2641 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2642 psk_identity=ghi psk=beef" \
2643 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002644 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002645 -s "SSL - Unknown identity received" \
2646 -S "SSL - Verification of the message MAC failed"
2647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002648run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002649 "$P_SRV psk_list=abc,dead,def,beef" \
2650 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2651 psk_identity=abc psk=beef" \
2652 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002653 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002654 -S "SSL - Unknown identity received" \
2655 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002656
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002657# Tests for ciphersuites per version
2658
Janos Follath542ee5d2016-03-07 15:57:05 +00002659requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002660run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002661 "$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 +02002662 "$P_CLI force_version=ssl3" \
2663 0 \
2664 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002666run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002667 "$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 +01002668 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002669 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002670 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002672run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002673 "$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 +02002674 "$P_CLI force_version=tls1_1" \
2675 0 \
2676 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002678run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002679 "$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 +02002680 "$P_CLI force_version=tls1_2" \
2681 0 \
2682 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2683
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002684# Test for ClientHello without extensions
2685
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002686requires_gnutls
2687run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002688 "$P_SRV debug_level=3" \
2689 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2690 0 \
2691 -s "dumping 'client hello extensions' (0 bytes)"
2692
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002693# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002694
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002695run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002696 "$P_SRV" \
2697 "$P_CLI request_size=100" \
2698 0 \
2699 -s "Read from client: 100 bytes read$"
2700
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002701run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002702 "$P_SRV" \
2703 "$P_CLI request_size=500" \
2704 0 \
2705 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002706
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002707# Tests for small packets
2708
Janos Follath542ee5d2016-03-07 15:57:05 +00002709requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002710run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002711 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002712 "$P_CLI request_size=1 force_version=ssl3 \
2713 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2714 0 \
2715 -s "Read from client: 1 bytes read"
2716
Janos Follath542ee5d2016-03-07 15:57:05 +00002717requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002718run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002719 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002720 "$P_CLI request_size=1 force_version=ssl3 \
2721 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2722 0 \
2723 -s "Read from client: 1 bytes read"
2724
2725run_test "Small packet TLS 1.0 BlockCipher" \
2726 "$P_SRV" \
2727 "$P_CLI request_size=1 force_version=tls1 \
2728 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2729 0 \
2730 -s "Read from client: 1 bytes read"
2731
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002732run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2733 "$P_SRV" \
2734 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2735 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2736 0 \
2737 -s "Read from client: 1 bytes read"
2738
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002739run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2740 "$P_SRV" \
2741 "$P_CLI request_size=1 force_version=tls1 \
2742 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2743 trunc_hmac=1" \
2744 0 \
2745 -s "Read from client: 1 bytes read"
2746
2747run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002748 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002749 "$P_CLI request_size=1 force_version=tls1 \
2750 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2751 trunc_hmac=1" \
2752 0 \
2753 -s "Read from client: 1 bytes read"
2754
2755run_test "Small packet TLS 1.1 BlockCipher" \
2756 "$P_SRV" \
2757 "$P_CLI request_size=1 force_version=tls1_1 \
2758 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2759 0 \
2760 -s "Read from client: 1 bytes read"
2761
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002762run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2763 "$P_SRV" \
2764 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2765 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2766 0 \
2767 -s "Read from client: 1 bytes read"
2768
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002769run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002770 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002771 "$P_CLI request_size=1 force_version=tls1_1 \
2772 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2773 0 \
2774 -s "Read from client: 1 bytes read"
2775
2776run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2777 "$P_SRV" \
2778 "$P_CLI request_size=1 force_version=tls1_1 \
2779 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2780 trunc_hmac=1" \
2781 0 \
2782 -s "Read from client: 1 bytes read"
2783
2784run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002785 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002786 "$P_CLI request_size=1 force_version=tls1_1 \
2787 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2788 trunc_hmac=1" \
2789 0 \
2790 -s "Read from client: 1 bytes read"
2791
2792run_test "Small packet TLS 1.2 BlockCipher" \
2793 "$P_SRV" \
2794 "$P_CLI request_size=1 force_version=tls1_2 \
2795 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2796 0 \
2797 -s "Read from client: 1 bytes read"
2798
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002799run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2800 "$P_SRV" \
2801 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2802 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2803 0 \
2804 -s "Read from client: 1 bytes read"
2805
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002806run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2807 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002808 "$P_CLI request_size=1 force_version=tls1_2 \
2809 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002810 0 \
2811 -s "Read from client: 1 bytes read"
2812
2813run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2814 "$P_SRV" \
2815 "$P_CLI request_size=1 force_version=tls1_2 \
2816 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2817 trunc_hmac=1" \
2818 0 \
2819 -s "Read from client: 1 bytes read"
2820
2821run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002822 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002823 "$P_CLI request_size=1 force_version=tls1_2 \
2824 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2825 0 \
2826 -s "Read from client: 1 bytes read"
2827
2828run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002829 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002830 "$P_CLI request_size=1 force_version=tls1_2 \
2831 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2832 trunc_hmac=1" \
2833 0 \
2834 -s "Read from client: 1 bytes read"
2835
2836run_test "Small packet TLS 1.2 AEAD" \
2837 "$P_SRV" \
2838 "$P_CLI request_size=1 force_version=tls1_2 \
2839 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2840 0 \
2841 -s "Read from client: 1 bytes read"
2842
2843run_test "Small packet TLS 1.2 AEAD shorter tag" \
2844 "$P_SRV" \
2845 "$P_CLI request_size=1 force_version=tls1_2 \
2846 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2847 0 \
2848 -s "Read from client: 1 bytes read"
2849
Janos Follathb700c462016-05-06 13:48:23 +01002850# A test for extensions in SSLv3
2851
2852requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2853run_test "SSLv3 with extensions, server side" \
2854 "$P_SRV min_version=ssl3 debug_level=3" \
2855 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2856 0 \
2857 -S "dumping 'client hello extensions'" \
2858 -S "server hello, total extension length:"
2859
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002860# Test for large packets
2861
Janos Follath542ee5d2016-03-07 15:57:05 +00002862requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002863run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002864 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002865 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002866 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2867 0 \
2868 -s "Read from client: 16384 bytes read"
2869
Janos Follath542ee5d2016-03-07 15:57:05 +00002870requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002871run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002872 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002873 "$P_CLI request_size=16384 force_version=ssl3 \
2874 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2875 0 \
2876 -s "Read from client: 16384 bytes read"
2877
2878run_test "Large packet TLS 1.0 BlockCipher" \
2879 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002880 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002881 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2882 0 \
2883 -s "Read from client: 16384 bytes read"
2884
2885run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2886 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002887 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002888 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2889 trunc_hmac=1" \
2890 0 \
2891 -s "Read from client: 16384 bytes read"
2892
2893run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002894 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002895 "$P_CLI request_size=16384 force_version=tls1 \
2896 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2897 trunc_hmac=1" \
2898 0 \
2899 -s "Read from client: 16384 bytes read"
2900
2901run_test "Large packet TLS 1.1 BlockCipher" \
2902 "$P_SRV" \
2903 "$P_CLI request_size=16384 force_version=tls1_1 \
2904 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2905 0 \
2906 -s "Read from client: 16384 bytes read"
2907
2908run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002909 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002910 "$P_CLI request_size=16384 force_version=tls1_1 \
2911 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2912 0 \
2913 -s "Read from client: 16384 bytes read"
2914
2915run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2916 "$P_SRV" \
2917 "$P_CLI request_size=16384 force_version=tls1_1 \
2918 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2919 trunc_hmac=1" \
2920 0 \
2921 -s "Read from client: 16384 bytes read"
2922
2923run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002924 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002925 "$P_CLI request_size=16384 force_version=tls1_1 \
2926 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2927 trunc_hmac=1" \
2928 0 \
2929 -s "Read from client: 16384 bytes read"
2930
2931run_test "Large packet TLS 1.2 BlockCipher" \
2932 "$P_SRV" \
2933 "$P_CLI request_size=16384 force_version=tls1_2 \
2934 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2935 0 \
2936 -s "Read from client: 16384 bytes read"
2937
2938run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2939 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002940 "$P_CLI request_size=16384 force_version=tls1_2 \
2941 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002942 0 \
2943 -s "Read from client: 16384 bytes read"
2944
2945run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2946 "$P_SRV" \
2947 "$P_CLI request_size=16384 force_version=tls1_2 \
2948 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2949 trunc_hmac=1" \
2950 0 \
2951 -s "Read from client: 16384 bytes read"
2952
2953run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002954 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002955 "$P_CLI request_size=16384 force_version=tls1_2 \
2956 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2957 0 \
2958 -s "Read from client: 16384 bytes read"
2959
2960run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002961 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002962 "$P_CLI request_size=16384 force_version=tls1_2 \
2963 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2964 trunc_hmac=1" \
2965 0 \
2966 -s "Read from client: 16384 bytes read"
2967
2968run_test "Large packet TLS 1.2 AEAD" \
2969 "$P_SRV" \
2970 "$P_CLI request_size=16384 force_version=tls1_2 \
2971 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2972 0 \
2973 -s "Read from client: 16384 bytes read"
2974
2975run_test "Large packet TLS 1.2 AEAD shorter tag" \
2976 "$P_SRV" \
2977 "$P_CLI request_size=16384 force_version=tls1_2 \
2978 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2979 0 \
2980 -s "Read from client: 16384 bytes read"
2981
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002982# Tests for DTLS HelloVerifyRequest
2983
2984run_test "DTLS cookie: enabled" \
2985 "$P_SRV dtls=1 debug_level=2" \
2986 "$P_CLI dtls=1 debug_level=2" \
2987 0 \
2988 -s "cookie verification failed" \
2989 -s "cookie verification passed" \
2990 -S "cookie verification skipped" \
2991 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002992 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002993 -S "SSL - The requested feature is not available"
2994
2995run_test "DTLS cookie: disabled" \
2996 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2997 "$P_CLI dtls=1 debug_level=2" \
2998 0 \
2999 -S "cookie verification failed" \
3000 -S "cookie verification passed" \
3001 -s "cookie verification skipped" \
3002 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003003 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003004 -S "SSL - The requested feature is not available"
3005
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003006run_test "DTLS cookie: default (failing)" \
3007 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3008 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3009 1 \
3010 -s "cookie verification failed" \
3011 -S "cookie verification passed" \
3012 -S "cookie verification skipped" \
3013 -C "received hello verify request" \
3014 -S "hello verification requested" \
3015 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003016
3017requires_ipv6
3018run_test "DTLS cookie: enabled, IPv6" \
3019 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3020 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3021 0 \
3022 -s "cookie verification failed" \
3023 -s "cookie verification passed" \
3024 -S "cookie verification skipped" \
3025 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003026 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003027 -S "SSL - The requested feature is not available"
3028
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003029run_test "DTLS cookie: enabled, nbio" \
3030 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3031 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3032 0 \
3033 -s "cookie verification failed" \
3034 -s "cookie verification passed" \
3035 -S "cookie verification skipped" \
3036 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003037 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003038 -S "SSL - The requested feature is not available"
3039
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003040# Tests for client reconnecting from the same port with DTLS
3041
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003042not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003043run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003044 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3045 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003046 0 \
3047 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003048 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003049 -S "Client initiated reconnection from same port"
3050
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003051not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003052run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003053 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3054 "$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 +02003055 0 \
3056 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003057 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003058 -s "Client initiated reconnection from same port"
3059
Paul Bakker3b224ff2016-05-13 10:33:25 +01003060not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3061run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003062 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3063 "$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 +02003064 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003065 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003066 -s "Client initiated reconnection from same port"
3067
Paul Bakker3b224ff2016-05-13 10:33:25 +01003068only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3069run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3070 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3071 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3072 0 \
3073 -S "The operation timed out" \
3074 -s "Client initiated reconnection from same port"
3075
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003076run_test "DTLS client reconnect from same port: no cookies" \
3077 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003078 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3079 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003080 -s "The operation timed out" \
3081 -S "Client initiated reconnection from same port"
3082
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003083# Tests for various cases of client authentication with DTLS
3084# (focused on handshake flows and message parsing)
3085
3086run_test "DTLS client auth: required" \
3087 "$P_SRV dtls=1 auth_mode=required" \
3088 "$P_CLI dtls=1" \
3089 0 \
3090 -s "Verifying peer X.509 certificate... ok"
3091
3092run_test "DTLS client auth: optional, client has no cert" \
3093 "$P_SRV dtls=1 auth_mode=optional" \
3094 "$P_CLI dtls=1 crt_file=none key_file=none" \
3095 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003096 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003097
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003098run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003099 "$P_SRV dtls=1 auth_mode=none" \
3100 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3101 0 \
3102 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003103 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003104
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003105run_test "DTLS wrong PSK: badmac alert" \
3106 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3107 "$P_CLI dtls=1 psk=abc124" \
3108 1 \
3109 -s "SSL - Verification of the message MAC failed" \
3110 -c "SSL - A fatal alert message was received from our peer"
3111
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003112# Tests for receiving fragmented handshake messages with DTLS
3113
3114requires_gnutls
3115run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3116 "$G_SRV -u --mtu 2048 -a" \
3117 "$P_CLI dtls=1 debug_level=2" \
3118 0 \
3119 -C "found fragmented DTLS handshake message" \
3120 -C "error"
3121
3122requires_gnutls
3123run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3124 "$G_SRV -u --mtu 512" \
3125 "$P_CLI dtls=1 debug_level=2" \
3126 0 \
3127 -c "found fragmented DTLS handshake message" \
3128 -C "error"
3129
3130requires_gnutls
3131run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3132 "$G_SRV -u --mtu 128" \
3133 "$P_CLI dtls=1 debug_level=2" \
3134 0 \
3135 -c "found fragmented DTLS handshake message" \
3136 -C "error"
3137
3138requires_gnutls
3139run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3140 "$G_SRV -u --mtu 128" \
3141 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3142 0 \
3143 -c "found fragmented DTLS handshake message" \
3144 -C "error"
3145
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003146requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003147run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3148 "$G_SRV -u --mtu 256" \
3149 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3150 0 \
3151 -c "found fragmented DTLS handshake message" \
3152 -c "client hello, adding renegotiation extension" \
3153 -c "found renegotiation extension" \
3154 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003155 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003156 -C "error" \
3157 -s "Extra-header:"
3158
3159requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003160run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3161 "$G_SRV -u --mtu 256" \
3162 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3163 0 \
3164 -c "found fragmented DTLS handshake message" \
3165 -c "client hello, adding renegotiation extension" \
3166 -c "found renegotiation extension" \
3167 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003168 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003169 -C "error" \
3170 -s "Extra-header:"
3171
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003172run_test "DTLS reassembly: no fragmentation (openssl server)" \
3173 "$O_SRV -dtls1 -mtu 2048" \
3174 "$P_CLI dtls=1 debug_level=2" \
3175 0 \
3176 -C "found fragmented DTLS handshake message" \
3177 -C "error"
3178
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003179run_test "DTLS reassembly: some fragmentation (openssl server)" \
3180 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003181 "$P_CLI dtls=1 debug_level=2" \
3182 0 \
3183 -c "found fragmented DTLS handshake message" \
3184 -C "error"
3185
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003186run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003187 "$O_SRV -dtls1 -mtu 256" \
3188 "$P_CLI dtls=1 debug_level=2" \
3189 0 \
3190 -c "found fragmented DTLS handshake message" \
3191 -C "error"
3192
3193run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3194 "$O_SRV -dtls1 -mtu 256" \
3195 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3196 0 \
3197 -c "found fragmented DTLS handshake message" \
3198 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003199
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003200# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003201
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003202not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003203run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003204 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003205 "$P_SRV dtls=1 debug_level=2" \
3206 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003207 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003208 -C "replayed record" \
3209 -S "replayed record" \
3210 -C "record from another epoch" \
3211 -S "record from another epoch" \
3212 -C "discarding invalid record" \
3213 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003214 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003215 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003216 -c "HTTP/1.0 200 OK"
3217
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003218not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003219run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003220 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003221 "$P_SRV dtls=1 debug_level=2" \
3222 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003223 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003224 -c "replayed record" \
3225 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003226 -c "discarding invalid record" \
3227 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003228 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003229 -s "Extra-header:" \
3230 -c "HTTP/1.0 200 OK"
3231
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003232run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3233 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003234 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3235 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003236 0 \
3237 -c "replayed record" \
3238 -S "replayed record" \
3239 -c "discarding invalid record" \
3240 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003241 -c "resend" \
3242 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003243 -s "Extra-header:" \
3244 -c "HTTP/1.0 200 OK"
3245
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003246run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003247 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003248 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003249 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003250 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003251 -c "discarding invalid record (mac)" \
3252 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003253 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003254 -c "HTTP/1.0 200 OK" \
3255 -S "too many records with bad MAC" \
3256 -S "Verification of the message MAC failed"
3257
3258run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3259 -p "$P_PXY bad_ad=1" \
3260 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3261 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3262 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003263 -C "discarding invalid record (mac)" \
3264 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003265 -S "Extra-header:" \
3266 -C "HTTP/1.0 200 OK" \
3267 -s "too many records with bad MAC" \
3268 -s "Verification of the message MAC failed"
3269
3270run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3271 -p "$P_PXY bad_ad=1" \
3272 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3273 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3274 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003275 -c "discarding invalid record (mac)" \
3276 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003277 -s "Extra-header:" \
3278 -c "HTTP/1.0 200 OK" \
3279 -S "too many records with bad MAC" \
3280 -S "Verification of the message MAC failed"
3281
3282run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3283 -p "$P_PXY bad_ad=1" \
3284 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3285 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3286 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003287 -c "discarding invalid record (mac)" \
3288 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003289 -s "Extra-header:" \
3290 -c "HTTP/1.0 200 OK" \
3291 -s "too many records with bad MAC" \
3292 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003293
3294run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003295 -p "$P_PXY delay_ccs=1" \
3296 "$P_SRV dtls=1 debug_level=1" \
3297 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003298 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003299 -c "record from another epoch" \
3300 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003301 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003302 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003303 -s "Extra-header:" \
3304 -c "HTTP/1.0 200 OK"
3305
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003306# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003307
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003308needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003309run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003310 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003311 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3312 psk=abc123" \
3313 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003314 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3315 0 \
3316 -s "Extra-header:" \
3317 -c "HTTP/1.0 200 OK"
3318
3319needs_more_time 2
3320run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3321 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003322 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3323 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003324 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3325 0 \
3326 -s "Extra-header:" \
3327 -c "HTTP/1.0 200 OK"
3328
3329needs_more_time 2
3330run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3331 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003332 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3333 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003334 0 \
3335 -s "Extra-header:" \
3336 -c "HTTP/1.0 200 OK"
3337
3338needs_more_time 2
3339run_test "DTLS proxy: 3d, FS, client auth" \
3340 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003341 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3342 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003343 0 \
3344 -s "Extra-header:" \
3345 -c "HTTP/1.0 200 OK"
3346
3347needs_more_time 2
3348run_test "DTLS proxy: 3d, FS, ticket" \
3349 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003350 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3351 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003352 0 \
3353 -s "Extra-header:" \
3354 -c "HTTP/1.0 200 OK"
3355
3356needs_more_time 2
3357run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3358 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003359 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3360 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003361 0 \
3362 -s "Extra-header:" \
3363 -c "HTTP/1.0 200 OK"
3364
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003365needs_more_time 2
3366run_test "DTLS proxy: 3d, max handshake, nbio" \
3367 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003368 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3369 auth_mode=required" \
3370 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003371 0 \
3372 -s "Extra-header:" \
3373 -c "HTTP/1.0 200 OK"
3374
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003375needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003376run_test "DTLS proxy: 3d, min handshake, resumption" \
3377 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3378 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3379 psk=abc123 debug_level=3" \
3380 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3381 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3382 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3383 0 \
3384 -s "a session has been resumed" \
3385 -c "a session has been resumed" \
3386 -s "Extra-header:" \
3387 -c "HTTP/1.0 200 OK"
3388
3389needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003390run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3391 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3392 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3393 psk=abc123 debug_level=3 nbio=2" \
3394 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3395 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3396 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3397 0 \
3398 -s "a session has been resumed" \
3399 -c "a session has been resumed" \
3400 -s "Extra-header:" \
3401 -c "HTTP/1.0 200 OK"
3402
3403needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003404run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003405 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003406 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3407 psk=abc123 renegotiation=1 debug_level=2" \
3408 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3409 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003410 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3411 0 \
3412 -c "=> renegotiate" \
3413 -s "=> renegotiate" \
3414 -s "Extra-header:" \
3415 -c "HTTP/1.0 200 OK"
3416
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003417needs_more_time 4
3418run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3419 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003420 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3421 psk=abc123 renegotiation=1 debug_level=2" \
3422 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3423 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003424 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3425 0 \
3426 -c "=> renegotiate" \
3427 -s "=> renegotiate" \
3428 -s "Extra-header:" \
3429 -c "HTTP/1.0 200 OK"
3430
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003431needs_more_time 4
3432run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003433 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003434 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003435 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003436 debug_level=2" \
3437 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003438 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003439 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3440 0 \
3441 -c "=> renegotiate" \
3442 -s "=> renegotiate" \
3443 -s "Extra-header:" \
3444 -c "HTTP/1.0 200 OK"
3445
3446needs_more_time 4
3447run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003448 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003449 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003450 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003451 debug_level=2 nbio=2" \
3452 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003453 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003454 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3455 0 \
3456 -c "=> renegotiate" \
3457 -s "=> renegotiate" \
3458 -s "Extra-header:" \
3459 -c "HTTP/1.0 200 OK"
3460
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003461needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003462not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003463run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003464 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3465 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003466 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003467 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003468 -c "HTTP/1.0 200 OK"
3469
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003470needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003471not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003472run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3473 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3474 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003475 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003476 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003477 -c "HTTP/1.0 200 OK"
3478
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003479needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003480not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003481run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3482 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3483 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003484 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003485 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003486 -c "HTTP/1.0 200 OK"
3487
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003488requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003489needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003490not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003491run_test "DTLS proxy: 3d, gnutls server" \
3492 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3493 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003494 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003495 0 \
3496 -s "Extra-header:" \
3497 -c "Extra-header:"
3498
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003499requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003500needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003501not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003502run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3503 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3504 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003505 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003506 0 \
3507 -s "Extra-header:" \
3508 -c "Extra-header:"
3509
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003510requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003511needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003512not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003513run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3514 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3515 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003516 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003517 0 \
3518 -s "Extra-header:" \
3519 -c "Extra-header:"
3520
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003521# Final report
3522
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003523echo "------------------------------------------------------------------------"
3524
3525if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003526 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003527else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003528 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003529fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003530PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003531echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003532
3533exit $FAILS