blob: e73d011053952fd427e9afe30c99c6696ca632eb [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010020
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020021O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010022O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020023G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010024G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010025
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010026TESTS=0
27FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020028SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010029
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000030CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020031
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010032MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010033FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020034EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010035
36print_usage() {
37 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010038 printf " -h|--help\tPrint this help.\n"
39 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
40 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
41 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010042}
43
44get_options() {
45 while [ $# -gt 0 ]; do
46 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010047 -f|--filter)
48 shift; FILTER=$1
49 ;;
50 -e|--exclude)
51 shift; EXCLUDE=$1
52 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010053 -m|--memcheck)
54 MEMCHECK=1
55 ;;
56 -h|--help)
57 print_usage
58 exit 0
59 ;;
60 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020061 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 print_usage
63 exit 1
64 ;;
65 esac
66 shift
67 done
68}
69
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010070# skip next test if the flag is not enabled in config.h
71requires_config_enabled() {
72 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
73 SKIP_NEXT="YES"
74 fi
75}
76
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020077# skip next test if OpenSSL doesn't support FALLBACK_SCSV
78requires_openssl_with_fallback_scsv() {
79 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
80 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
81 then
82 OPENSSL_HAS_FBSCSV="YES"
83 else
84 OPENSSL_HAS_FBSCSV="NO"
85 fi
86 fi
87 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
88 SKIP_NEXT="YES"
89 fi
90}
91
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020092# skip next test if GnuTLS isn't available
93requires_gnutls() {
94 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +020095 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020096 GNUTLS_AVAILABLE="YES"
97 else
98 GNUTLS_AVAILABLE="NO"
99 fi
100 fi
101 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
102 SKIP_NEXT="YES"
103 fi
104}
105
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200106# skip next test if IPv6 isn't available on this host
107requires_ipv6() {
108 if [ -z "${HAS_IPV6:-}" ]; then
109 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
110 SRV_PID=$!
111 sleep 1
112 kill $SRV_PID >/dev/null 2>&1
113 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
114 HAS_IPV6="NO"
115 else
116 HAS_IPV6="YES"
117 fi
118 rm -r $SRV_OUT
119 fi
120
121 if [ "$HAS_IPV6" = "NO" ]; then
122 SKIP_NEXT="YES"
123 fi
124}
125
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200126# skip the next test if valgrind is in use
127not_with_valgrind() {
128 if [ "$MEMCHECK" -gt 0 ]; then
129 SKIP_NEXT="YES"
130 fi
131}
132
Paul Bakker3b224ff2016-05-13 10:33:25 +0100133# skip the next test if valgrind is NOT in use
134only_with_valgrind() {
135 if [ "$MEMCHECK" -eq 0 ]; then
136 SKIP_NEXT="YES"
137 fi
138}
139
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200140# multiply the client timeout delay by the given factor for the next test
141needs_more_time() {
142 CLI_DELAY_FACTOR=$1
143}
144
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100145# print_name <name>
146print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100147 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200148 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100149 for i in `seq 1 $LEN`; do printf '.'; done
150 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100151
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200152 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100153}
154
155# fail <message>
156fail() {
157 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100158 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100159
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200160 mv $SRV_OUT o-srv-${TESTS}.log
161 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200162 if [ -n "$PXY_CMD" ]; then
163 mv $PXY_OUT o-pxy-${TESTS}.log
164 fi
165 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100166
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200167 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
168 echo " ! server output:"
169 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200170 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200171 echo " ! client output:"
172 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200173 if [ -n "$PXY_CMD" ]; then
174 echo " ! ========================================================"
175 echo " ! proxy output:"
176 cat o-pxy-${TESTS}.log
177 fi
178 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200179 fi
180
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200181 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100182}
183
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100184# is_polar <cmd_line>
185is_polar() {
186 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
187}
188
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200189# openssl s_server doesn't have -www with DTLS
190check_osrv_dtls() {
191 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
192 NEEDS_INPUT=1
193 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
194 else
195 NEEDS_INPUT=0
196 fi
197}
198
199# provide input to commands that need it
200provide_input() {
201 if [ $NEEDS_INPUT -eq 0 ]; then
202 return
203 fi
204
205 while true; do
206 echo "HTTP/1.0 200 OK"
207 sleep 1
208 done
209}
210
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100211# has_mem_err <log_file_name>
212has_mem_err() {
213 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
214 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
215 then
216 return 1 # false: does not have errors
217 else
218 return 0 # true: has errors
219 fi
220}
221
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200222# wait for server to start: two versions depending on lsof availability
223wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200224 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200225 START_TIME=$( date +%s )
226 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200227
228 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200229 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200230 while [ $DONE -eq 0 ]; do
231 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
232 then
233 DONE=1
234 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
235 echo "SERVERSTART TIMEOUT"
236 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
237 DONE=1
238 fi
239 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200240 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200241 while [ $DONE -eq 0 ]; do
242 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
243 then
244 DONE=1
245 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
246 echo "SERVERSTART TIMEOUT"
247 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
248 DONE=1
249 fi
250 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200251 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200252 else
253 sleep "$START_DELAY"
254 fi
255}
256
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200257# wait for client to terminate and set CLI_EXIT
258# must be called right after starting the client
259wait_client_done() {
260 CLI_PID=$!
261
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200262 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
263 CLI_DELAY_FACTOR=1
264
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200265 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200266 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200267
268 wait $CLI_PID
269 CLI_EXIT=$?
270
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200271 kill $DOG_PID >/dev/null 2>&1
272 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200273
274 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
275}
276
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200277# check if the given command uses dtls and sets global variable DTLS
278detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200279 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200280 DTLS=1
281 else
282 DTLS=0
283 fi
284}
285
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200286# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100287# Options: -s pattern pattern that must be present in server output
288# -c pattern pattern that must be present in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100289# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100290# -S pattern pattern that must be absent in server output
291# -C pattern pattern that must be absent in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100292# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100293run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100294 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200295 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100296
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100297 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
298 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200299 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100300 return
301 fi
302
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100303 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100304
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200305 # should we skip?
306 if [ "X$SKIP_NEXT" = "XYES" ]; then
307 SKIP_NEXT="NO"
308 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200309 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200310 return
311 fi
312
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200313 # does this test use a proxy?
314 if [ "X$1" = "X-p" ]; then
315 PXY_CMD="$2"
316 shift 2
317 else
318 PXY_CMD=""
319 fi
320
321 # get commands and client output
322 SRV_CMD="$1"
323 CLI_CMD="$2"
324 CLI_EXPECT="$3"
325 shift 3
326
327 # fix client port
328 if [ -n "$PXY_CMD" ]; then
329 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
330 else
331 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
332 fi
333
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200334 # update DTLS variable
335 detect_dtls "$SRV_CMD"
336
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100337 # prepend valgrind to our commands if active
338 if [ "$MEMCHECK" -gt 0 ]; then
339 if is_polar "$SRV_CMD"; then
340 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
341 fi
342 if is_polar "$CLI_CMD"; then
343 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
344 fi
345 fi
346
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200347 TIMES_LEFT=2
348 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200349 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200350
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200351 # run the commands
352 if [ -n "$PXY_CMD" ]; then
353 echo "$PXY_CMD" > $PXY_OUT
354 $PXY_CMD >> $PXY_OUT 2>&1 &
355 PXY_PID=$!
356 # assume proxy starts faster than server
357 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200358
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200359 check_osrv_dtls
360 echo "$SRV_CMD" > $SRV_OUT
361 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
362 SRV_PID=$!
363 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200364
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200365 echo "$CLI_CMD" > $CLI_OUT
366 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
367 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100368
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200369 # terminate the server (and the proxy)
370 kill $SRV_PID
371 wait $SRV_PID
372 if [ -n "$PXY_CMD" ]; then
373 kill $PXY_PID >/dev/null 2>&1
374 wait $PXY_PID
375 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100376
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200377 # retry only on timeouts
378 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
379 printf "RETRY "
380 else
381 TIMES_LEFT=0
382 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200383 done
384
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100385 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200386 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100387 # expected client exit to incorrectly succeed in case of catastrophic
388 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100389 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200390 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100391 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100392 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100393 return
394 fi
395 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100396 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200397 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100398 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100399 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100400 return
401 fi
402 fi
403
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100404 # check server exit code
405 if [ $? != 0 ]; then
406 fail "server fail"
407 return
408 fi
409
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100410 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100411 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
412 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100413 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200414 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100415 return
416 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100417
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100418 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200419 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100420 while [ $# -gt 0 ]
421 do
422 case $1 in
423 "-s")
Janos Follath6d3e3382016-09-07 15:48:48 +0100424 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
425 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426 return
427 fi
428 ;;
429
430 "-c")
Janos Follath6d3e3382016-09-07 15:48:48 +0100431 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
432 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100433 return
434 fi
435 ;;
436
437 "-S")
Janos Follath6d3e3382016-09-07 15:48:48 +0100438 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
439 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100440 return
441 fi
442 ;;
443
444 "-C")
Janos Follath6d3e3382016-09-07 15:48:48 +0100445 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
446 fail "pattern '$2' MUST NOT be present in the Client output"
447 return
448 fi
449 ;;
450
451 # The filtering in the following two options (-u and -U) do the following
452 # - ignore valgrind output
453 # - filter out everything but lines right after the pattern occurances
454 # - keep one of each non-unique line
455 # - count how many lines remain
456 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
457 # if there were no duplicates.
458 "-U")
459 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
460 fail "lines following pattern '$2' must be unique in Server output"
461 return
462 fi
463 ;;
464
465 "-u")
466 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
467 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100468 return
469 fi
470 ;;
471
472 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200473 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100474 exit 1
475 esac
476 shift 2
477 done
478
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100479 # check valgrind's results
480 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200481 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100482 fail "Server has memory errors"
483 return
484 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200485 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100486 fail "Client has memory errors"
487 return
488 fi
489 fi
490
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100491 # if we're here, everything is ok
492 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200493 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100494}
495
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100496cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200497 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200498 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
499 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
500 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
501 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100502 exit 1
503}
504
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100505#
506# MAIN
507#
508
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000509if cd $( dirname $0 ); then :; else
510 echo "cd $( dirname $0 ) failed" >&2
511 exit 1
512fi
513
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100514get_options "$@"
515
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100516# sanity checks, avoid an avalanche of errors
517if [ ! -x "$P_SRV" ]; then
518 echo "Command '$P_SRV' is not an executable file"
519 exit 1
520fi
521if [ ! -x "$P_CLI" ]; then
522 echo "Command '$P_CLI' is not an executable file"
523 exit 1
524fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200525if [ ! -x "$P_PXY" ]; then
526 echo "Command '$P_PXY' is not an executable file"
527 exit 1
528fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100529if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
530 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100531 exit 1
532fi
533
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200534# used by watchdog
535MAIN_PID="$$"
536
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200537# be more patient with valgrind
538if [ "$MEMCHECK" -gt 0 ]; then
539 START_DELAY=3
540 DOG_DELAY=30
541else
542 START_DELAY=1
543 DOG_DELAY=10
544fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200545CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200546
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200547# Pick a "unique" server port in the range 10000-19999, and a proxy port
548PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000549PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200550SRV_PORT="1$PORT_BASE"
551PXY_PORT="2$PORT_BASE"
552unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200553
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200554# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000555# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200556P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
557P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
558P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200559O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200560O_CLI="$O_CLI -connect localhost:+SRV_PORT"
561G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000562G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200563
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200564# Also pick a unique name for intermediate files
565SRV_OUT="srv_out.$$"
566CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200567PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200568SESSION="session.$$"
569
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200570SKIP_NEXT="NO"
571
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100572trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100573
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200574# Basic test
575
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200576# Checks that:
577# - things work with all ciphersuites active (used with config-full in all.sh)
578# - the expected (highest security) parameters are selected
579# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200580run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200581 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200582 "$P_CLI" \
583 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200584 -s "Protocol is TLSv1.2" \
585 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
586 -s "client hello v3, signature_algorithm ext: 6" \
587 -s "ECDHE curve: secp521r1" \
588 -S "error" \
589 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200590
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000591run_test "Default, DTLS" \
592 "$P_SRV dtls=1" \
593 "$P_CLI dtls=1" \
594 0 \
595 -s "Protocol is DTLSv1.2" \
596 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
597
Janos Follath6d3e3382016-09-07 15:48:48 +0100598# Test for uniqueness of IVs in AEAD ciphersuites
599run_test "Unique IV in GCM" \
600 "$P_SRV exchanges=20 debug_level=4" \
601 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
602 0 \
603 -u "IV used" \
604 -U "IV used"
605
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100606# Tests for rc4 option
607
Simon Butcher6eb066e2016-05-19 22:12:18 +0100608requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100609run_test "RC4: server disabled, client enabled" \
610 "$P_SRV" \
611 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
612 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100613 -s "SSL - The server has no ciphersuites in common"
614
Simon Butcher6eb066e2016-05-19 22:12:18 +0100615requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100616run_test "RC4: server half, client enabled" \
617 "$P_SRV arc4=1" \
618 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
619 1 \
620 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100621
622run_test "RC4: server enabled, client disabled" \
623 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
624 "$P_CLI" \
625 1 \
626 -s "SSL - The server has no ciphersuites in common"
627
628run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100629 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100630 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
631 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100632 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100633 -S "SSL - The server has no ciphersuites in common"
634
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100635# Tests for Truncated HMAC extension
636
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100637run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200638 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100639 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100640 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100641 -s "dumping 'computed mac' (20 bytes)" \
642 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100643
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100644run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200645 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100646 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
647 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100648 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100649 -s "dumping 'computed mac' (20 bytes)" \
650 -S "dumping 'computed mac' (10 bytes)"
651
652run_test "Truncated HMAC: client enabled, server default" \
653 "$P_SRV debug_level=4" \
654 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
655 trunc_hmac=1" \
656 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100657 -s "dumping 'computed mac' (20 bytes)" \
658 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100659
660run_test "Truncated HMAC: client enabled, server disabled" \
661 "$P_SRV debug_level=4 trunc_hmac=0" \
662 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
663 trunc_hmac=1" \
664 0 \
665 -s "dumping 'computed mac' (20 bytes)" \
666 -S "dumping 'computed mac' (10 bytes)"
667
668run_test "Truncated HMAC: client enabled, server enabled" \
669 "$P_SRV debug_level=4 trunc_hmac=1" \
670 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
671 trunc_hmac=1" \
672 0 \
673 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100674 -s "dumping 'computed mac' (10 bytes)"
675
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100676# Tests for Encrypt-then-MAC extension
677
678run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100679 "$P_SRV debug_level=3 \
680 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100681 "$P_CLI debug_level=3" \
682 0 \
683 -c "client hello, adding encrypt_then_mac extension" \
684 -s "found encrypt then mac extension" \
685 -s "server hello, adding encrypt then mac extension" \
686 -c "found encrypt_then_mac extension" \
687 -c "using encrypt then mac" \
688 -s "using encrypt then mac"
689
690run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100691 "$P_SRV debug_level=3 etm=0 \
692 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100693 "$P_CLI debug_level=3 etm=1" \
694 0 \
695 -c "client hello, adding encrypt_then_mac extension" \
696 -s "found encrypt then mac extension" \
697 -S "server hello, adding encrypt then mac extension" \
698 -C "found encrypt_then_mac extension" \
699 -C "using encrypt then mac" \
700 -S "using encrypt then mac"
701
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100702run_test "Encrypt then MAC: client enabled, aead cipher" \
703 "$P_SRV debug_level=3 etm=1 \
704 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
705 "$P_CLI debug_level=3 etm=1" \
706 0 \
707 -c "client hello, adding encrypt_then_mac extension" \
708 -s "found encrypt then mac extension" \
709 -S "server hello, adding encrypt then mac extension" \
710 -C "found encrypt_then_mac extension" \
711 -C "using encrypt then mac" \
712 -S "using encrypt then mac"
713
714run_test "Encrypt then MAC: client enabled, stream cipher" \
715 "$P_SRV debug_level=3 etm=1 \
716 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100717 "$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 +0100718 0 \
719 -c "client hello, adding encrypt_then_mac extension" \
720 -s "found encrypt then mac extension" \
721 -S "server hello, adding encrypt then mac extension" \
722 -C "found encrypt_then_mac extension" \
723 -C "using encrypt then mac" \
724 -S "using encrypt then mac"
725
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100726run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100727 "$P_SRV debug_level=3 etm=1 \
728 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100729 "$P_CLI debug_level=3 etm=0" \
730 0 \
731 -C "client hello, adding encrypt_then_mac extension" \
732 -S "found encrypt then mac extension" \
733 -S "server hello, adding encrypt then mac extension" \
734 -C "found encrypt_then_mac extension" \
735 -C "using encrypt then mac" \
736 -S "using encrypt then mac"
737
Janos Follath542ee5d2016-03-07 15:57:05 +0000738requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100739run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100740 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100741 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100742 "$P_CLI debug_level=3 force_version=ssl3" \
743 0 \
744 -C "client hello, adding encrypt_then_mac extension" \
745 -S "found encrypt then mac extension" \
746 -S "server hello, adding encrypt then mac extension" \
747 -C "found encrypt_then_mac extension" \
748 -C "using encrypt then mac" \
749 -S "using encrypt then mac"
750
Janos Follath542ee5d2016-03-07 15:57:05 +0000751requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100752run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100753 "$P_SRV debug_level=3 force_version=ssl3 \
754 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100755 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100756 0 \
757 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100758 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100759 -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é-Gonnard367381f2014-10-20 18:40:56 +0200764# Tests for Extended Master Secret extension
765
766run_test "Extended Master Secret: default" \
767 "$P_SRV debug_level=3" \
768 "$P_CLI debug_level=3" \
769 0 \
770 -c "client hello, adding extended_master_secret extension" \
771 -s "found extended master secret extension" \
772 -s "server hello, adding extended master secret extension" \
773 -c "found extended_master_secret extension" \
774 -c "using extended master secret" \
775 -s "using extended master secret"
776
777run_test "Extended Master Secret: client enabled, server disabled" \
778 "$P_SRV debug_level=3 extended_ms=0" \
779 "$P_CLI debug_level=3 extended_ms=1" \
780 0 \
781 -c "client hello, adding extended_master_secret extension" \
782 -s "found extended master secret extension" \
783 -S "server hello, adding extended master secret extension" \
784 -C "found extended_master_secret extension" \
785 -C "using extended master secret" \
786 -S "using extended master secret"
787
788run_test "Extended Master Secret: client disabled, server enabled" \
789 "$P_SRV debug_level=3 extended_ms=1" \
790 "$P_CLI debug_level=3 extended_ms=0" \
791 0 \
792 -C "client hello, adding extended_master_secret extension" \
793 -S "found extended master secret extension" \
794 -S "server hello, adding extended master secret extension" \
795 -C "found extended_master_secret extension" \
796 -C "using extended master secret" \
797 -S "using extended master secret"
798
Janos Follath542ee5d2016-03-07 15:57:05 +0000799requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200800run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100801 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200802 "$P_CLI debug_level=3 force_version=ssl3" \
803 0 \
804 -C "client hello, adding extended_master_secret extension" \
805 -S "found extended master secret extension" \
806 -S "server hello, adding extended master secret extension" \
807 -C "found extended_master_secret extension" \
808 -C "using extended master secret" \
809 -S "using extended master secret"
810
Janos Follath542ee5d2016-03-07 15:57:05 +0000811requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200812run_test "Extended Master Secret: client enabled, server SSLv3" \
813 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100814 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200815 0 \
816 -c "client hello, adding extended_master_secret extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100817 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200818 -S "server hello, adding extended master secret extension" \
819 -C "found extended_master_secret extension" \
820 -C "using extended master secret" \
821 -S "using extended master secret"
822
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200823# Tests for FALLBACK_SCSV
824
825run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200826 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200827 "$P_CLI debug_level=3 force_version=tls1_1" \
828 0 \
829 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200830 -S "received FALLBACK_SCSV" \
831 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200832 -C "is a fatal alert message (msg 86)"
833
834run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200835 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200836 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
837 0 \
838 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200839 -S "received FALLBACK_SCSV" \
840 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200841 -C "is a fatal alert message (msg 86)"
842
843run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200844 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200845 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200846 1 \
847 -c "adding FALLBACK_SCSV" \
848 -s "received FALLBACK_SCSV" \
849 -s "inapropriate fallback" \
850 -c "is a fatal alert message (msg 86)"
851
852run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200853 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200854 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200855 0 \
856 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200857 -s "received FALLBACK_SCSV" \
858 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200859 -C "is a fatal alert message (msg 86)"
860
861requires_openssl_with_fallback_scsv
862run_test "Fallback SCSV: default, openssl server" \
863 "$O_SRV" \
864 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
865 0 \
866 -C "adding FALLBACK_SCSV" \
867 -C "is a fatal alert message (msg 86)"
868
869requires_openssl_with_fallback_scsv
870run_test "Fallback SCSV: enabled, openssl server" \
871 "$O_SRV" \
872 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
873 1 \
874 -c "adding FALLBACK_SCSV" \
875 -c "is a fatal alert message (msg 86)"
876
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200877requires_openssl_with_fallback_scsv
878run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200879 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200880 "$O_CLI -tls1_1" \
881 0 \
882 -S "received FALLBACK_SCSV" \
883 -S "inapropriate fallback"
884
885requires_openssl_with_fallback_scsv
886run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200887 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200888 "$O_CLI -tls1_1 -fallback_scsv" \
889 1 \
890 -s "received FALLBACK_SCSV" \
891 -s "inapropriate fallback"
892
893requires_openssl_with_fallback_scsv
894run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200895 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200896 "$O_CLI -fallback_scsv" \
897 0 \
898 -s "received FALLBACK_SCSV" \
899 -S "inapropriate fallback"
900
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100901# Tests for CBC 1/n-1 record splitting
902
903run_test "CBC Record splitting: TLS 1.2, no splitting" \
904 "$P_SRV" \
905 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
906 request_size=123 force_version=tls1_2" \
907 0 \
908 -s "Read from client: 123 bytes read" \
909 -S "Read from client: 1 bytes read" \
910 -S "122 bytes read"
911
912run_test "CBC Record splitting: TLS 1.1, no splitting" \
913 "$P_SRV" \
914 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
915 request_size=123 force_version=tls1_1" \
916 0 \
917 -s "Read from client: 123 bytes read" \
918 -S "Read from client: 1 bytes read" \
919 -S "122 bytes read"
920
921run_test "CBC Record splitting: TLS 1.0, splitting" \
922 "$P_SRV" \
923 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
924 request_size=123 force_version=tls1" \
925 0 \
926 -S "Read from client: 123 bytes read" \
927 -s "Read from client: 1 bytes read" \
928 -s "122 bytes read"
929
Janos Follath542ee5d2016-03-07 15:57:05 +0000930requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100931run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100932 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100933 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
934 request_size=123 force_version=ssl3" \
935 0 \
936 -S "Read from client: 123 bytes read" \
937 -s "Read from client: 1 bytes read" \
938 -s "122 bytes read"
939
940run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100941 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100942 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
943 request_size=123 force_version=tls1" \
944 0 \
945 -s "Read from client: 123 bytes read" \
946 -S "Read from client: 1 bytes read" \
947 -S "122 bytes read"
948
949run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
950 "$P_SRV" \
951 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
952 request_size=123 force_version=tls1 recsplit=0" \
953 0 \
954 -s "Read from client: 123 bytes read" \
955 -S "Read from client: 1 bytes read" \
956 -S "122 bytes read"
957
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100958run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
959 "$P_SRV nbio=2" \
960 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
961 request_size=123 force_version=tls1" \
962 0 \
963 -S "Read from client: 123 bytes read" \
964 -s "Read from client: 1 bytes read" \
965 -s "122 bytes read"
966
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100967# Tests for Session Tickets
968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200969run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200970 "$P_SRV debug_level=3 tickets=1" \
971 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100972 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100973 -c "client hello, adding session ticket extension" \
974 -s "found session ticket extension" \
975 -s "server hello, adding session ticket extension" \
976 -c "found session_ticket extension" \
977 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100978 -S "session successfully restored from cache" \
979 -s "session successfully restored from ticket" \
980 -s "a session has been resumed" \
981 -c "a session has been resumed"
982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200983run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200984 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
985 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100986 0 \
987 -c "client hello, adding session ticket extension" \
988 -s "found session ticket extension" \
989 -s "server hello, adding session ticket extension" \
990 -c "found session_ticket extension" \
991 -c "parse new session ticket" \
992 -S "session successfully restored from cache" \
993 -s "session successfully restored from ticket" \
994 -s "a session has been resumed" \
995 -c "a session has been resumed"
996
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200997run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200998 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
999 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001000 0 \
1001 -c "client hello, adding session ticket extension" \
1002 -s "found session ticket extension" \
1003 -s "server hello, adding session ticket extension" \
1004 -c "found session_ticket extension" \
1005 -c "parse new session ticket" \
1006 -S "session successfully restored from cache" \
1007 -S "session successfully restored from ticket" \
1008 -S "a session has been resumed" \
1009 -C "a session has been resumed"
1010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001011run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001012 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001013 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001014 0 \
1015 -c "client hello, adding session ticket extension" \
1016 -c "found session_ticket extension" \
1017 -c "parse new session ticket" \
1018 -c "a session has been resumed"
1019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001020run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001021 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001022 "( $O_CLI -sess_out $SESSION; \
1023 $O_CLI -sess_in $SESSION; \
1024 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001025 0 \
1026 -s "found session ticket extension" \
1027 -s "server hello, adding session ticket extension" \
1028 -S "session successfully restored from cache" \
1029 -s "session successfully restored from ticket" \
1030 -s "a session has been resumed"
1031
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001032# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001034run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001035 "$P_SRV debug_level=3 tickets=0" \
1036 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001037 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001038 -c "client hello, adding session ticket extension" \
1039 -s "found session ticket extension" \
1040 -S "server hello, adding session ticket extension" \
1041 -C "found session_ticket extension" \
1042 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001043 -s "session successfully restored from cache" \
1044 -S "session successfully restored from ticket" \
1045 -s "a session has been resumed" \
1046 -c "a session has been resumed"
1047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001048run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001049 "$P_SRV debug_level=3 tickets=1" \
1050 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001051 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001052 -C "client hello, adding session ticket extension" \
1053 -S "found session ticket extension" \
1054 -S "server hello, adding session ticket extension" \
1055 -C "found session_ticket extension" \
1056 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001057 -s "session successfully restored from cache" \
1058 -S "session successfully restored from ticket" \
1059 -s "a session has been resumed" \
1060 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001062run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001063 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1064 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001065 0 \
1066 -S "session successfully restored from cache" \
1067 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001068 -S "a session has been resumed" \
1069 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001071run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001072 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1073 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001074 0 \
1075 -s "session successfully restored from cache" \
1076 -S "session successfully restored from ticket" \
1077 -s "a session has been resumed" \
1078 -c "a session has been resumed"
1079
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001080run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001081 "$P_SRV debug_level=3 tickets=0" \
1082 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001083 0 \
1084 -s "session successfully restored from cache" \
1085 -S "session successfully restored from ticket" \
1086 -s "a session has been resumed" \
1087 -c "a session has been resumed"
1088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001089run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001090 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1091 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001092 0 \
1093 -S "session successfully restored from cache" \
1094 -S "session successfully restored from ticket" \
1095 -S "a session has been resumed" \
1096 -C "a session has been resumed"
1097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001098run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001099 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1100 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001101 0 \
1102 -s "session successfully restored from cache" \
1103 -S "session successfully restored from ticket" \
1104 -s "a session has been resumed" \
1105 -c "a session has been resumed"
1106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001107run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001108 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001109 "( $O_CLI -sess_out $SESSION; \
1110 $O_CLI -sess_in $SESSION; \
1111 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001112 0 \
1113 -s "found session ticket extension" \
1114 -S "server hello, adding session ticket extension" \
1115 -s "session successfully restored from cache" \
1116 -S "session successfully restored from ticket" \
1117 -s "a session has been resumed"
1118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001119run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001120 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001121 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001122 0 \
1123 -C "found session_ticket extension" \
1124 -C "parse new session ticket" \
1125 -c "a session has been resumed"
1126
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001127# Tests for Max Fragment Length extension
1128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001129run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001130 "$P_SRV debug_level=3" \
1131 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001132 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001133 -c "Maximum fragment length is 16384" \
1134 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001135 -C "client hello, adding max_fragment_length extension" \
1136 -S "found max fragment length extension" \
1137 -S "server hello, max_fragment_length extension" \
1138 -C "found max_fragment_length extension"
1139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001140run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001141 "$P_SRV debug_level=3" \
1142 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001143 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001144 -c "Maximum fragment length is 4096" \
1145 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001146 -c "client hello, adding max_fragment_length extension" \
1147 -s "found max fragment length extension" \
1148 -s "server hello, max_fragment_length extension" \
1149 -c "found max_fragment_length extension"
1150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001151run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001152 "$P_SRV debug_level=3 max_frag_len=4096" \
1153 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001154 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001155 -c "Maximum fragment length is 16384" \
1156 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001157 -C "client hello, adding max_fragment_length extension" \
1158 -S "found max fragment length extension" \
1159 -S "server hello, max_fragment_length extension" \
1160 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001161
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001162requires_gnutls
1163run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001164 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001165 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001166 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001167 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001168 -c "client hello, adding max_fragment_length extension" \
1169 -c "found max_fragment_length extension"
1170
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001171run_test "Max fragment length: client, message just fits" \
1172 "$P_SRV debug_level=3" \
1173 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1174 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001175 -c "Maximum fragment length is 2048" \
1176 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001177 -c "client hello, adding max_fragment_length extension" \
1178 -s "found max fragment length extension" \
1179 -s "server hello, max_fragment_length extension" \
1180 -c "found max_fragment_length extension" \
1181 -c "2048 bytes written in 1 fragments" \
1182 -s "2048 bytes read"
1183
1184run_test "Max fragment length: client, larger message" \
1185 "$P_SRV debug_level=3" \
1186 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1187 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001188 -c "Maximum fragment length is 2048" \
1189 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001190 -c "client hello, adding max_fragment_length extension" \
1191 -s "found max fragment length extension" \
1192 -s "server hello, max_fragment_length extension" \
1193 -c "found max_fragment_length extension" \
1194 -c "2345 bytes written in 2 fragments" \
1195 -s "2048 bytes read" \
1196 -s "297 bytes read"
1197
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001198run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001199 "$P_SRV debug_level=3 dtls=1" \
1200 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1201 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001202 -c "Maximum fragment length is 2048" \
1203 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001204 -c "client hello, adding max_fragment_length extension" \
1205 -s "found max fragment length extension" \
1206 -s "server hello, max_fragment_length extension" \
1207 -c "found max_fragment_length extension" \
1208 -c "fragment larger than.*maximum"
1209
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001210# Tests for renegotiation
1211
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001212run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001213 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001214 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001215 0 \
1216 -C "client hello, adding renegotiation extension" \
1217 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1218 -S "found renegotiation extension" \
1219 -s "server hello, secure renegotiation extension" \
1220 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001221 -C "=> renegotiate" \
1222 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001223 -S "write hello request"
1224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001225run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001226 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001227 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001228 0 \
1229 -c "client hello, adding renegotiation extension" \
1230 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1231 -s "found renegotiation extension" \
1232 -s "server hello, secure renegotiation extension" \
1233 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001234 -c "=> renegotiate" \
1235 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001236 -S "write hello request"
1237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001238run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001239 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001240 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001241 0 \
1242 -c "client hello, adding renegotiation extension" \
1243 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1244 -s "found renegotiation extension" \
1245 -s "server hello, secure renegotiation extension" \
1246 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001247 -c "=> renegotiate" \
1248 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001249 -s "write hello request"
1250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001251run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001252 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001253 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001254 0 \
1255 -c "client hello, adding renegotiation extension" \
1256 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1257 -s "found renegotiation extension" \
1258 -s "server hello, secure renegotiation extension" \
1259 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001260 -c "=> renegotiate" \
1261 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001262 -s "write hello request"
1263
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001264run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001265 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001266 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001267 1 \
1268 -c "client hello, adding renegotiation extension" \
1269 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1270 -S "found renegotiation extension" \
1271 -s "server hello, secure renegotiation extension" \
1272 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001273 -c "=> renegotiate" \
1274 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001275 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001276 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001277 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001279run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001280 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001281 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001282 0 \
1283 -C "client hello, adding renegotiation extension" \
1284 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1285 -S "found renegotiation extension" \
1286 -s "server hello, secure renegotiation extension" \
1287 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001288 -C "=> renegotiate" \
1289 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001290 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001291 -S "SSL - An unexpected message was received from our peer" \
1292 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001293
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001294run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001295 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001296 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001297 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001298 0 \
1299 -C "client hello, adding renegotiation extension" \
1300 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1301 -S "found renegotiation extension" \
1302 -s "server hello, secure renegotiation extension" \
1303 -c "found renegotiation extension" \
1304 -C "=> renegotiate" \
1305 -S "=> renegotiate" \
1306 -s "write hello request" \
1307 -S "SSL - An unexpected message was received from our peer" \
1308 -S "failed"
1309
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001310# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001311run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001312 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001313 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001314 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001315 0 \
1316 -C "client hello, adding renegotiation extension" \
1317 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1318 -S "found renegotiation extension" \
1319 -s "server hello, secure renegotiation extension" \
1320 -c "found renegotiation extension" \
1321 -C "=> renegotiate" \
1322 -S "=> renegotiate" \
1323 -s "write hello request" \
1324 -S "SSL - An unexpected message was received from our peer" \
1325 -S "failed"
1326
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001327run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001328 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001329 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001330 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001331 0 \
1332 -C "client hello, adding renegotiation extension" \
1333 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1334 -S "found renegotiation extension" \
1335 -s "server hello, secure renegotiation extension" \
1336 -c "found renegotiation extension" \
1337 -C "=> renegotiate" \
1338 -S "=> renegotiate" \
1339 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001340 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001342run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001343 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001344 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001345 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001346 0 \
1347 -c "client hello, adding renegotiation extension" \
1348 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1349 -s "found renegotiation extension" \
1350 -s "server hello, secure renegotiation extension" \
1351 -c "found renegotiation extension" \
1352 -c "=> renegotiate" \
1353 -s "=> renegotiate" \
1354 -s "write hello request" \
1355 -S "SSL - An unexpected message was received from our peer" \
1356 -S "failed"
1357
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001358run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001359 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001360 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1361 0 \
1362 -C "client hello, adding renegotiation extension" \
1363 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1364 -S "found renegotiation extension" \
1365 -s "server hello, secure renegotiation extension" \
1366 -c "found renegotiation extension" \
1367 -S "record counter limit reached: renegotiate" \
1368 -C "=> renegotiate" \
1369 -S "=> renegotiate" \
1370 -S "write hello request" \
1371 -S "SSL - An unexpected message was received from our peer" \
1372 -S "failed"
1373
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001374# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001375run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001376 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001377 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001378 0 \
1379 -c "client hello, adding renegotiation extension" \
1380 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1381 -s "found renegotiation extension" \
1382 -s "server hello, secure renegotiation extension" \
1383 -c "found renegotiation extension" \
1384 -s "record counter limit reached: renegotiate" \
1385 -c "=> renegotiate" \
1386 -s "=> renegotiate" \
1387 -s "write hello request" \
1388 -S "SSL - An unexpected message was received from our peer" \
1389 -S "failed"
1390
1391run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001392 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001393 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001394 0 \
1395 -c "client hello, adding renegotiation extension" \
1396 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1397 -s "found renegotiation extension" \
1398 -s "server hello, secure renegotiation extension" \
1399 -c "found renegotiation extension" \
1400 -s "record counter limit reached: renegotiate" \
1401 -c "=> renegotiate" \
1402 -s "=> renegotiate" \
1403 -s "write hello request" \
1404 -S "SSL - An unexpected message was received from our peer" \
1405 -S "failed"
1406
1407run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001408 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001409 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1410 0 \
1411 -C "client hello, adding renegotiation extension" \
1412 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1413 -S "found renegotiation extension" \
1414 -s "server hello, secure renegotiation extension" \
1415 -c "found renegotiation extension" \
1416 -S "record counter limit reached: renegotiate" \
1417 -C "=> renegotiate" \
1418 -S "=> renegotiate" \
1419 -S "write hello request" \
1420 -S "SSL - An unexpected message was received from our peer" \
1421 -S "failed"
1422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001423run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001424 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001425 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001426 0 \
1427 -c "client hello, adding renegotiation extension" \
1428 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1429 -s "found renegotiation extension" \
1430 -s "server hello, secure renegotiation extension" \
1431 -c "found renegotiation extension" \
1432 -c "=> renegotiate" \
1433 -s "=> renegotiate" \
1434 -S "write hello request"
1435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001436run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001437 "$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 +02001438 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001439 0 \
1440 -c "client hello, adding renegotiation extension" \
1441 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1442 -s "found renegotiation extension" \
1443 -s "server hello, secure renegotiation extension" \
1444 -c "found renegotiation extension" \
1445 -c "=> renegotiate" \
1446 -s "=> renegotiate" \
1447 -s "write hello request"
1448
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001449run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001450 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001451 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001452 0 \
1453 -c "client hello, adding renegotiation extension" \
1454 -c "found renegotiation extension" \
1455 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001456 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001457 -C "error" \
1458 -c "HTTP/1.0 200 [Oo][Kk]"
1459
Paul Bakker539d9722015-02-08 16:18:35 +01001460requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001461run_test "Renegotiation: gnutls server strict, client-initiated" \
1462 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001463 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001464 0 \
1465 -c "client hello, adding renegotiation extension" \
1466 -c "found renegotiation extension" \
1467 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001468 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001469 -C "error" \
1470 -c "HTTP/1.0 200 [Oo][Kk]"
1471
Paul Bakker539d9722015-02-08 16:18:35 +01001472requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001473run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1474 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1475 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1476 1 \
1477 -c "client hello, adding renegotiation extension" \
1478 -C "found renegotiation extension" \
1479 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001480 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001481 -c "error" \
1482 -C "HTTP/1.0 200 [Oo][Kk]"
1483
Paul Bakker539d9722015-02-08 16:18:35 +01001484requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001485run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1486 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1487 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1488 allow_legacy=0" \
1489 1 \
1490 -c "client hello, adding renegotiation extension" \
1491 -C "found renegotiation extension" \
1492 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001493 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001494 -c "error" \
1495 -C "HTTP/1.0 200 [Oo][Kk]"
1496
Paul Bakker539d9722015-02-08 16:18:35 +01001497requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001498run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1499 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1500 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1501 allow_legacy=1" \
1502 0 \
1503 -c "client hello, adding renegotiation extension" \
1504 -C "found renegotiation extension" \
1505 -c "=> renegotiate" \
1506 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001507 -C "error" \
1508 -c "HTTP/1.0 200 [Oo][Kk]"
1509
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001510run_test "Renegotiation: DTLS, client-initiated" \
1511 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1512 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1513 0 \
1514 -c "client hello, adding renegotiation extension" \
1515 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1516 -s "found renegotiation extension" \
1517 -s "server hello, secure renegotiation extension" \
1518 -c "found renegotiation extension" \
1519 -c "=> renegotiate" \
1520 -s "=> renegotiate" \
1521 -S "write hello request"
1522
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001523run_test "Renegotiation: DTLS, server-initiated" \
1524 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001525 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1526 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001527 0 \
1528 -c "client hello, adding renegotiation extension" \
1529 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1530 -s "found renegotiation extension" \
1531 -s "server hello, secure renegotiation extension" \
1532 -c "found renegotiation extension" \
1533 -c "=> renegotiate" \
1534 -s "=> renegotiate" \
1535 -s "write hello request"
1536
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001537requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001538run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1539 "$G_SRV -u --mtu 4096" \
1540 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1541 0 \
1542 -c "client hello, adding renegotiation extension" \
1543 -c "found renegotiation extension" \
1544 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001545 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001546 -C "error" \
1547 -s "Extra-header:"
1548
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001549# Test for the "secure renegotation" extension only (no actual renegotiation)
1550
Paul Bakker539d9722015-02-08 16:18:35 +01001551requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001552run_test "Renego ext: gnutls server strict, client default" \
1553 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1554 "$P_CLI debug_level=3" \
1555 0 \
1556 -c "found renegotiation extension" \
1557 -C "error" \
1558 -c "HTTP/1.0 200 [Oo][Kk]"
1559
Paul Bakker539d9722015-02-08 16:18:35 +01001560requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001561run_test "Renego ext: gnutls server unsafe, client default" \
1562 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1563 "$P_CLI debug_level=3" \
1564 0 \
1565 -C "found renegotiation extension" \
1566 -C "error" \
1567 -c "HTTP/1.0 200 [Oo][Kk]"
1568
Paul Bakker539d9722015-02-08 16:18:35 +01001569requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001570run_test "Renego ext: gnutls server unsafe, client break legacy" \
1571 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1572 "$P_CLI debug_level=3 allow_legacy=-1" \
1573 1 \
1574 -C "found renegotiation extension" \
1575 -c "error" \
1576 -C "HTTP/1.0 200 [Oo][Kk]"
1577
Paul Bakker539d9722015-02-08 16:18:35 +01001578requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001579run_test "Renego ext: gnutls client strict, server default" \
1580 "$P_SRV debug_level=3" \
1581 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1582 0 \
1583 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1584 -s "server hello, secure renegotiation extension"
1585
Paul Bakker539d9722015-02-08 16:18:35 +01001586requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001587run_test "Renego ext: gnutls client unsafe, server default" \
1588 "$P_SRV debug_level=3" \
1589 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1590 0 \
1591 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1592 -S "server hello, secure renegotiation extension"
1593
Paul Bakker539d9722015-02-08 16:18:35 +01001594requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001595run_test "Renego ext: gnutls client unsafe, server break legacy" \
1596 "$P_SRV debug_level=3 allow_legacy=-1" \
1597 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1598 1 \
1599 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1600 -S "server hello, secure renegotiation extension"
1601
Janos Follath365b2262016-02-17 10:11:21 +00001602# Tests for silently dropping trailing extra bytes in .der certificates
1603
1604requires_gnutls
1605run_test "DER format: no trailing bytes" \
1606 "$P_SRV crt_file=data_files/server5-der0.crt \
1607 key_file=data_files/server5.key" \
1608 "$G_CLI " \
1609 0 \
1610 -c "Handshake was completed" \
1611
1612requires_gnutls
1613run_test "DER format: with a trailing zero byte" \
1614 "$P_SRV crt_file=data_files/server5-der1a.crt \
1615 key_file=data_files/server5.key" \
1616 "$G_CLI " \
1617 0 \
1618 -c "Handshake was completed" \
1619
1620requires_gnutls
1621run_test "DER format: with a trailing random byte" \
1622 "$P_SRV crt_file=data_files/server5-der1b.crt \
1623 key_file=data_files/server5.key" \
1624 "$G_CLI " \
1625 0 \
1626 -c "Handshake was completed" \
1627
1628requires_gnutls
1629run_test "DER format: with 2 trailing random bytes" \
1630 "$P_SRV crt_file=data_files/server5-der2.crt \
1631 key_file=data_files/server5.key" \
1632 "$G_CLI " \
1633 0 \
1634 -c "Handshake was completed" \
1635
1636requires_gnutls
1637run_test "DER format: with 4 trailing random bytes" \
1638 "$P_SRV crt_file=data_files/server5-der4.crt \
1639 key_file=data_files/server5.key" \
1640 "$G_CLI " \
1641 0 \
1642 -c "Handshake was completed" \
1643
1644requires_gnutls
1645run_test "DER format: with 8 trailing random bytes" \
1646 "$P_SRV crt_file=data_files/server5-der8.crt \
1647 key_file=data_files/server5.key" \
1648 "$G_CLI " \
1649 0 \
1650 -c "Handshake was completed" \
1651
1652requires_gnutls
1653run_test "DER format: with 9 trailing random bytes" \
1654 "$P_SRV crt_file=data_files/server5-der9.crt \
1655 key_file=data_files/server5.key" \
1656 "$G_CLI " \
1657 0 \
1658 -c "Handshake was completed" \
1659
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001660# Tests for auth_mode
1661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001662run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001663 "$P_SRV crt_file=data_files/server5-badsign.crt \
1664 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001665 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001666 1 \
1667 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001668 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001669 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001670 -c "X509 - Certificate verification failed"
1671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001672run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001673 "$P_SRV crt_file=data_files/server5-badsign.crt \
1674 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001675 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001676 0 \
1677 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001678 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001679 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001680 -C "X509 - Certificate verification failed"
1681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001682run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001683 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001684 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001685 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001686 0 \
1687 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001688 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001689 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001690 -C "X509 - Certificate verification failed"
1691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001692run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001693 "$P_SRV debug_level=3 auth_mode=required" \
1694 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001695 key_file=data_files/server5.key" \
1696 1 \
1697 -S "skip write certificate request" \
1698 -C "skip parse certificate request" \
1699 -c "got a certificate request" \
1700 -C "skip write certificate" \
1701 -C "skip write certificate verify" \
1702 -S "skip parse certificate verify" \
1703 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001704 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001705 -s "! mbedtls_ssl_handshake returned" \
1706 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001707 -s "X509 - Certificate verification failed"
1708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001709run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001710 "$P_SRV debug_level=3 auth_mode=optional" \
1711 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001712 key_file=data_files/server5.key" \
1713 0 \
1714 -S "skip write certificate request" \
1715 -C "skip parse certificate request" \
1716 -c "got a certificate request" \
1717 -C "skip write certificate" \
1718 -C "skip write certificate verify" \
1719 -S "skip parse certificate verify" \
1720 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001721 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001722 -S "! mbedtls_ssl_handshake returned" \
1723 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001724 -S "X509 - Certificate verification failed"
1725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001726run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001727 "$P_SRV debug_level=3 auth_mode=none" \
1728 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001729 key_file=data_files/server5.key" \
1730 0 \
1731 -s "skip write certificate request" \
1732 -C "skip parse certificate request" \
1733 -c "got no certificate request" \
1734 -c "skip write certificate" \
1735 -c "skip write certificate verify" \
1736 -s "skip parse certificate verify" \
1737 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001738 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001739 -S "! mbedtls_ssl_handshake returned" \
1740 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001741 -S "X509 - Certificate verification failed"
1742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001743run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001744 "$P_SRV debug_level=3 auth_mode=optional" \
1745 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001746 0 \
1747 -S "skip write certificate request" \
1748 -C "skip parse certificate request" \
1749 -c "got a certificate request" \
1750 -C "skip write certificate$" \
1751 -C "got no certificate to send" \
1752 -S "SSLv3 client has no certificate" \
1753 -c "skip write certificate verify" \
1754 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001755 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001756 -S "! mbedtls_ssl_handshake returned" \
1757 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001758 -S "X509 - Certificate verification failed"
1759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001760run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001761 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001762 "$O_CLI" \
1763 0 \
1764 -S "skip write certificate request" \
1765 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001766 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001767 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001768 -S "X509 - Certificate verification failed"
1769
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001770run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001771 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001772 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001773 0 \
1774 -C "skip parse certificate request" \
1775 -c "got a certificate request" \
1776 -C "skip write certificate$" \
1777 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001778 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001779
Janos Follath542ee5d2016-03-07 15:57:05 +00001780requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001781run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001782 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001783 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001784 0 \
1785 -S "skip write certificate request" \
1786 -C "skip parse certificate request" \
1787 -c "got a certificate request" \
1788 -C "skip write certificate$" \
1789 -c "skip write certificate verify" \
1790 -c "got no certificate to send" \
1791 -s "SSLv3 client has no certificate" \
1792 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001793 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001794 -S "! mbedtls_ssl_handshake returned" \
1795 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001796 -S "X509 - Certificate verification failed"
1797
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001798# Tests for certificate selection based on SHA verson
1799
1800run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1801 "$P_SRV crt_file=data_files/server5.crt \
1802 key_file=data_files/server5.key \
1803 crt_file2=data_files/server5-sha1.crt \
1804 key_file2=data_files/server5.key" \
1805 "$P_CLI force_version=tls1_2" \
1806 0 \
1807 -c "signed using.*ECDSA with SHA256" \
1808 -C "signed using.*ECDSA with SHA1"
1809
1810run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1811 "$P_SRV crt_file=data_files/server5.crt \
1812 key_file=data_files/server5.key \
1813 crt_file2=data_files/server5-sha1.crt \
1814 key_file2=data_files/server5.key" \
1815 "$P_CLI force_version=tls1_1" \
1816 0 \
1817 -C "signed using.*ECDSA with SHA256" \
1818 -c "signed using.*ECDSA with SHA1"
1819
1820run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1821 "$P_SRV crt_file=data_files/server5.crt \
1822 key_file=data_files/server5.key \
1823 crt_file2=data_files/server5-sha1.crt \
1824 key_file2=data_files/server5.key" \
1825 "$P_CLI force_version=tls1" \
1826 0 \
1827 -C "signed using.*ECDSA with SHA256" \
1828 -c "signed using.*ECDSA with SHA1"
1829
1830run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1831 "$P_SRV crt_file=data_files/server5.crt \
1832 key_file=data_files/server5.key \
1833 crt_file2=data_files/server6.crt \
1834 key_file2=data_files/server6.key" \
1835 "$P_CLI force_version=tls1_1" \
1836 0 \
1837 -c "serial number.*09" \
1838 -c "signed using.*ECDSA with SHA256" \
1839 -C "signed using.*ECDSA with SHA1"
1840
1841run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1842 "$P_SRV crt_file=data_files/server6.crt \
1843 key_file=data_files/server6.key \
1844 crt_file2=data_files/server5.crt \
1845 key_file2=data_files/server5.key" \
1846 "$P_CLI force_version=tls1_1" \
1847 0 \
1848 -c "serial number.*0A" \
1849 -c "signed using.*ECDSA with SHA256" \
1850 -C "signed using.*ECDSA with SHA1"
1851
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001852# tests for SNI
1853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001854run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001855 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001856 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001857 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001858 0 \
1859 -S "parse ServerName extension" \
1860 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1861 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001862
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001863run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001864 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001865 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001866 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 +02001867 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001868 0 \
1869 -s "parse ServerName extension" \
1870 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1871 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001873run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001874 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001875 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001876 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 +02001877 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001878 0 \
1879 -s "parse ServerName extension" \
1880 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1881 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001883run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001884 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001885 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001886 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 +02001887 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001888 1 \
1889 -s "parse ServerName extension" \
1890 -s "ssl_sni_wrapper() returned" \
1891 -s "mbedtls_ssl_handshake returned" \
1892 -c "mbedtls_ssl_handshake returned" \
1893 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001894
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001895run_test "SNI: client auth no override: optional" \
1896 "$P_SRV debug_level=3 auth_mode=optional \
1897 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1898 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1899 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001900 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001901 -S "skip write certificate request" \
1902 -C "skip parse certificate request" \
1903 -c "got a certificate request" \
1904 -C "skip write certificate" \
1905 -C "skip write certificate verify" \
1906 -S "skip parse certificate verify"
1907
1908run_test "SNI: client auth override: none -> optional" \
1909 "$P_SRV debug_level=3 auth_mode=none \
1910 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1911 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1912 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001913 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001914 -S "skip write certificate request" \
1915 -C "skip parse certificate request" \
1916 -c "got a certificate request" \
1917 -C "skip write certificate" \
1918 -C "skip write certificate verify" \
1919 -S "skip parse certificate verify"
1920
1921run_test "SNI: client auth override: optional -> none" \
1922 "$P_SRV debug_level=3 auth_mode=optional \
1923 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1924 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1925 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001926 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001927 -s "skip write certificate request" \
1928 -C "skip parse certificate request" \
1929 -c "got no certificate request" \
1930 -c "skip write certificate" \
1931 -c "skip write certificate verify" \
1932 -s "skip parse certificate verify"
1933
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001934run_test "SNI: CA no override" \
1935 "$P_SRV debug_level=3 auth_mode=optional \
1936 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1937 ca_file=data_files/test-ca.crt \
1938 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1939 "$P_CLI debug_level=3 server_name=localhost \
1940 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1941 1 \
1942 -S "skip write certificate request" \
1943 -C "skip parse certificate request" \
1944 -c "got a certificate request" \
1945 -C "skip write certificate" \
1946 -C "skip write certificate verify" \
1947 -S "skip parse certificate verify" \
1948 -s "x509_verify_cert() returned" \
1949 -s "! The certificate is not correctly signed by the trusted CA" \
1950 -S "The certificate has been revoked (is on a CRL)"
1951
1952run_test "SNI: CA override" \
1953 "$P_SRV debug_level=3 auth_mode=optional \
1954 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1955 ca_file=data_files/test-ca.crt \
1956 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1957 "$P_CLI debug_level=3 server_name=localhost \
1958 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1959 0 \
1960 -S "skip write certificate request" \
1961 -C "skip parse certificate request" \
1962 -c "got a certificate request" \
1963 -C "skip write certificate" \
1964 -C "skip write certificate verify" \
1965 -S "skip parse certificate verify" \
1966 -S "x509_verify_cert() returned" \
1967 -S "! The certificate is not correctly signed by the trusted CA" \
1968 -S "The certificate has been revoked (is on a CRL)"
1969
1970run_test "SNI: CA override with CRL" \
1971 "$P_SRV debug_level=3 auth_mode=optional \
1972 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1973 ca_file=data_files/test-ca.crt \
1974 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1975 "$P_CLI debug_level=3 server_name=localhost \
1976 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1977 1 \
1978 -S "skip write certificate request" \
1979 -C "skip parse certificate request" \
1980 -c "got a certificate request" \
1981 -C "skip write certificate" \
1982 -C "skip write certificate verify" \
1983 -S "skip parse certificate verify" \
1984 -s "x509_verify_cert() returned" \
1985 -S "! The certificate is not correctly signed by the trusted CA" \
1986 -s "The certificate has been revoked (is on a CRL)"
1987
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001988# Tests for non-blocking I/O: exercise a variety of handshake flows
1989
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001990run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001991 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1992 "$P_CLI nbio=2 tickets=0" \
1993 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001994 -S "mbedtls_ssl_handshake returned" \
1995 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001996 -c "Read from server: .* bytes read"
1997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001998run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001999 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2000 "$P_CLI nbio=2 tickets=0" \
2001 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002002 -S "mbedtls_ssl_handshake returned" \
2003 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002004 -c "Read from server: .* bytes read"
2005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002006run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002007 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2008 "$P_CLI nbio=2 tickets=1" \
2009 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002010 -S "mbedtls_ssl_handshake returned" \
2011 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002012 -c "Read from server: .* bytes read"
2013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002014run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002015 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2016 "$P_CLI nbio=2 tickets=1" \
2017 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002018 -S "mbedtls_ssl_handshake returned" \
2019 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002020 -c "Read from server: .* bytes read"
2021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002022run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002023 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2024 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2025 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002026 -S "mbedtls_ssl_handshake returned" \
2027 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002028 -c "Read from server: .* bytes read"
2029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002030run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002031 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2032 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2033 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002034 -S "mbedtls_ssl_handshake returned" \
2035 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002036 -c "Read from server: .* bytes read"
2037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002038run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002039 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2040 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2041 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002042 -S "mbedtls_ssl_handshake returned" \
2043 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002044 -c "Read from server: .* bytes read"
2045
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002046# Tests for version negotiation
2047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002048run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002049 "$P_SRV" \
2050 "$P_CLI" \
2051 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002052 -S "mbedtls_ssl_handshake returned" \
2053 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002054 -s "Protocol is TLSv1.2" \
2055 -c "Protocol is TLSv1.2"
2056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002057run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002058 "$P_SRV" \
2059 "$P_CLI max_version=tls1_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é-Gonnarda3d808e2014-02-26 16:33:03 +01002063 -s "Protocol is TLSv1.1" \
2064 -c "Protocol is TLSv1.1"
2065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002066run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002067 "$P_SRV max_version=tls1_1" \
2068 "$P_CLI" \
2069 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002070 -S "mbedtls_ssl_handshake returned" \
2071 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002072 -s "Protocol is TLSv1.1" \
2073 -c "Protocol is TLSv1.1"
2074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002075run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002076 "$P_SRV max_version=tls1_1" \
2077 "$P_CLI max_version=tls1_1" \
2078 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002079 -S "mbedtls_ssl_handshake returned" \
2080 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002081 -s "Protocol is TLSv1.1" \
2082 -c "Protocol is TLSv1.1"
2083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002084run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002085 "$P_SRV min_version=tls1_1" \
2086 "$P_CLI max_version=tls1_1" \
2087 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002088 -S "mbedtls_ssl_handshake returned" \
2089 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002090 -s "Protocol is TLSv1.1" \
2091 -c "Protocol is TLSv1.1"
2092
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002093run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002094 "$P_SRV max_version=tls1_1" \
2095 "$P_CLI min_version=tls1_1" \
2096 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002097 -S "mbedtls_ssl_handshake returned" \
2098 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002099 -s "Protocol is TLSv1.1" \
2100 -c "Protocol is TLSv1.1"
2101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002102run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002103 "$P_SRV max_version=tls1_1" \
2104 "$P_CLI min_version=tls1_2" \
2105 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002106 -s "mbedtls_ssl_handshake returned" \
2107 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002108 -c "SSL - Handshake protocol not within min/max boundaries"
2109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002110run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002111 "$P_SRV min_version=tls1_2" \
2112 "$P_CLI max_version=tls1_1" \
2113 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002114 -s "mbedtls_ssl_handshake returned" \
2115 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002116 -s "SSL - Handshake protocol not within min/max boundaries"
2117
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002118# Tests for ALPN extension
2119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002120run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002121 "$P_SRV debug_level=3" \
2122 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002123 0 \
2124 -C "client hello, adding alpn extension" \
2125 -S "found alpn extension" \
2126 -C "got an alert message, type: \\[2:120]" \
2127 -S "server hello, adding alpn extension" \
2128 -C "found alpn extension " \
2129 -C "Application Layer Protocol is" \
2130 -S "Application Layer Protocol is"
2131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002132run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002133 "$P_SRV debug_level=3" \
2134 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002135 0 \
2136 -c "client hello, adding alpn extension" \
2137 -s "found alpn extension" \
2138 -C "got an alert message, type: \\[2:120]" \
2139 -S "server hello, adding alpn extension" \
2140 -C "found alpn extension " \
2141 -c "Application Layer Protocol is (none)" \
2142 -S "Application Layer Protocol is"
2143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002144run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002145 "$P_SRV debug_level=3 alpn=abc,1234" \
2146 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002147 0 \
2148 -C "client hello, adding alpn extension" \
2149 -S "found alpn extension" \
2150 -C "got an alert message, type: \\[2:120]" \
2151 -S "server hello, adding alpn extension" \
2152 -C "found alpn extension " \
2153 -C "Application Layer Protocol is" \
2154 -s "Application Layer Protocol is (none)"
2155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002156run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002157 "$P_SRV debug_level=3 alpn=abc,1234" \
2158 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002159 0 \
2160 -c "client hello, adding alpn extension" \
2161 -s "found alpn extension" \
2162 -C "got an alert message, type: \\[2:120]" \
2163 -s "server hello, adding alpn extension" \
2164 -c "found alpn extension" \
2165 -c "Application Layer Protocol is abc" \
2166 -s "Application Layer Protocol is abc"
2167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002168run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002169 "$P_SRV debug_level=3 alpn=abc,1234" \
2170 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002171 0 \
2172 -c "client hello, adding alpn extension" \
2173 -s "found alpn extension" \
2174 -C "got an alert message, type: \\[2:120]" \
2175 -s "server hello, adding alpn extension" \
2176 -c "found alpn extension" \
2177 -c "Application Layer Protocol is abc" \
2178 -s "Application Layer Protocol is abc"
2179
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002180run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002181 "$P_SRV debug_level=3 alpn=abc,1234" \
2182 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002183 0 \
2184 -c "client hello, adding alpn extension" \
2185 -s "found alpn extension" \
2186 -C "got an alert message, type: \\[2:120]" \
2187 -s "server hello, adding alpn extension" \
2188 -c "found alpn extension" \
2189 -c "Application Layer Protocol is 1234" \
2190 -s "Application Layer Protocol is 1234"
2191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002192run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002193 "$P_SRV debug_level=3 alpn=abc,123" \
2194 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002195 1 \
2196 -c "client hello, adding alpn extension" \
2197 -s "found alpn extension" \
2198 -c "got an alert message, type: \\[2:120]" \
2199 -S "server hello, adding alpn extension" \
2200 -C "found alpn extension" \
2201 -C "Application Layer Protocol is 1234" \
2202 -S "Application Layer Protocol is 1234"
2203
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002204
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002205# Tests for keyUsage in leaf certificates, part 1:
2206# server-side certificate/suite selection
2207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002208run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002209 "$P_SRV key_file=data_files/server2.key \
2210 crt_file=data_files/server2.ku-ds.crt" \
2211 "$P_CLI" \
2212 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002213 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002214
2215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002216run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002217 "$P_SRV key_file=data_files/server2.key \
2218 crt_file=data_files/server2.ku-ke.crt" \
2219 "$P_CLI" \
2220 0 \
2221 -c "Ciphersuite is TLS-RSA-WITH-"
2222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002223run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002224 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002225 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002226 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002227 1 \
2228 -C "Ciphersuite is "
2229
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002230run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002231 "$P_SRV key_file=data_files/server5.key \
2232 crt_file=data_files/server5.ku-ds.crt" \
2233 "$P_CLI" \
2234 0 \
2235 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2236
2237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002238run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002239 "$P_SRV key_file=data_files/server5.key \
2240 crt_file=data_files/server5.ku-ka.crt" \
2241 "$P_CLI" \
2242 0 \
2243 -c "Ciphersuite is TLS-ECDH-"
2244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002245run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002246 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002247 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002248 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002249 1 \
2250 -C "Ciphersuite is "
2251
2252# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002253# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002254
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002255run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002256 "$O_SRV -key data_files/server2.key \
2257 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002258 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002259 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2260 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002261 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002262 -C "Processing of the Certificate handshake message failed" \
2263 -c "Ciphersuite is TLS-"
2264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002265run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002266 "$O_SRV -key data_files/server2.key \
2267 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002268 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002269 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2270 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002271 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002272 -C "Processing of the Certificate handshake message failed" \
2273 -c "Ciphersuite is TLS-"
2274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002275run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002276 "$O_SRV -key data_files/server2.key \
2277 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002278 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002279 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2280 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002281 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002282 -C "Processing of the Certificate handshake message failed" \
2283 -c "Ciphersuite is TLS-"
2284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002285run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002286 "$O_SRV -key data_files/server2.key \
2287 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002288 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002289 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2290 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002291 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002292 -c "Processing of the Certificate handshake message failed" \
2293 -C "Ciphersuite is TLS-"
2294
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002295run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2296 "$O_SRV -key data_files/server2.key \
2297 -cert data_files/server2.ku-ke.crt" \
2298 "$P_CLI debug_level=1 auth_mode=optional \
2299 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2300 0 \
2301 -c "bad certificate (usage extensions)" \
2302 -C "Processing of the Certificate handshake message failed" \
2303 -c "Ciphersuite is TLS-" \
2304 -c "! Usage does not match the keyUsage extension"
2305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002306run_test "keyUsage cli: DigitalSignature, DHE-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.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-DHE-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, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002317 "$O_SRV -key data_files/server2.key \
2318 -cert data_files/server2.ku-ds.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-RSA-WITH-AES-128-CBC-SHA" \
2321 1 \
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é-Gonnarde6efa6f2015-04-20 11:01:48 +01002326run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2327 "$O_SRV -key data_files/server2.key \
2328 -cert data_files/server2.ku-ds.crt" \
2329 "$P_CLI debug_level=1 auth_mode=optional \
2330 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2331 0 \
2332 -c "bad certificate (usage extensions)" \
2333 -C "Processing of the Certificate handshake message failed" \
2334 -c "Ciphersuite is TLS-" \
2335 -c "! Usage does not match the keyUsage extension"
2336
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002337# Tests for keyUsage in leaf certificates, part 3:
2338# server-side checking of client cert
2339
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002340run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002341 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002342 "$O_CLI -key data_files/server2.key \
2343 -cert data_files/server2.ku-ds.crt" \
2344 0 \
2345 -S "bad certificate (usage extensions)" \
2346 -S "Processing of the Certificate handshake message failed"
2347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002348run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002349 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002350 "$O_CLI -key data_files/server2.key \
2351 -cert data_files/server2.ku-ke.crt" \
2352 0 \
2353 -s "bad certificate (usage extensions)" \
2354 -S "Processing of the Certificate handshake message failed"
2355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002356run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002357 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002358 "$O_CLI -key data_files/server2.key \
2359 -cert data_files/server2.ku-ke.crt" \
2360 1 \
2361 -s "bad certificate (usage extensions)" \
2362 -s "Processing of the Certificate handshake message failed"
2363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002364run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002365 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002366 "$O_CLI -key data_files/server5.key \
2367 -cert data_files/server5.ku-ds.crt" \
2368 0 \
2369 -S "bad certificate (usage extensions)" \
2370 -S "Processing of the Certificate handshake message failed"
2371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002372run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002373 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002374 "$O_CLI -key data_files/server5.key \
2375 -cert data_files/server5.ku-ka.crt" \
2376 0 \
2377 -s "bad certificate (usage extensions)" \
2378 -S "Processing of the Certificate handshake message failed"
2379
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002380# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002382run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002383 "$P_SRV key_file=data_files/server5.key \
2384 crt_file=data_files/server5.eku-srv.crt" \
2385 "$P_CLI" \
2386 0
2387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002388run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002389 "$P_SRV key_file=data_files/server5.key \
2390 crt_file=data_files/server5.eku-srv.crt" \
2391 "$P_CLI" \
2392 0
2393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002394run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002395 "$P_SRV key_file=data_files/server5.key \
2396 crt_file=data_files/server5.eku-cs_any.crt" \
2397 "$P_CLI" \
2398 0
2399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002400run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002401 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002402 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002403 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002404 1
2405
2406# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002408run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002409 "$O_SRV -key data_files/server5.key \
2410 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002411 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002412 0 \
2413 -C "bad certificate (usage extensions)" \
2414 -C "Processing of the Certificate handshake message failed" \
2415 -c "Ciphersuite is TLS-"
2416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002417run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002418 "$O_SRV -key data_files/server5.key \
2419 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002420 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002421 0 \
2422 -C "bad certificate (usage extensions)" \
2423 -C "Processing of the Certificate handshake message failed" \
2424 -c "Ciphersuite is TLS-"
2425
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002426run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002427 "$O_SRV -key data_files/server5.key \
2428 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002429 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002430 0 \
2431 -C "bad certificate (usage extensions)" \
2432 -C "Processing of the Certificate handshake message failed" \
2433 -c "Ciphersuite is TLS-"
2434
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002435run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002436 "$O_SRV -key data_files/server5.key \
2437 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002438 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002439 1 \
2440 -c "bad certificate (usage extensions)" \
2441 -c "Processing of the Certificate handshake message failed" \
2442 -C "Ciphersuite is TLS-"
2443
2444# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002446run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002447 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002448 "$O_CLI -key data_files/server5.key \
2449 -cert data_files/server5.eku-cli.crt" \
2450 0 \
2451 -S "bad certificate (usage extensions)" \
2452 -S "Processing of the Certificate handshake message failed"
2453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002454run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002455 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002456 "$O_CLI -key data_files/server5.key \
2457 -cert data_files/server5.eku-srv_cli.crt" \
2458 0 \
2459 -S "bad certificate (usage extensions)" \
2460 -S "Processing of the Certificate handshake message failed"
2461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002462run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002463 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002464 "$O_CLI -key data_files/server5.key \
2465 -cert data_files/server5.eku-cs_any.crt" \
2466 0 \
2467 -S "bad certificate (usage extensions)" \
2468 -S "Processing of the Certificate handshake message failed"
2469
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002470run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002471 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002472 "$O_CLI -key data_files/server5.key \
2473 -cert data_files/server5.eku-cs.crt" \
2474 0 \
2475 -s "bad certificate (usage extensions)" \
2476 -S "Processing of the Certificate handshake message failed"
2477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002478run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002479 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002480 "$O_CLI -key data_files/server5.key \
2481 -cert data_files/server5.eku-cs.crt" \
2482 1 \
2483 -s "bad certificate (usage extensions)" \
2484 -s "Processing of the Certificate handshake message failed"
2485
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002486# Tests for DHM parameters loading
2487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002488run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002489 "$P_SRV" \
2490 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2491 debug_level=3" \
2492 0 \
2493 -c "value of 'DHM: P ' (2048 bits)" \
2494 -c "value of 'DHM: G ' (2048 bits)"
2495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002496run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002497 "$P_SRV dhm_file=data_files/dhparams.pem" \
2498 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2499 debug_level=3" \
2500 0 \
2501 -c "value of 'DHM: P ' (1024 bits)" \
2502 -c "value of 'DHM: G ' (2 bits)"
2503
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002504# Tests for DHM client-side size checking
2505
2506run_test "DHM size: server default, client default, OK" \
2507 "$P_SRV" \
2508 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2509 debug_level=1" \
2510 0 \
2511 -C "DHM prime too short:"
2512
2513run_test "DHM size: server default, client 2048, OK" \
2514 "$P_SRV" \
2515 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2516 debug_level=1 dhmlen=2048" \
2517 0 \
2518 -C "DHM prime too short:"
2519
2520run_test "DHM size: server 1024, client default, OK" \
2521 "$P_SRV dhm_file=data_files/dhparams.pem" \
2522 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2523 debug_level=1" \
2524 0 \
2525 -C "DHM prime too short:"
2526
2527run_test "DHM size: server 1000, client default, rejected" \
2528 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2529 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2530 debug_level=1" \
2531 1 \
2532 -c "DHM prime too short:"
2533
2534run_test "DHM size: server default, client 2049, rejected" \
2535 "$P_SRV" \
2536 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2537 debug_level=1 dhmlen=2049" \
2538 1 \
2539 -c "DHM prime too short:"
2540
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002541# Tests for PSK callback
2542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002543run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002544 "$P_SRV psk=abc123 psk_identity=foo" \
2545 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2546 psk_identity=foo psk=abc123" \
2547 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002548 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002549 -S "SSL - Unknown identity received" \
2550 -S "SSL - Verification of the message MAC failed"
2551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002552run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002553 "$P_SRV" \
2554 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2555 psk_identity=foo psk=abc123" \
2556 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002557 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002558 -S "SSL - Unknown identity received" \
2559 -S "SSL - Verification of the message MAC failed"
2560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002561run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002562 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2563 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2564 psk_identity=foo psk=abc123" \
2565 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002566 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002567 -s "SSL - Unknown identity received" \
2568 -S "SSL - Verification of the message MAC failed"
2569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002570run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002571 "$P_SRV psk_list=abc,dead,def,beef" \
2572 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2573 psk_identity=abc psk=dead" \
2574 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002575 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002576 -S "SSL - Unknown identity received" \
2577 -S "SSL - Verification of the message MAC failed"
2578
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002579run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002580 "$P_SRV psk_list=abc,dead,def,beef" \
2581 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2582 psk_identity=def psk=beef" \
2583 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002584 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002585 -S "SSL - Unknown identity received" \
2586 -S "SSL - Verification of the message MAC failed"
2587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002588run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002589 "$P_SRV psk_list=abc,dead,def,beef" \
2590 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2591 psk_identity=ghi psk=beef" \
2592 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002593 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002594 -s "SSL - Unknown identity received" \
2595 -S "SSL - Verification of the message MAC failed"
2596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002597run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002598 "$P_SRV psk_list=abc,dead,def,beef" \
2599 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2600 psk_identity=abc psk=beef" \
2601 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002602 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002603 -S "SSL - Unknown identity received" \
2604 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002605
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002606# Tests for ciphersuites per version
2607
Janos Follath542ee5d2016-03-07 15:57:05 +00002608requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002609run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002610 "$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 +02002611 "$P_CLI force_version=ssl3" \
2612 0 \
2613 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002615run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002616 "$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 +01002617 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002618 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002619 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002621run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002622 "$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 +02002623 "$P_CLI force_version=tls1_1" \
2624 0 \
2625 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002627run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002628 "$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 +02002629 "$P_CLI force_version=tls1_2" \
2630 0 \
2631 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2632
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002633# Test for ClientHello without extensions
2634
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002635requires_gnutls
2636run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002637 "$P_SRV debug_level=3" \
2638 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2639 0 \
2640 -s "dumping 'client hello extensions' (0 bytes)"
2641
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002642# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002643
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002644run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002645 "$P_SRV" \
2646 "$P_CLI request_size=100" \
2647 0 \
2648 -s "Read from client: 100 bytes read$"
2649
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002650run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002651 "$P_SRV" \
2652 "$P_CLI request_size=500" \
2653 0 \
2654 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002655
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002656# Tests for small packets
2657
Janos Follath542ee5d2016-03-07 15:57:05 +00002658requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002659run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002660 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002661 "$P_CLI request_size=1 force_version=ssl3 \
2662 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2663 0 \
2664 -s "Read from client: 1 bytes read"
2665
Janos Follath542ee5d2016-03-07 15:57:05 +00002666requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002667run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002668 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002669 "$P_CLI request_size=1 force_version=ssl3 \
2670 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2671 0 \
2672 -s "Read from client: 1 bytes read"
2673
2674run_test "Small packet TLS 1.0 BlockCipher" \
2675 "$P_SRV" \
2676 "$P_CLI request_size=1 force_version=tls1 \
2677 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2678 0 \
2679 -s "Read from client: 1 bytes read"
2680
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002681run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2682 "$P_SRV" \
2683 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2684 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2685 0 \
2686 -s "Read from client: 1 bytes read"
2687
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002688run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2689 "$P_SRV" \
2690 "$P_CLI request_size=1 force_version=tls1 \
2691 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2692 trunc_hmac=1" \
2693 0 \
2694 -s "Read from client: 1 bytes read"
2695
2696run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002697 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002698 "$P_CLI request_size=1 force_version=tls1 \
2699 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2700 trunc_hmac=1" \
2701 0 \
2702 -s "Read from client: 1 bytes read"
2703
2704run_test "Small packet TLS 1.1 BlockCipher" \
2705 "$P_SRV" \
2706 "$P_CLI request_size=1 force_version=tls1_1 \
2707 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2708 0 \
2709 -s "Read from client: 1 bytes read"
2710
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002711run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2712 "$P_SRV" \
2713 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2714 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2715 0 \
2716 -s "Read from client: 1 bytes read"
2717
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002718run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002719 "$P_SRV 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=tls1_1 \
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.1 BlockCipher truncated MAC" \
2726 "$P_SRV" \
2727 "$P_CLI request_size=1 force_version=tls1_1 \
2728 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2729 trunc_hmac=1" \
2730 0 \
2731 -s "Read from client: 1 bytes read"
2732
2733run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002734 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002735 "$P_CLI request_size=1 force_version=tls1_1 \
2736 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2737 trunc_hmac=1" \
2738 0 \
2739 -s "Read from client: 1 bytes read"
2740
2741run_test "Small packet TLS 1.2 BlockCipher" \
2742 "$P_SRV" \
2743 "$P_CLI request_size=1 force_version=tls1_2 \
2744 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2745 0 \
2746 -s "Read from client: 1 bytes read"
2747
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002748run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2749 "$P_SRV" \
2750 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2751 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2752 0 \
2753 -s "Read from client: 1 bytes read"
2754
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002755run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2756 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002757 "$P_CLI request_size=1 force_version=tls1_2 \
2758 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002759 0 \
2760 -s "Read from client: 1 bytes read"
2761
2762run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2763 "$P_SRV" \
2764 "$P_CLI request_size=1 force_version=tls1_2 \
2765 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2766 trunc_hmac=1" \
2767 0 \
2768 -s "Read from client: 1 bytes read"
2769
2770run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002771 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002772 "$P_CLI request_size=1 force_version=tls1_2 \
2773 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2774 0 \
2775 -s "Read from client: 1 bytes read"
2776
2777run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002778 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002779 "$P_CLI request_size=1 force_version=tls1_2 \
2780 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2781 trunc_hmac=1" \
2782 0 \
2783 -s "Read from client: 1 bytes read"
2784
2785run_test "Small packet TLS 1.2 AEAD" \
2786 "$P_SRV" \
2787 "$P_CLI request_size=1 force_version=tls1_2 \
2788 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2789 0 \
2790 -s "Read from client: 1 bytes read"
2791
2792run_test "Small packet TLS 1.2 AEAD shorter tag" \
2793 "$P_SRV" \
2794 "$P_CLI request_size=1 force_version=tls1_2 \
2795 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2796 0 \
2797 -s "Read from client: 1 bytes read"
2798
Janos Follathb700c462016-05-06 13:48:23 +01002799# A test for extensions in SSLv3
2800
2801requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2802run_test "SSLv3 with extensions, server side" \
2803 "$P_SRV min_version=ssl3 debug_level=3" \
2804 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2805 0 \
2806 -S "dumping 'client hello extensions'" \
2807 -S "server hello, total extension length:"
2808
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002809# Test for large packets
2810
Janos Follath542ee5d2016-03-07 15:57:05 +00002811requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002812run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002813 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002814 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002815 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2816 0 \
2817 -s "Read from client: 16384 bytes read"
2818
Janos Follath542ee5d2016-03-07 15:57:05 +00002819requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002820run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002821 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002822 "$P_CLI request_size=16384 force_version=ssl3 \
2823 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2824 0 \
2825 -s "Read from client: 16384 bytes read"
2826
2827run_test "Large packet TLS 1.0 BlockCipher" \
2828 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002829 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002830 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2831 0 \
2832 -s "Read from client: 16384 bytes read"
2833
2834run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2835 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002836 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002837 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2838 trunc_hmac=1" \
2839 0 \
2840 -s "Read from client: 16384 bytes read"
2841
2842run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002843 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002844 "$P_CLI request_size=16384 force_version=tls1 \
2845 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2846 trunc_hmac=1" \
2847 0 \
2848 -s "Read from client: 16384 bytes read"
2849
2850run_test "Large packet TLS 1.1 BlockCipher" \
2851 "$P_SRV" \
2852 "$P_CLI request_size=16384 force_version=tls1_1 \
2853 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2854 0 \
2855 -s "Read from client: 16384 bytes read"
2856
2857run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002858 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002859 "$P_CLI request_size=16384 force_version=tls1_1 \
2860 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2861 0 \
2862 -s "Read from client: 16384 bytes read"
2863
2864run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2865 "$P_SRV" \
2866 "$P_CLI request_size=16384 force_version=tls1_1 \
2867 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2868 trunc_hmac=1" \
2869 0 \
2870 -s "Read from client: 16384 bytes read"
2871
2872run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002873 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002874 "$P_CLI request_size=16384 force_version=tls1_1 \
2875 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2876 trunc_hmac=1" \
2877 0 \
2878 -s "Read from client: 16384 bytes read"
2879
2880run_test "Large packet TLS 1.2 BlockCipher" \
2881 "$P_SRV" \
2882 "$P_CLI request_size=16384 force_version=tls1_2 \
2883 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2884 0 \
2885 -s "Read from client: 16384 bytes read"
2886
2887run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2888 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002889 "$P_CLI request_size=16384 force_version=tls1_2 \
2890 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002891 0 \
2892 -s "Read from client: 16384 bytes read"
2893
2894run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2895 "$P_SRV" \
2896 "$P_CLI request_size=16384 force_version=tls1_2 \
2897 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2898 trunc_hmac=1" \
2899 0 \
2900 -s "Read from client: 16384 bytes read"
2901
2902run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002903 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002904 "$P_CLI request_size=16384 force_version=tls1_2 \
2905 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2906 0 \
2907 -s "Read from client: 16384 bytes read"
2908
2909run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002910 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002911 "$P_CLI request_size=16384 force_version=tls1_2 \
2912 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2913 trunc_hmac=1" \
2914 0 \
2915 -s "Read from client: 16384 bytes read"
2916
2917run_test "Large packet TLS 1.2 AEAD" \
2918 "$P_SRV" \
2919 "$P_CLI request_size=16384 force_version=tls1_2 \
2920 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2921 0 \
2922 -s "Read from client: 16384 bytes read"
2923
2924run_test "Large packet TLS 1.2 AEAD shorter tag" \
2925 "$P_SRV" \
2926 "$P_CLI request_size=16384 force_version=tls1_2 \
2927 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2928 0 \
2929 -s "Read from client: 16384 bytes read"
2930
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002931# Tests for DTLS HelloVerifyRequest
2932
2933run_test "DTLS cookie: enabled" \
2934 "$P_SRV dtls=1 debug_level=2" \
2935 "$P_CLI dtls=1 debug_level=2" \
2936 0 \
2937 -s "cookie verification failed" \
2938 -s "cookie verification passed" \
2939 -S "cookie verification skipped" \
2940 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002941 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002942 -S "SSL - The requested feature is not available"
2943
2944run_test "DTLS cookie: disabled" \
2945 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2946 "$P_CLI dtls=1 debug_level=2" \
2947 0 \
2948 -S "cookie verification failed" \
2949 -S "cookie verification passed" \
2950 -s "cookie verification skipped" \
2951 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002952 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002953 -S "SSL - The requested feature is not available"
2954
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002955run_test "DTLS cookie: default (failing)" \
2956 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2957 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2958 1 \
2959 -s "cookie verification failed" \
2960 -S "cookie verification passed" \
2961 -S "cookie verification skipped" \
2962 -C "received hello verify request" \
2963 -S "hello verification requested" \
2964 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002965
2966requires_ipv6
2967run_test "DTLS cookie: enabled, IPv6" \
2968 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2969 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2970 0 \
2971 -s "cookie verification failed" \
2972 -s "cookie verification passed" \
2973 -S "cookie verification skipped" \
2974 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002975 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002976 -S "SSL - The requested feature is not available"
2977
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002978run_test "DTLS cookie: enabled, nbio" \
2979 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2980 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2981 0 \
2982 -s "cookie verification failed" \
2983 -s "cookie verification passed" \
2984 -S "cookie verification skipped" \
2985 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002986 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002987 -S "SSL - The requested feature is not available"
2988
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002989# Tests for client reconnecting from the same port with DTLS
2990
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002991not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002992run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002993 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
2994 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002995 0 \
2996 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002997 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002998 -S "Client initiated reconnection from same port"
2999
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003000not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003001run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003002 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3003 "$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 +02003004 0 \
3005 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003006 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003007 -s "Client initiated reconnection from same port"
3008
Paul Bakker3b224ff2016-05-13 10:33:25 +01003009not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3010run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003011 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3012 "$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 +02003013 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003014 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003015 -s "Client initiated reconnection from same port"
3016
Paul Bakker3b224ff2016-05-13 10:33:25 +01003017only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3018run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3019 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3020 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3021 0 \
3022 -S "The operation timed out" \
3023 -s "Client initiated reconnection from same port"
3024
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003025run_test "DTLS client reconnect from same port: no cookies" \
3026 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003027 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3028 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003029 -s "The operation timed out" \
3030 -S "Client initiated reconnection from same port"
3031
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003032# Tests for various cases of client authentication with DTLS
3033# (focused on handshake flows and message parsing)
3034
3035run_test "DTLS client auth: required" \
3036 "$P_SRV dtls=1 auth_mode=required" \
3037 "$P_CLI dtls=1" \
3038 0 \
3039 -s "Verifying peer X.509 certificate... ok"
3040
3041run_test "DTLS client auth: optional, client has no cert" \
3042 "$P_SRV dtls=1 auth_mode=optional" \
3043 "$P_CLI dtls=1 crt_file=none key_file=none" \
3044 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003045 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003046
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003047run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003048 "$P_SRV dtls=1 auth_mode=none" \
3049 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3050 0 \
3051 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003052 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003053
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003054run_test "DTLS wrong PSK: badmac alert" \
3055 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3056 "$P_CLI dtls=1 psk=abc124" \
3057 1 \
3058 -s "SSL - Verification of the message MAC failed" \
3059 -c "SSL - A fatal alert message was received from our peer"
3060
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003061# Tests for receiving fragmented handshake messages with DTLS
3062
3063requires_gnutls
3064run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3065 "$G_SRV -u --mtu 2048 -a" \
3066 "$P_CLI dtls=1 debug_level=2" \
3067 0 \
3068 -C "found fragmented DTLS handshake message" \
3069 -C "error"
3070
3071requires_gnutls
3072run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3073 "$G_SRV -u --mtu 512" \
3074 "$P_CLI dtls=1 debug_level=2" \
3075 0 \
3076 -c "found fragmented DTLS handshake message" \
3077 -C "error"
3078
3079requires_gnutls
3080run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3081 "$G_SRV -u --mtu 128" \
3082 "$P_CLI dtls=1 debug_level=2" \
3083 0 \
3084 -c "found fragmented DTLS handshake message" \
3085 -C "error"
3086
3087requires_gnutls
3088run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3089 "$G_SRV -u --mtu 128" \
3090 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3091 0 \
3092 -c "found fragmented DTLS handshake message" \
3093 -C "error"
3094
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003095requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003096run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3097 "$G_SRV -u --mtu 256" \
3098 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3099 0 \
3100 -c "found fragmented DTLS handshake message" \
3101 -c "client hello, adding renegotiation extension" \
3102 -c "found renegotiation extension" \
3103 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003104 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003105 -C "error" \
3106 -s "Extra-header:"
3107
3108requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003109run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3110 "$G_SRV -u --mtu 256" \
3111 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3112 0 \
3113 -c "found fragmented DTLS handshake message" \
3114 -c "client hello, adding renegotiation extension" \
3115 -c "found renegotiation extension" \
3116 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003117 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003118 -C "error" \
3119 -s "Extra-header:"
3120
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003121run_test "DTLS reassembly: no fragmentation (openssl server)" \
3122 "$O_SRV -dtls1 -mtu 2048" \
3123 "$P_CLI dtls=1 debug_level=2" \
3124 0 \
3125 -C "found fragmented DTLS handshake message" \
3126 -C "error"
3127
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003128run_test "DTLS reassembly: some fragmentation (openssl server)" \
3129 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003130 "$P_CLI dtls=1 debug_level=2" \
3131 0 \
3132 -c "found fragmented DTLS handshake message" \
3133 -C "error"
3134
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003135run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003136 "$O_SRV -dtls1 -mtu 256" \
3137 "$P_CLI dtls=1 debug_level=2" \
3138 0 \
3139 -c "found fragmented DTLS handshake message" \
3140 -C "error"
3141
3142run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3143 "$O_SRV -dtls1 -mtu 256" \
3144 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3145 0 \
3146 -c "found fragmented DTLS handshake message" \
3147 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003148
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003149# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003150
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003151not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003152run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003153 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003154 "$P_SRV dtls=1 debug_level=2" \
3155 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003156 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003157 -C "replayed record" \
3158 -S "replayed record" \
3159 -C "record from another epoch" \
3160 -S "record from another epoch" \
3161 -C "discarding invalid record" \
3162 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003163 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003164 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003165 -c "HTTP/1.0 200 OK"
3166
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003167not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003168run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003169 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003170 "$P_SRV dtls=1 debug_level=2" \
3171 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003172 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003173 -c "replayed record" \
3174 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003175 -c "discarding invalid record" \
3176 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003177 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003178 -s "Extra-header:" \
3179 -c "HTTP/1.0 200 OK"
3180
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003181run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3182 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003183 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3184 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003185 0 \
3186 -c "replayed record" \
3187 -S "replayed record" \
3188 -c "discarding invalid record" \
3189 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003190 -c "resend" \
3191 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003192 -s "Extra-header:" \
3193 -c "HTTP/1.0 200 OK"
3194
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003195run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003196 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003197 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003198 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003199 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003200 -c "discarding invalid record (mac)" \
3201 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003202 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003203 -c "HTTP/1.0 200 OK" \
3204 -S "too many records with bad MAC" \
3205 -S "Verification of the message MAC failed"
3206
3207run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3208 -p "$P_PXY bad_ad=1" \
3209 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3210 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3211 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003212 -C "discarding invalid record (mac)" \
3213 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003214 -S "Extra-header:" \
3215 -C "HTTP/1.0 200 OK" \
3216 -s "too many records with bad MAC" \
3217 -s "Verification of the message MAC failed"
3218
3219run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3220 -p "$P_PXY bad_ad=1" \
3221 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3222 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3223 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003224 -c "discarding invalid record (mac)" \
3225 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003226 -s "Extra-header:" \
3227 -c "HTTP/1.0 200 OK" \
3228 -S "too many records with bad MAC" \
3229 -S "Verification of the message MAC failed"
3230
3231run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3232 -p "$P_PXY bad_ad=1" \
3233 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3234 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3235 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003236 -c "discarding invalid record (mac)" \
3237 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003238 -s "Extra-header:" \
3239 -c "HTTP/1.0 200 OK" \
3240 -s "too many records with bad MAC" \
3241 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003242
3243run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003244 -p "$P_PXY delay_ccs=1" \
3245 "$P_SRV dtls=1 debug_level=1" \
3246 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003247 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003248 -c "record from another epoch" \
3249 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003250 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003251 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003252 -s "Extra-header:" \
3253 -c "HTTP/1.0 200 OK"
3254
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003255# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003256
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003257needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003258run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003259 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003260 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3261 psk=abc123" \
3262 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003263 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3264 0 \
3265 -s "Extra-header:" \
3266 -c "HTTP/1.0 200 OK"
3267
3268needs_more_time 2
3269run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3270 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003271 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3272 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003273 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3274 0 \
3275 -s "Extra-header:" \
3276 -c "HTTP/1.0 200 OK"
3277
3278needs_more_time 2
3279run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3280 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003281 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3282 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003283 0 \
3284 -s "Extra-header:" \
3285 -c "HTTP/1.0 200 OK"
3286
3287needs_more_time 2
3288run_test "DTLS proxy: 3d, FS, client auth" \
3289 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003290 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3291 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003292 0 \
3293 -s "Extra-header:" \
3294 -c "HTTP/1.0 200 OK"
3295
3296needs_more_time 2
3297run_test "DTLS proxy: 3d, FS, ticket" \
3298 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003299 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3300 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003301 0 \
3302 -s "Extra-header:" \
3303 -c "HTTP/1.0 200 OK"
3304
3305needs_more_time 2
3306run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3307 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003308 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3309 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003310 0 \
3311 -s "Extra-header:" \
3312 -c "HTTP/1.0 200 OK"
3313
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003314needs_more_time 2
3315run_test "DTLS proxy: 3d, max handshake, nbio" \
3316 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003317 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3318 auth_mode=required" \
3319 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003320 0 \
3321 -s "Extra-header:" \
3322 -c "HTTP/1.0 200 OK"
3323
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003324needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003325run_test "DTLS proxy: 3d, min handshake, resumption" \
3326 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3327 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3328 psk=abc123 debug_level=3" \
3329 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3330 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3331 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3332 0 \
3333 -s "a session has been resumed" \
3334 -c "a session has been resumed" \
3335 -s "Extra-header:" \
3336 -c "HTTP/1.0 200 OK"
3337
3338needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003339run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3340 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3341 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3342 psk=abc123 debug_level=3 nbio=2" \
3343 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3344 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3345 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3346 0 \
3347 -s "a session has been resumed" \
3348 -c "a session has been resumed" \
3349 -s "Extra-header:" \
3350 -c "HTTP/1.0 200 OK"
3351
3352needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003353run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003354 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003355 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3356 psk=abc123 renegotiation=1 debug_level=2" \
3357 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3358 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003359 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3360 0 \
3361 -c "=> renegotiate" \
3362 -s "=> renegotiate" \
3363 -s "Extra-header:" \
3364 -c "HTTP/1.0 200 OK"
3365
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003366needs_more_time 4
3367run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3368 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003369 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3370 psk=abc123 renegotiation=1 debug_level=2" \
3371 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3372 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003373 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3374 0 \
3375 -c "=> renegotiate" \
3376 -s "=> renegotiate" \
3377 -s "Extra-header:" \
3378 -c "HTTP/1.0 200 OK"
3379
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003380needs_more_time 4
3381run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003382 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003383 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003384 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003385 debug_level=2" \
3386 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003387 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003388 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3389 0 \
3390 -c "=> renegotiate" \
3391 -s "=> renegotiate" \
3392 -s "Extra-header:" \
3393 -c "HTTP/1.0 200 OK"
3394
3395needs_more_time 4
3396run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003397 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003398 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003399 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003400 debug_level=2 nbio=2" \
3401 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003402 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003403 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3404 0 \
3405 -c "=> renegotiate" \
3406 -s "=> renegotiate" \
3407 -s "Extra-header:" \
3408 -c "HTTP/1.0 200 OK"
3409
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003410needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003411not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003412run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003413 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3414 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003415 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003416 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003417 -c "HTTP/1.0 200 OK"
3418
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003419needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003420not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003421run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3422 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3423 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003424 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003425 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003426 -c "HTTP/1.0 200 OK"
3427
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003428needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003429not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003430run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3431 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3432 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003433 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003434 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003435 -c "HTTP/1.0 200 OK"
3436
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003437requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003438needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003439not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003440run_test "DTLS proxy: 3d, gnutls server" \
3441 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3442 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003443 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003444 0 \
3445 -s "Extra-header:" \
3446 -c "Extra-header:"
3447
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003448requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003449needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003450not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003451run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3452 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3453 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003454 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003455 0 \
3456 -s "Extra-header:" \
3457 -c "Extra-header:"
3458
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003459requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003460needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003461not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003462run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3463 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3464 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003465 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003466 0 \
3467 -s "Extra-header:" \
3468 -c "Extra-header:"
3469
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003470# Final report
3471
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003472echo "------------------------------------------------------------------------"
3473
3474if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003475 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003476else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003477 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003478fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003479PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003480echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003481
3482exit $FAILS