blob: 24b0fff144bc37cd90a6c8fb14b4f145f5c97de4 [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
Andres AG9b1927b2017-01-19 16:30:57 +00001537run_test "Renegotiation: DTLS, renego_period overflow" \
1538 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1539 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1540 0 \
1541 -c "client hello, adding renegotiation extension" \
1542 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1543 -s "found renegotiation extension" \
1544 -s "server hello, secure renegotiation extension" \
1545 -s "record counter limit reached: renegotiate" \
1546 -c "=> renegotiate" \
1547 -s "=> renegotiate" \
1548 -s "write hello request" \
1549
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001550requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001551run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1552 "$G_SRV -u --mtu 4096" \
1553 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1554 0 \
1555 -c "client hello, adding renegotiation extension" \
1556 -c "found renegotiation extension" \
1557 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001558 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001559 -C "error" \
1560 -s "Extra-header:"
1561
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001562# Test for the "secure renegotation" extension only (no actual renegotiation)
1563
Paul Bakker539d9722015-02-08 16:18:35 +01001564requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001565run_test "Renego ext: gnutls server strict, client default" \
1566 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1567 "$P_CLI debug_level=3" \
1568 0 \
1569 -c "found renegotiation extension" \
1570 -C "error" \
1571 -c "HTTP/1.0 200 [Oo][Kk]"
1572
Paul Bakker539d9722015-02-08 16:18:35 +01001573requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001574run_test "Renego ext: gnutls server unsafe, client default" \
1575 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1576 "$P_CLI debug_level=3" \
1577 0 \
1578 -C "found renegotiation extension" \
1579 -C "error" \
1580 -c "HTTP/1.0 200 [Oo][Kk]"
1581
Paul Bakker539d9722015-02-08 16:18:35 +01001582requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001583run_test "Renego ext: gnutls server unsafe, client break legacy" \
1584 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1585 "$P_CLI debug_level=3 allow_legacy=-1" \
1586 1 \
1587 -C "found renegotiation extension" \
1588 -c "error" \
1589 -C "HTTP/1.0 200 [Oo][Kk]"
1590
Paul Bakker539d9722015-02-08 16:18:35 +01001591requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001592run_test "Renego ext: gnutls client strict, server default" \
1593 "$P_SRV debug_level=3" \
1594 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1595 0 \
1596 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1597 -s "server hello, secure renegotiation extension"
1598
Paul Bakker539d9722015-02-08 16:18:35 +01001599requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001600run_test "Renego ext: gnutls client unsafe, server default" \
1601 "$P_SRV debug_level=3" \
1602 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1603 0 \
1604 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1605 -S "server hello, secure renegotiation extension"
1606
Paul Bakker539d9722015-02-08 16:18:35 +01001607requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001608run_test "Renego ext: gnutls client unsafe, server break legacy" \
1609 "$P_SRV debug_level=3 allow_legacy=-1" \
1610 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1611 1 \
1612 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1613 -S "server hello, secure renegotiation extension"
1614
Janos Follath365b2262016-02-17 10:11:21 +00001615# Tests for silently dropping trailing extra bytes in .der certificates
1616
1617requires_gnutls
1618run_test "DER format: no trailing bytes" \
1619 "$P_SRV crt_file=data_files/server5-der0.crt \
1620 key_file=data_files/server5.key" \
1621 "$G_CLI " \
1622 0 \
1623 -c "Handshake was completed" \
1624
1625requires_gnutls
1626run_test "DER format: with a trailing zero byte" \
1627 "$P_SRV crt_file=data_files/server5-der1a.crt \
1628 key_file=data_files/server5.key" \
1629 "$G_CLI " \
1630 0 \
1631 -c "Handshake was completed" \
1632
1633requires_gnutls
1634run_test "DER format: with a trailing random byte" \
1635 "$P_SRV crt_file=data_files/server5-der1b.crt \
1636 key_file=data_files/server5.key" \
1637 "$G_CLI " \
1638 0 \
1639 -c "Handshake was completed" \
1640
1641requires_gnutls
1642run_test "DER format: with 2 trailing random bytes" \
1643 "$P_SRV crt_file=data_files/server5-der2.crt \
1644 key_file=data_files/server5.key" \
1645 "$G_CLI " \
1646 0 \
1647 -c "Handshake was completed" \
1648
1649requires_gnutls
1650run_test "DER format: with 4 trailing random bytes" \
1651 "$P_SRV crt_file=data_files/server5-der4.crt \
1652 key_file=data_files/server5.key" \
1653 "$G_CLI " \
1654 0 \
1655 -c "Handshake was completed" \
1656
1657requires_gnutls
1658run_test "DER format: with 8 trailing random bytes" \
1659 "$P_SRV crt_file=data_files/server5-der8.crt \
1660 key_file=data_files/server5.key" \
1661 "$G_CLI " \
1662 0 \
1663 -c "Handshake was completed" \
1664
1665requires_gnutls
1666run_test "DER format: with 9 trailing random bytes" \
1667 "$P_SRV crt_file=data_files/server5-der9.crt \
1668 key_file=data_files/server5.key" \
1669 "$G_CLI " \
1670 0 \
1671 -c "Handshake was completed" \
1672
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001673# Tests for auth_mode
1674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001675run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001676 "$P_SRV crt_file=data_files/server5-badsign.crt \
1677 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001678 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001679 1 \
1680 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001681 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001682 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001683 -c "X509 - Certificate verification failed"
1684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001685run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001686 "$P_SRV crt_file=data_files/server5-badsign.crt \
1687 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001688 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001689 0 \
1690 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001691 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001692 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001693 -C "X509 - Certificate verification failed"
1694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001695run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001696 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001697 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001698 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001699 0 \
1700 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001701 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001702 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001703 -C "X509 - Certificate verification failed"
1704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001705run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001706 "$P_SRV debug_level=3 auth_mode=required" \
1707 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001708 key_file=data_files/server5.key" \
1709 1 \
1710 -S "skip write certificate request" \
1711 -C "skip parse certificate request" \
1712 -c "got a certificate request" \
1713 -C "skip write certificate" \
1714 -C "skip write certificate verify" \
1715 -S "skip parse certificate verify" \
1716 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001717 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001718 -s "! mbedtls_ssl_handshake returned" \
1719 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001720 -s "X509 - Certificate verification failed"
1721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001722run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001723 "$P_SRV debug_level=3 auth_mode=optional" \
1724 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001725 key_file=data_files/server5.key" \
1726 0 \
1727 -S "skip write certificate request" \
1728 -C "skip parse certificate request" \
1729 -c "got a certificate request" \
1730 -C "skip write certificate" \
1731 -C "skip write certificate verify" \
1732 -S "skip parse certificate verify" \
1733 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001734 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001735 -S "! mbedtls_ssl_handshake returned" \
1736 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001737 -S "X509 - Certificate verification failed"
1738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001739run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001740 "$P_SRV debug_level=3 auth_mode=none" \
1741 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001742 key_file=data_files/server5.key" \
1743 0 \
1744 -s "skip write certificate request" \
1745 -C "skip parse certificate request" \
1746 -c "got no certificate request" \
1747 -c "skip write certificate" \
1748 -c "skip write certificate verify" \
1749 -s "skip parse certificate verify" \
1750 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001751 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001752 -S "! mbedtls_ssl_handshake returned" \
1753 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001754 -S "X509 - Certificate verification failed"
1755
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001756run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001757 "$P_SRV debug_level=3 auth_mode=optional" \
1758 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001759 0 \
1760 -S "skip write certificate request" \
1761 -C "skip parse certificate request" \
1762 -c "got a certificate request" \
1763 -C "skip write certificate$" \
1764 -C "got no certificate to send" \
1765 -S "SSLv3 client has no certificate" \
1766 -c "skip write certificate verify" \
1767 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001768 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001769 -S "! mbedtls_ssl_handshake returned" \
1770 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001771 -S "X509 - Certificate verification failed"
1772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001773run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001774 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001775 "$O_CLI" \
1776 0 \
1777 -S "skip write certificate request" \
1778 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001779 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001780 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001781 -S "X509 - Certificate verification failed"
1782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001783run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001784 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001785 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001786 0 \
1787 -C "skip parse certificate request" \
1788 -c "got a certificate request" \
1789 -C "skip write certificate$" \
1790 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001791 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001792
Janos Follath542ee5d2016-03-07 15:57:05 +00001793requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001794run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001795 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001796 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001797 0 \
1798 -S "skip write certificate request" \
1799 -C "skip parse certificate request" \
1800 -c "got a certificate request" \
1801 -C "skip write certificate$" \
1802 -c "skip write certificate verify" \
1803 -c "got no certificate to send" \
1804 -s "SSLv3 client has no certificate" \
1805 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001806 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001807 -S "! mbedtls_ssl_handshake returned" \
1808 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001809 -S "X509 - Certificate verification failed"
1810
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001811# Tests for certificate selection based on SHA verson
1812
1813run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1814 "$P_SRV crt_file=data_files/server5.crt \
1815 key_file=data_files/server5.key \
1816 crt_file2=data_files/server5-sha1.crt \
1817 key_file2=data_files/server5.key" \
1818 "$P_CLI force_version=tls1_2" \
1819 0 \
1820 -c "signed using.*ECDSA with SHA256" \
1821 -C "signed using.*ECDSA with SHA1"
1822
1823run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1824 "$P_SRV crt_file=data_files/server5.crt \
1825 key_file=data_files/server5.key \
1826 crt_file2=data_files/server5-sha1.crt \
1827 key_file2=data_files/server5.key" \
1828 "$P_CLI force_version=tls1_1" \
1829 0 \
1830 -C "signed using.*ECDSA with SHA256" \
1831 -c "signed using.*ECDSA with SHA1"
1832
1833run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1834 "$P_SRV crt_file=data_files/server5.crt \
1835 key_file=data_files/server5.key \
1836 crt_file2=data_files/server5-sha1.crt \
1837 key_file2=data_files/server5.key" \
1838 "$P_CLI force_version=tls1" \
1839 0 \
1840 -C "signed using.*ECDSA with SHA256" \
1841 -c "signed using.*ECDSA with SHA1"
1842
1843run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1844 "$P_SRV crt_file=data_files/server5.crt \
1845 key_file=data_files/server5.key \
1846 crt_file2=data_files/server6.crt \
1847 key_file2=data_files/server6.key" \
1848 "$P_CLI force_version=tls1_1" \
1849 0 \
1850 -c "serial number.*09" \
1851 -c "signed using.*ECDSA with SHA256" \
1852 -C "signed using.*ECDSA with SHA1"
1853
1854run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1855 "$P_SRV crt_file=data_files/server6.crt \
1856 key_file=data_files/server6.key \
1857 crt_file2=data_files/server5.crt \
1858 key_file2=data_files/server5.key" \
1859 "$P_CLI force_version=tls1_1" \
1860 0 \
1861 -c "serial number.*0A" \
1862 -c "signed using.*ECDSA with SHA256" \
1863 -C "signed using.*ECDSA with SHA1"
1864
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001865# tests for SNI
1866
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001867run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001868 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001869 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001870 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001871 0 \
1872 -S "parse ServerName extension" \
1873 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1874 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001876run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001877 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001878 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001879 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 +02001880 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001881 0 \
1882 -s "parse ServerName extension" \
1883 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1884 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001886run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001887 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001888 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001889 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 +02001890 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001891 0 \
1892 -s "parse ServerName extension" \
1893 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1894 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001896run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001897 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001898 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001899 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 +02001900 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001901 1 \
1902 -s "parse ServerName extension" \
1903 -s "ssl_sni_wrapper() returned" \
1904 -s "mbedtls_ssl_handshake returned" \
1905 -c "mbedtls_ssl_handshake returned" \
1906 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001907
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001908run_test "SNI: client auth no override: optional" \
1909 "$P_SRV debug_level=3 auth_mode=optional \
1910 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1911 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
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: none -> optional" \
1922 "$P_SRV debug_level=3 auth_mode=none \
1923 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1924 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
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 a certificate request" \
1930 -C "skip write certificate" \
1931 -C "skip write certificate verify" \
1932 -S "skip parse certificate verify"
1933
1934run_test "SNI: client auth override: optional -> none" \
1935 "$P_SRV debug_level=3 auth_mode=optional \
1936 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1937 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1938 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001939 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001940 -s "skip write certificate request" \
1941 -C "skip parse certificate request" \
1942 -c "got no certificate request" \
1943 -c "skip write certificate" \
1944 -c "skip write certificate verify" \
1945 -s "skip parse certificate verify"
1946
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001947run_test "SNI: CA no override" \
1948 "$P_SRV debug_level=3 auth_mode=optional \
1949 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1950 ca_file=data_files/test-ca.crt \
1951 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1952 "$P_CLI debug_level=3 server_name=localhost \
1953 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1954 1 \
1955 -S "skip write certificate request" \
1956 -C "skip parse certificate request" \
1957 -c "got a certificate request" \
1958 -C "skip write certificate" \
1959 -C "skip write certificate verify" \
1960 -S "skip parse certificate verify" \
1961 -s "x509_verify_cert() returned" \
1962 -s "! The certificate is not correctly signed by the trusted CA" \
1963 -S "The certificate has been revoked (is on a CRL)"
1964
1965run_test "SNI: CA override" \
1966 "$P_SRV debug_level=3 auth_mode=optional \
1967 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1968 ca_file=data_files/test-ca.crt \
1969 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1970 "$P_CLI debug_level=3 server_name=localhost \
1971 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1972 0 \
1973 -S "skip write certificate request" \
1974 -C "skip parse certificate request" \
1975 -c "got a certificate request" \
1976 -C "skip write certificate" \
1977 -C "skip write certificate verify" \
1978 -S "skip parse certificate verify" \
1979 -S "x509_verify_cert() returned" \
1980 -S "! The certificate is not correctly signed by the trusted CA" \
1981 -S "The certificate has been revoked (is on a CRL)"
1982
1983run_test "SNI: CA override with CRL" \
1984 "$P_SRV debug_level=3 auth_mode=optional \
1985 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1986 ca_file=data_files/test-ca.crt \
1987 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1988 "$P_CLI debug_level=3 server_name=localhost \
1989 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1990 1 \
1991 -S "skip write certificate request" \
1992 -C "skip parse certificate request" \
1993 -c "got a certificate request" \
1994 -C "skip write certificate" \
1995 -C "skip write certificate verify" \
1996 -S "skip parse certificate verify" \
1997 -s "x509_verify_cert() returned" \
1998 -S "! The certificate is not correctly signed by the trusted CA" \
1999 -s "The certificate has been revoked (is on a CRL)"
2000
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002001# Tests for non-blocking I/O: exercise a variety of handshake flows
2002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002003run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002004 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2005 "$P_CLI nbio=2 tickets=0" \
2006 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002007 -S "mbedtls_ssl_handshake returned" \
2008 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002009 -c "Read from server: .* bytes read"
2010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002011run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002012 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2013 "$P_CLI nbio=2 tickets=0" \
2014 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002015 -S "mbedtls_ssl_handshake returned" \
2016 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002017 -c "Read from server: .* bytes read"
2018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002019run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002020 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2021 "$P_CLI nbio=2 tickets=1" \
2022 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002023 -S "mbedtls_ssl_handshake returned" \
2024 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002025 -c "Read from server: .* bytes read"
2026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002027run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002028 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2029 "$P_CLI nbio=2 tickets=1" \
2030 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002031 -S "mbedtls_ssl_handshake returned" \
2032 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002033 -c "Read from server: .* bytes read"
2034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002035run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002036 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2037 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2038 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002039 -S "mbedtls_ssl_handshake returned" \
2040 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002041 -c "Read from server: .* bytes read"
2042
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002043run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002044 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2045 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2046 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002047 -S "mbedtls_ssl_handshake returned" \
2048 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002049 -c "Read from server: .* bytes read"
2050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002051run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002052 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2053 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2054 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002055 -S "mbedtls_ssl_handshake returned" \
2056 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002057 -c "Read from server: .* bytes read"
2058
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002059# Tests for version negotiation
2060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002061run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002062 "$P_SRV" \
2063 "$P_CLI" \
2064 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002065 -S "mbedtls_ssl_handshake returned" \
2066 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002067 -s "Protocol is TLSv1.2" \
2068 -c "Protocol is TLSv1.2"
2069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002070run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002071 "$P_SRV" \
2072 "$P_CLI max_version=tls1_1" \
2073 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002074 -S "mbedtls_ssl_handshake returned" \
2075 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002076 -s "Protocol is TLSv1.1" \
2077 -c "Protocol is TLSv1.1"
2078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002079run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002080 "$P_SRV max_version=tls1_1" \
2081 "$P_CLI" \
2082 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002083 -S "mbedtls_ssl_handshake returned" \
2084 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002085 -s "Protocol is TLSv1.1" \
2086 -c "Protocol is TLSv1.1"
2087
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002088run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002089 "$P_SRV max_version=tls1_1" \
2090 "$P_CLI max_version=tls1_1" \
2091 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002092 -S "mbedtls_ssl_handshake returned" \
2093 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002094 -s "Protocol is TLSv1.1" \
2095 -c "Protocol is TLSv1.1"
2096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002097run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002098 "$P_SRV min_version=tls1_1" \
2099 "$P_CLI max_version=tls1_1" \
2100 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002101 -S "mbedtls_ssl_handshake returned" \
2102 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002103 -s "Protocol is TLSv1.1" \
2104 -c "Protocol is TLSv1.1"
2105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002106run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002107 "$P_SRV max_version=tls1_1" \
2108 "$P_CLI min_version=tls1_1" \
2109 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002110 -S "mbedtls_ssl_handshake returned" \
2111 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002112 -s "Protocol is TLSv1.1" \
2113 -c "Protocol is TLSv1.1"
2114
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002115run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002116 "$P_SRV max_version=tls1_1" \
2117 "$P_CLI min_version=tls1_2" \
2118 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002119 -s "mbedtls_ssl_handshake returned" \
2120 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002121 -c "SSL - Handshake protocol not within min/max boundaries"
2122
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002123run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002124 "$P_SRV min_version=tls1_2" \
2125 "$P_CLI max_version=tls1_1" \
2126 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002127 -s "mbedtls_ssl_handshake returned" \
2128 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002129 -s "SSL - Handshake protocol not within min/max boundaries"
2130
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002131# Tests for ALPN extension
2132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002133run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002134 "$P_SRV debug_level=3" \
2135 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002136 0 \
2137 -C "client hello, adding alpn extension" \
2138 -S "found alpn extension" \
2139 -C "got an alert message, type: \\[2:120]" \
2140 -S "server hello, adding alpn extension" \
2141 -C "found alpn extension " \
2142 -C "Application Layer Protocol is" \
2143 -S "Application Layer Protocol is"
2144
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002145run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002146 "$P_SRV debug_level=3" \
2147 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002148 0 \
2149 -c "client hello, adding alpn extension" \
2150 -s "found alpn extension" \
2151 -C "got an alert message, type: \\[2:120]" \
2152 -S "server hello, adding alpn extension" \
2153 -C "found alpn extension " \
2154 -c "Application Layer Protocol is (none)" \
2155 -S "Application Layer Protocol is"
2156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002157run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002158 "$P_SRV debug_level=3 alpn=abc,1234" \
2159 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002160 0 \
2161 -C "client hello, adding alpn extension" \
2162 -S "found alpn extension" \
2163 -C "got an alert message, type: \\[2:120]" \
2164 -S "server hello, adding alpn extension" \
2165 -C "found alpn extension " \
2166 -C "Application Layer Protocol is" \
2167 -s "Application Layer Protocol is (none)"
2168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002169run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002170 "$P_SRV debug_level=3 alpn=abc,1234" \
2171 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002172 0 \
2173 -c "client hello, adding alpn extension" \
2174 -s "found alpn extension" \
2175 -C "got an alert message, type: \\[2:120]" \
2176 -s "server hello, adding alpn extension" \
2177 -c "found alpn extension" \
2178 -c "Application Layer Protocol is abc" \
2179 -s "Application Layer Protocol is abc"
2180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002181run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002182 "$P_SRV debug_level=3 alpn=abc,1234" \
2183 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002184 0 \
2185 -c "client hello, adding alpn extension" \
2186 -s "found alpn extension" \
2187 -C "got an alert message, type: \\[2:120]" \
2188 -s "server hello, adding alpn extension" \
2189 -c "found alpn extension" \
2190 -c "Application Layer Protocol is abc" \
2191 -s "Application Layer Protocol is abc"
2192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002193run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002194 "$P_SRV debug_level=3 alpn=abc,1234" \
2195 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002196 0 \
2197 -c "client hello, adding alpn extension" \
2198 -s "found alpn extension" \
2199 -C "got an alert message, type: \\[2:120]" \
2200 -s "server hello, adding alpn extension" \
2201 -c "found alpn extension" \
2202 -c "Application Layer Protocol is 1234" \
2203 -s "Application Layer Protocol is 1234"
2204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002205run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002206 "$P_SRV debug_level=3 alpn=abc,123" \
2207 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002208 1 \
2209 -c "client hello, adding alpn extension" \
2210 -s "found alpn extension" \
2211 -c "got an alert message, type: \\[2:120]" \
2212 -S "server hello, adding alpn extension" \
2213 -C "found alpn extension" \
2214 -C "Application Layer Protocol is 1234" \
2215 -S "Application Layer Protocol is 1234"
2216
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002217
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002218# Tests for keyUsage in leaf certificates, part 1:
2219# server-side certificate/suite selection
2220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002221run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002222 "$P_SRV key_file=data_files/server2.key \
2223 crt_file=data_files/server2.ku-ds.crt" \
2224 "$P_CLI" \
2225 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002226 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002227
2228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002229run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002230 "$P_SRV key_file=data_files/server2.key \
2231 crt_file=data_files/server2.ku-ke.crt" \
2232 "$P_CLI" \
2233 0 \
2234 -c "Ciphersuite is TLS-RSA-WITH-"
2235
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002236run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002237 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002238 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002239 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002240 1 \
2241 -C "Ciphersuite is "
2242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002243run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002244 "$P_SRV key_file=data_files/server5.key \
2245 crt_file=data_files/server5.ku-ds.crt" \
2246 "$P_CLI" \
2247 0 \
2248 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2249
2250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002251run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002252 "$P_SRV key_file=data_files/server5.key \
2253 crt_file=data_files/server5.ku-ka.crt" \
2254 "$P_CLI" \
2255 0 \
2256 -c "Ciphersuite is TLS-ECDH-"
2257
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002258run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002259 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002260 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002261 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002262 1 \
2263 -C "Ciphersuite is "
2264
2265# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002266# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002268run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002269 "$O_SRV -key data_files/server2.key \
2270 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002271 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002272 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2273 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002274 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002275 -C "Processing of the Certificate handshake message failed" \
2276 -c "Ciphersuite is TLS-"
2277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002278run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002279 "$O_SRV -key data_files/server2.key \
2280 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002281 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002282 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2283 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002284 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002285 -C "Processing of the Certificate handshake message failed" \
2286 -c "Ciphersuite is TLS-"
2287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002288run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002289 "$O_SRV -key data_files/server2.key \
2290 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002291 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002292 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2293 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002294 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002295 -C "Processing of the Certificate handshake message failed" \
2296 -c "Ciphersuite is TLS-"
2297
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002298run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002299 "$O_SRV -key data_files/server2.key \
2300 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002301 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002302 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2303 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002304 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002305 -c "Processing of the Certificate handshake message failed" \
2306 -C "Ciphersuite is TLS-"
2307
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002308run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2309 "$O_SRV -key data_files/server2.key \
2310 -cert data_files/server2.ku-ke.crt" \
2311 "$P_CLI debug_level=1 auth_mode=optional \
2312 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2313 0 \
2314 -c "bad certificate (usage extensions)" \
2315 -C "Processing of the Certificate handshake message failed" \
2316 -c "Ciphersuite is TLS-" \
2317 -c "! Usage does not match the keyUsage extension"
2318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002319run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002320 "$O_SRV -key data_files/server2.key \
2321 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002322 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002323 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2324 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002325 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002326 -C "Processing of the Certificate handshake message failed" \
2327 -c "Ciphersuite is TLS-"
2328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002329run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002330 "$O_SRV -key data_files/server2.key \
2331 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002332 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002333 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2334 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002335 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002336 -c "Processing of the Certificate handshake message failed" \
2337 -C "Ciphersuite is TLS-"
2338
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002339run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2340 "$O_SRV -key data_files/server2.key \
2341 -cert data_files/server2.ku-ds.crt" \
2342 "$P_CLI debug_level=1 auth_mode=optional \
2343 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2344 0 \
2345 -c "bad certificate (usage extensions)" \
2346 -C "Processing of the Certificate handshake message failed" \
2347 -c "Ciphersuite is TLS-" \
2348 -c "! Usage does not match the keyUsage extension"
2349
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002350# Tests for keyUsage in leaf certificates, part 3:
2351# server-side checking of client cert
2352
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002353run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002354 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002355 "$O_CLI -key data_files/server2.key \
2356 -cert data_files/server2.ku-ds.crt" \
2357 0 \
2358 -S "bad certificate (usage extensions)" \
2359 -S "Processing of the Certificate handshake message failed"
2360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002361run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002362 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002363 "$O_CLI -key data_files/server2.key \
2364 -cert data_files/server2.ku-ke.crt" \
2365 0 \
2366 -s "bad certificate (usage extensions)" \
2367 -S "Processing of the Certificate handshake message failed"
2368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002369run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002370 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002371 "$O_CLI -key data_files/server2.key \
2372 -cert data_files/server2.ku-ke.crt" \
2373 1 \
2374 -s "bad certificate (usage extensions)" \
2375 -s "Processing of the Certificate handshake message failed"
2376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002377run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002378 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002379 "$O_CLI -key data_files/server5.key \
2380 -cert data_files/server5.ku-ds.crt" \
2381 0 \
2382 -S "bad certificate (usage extensions)" \
2383 -S "Processing of the Certificate handshake message failed"
2384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002385run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002386 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002387 "$O_CLI -key data_files/server5.key \
2388 -cert data_files/server5.ku-ka.crt" \
2389 0 \
2390 -s "bad certificate (usage extensions)" \
2391 -S "Processing of the Certificate handshake message failed"
2392
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002393# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2394
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002395run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002396 "$P_SRV key_file=data_files/server5.key \
2397 crt_file=data_files/server5.eku-srv.crt" \
2398 "$P_CLI" \
2399 0
2400
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002401run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002402 "$P_SRV key_file=data_files/server5.key \
2403 crt_file=data_files/server5.eku-srv.crt" \
2404 "$P_CLI" \
2405 0
2406
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002407run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002408 "$P_SRV key_file=data_files/server5.key \
2409 crt_file=data_files/server5.eku-cs_any.crt" \
2410 "$P_CLI" \
2411 0
2412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002413run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002414 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002415 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002416 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002417 1
2418
2419# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002421run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002422 "$O_SRV -key data_files/server5.key \
2423 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002424 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002425 0 \
2426 -C "bad certificate (usage extensions)" \
2427 -C "Processing of the Certificate handshake message failed" \
2428 -c "Ciphersuite is TLS-"
2429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002430run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002431 "$O_SRV -key data_files/server5.key \
2432 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002433 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002434 0 \
2435 -C "bad certificate (usage extensions)" \
2436 -C "Processing of the Certificate handshake message failed" \
2437 -c "Ciphersuite is TLS-"
2438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002439run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002440 "$O_SRV -key data_files/server5.key \
2441 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002442 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002443 0 \
2444 -C "bad certificate (usage extensions)" \
2445 -C "Processing of the Certificate handshake message failed" \
2446 -c "Ciphersuite is TLS-"
2447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002448run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002449 "$O_SRV -key data_files/server5.key \
2450 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002451 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002452 1 \
2453 -c "bad certificate (usage extensions)" \
2454 -c "Processing of the Certificate handshake message failed" \
2455 -C "Ciphersuite is TLS-"
2456
2457# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002459run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002460 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002461 "$O_CLI -key data_files/server5.key \
2462 -cert data_files/server5.eku-cli.crt" \
2463 0 \
2464 -S "bad certificate (usage extensions)" \
2465 -S "Processing of the Certificate handshake message failed"
2466
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002467run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002468 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002469 "$O_CLI -key data_files/server5.key \
2470 -cert data_files/server5.eku-srv_cli.crt" \
2471 0 \
2472 -S "bad certificate (usage extensions)" \
2473 -S "Processing of the Certificate handshake message failed"
2474
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002475run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002476 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002477 "$O_CLI -key data_files/server5.key \
2478 -cert data_files/server5.eku-cs_any.crt" \
2479 0 \
2480 -S "bad certificate (usage extensions)" \
2481 -S "Processing of the Certificate handshake message failed"
2482
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002483run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002484 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002485 "$O_CLI -key data_files/server5.key \
2486 -cert data_files/server5.eku-cs.crt" \
2487 0 \
2488 -s "bad certificate (usage extensions)" \
2489 -S "Processing of the Certificate handshake message failed"
2490
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002491run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002492 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002493 "$O_CLI -key data_files/server5.key \
2494 -cert data_files/server5.eku-cs.crt" \
2495 1 \
2496 -s "bad certificate (usage extensions)" \
2497 -s "Processing of the Certificate handshake message failed"
2498
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002499# Tests for DHM parameters loading
2500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002501run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002502 "$P_SRV" \
2503 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2504 debug_level=3" \
2505 0 \
2506 -c "value of 'DHM: P ' (2048 bits)" \
2507 -c "value of 'DHM: G ' (2048 bits)"
2508
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002509run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002510 "$P_SRV dhm_file=data_files/dhparams.pem" \
2511 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2512 debug_level=3" \
2513 0 \
2514 -c "value of 'DHM: P ' (1024 bits)" \
2515 -c "value of 'DHM: G ' (2 bits)"
2516
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002517# Tests for DHM client-side size checking
2518
2519run_test "DHM size: server default, client default, OK" \
2520 "$P_SRV" \
2521 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2522 debug_level=1" \
2523 0 \
2524 -C "DHM prime too short:"
2525
2526run_test "DHM size: server default, client 2048, OK" \
2527 "$P_SRV" \
2528 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2529 debug_level=1 dhmlen=2048" \
2530 0 \
2531 -C "DHM prime too short:"
2532
2533run_test "DHM size: server 1024, client default, OK" \
2534 "$P_SRV dhm_file=data_files/dhparams.pem" \
2535 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2536 debug_level=1" \
2537 0 \
2538 -C "DHM prime too short:"
2539
2540run_test "DHM size: server 1000, client default, rejected" \
2541 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2542 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2543 debug_level=1" \
2544 1 \
2545 -c "DHM prime too short:"
2546
2547run_test "DHM size: server default, client 2049, rejected" \
2548 "$P_SRV" \
2549 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2550 debug_level=1 dhmlen=2049" \
2551 1 \
2552 -c "DHM prime too short:"
2553
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002554# Tests for PSK callback
2555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002556run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002557 "$P_SRV psk=abc123 psk_identity=foo" \
2558 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2559 psk_identity=foo psk=abc123" \
2560 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002561 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002562 -S "SSL - Unknown identity received" \
2563 -S "SSL - Verification of the message MAC failed"
2564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002565run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002566 "$P_SRV" \
2567 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2568 psk_identity=foo psk=abc123" \
2569 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002570 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002571 -S "SSL - Unknown identity received" \
2572 -S "SSL - Verification of the message MAC failed"
2573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002574run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002575 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2576 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2577 psk_identity=foo psk=abc123" \
2578 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002579 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002580 -s "SSL - Unknown identity received" \
2581 -S "SSL - Verification of the message MAC failed"
2582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002583run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002584 "$P_SRV psk_list=abc,dead,def,beef" \
2585 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2586 psk_identity=abc psk=dead" \
2587 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002588 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002589 -S "SSL - Unknown identity received" \
2590 -S "SSL - Verification of the message MAC failed"
2591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002592run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002593 "$P_SRV psk_list=abc,dead,def,beef" \
2594 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2595 psk_identity=def psk=beef" \
2596 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002597 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002598 -S "SSL - Unknown identity received" \
2599 -S "SSL - Verification of the message MAC failed"
2600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002601run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002602 "$P_SRV psk_list=abc,dead,def,beef" \
2603 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2604 psk_identity=ghi psk=beef" \
2605 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002606 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002607 -s "SSL - Unknown identity received" \
2608 -S "SSL - Verification of the message MAC failed"
2609
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002610run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002611 "$P_SRV psk_list=abc,dead,def,beef" \
2612 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2613 psk_identity=abc psk=beef" \
2614 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002615 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002616 -S "SSL - Unknown identity received" \
2617 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002618
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002619# Tests for ciphersuites per version
2620
Janos Follath542ee5d2016-03-07 15:57:05 +00002621requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002622run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002623 "$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 +02002624 "$P_CLI force_version=ssl3" \
2625 0 \
2626 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002628run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002629 "$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 +01002630 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002631 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002632 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002634run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002635 "$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 +02002636 "$P_CLI force_version=tls1_1" \
2637 0 \
2638 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2639
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002640run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002641 "$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 +02002642 "$P_CLI force_version=tls1_2" \
2643 0 \
2644 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2645
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002646# Test for ClientHello without extensions
2647
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002648requires_gnutls
2649run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002650 "$P_SRV debug_level=3" \
2651 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2652 0 \
2653 -s "dumping 'client hello extensions' (0 bytes)"
2654
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002655# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002656
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002657run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002658 "$P_SRV" \
2659 "$P_CLI request_size=100" \
2660 0 \
2661 -s "Read from client: 100 bytes read$"
2662
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002663run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002664 "$P_SRV" \
2665 "$P_CLI request_size=500" \
2666 0 \
2667 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002668
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002669# Tests for small packets
2670
Janos Follath542ee5d2016-03-07 15:57:05 +00002671requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002672run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002673 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002674 "$P_CLI request_size=1 force_version=ssl3 \
2675 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2676 0 \
2677 -s "Read from client: 1 bytes read"
2678
Janos Follath542ee5d2016-03-07 15:57:05 +00002679requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002680run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002681 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002682 "$P_CLI request_size=1 force_version=ssl3 \
2683 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2684 0 \
2685 -s "Read from client: 1 bytes read"
2686
2687run_test "Small packet TLS 1.0 BlockCipher" \
2688 "$P_SRV" \
2689 "$P_CLI request_size=1 force_version=tls1 \
2690 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2691 0 \
2692 -s "Read from client: 1 bytes read"
2693
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002694run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2695 "$P_SRV" \
2696 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2697 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2698 0 \
2699 -s "Read from client: 1 bytes read"
2700
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002701run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2702 "$P_SRV" \
2703 "$P_CLI request_size=1 force_version=tls1 \
2704 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2705 trunc_hmac=1" \
2706 0 \
2707 -s "Read from client: 1 bytes read"
2708
2709run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002710 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002711 "$P_CLI request_size=1 force_version=tls1 \
2712 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2713 trunc_hmac=1" \
2714 0 \
2715 -s "Read from client: 1 bytes read"
2716
2717run_test "Small packet TLS 1.1 BlockCipher" \
2718 "$P_SRV" \
2719 "$P_CLI request_size=1 force_version=tls1_1 \
2720 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2721 0 \
2722 -s "Read from client: 1 bytes read"
2723
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002724run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2725 "$P_SRV" \
2726 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2727 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2728 0 \
2729 -s "Read from client: 1 bytes read"
2730
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002731run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002732 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002733 "$P_CLI request_size=1 force_version=tls1_1 \
2734 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2735 0 \
2736 -s "Read from client: 1 bytes read"
2737
2738run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2739 "$P_SRV" \
2740 "$P_CLI request_size=1 force_version=tls1_1 \
2741 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2742 trunc_hmac=1" \
2743 0 \
2744 -s "Read from client: 1 bytes read"
2745
2746run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002747 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002748 "$P_CLI request_size=1 force_version=tls1_1 \
2749 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2750 trunc_hmac=1" \
2751 0 \
2752 -s "Read from client: 1 bytes read"
2753
2754run_test "Small packet TLS 1.2 BlockCipher" \
2755 "$P_SRV" \
2756 "$P_CLI request_size=1 force_version=tls1_2 \
2757 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2758 0 \
2759 -s "Read from client: 1 bytes read"
2760
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002761run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2762 "$P_SRV" \
2763 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2764 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2765 0 \
2766 -s "Read from client: 1 bytes read"
2767
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002768run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2769 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002770 "$P_CLI request_size=1 force_version=tls1_2 \
2771 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002772 0 \
2773 -s "Read from client: 1 bytes read"
2774
2775run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2776 "$P_SRV" \
2777 "$P_CLI request_size=1 force_version=tls1_2 \
2778 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2779 trunc_hmac=1" \
2780 0 \
2781 -s "Read from client: 1 bytes read"
2782
2783run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002784 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002785 "$P_CLI request_size=1 force_version=tls1_2 \
2786 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2787 0 \
2788 -s "Read from client: 1 bytes read"
2789
2790run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002791 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002792 "$P_CLI request_size=1 force_version=tls1_2 \
2793 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2794 trunc_hmac=1" \
2795 0 \
2796 -s "Read from client: 1 bytes read"
2797
2798run_test "Small packet TLS 1.2 AEAD" \
2799 "$P_SRV" \
2800 "$P_CLI request_size=1 force_version=tls1_2 \
2801 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2802 0 \
2803 -s "Read from client: 1 bytes read"
2804
2805run_test "Small packet TLS 1.2 AEAD shorter tag" \
2806 "$P_SRV" \
2807 "$P_CLI request_size=1 force_version=tls1_2 \
2808 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2809 0 \
2810 -s "Read from client: 1 bytes read"
2811
Janos Follathb700c462016-05-06 13:48:23 +01002812# A test for extensions in SSLv3
2813
2814requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2815run_test "SSLv3 with extensions, server side" \
2816 "$P_SRV min_version=ssl3 debug_level=3" \
2817 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2818 0 \
2819 -S "dumping 'client hello extensions'" \
2820 -S "server hello, total extension length:"
2821
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002822# Test for large packets
2823
Janos Follath542ee5d2016-03-07 15:57:05 +00002824requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002825run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002826 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002827 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002828 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2829 0 \
2830 -s "Read from client: 16384 bytes read"
2831
Janos Follath542ee5d2016-03-07 15:57:05 +00002832requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002833run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002834 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002835 "$P_CLI request_size=16384 force_version=ssl3 \
2836 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2837 0 \
2838 -s "Read from client: 16384 bytes read"
2839
2840run_test "Large packet TLS 1.0 BlockCipher" \
2841 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002842 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002843 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2844 0 \
2845 -s "Read from client: 16384 bytes read"
2846
2847run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2848 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002849 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002850 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2851 trunc_hmac=1" \
2852 0 \
2853 -s "Read from client: 16384 bytes read"
2854
2855run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002856 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002857 "$P_CLI request_size=16384 force_version=tls1 \
2858 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2859 trunc_hmac=1" \
2860 0 \
2861 -s "Read from client: 16384 bytes read"
2862
2863run_test "Large packet TLS 1.1 BlockCipher" \
2864 "$P_SRV" \
2865 "$P_CLI request_size=16384 force_version=tls1_1 \
2866 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2867 0 \
2868 -s "Read from client: 16384 bytes read"
2869
2870run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002871 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002872 "$P_CLI request_size=16384 force_version=tls1_1 \
2873 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2874 0 \
2875 -s "Read from client: 16384 bytes read"
2876
2877run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2878 "$P_SRV" \
2879 "$P_CLI request_size=16384 force_version=tls1_1 \
2880 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2881 trunc_hmac=1" \
2882 0 \
2883 -s "Read from client: 16384 bytes read"
2884
2885run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002886 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002887 "$P_CLI request_size=16384 force_version=tls1_1 \
2888 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2889 trunc_hmac=1" \
2890 0 \
2891 -s "Read from client: 16384 bytes read"
2892
2893run_test "Large packet TLS 1.2 BlockCipher" \
2894 "$P_SRV" \
2895 "$P_CLI request_size=16384 force_version=tls1_2 \
2896 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2897 0 \
2898 -s "Read from client: 16384 bytes read"
2899
2900run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2901 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002902 "$P_CLI request_size=16384 force_version=tls1_2 \
2903 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002904 0 \
2905 -s "Read from client: 16384 bytes read"
2906
2907run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2908 "$P_SRV" \
2909 "$P_CLI request_size=16384 force_version=tls1_2 \
2910 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2911 trunc_hmac=1" \
2912 0 \
2913 -s "Read from client: 16384 bytes read"
2914
2915run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002916 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002917 "$P_CLI request_size=16384 force_version=tls1_2 \
2918 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2919 0 \
2920 -s "Read from client: 16384 bytes read"
2921
2922run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002923 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002924 "$P_CLI request_size=16384 force_version=tls1_2 \
2925 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2926 trunc_hmac=1" \
2927 0 \
2928 -s "Read from client: 16384 bytes read"
2929
2930run_test "Large packet TLS 1.2 AEAD" \
2931 "$P_SRV" \
2932 "$P_CLI request_size=16384 force_version=tls1_2 \
2933 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2934 0 \
2935 -s "Read from client: 16384 bytes read"
2936
2937run_test "Large packet TLS 1.2 AEAD shorter tag" \
2938 "$P_SRV" \
2939 "$P_CLI request_size=16384 force_version=tls1_2 \
2940 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2941 0 \
2942 -s "Read from client: 16384 bytes read"
2943
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002944# Tests for DTLS HelloVerifyRequest
2945
2946run_test "DTLS cookie: enabled" \
2947 "$P_SRV dtls=1 debug_level=2" \
2948 "$P_CLI dtls=1 debug_level=2" \
2949 0 \
2950 -s "cookie verification failed" \
2951 -s "cookie verification passed" \
2952 -S "cookie verification skipped" \
2953 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002954 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002955 -S "SSL - The requested feature is not available"
2956
2957run_test "DTLS cookie: disabled" \
2958 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2959 "$P_CLI dtls=1 debug_level=2" \
2960 0 \
2961 -S "cookie verification failed" \
2962 -S "cookie verification passed" \
2963 -s "cookie verification skipped" \
2964 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002965 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002966 -S "SSL - The requested feature is not available"
2967
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002968run_test "DTLS cookie: default (failing)" \
2969 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2970 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2971 1 \
2972 -s "cookie verification failed" \
2973 -S "cookie verification passed" \
2974 -S "cookie verification skipped" \
2975 -C "received hello verify request" \
2976 -S "hello verification requested" \
2977 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002978
2979requires_ipv6
2980run_test "DTLS cookie: enabled, IPv6" \
2981 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2982 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2983 0 \
2984 -s "cookie verification failed" \
2985 -s "cookie verification passed" \
2986 -S "cookie verification skipped" \
2987 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002988 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002989 -S "SSL - The requested feature is not available"
2990
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002991run_test "DTLS cookie: enabled, nbio" \
2992 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2993 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2994 0 \
2995 -s "cookie verification failed" \
2996 -s "cookie verification passed" \
2997 -S "cookie verification skipped" \
2998 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002999 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003000 -S "SSL - The requested feature is not available"
3001
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003002# Tests for client reconnecting from the same port with DTLS
3003
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003004not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003005run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003006 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3007 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003008 0 \
3009 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003010 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003011 -S "Client initiated reconnection from same port"
3012
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003013not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003014run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003015 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3016 "$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 +02003017 0 \
3018 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003019 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003020 -s "Client initiated reconnection from same port"
3021
Paul Bakker3b224ff2016-05-13 10:33:25 +01003022not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3023run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003024 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3025 "$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 +02003026 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003027 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003028 -s "Client initiated reconnection from same port"
3029
Paul Bakker3b224ff2016-05-13 10:33:25 +01003030only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3031run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3032 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3033 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3034 0 \
3035 -S "The operation timed out" \
3036 -s "Client initiated reconnection from same port"
3037
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003038run_test "DTLS client reconnect from same port: no cookies" \
3039 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003040 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3041 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003042 -s "The operation timed out" \
3043 -S "Client initiated reconnection from same port"
3044
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003045# Tests for various cases of client authentication with DTLS
3046# (focused on handshake flows and message parsing)
3047
3048run_test "DTLS client auth: required" \
3049 "$P_SRV dtls=1 auth_mode=required" \
3050 "$P_CLI dtls=1" \
3051 0 \
3052 -s "Verifying peer X.509 certificate... ok"
3053
3054run_test "DTLS client auth: optional, client has no cert" \
3055 "$P_SRV dtls=1 auth_mode=optional" \
3056 "$P_CLI dtls=1 crt_file=none key_file=none" \
3057 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003058 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003059
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003060run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003061 "$P_SRV dtls=1 auth_mode=none" \
3062 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3063 0 \
3064 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003065 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003066
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003067run_test "DTLS wrong PSK: badmac alert" \
3068 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3069 "$P_CLI dtls=1 psk=abc124" \
3070 1 \
3071 -s "SSL - Verification of the message MAC failed" \
3072 -c "SSL - A fatal alert message was received from our peer"
3073
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003074# Tests for receiving fragmented handshake messages with DTLS
3075
3076requires_gnutls
3077run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3078 "$G_SRV -u --mtu 2048 -a" \
3079 "$P_CLI dtls=1 debug_level=2" \
3080 0 \
3081 -C "found fragmented DTLS handshake message" \
3082 -C "error"
3083
3084requires_gnutls
3085run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3086 "$G_SRV -u --mtu 512" \
3087 "$P_CLI dtls=1 debug_level=2" \
3088 0 \
3089 -c "found fragmented DTLS handshake message" \
3090 -C "error"
3091
3092requires_gnutls
3093run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3094 "$G_SRV -u --mtu 128" \
3095 "$P_CLI dtls=1 debug_level=2" \
3096 0 \
3097 -c "found fragmented DTLS handshake message" \
3098 -C "error"
3099
3100requires_gnutls
3101run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3102 "$G_SRV -u --mtu 128" \
3103 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3104 0 \
3105 -c "found fragmented DTLS handshake message" \
3106 -C "error"
3107
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003108requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003109run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3110 "$G_SRV -u --mtu 256" \
3111 "$P_CLI debug_level=3 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
3121requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003122run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3123 "$G_SRV -u --mtu 256" \
3124 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3125 0 \
3126 -c "found fragmented DTLS handshake message" \
3127 -c "client hello, adding renegotiation extension" \
3128 -c "found renegotiation extension" \
3129 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003130 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003131 -C "error" \
3132 -s "Extra-header:"
3133
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003134run_test "DTLS reassembly: no fragmentation (openssl server)" \
3135 "$O_SRV -dtls1 -mtu 2048" \
3136 "$P_CLI dtls=1 debug_level=2" \
3137 0 \
3138 -C "found fragmented DTLS handshake message" \
3139 -C "error"
3140
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003141run_test "DTLS reassembly: some fragmentation (openssl server)" \
3142 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003143 "$P_CLI dtls=1 debug_level=2" \
3144 0 \
3145 -c "found fragmented DTLS handshake message" \
3146 -C "error"
3147
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003148run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003149 "$O_SRV -dtls1 -mtu 256" \
3150 "$P_CLI dtls=1 debug_level=2" \
3151 0 \
3152 -c "found fragmented DTLS handshake message" \
3153 -C "error"
3154
3155run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3156 "$O_SRV -dtls1 -mtu 256" \
3157 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3158 0 \
3159 -c "found fragmented DTLS handshake message" \
3160 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003161
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003162# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003163
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003164not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003165run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003166 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003167 "$P_SRV dtls=1 debug_level=2" \
3168 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003169 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003170 -C "replayed record" \
3171 -S "replayed record" \
3172 -C "record from another epoch" \
3173 -S "record from another epoch" \
3174 -C "discarding invalid record" \
3175 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003176 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003177 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003178 -c "HTTP/1.0 200 OK"
3179
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003180not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003181run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003182 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003183 "$P_SRV dtls=1 debug_level=2" \
3184 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003185 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003186 -c "replayed record" \
3187 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003188 -c "discarding invalid record" \
3189 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003190 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003191 -s "Extra-header:" \
3192 -c "HTTP/1.0 200 OK"
3193
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003194run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3195 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003196 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3197 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003198 0 \
3199 -c "replayed record" \
3200 -S "replayed record" \
3201 -c "discarding invalid record" \
3202 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003203 -c "resend" \
3204 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003205 -s "Extra-header:" \
3206 -c "HTTP/1.0 200 OK"
3207
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003208run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003209 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003210 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003211 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003212 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003213 -c "discarding invalid record (mac)" \
3214 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003215 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003216 -c "HTTP/1.0 200 OK" \
3217 -S "too many records with bad MAC" \
3218 -S "Verification of the message MAC failed"
3219
3220run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3221 -p "$P_PXY bad_ad=1" \
3222 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3223 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3224 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003225 -C "discarding invalid record (mac)" \
3226 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003227 -S "Extra-header:" \
3228 -C "HTTP/1.0 200 OK" \
3229 -s "too many records with bad MAC" \
3230 -s "Verification of the message MAC failed"
3231
3232run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3233 -p "$P_PXY bad_ad=1" \
3234 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3235 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3236 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003237 -c "discarding invalid record (mac)" \
3238 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003239 -s "Extra-header:" \
3240 -c "HTTP/1.0 200 OK" \
3241 -S "too many records with bad MAC" \
3242 -S "Verification of the message MAC failed"
3243
3244run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3245 -p "$P_PXY bad_ad=1" \
3246 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3247 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3248 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003249 -c "discarding invalid record (mac)" \
3250 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003251 -s "Extra-header:" \
3252 -c "HTTP/1.0 200 OK" \
3253 -s "too many records with bad MAC" \
3254 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003255
3256run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003257 -p "$P_PXY delay_ccs=1" \
3258 "$P_SRV dtls=1 debug_level=1" \
3259 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003260 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003261 -c "record from another epoch" \
3262 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003263 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003264 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003265 -s "Extra-header:" \
3266 -c "HTTP/1.0 200 OK"
3267
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003268# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003269
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003270needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003271run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003272 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003273 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3274 psk=abc123" \
3275 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003276 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3277 0 \
3278 -s "Extra-header:" \
3279 -c "HTTP/1.0 200 OK"
3280
3281needs_more_time 2
3282run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3283 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003284 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3285 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003286 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3287 0 \
3288 -s "Extra-header:" \
3289 -c "HTTP/1.0 200 OK"
3290
3291needs_more_time 2
3292run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3293 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003294 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3295 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003296 0 \
3297 -s "Extra-header:" \
3298 -c "HTTP/1.0 200 OK"
3299
3300needs_more_time 2
3301run_test "DTLS proxy: 3d, FS, client auth" \
3302 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003303 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3304 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003305 0 \
3306 -s "Extra-header:" \
3307 -c "HTTP/1.0 200 OK"
3308
3309needs_more_time 2
3310run_test "DTLS proxy: 3d, FS, ticket" \
3311 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003312 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3313 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003314 0 \
3315 -s "Extra-header:" \
3316 -c "HTTP/1.0 200 OK"
3317
3318needs_more_time 2
3319run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3320 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003321 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3322 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003323 0 \
3324 -s "Extra-header:" \
3325 -c "HTTP/1.0 200 OK"
3326
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003327needs_more_time 2
3328run_test "DTLS proxy: 3d, max handshake, nbio" \
3329 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003330 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3331 auth_mode=required" \
3332 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003333 0 \
3334 -s "Extra-header:" \
3335 -c "HTTP/1.0 200 OK"
3336
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003337needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003338run_test "DTLS proxy: 3d, min handshake, resumption" \
3339 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3340 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3341 psk=abc123 debug_level=3" \
3342 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3343 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3344 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3345 0 \
3346 -s "a session has been resumed" \
3347 -c "a session has been resumed" \
3348 -s "Extra-header:" \
3349 -c "HTTP/1.0 200 OK"
3350
3351needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003352run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3353 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3354 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3355 psk=abc123 debug_level=3 nbio=2" \
3356 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3357 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3358 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3359 0 \
3360 -s "a session has been resumed" \
3361 -c "a session has been resumed" \
3362 -s "Extra-header:" \
3363 -c "HTTP/1.0 200 OK"
3364
3365needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003366run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003367 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003368 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3369 psk=abc123 renegotiation=1 debug_level=2" \
3370 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3371 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003372 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3373 0 \
3374 -c "=> renegotiate" \
3375 -s "=> renegotiate" \
3376 -s "Extra-header:" \
3377 -c "HTTP/1.0 200 OK"
3378
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003379needs_more_time 4
3380run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3381 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003382 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3383 psk=abc123 renegotiation=1 debug_level=2" \
3384 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3385 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003386 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3387 0 \
3388 -c "=> renegotiate" \
3389 -s "=> renegotiate" \
3390 -s "Extra-header:" \
3391 -c "HTTP/1.0 200 OK"
3392
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003393needs_more_time 4
3394run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003395 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003396 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003397 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003398 debug_level=2" \
3399 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003400 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003401 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3402 0 \
3403 -c "=> renegotiate" \
3404 -s "=> renegotiate" \
3405 -s "Extra-header:" \
3406 -c "HTTP/1.0 200 OK"
3407
3408needs_more_time 4
3409run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003410 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003411 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003412 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003413 debug_level=2 nbio=2" \
3414 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003415 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003416 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3417 0 \
3418 -c "=> renegotiate" \
3419 -s "=> renegotiate" \
3420 -s "Extra-header:" \
3421 -c "HTTP/1.0 200 OK"
3422
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003423needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003424not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003425run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003426 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3427 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003428 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003429 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003430 -c "HTTP/1.0 200 OK"
3431
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003432needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003433not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003434run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3435 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3436 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003437 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003438 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003439 -c "HTTP/1.0 200 OK"
3440
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003441needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003442not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003443run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3444 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3445 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003446 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003447 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003448 -c "HTTP/1.0 200 OK"
3449
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003450requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003451needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003452not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003453run_test "DTLS proxy: 3d, gnutls server" \
3454 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3455 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003456 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003457 0 \
3458 -s "Extra-header:" \
3459 -c "Extra-header:"
3460
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003461requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003462needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003463not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003464run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3465 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3466 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003467 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003468 0 \
3469 -s "Extra-header:" \
3470 -c "Extra-header:"
3471
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003472requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003473needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003474not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003475run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3476 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3477 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003478 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003479 0 \
3480 -s "Extra-header:" \
3481 -c "Extra-header:"
3482
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003483# Final report
3484
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003485echo "------------------------------------------------------------------------"
3486
3487if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003488 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003489else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003490 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003491fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003492PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003493echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003494
3495exit $FAILS