blob: de50724412bd935c1a2e50640b4101f2e5923751 [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
Paul Bakkere20310a2016-05-10 11:18:17 +010036SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010037RUN_TEST_NUMBER=''
38
Paul Bakkeracaac852016-05-10 11:47:13 +010039PRESERVE_LOGS=0
40
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041print_usage() {
42 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010043 printf " -h|--help\tPrint this help.\n"
44 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
45 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
46 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010047 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010048 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010049 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010050}
51
52get_options() {
53 while [ $# -gt 0 ]; do
54 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010055 -f|--filter)
56 shift; FILTER=$1
57 ;;
58 -e|--exclude)
59 shift; EXCLUDE=$1
60 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 -m|--memcheck)
62 MEMCHECK=1
63 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010064 -n|--number)
65 shift; RUN_TEST_NUMBER=$1
66 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010067 -s|--show-numbers)
68 SHOW_TEST_NUMBER=1
69 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010070 -p|--preserve-logs)
71 PRESERVE_LOGS=1
72 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010073 -h|--help)
74 print_usage
75 exit 0
76 ;;
77 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020078 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010079 print_usage
80 exit 1
81 ;;
82 esac
83 shift
84 done
85}
86
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010087# skip next test if the flag is not enabled in config.h
88requires_config_enabled() {
89 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
90 SKIP_NEXT="YES"
91 fi
92}
93
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020094# skip next test if OpenSSL doesn't support FALLBACK_SCSV
95requires_openssl_with_fallback_scsv() {
96 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
97 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
98 then
99 OPENSSL_HAS_FBSCSV="YES"
100 else
101 OPENSSL_HAS_FBSCSV="NO"
102 fi
103 fi
104 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
105 SKIP_NEXT="YES"
106 fi
107}
108
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200109# skip next test if GnuTLS isn't available
110requires_gnutls() {
111 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200112 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200113 GNUTLS_AVAILABLE="YES"
114 else
115 GNUTLS_AVAILABLE="NO"
116 fi
117 fi
118 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
119 SKIP_NEXT="YES"
120 fi
121}
122
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200123# skip next test if IPv6 isn't available on this host
124requires_ipv6() {
125 if [ -z "${HAS_IPV6:-}" ]; then
126 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
127 SRV_PID=$!
128 sleep 1
129 kill $SRV_PID >/dev/null 2>&1
130 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
131 HAS_IPV6="NO"
132 else
133 HAS_IPV6="YES"
134 fi
135 rm -r $SRV_OUT
136 fi
137
138 if [ "$HAS_IPV6" = "NO" ]; then
139 SKIP_NEXT="YES"
140 fi
141}
142
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200143# skip the next test if valgrind is in use
144not_with_valgrind() {
145 if [ "$MEMCHECK" -gt 0 ]; then
146 SKIP_NEXT="YES"
147 fi
148}
149
Paul Bakker362689d2016-05-13 10:33:25 +0100150# skip the next test if valgrind is NOT in use
151only_with_valgrind() {
152 if [ "$MEMCHECK" -eq 0 ]; then
153 SKIP_NEXT="YES"
154 fi
155}
156
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200157# multiply the client timeout delay by the given factor for the next test
158needs_more_time() {
159 CLI_DELAY_FACTOR=$1
160}
161
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100162# print_name <name>
163print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100164 TESTS=$(( $TESTS + 1 ))
165 LINE=""
166
167 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
168 LINE="$TESTS "
169 fi
170
171 LINE="$LINE$1"
172 printf "$LINE "
173 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100174 for i in `seq 1 $LEN`; do printf '.'; done
175 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100176
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100177}
178
179# fail <message>
180fail() {
181 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100182 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100183
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200184 mv $SRV_OUT o-srv-${TESTS}.log
185 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200186 if [ -n "$PXY_CMD" ]; then
187 mv $PXY_OUT o-pxy-${TESTS}.log
188 fi
189 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100190
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200191 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
192 echo " ! server output:"
193 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200194 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200195 echo " ! client output:"
196 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200197 if [ -n "$PXY_CMD" ]; then
198 echo " ! ========================================================"
199 echo " ! proxy output:"
200 cat o-pxy-${TESTS}.log
201 fi
202 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200203 fi
204
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200205 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100206}
207
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100208# is_polar <cmd_line>
209is_polar() {
210 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
211}
212
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200213# openssl s_server doesn't have -www with DTLS
214check_osrv_dtls() {
215 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
216 NEEDS_INPUT=1
217 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
218 else
219 NEEDS_INPUT=0
220 fi
221}
222
223# provide input to commands that need it
224provide_input() {
225 if [ $NEEDS_INPUT -eq 0 ]; then
226 return
227 fi
228
229 while true; do
230 echo "HTTP/1.0 200 OK"
231 sleep 1
232 done
233}
234
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100235# has_mem_err <log_file_name>
236has_mem_err() {
237 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
238 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
239 then
240 return 1 # false: does not have errors
241 else
242 return 0 # true: has errors
243 fi
244}
245
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200246# wait for server to start: two versions depending on lsof availability
247wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200248 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200249 START_TIME=$( date +%s )
250 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200251
252 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200253 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200254 while [ $DONE -eq 0 ]; do
255 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
256 then
257 DONE=1
258 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
259 echo "SERVERSTART TIMEOUT"
260 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
261 DONE=1
262 fi
263 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200264 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200265 while [ $DONE -eq 0 ]; do
266 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
267 then
268 DONE=1
269 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
270 echo "SERVERSTART TIMEOUT"
271 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
272 DONE=1
273 fi
274 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200275 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200276 else
277 sleep "$START_DELAY"
278 fi
279}
280
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200281# wait for client to terminate and set CLI_EXIT
282# must be called right after starting the client
283wait_client_done() {
284 CLI_PID=$!
285
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200286 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
287 CLI_DELAY_FACTOR=1
288
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200289 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200290 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200291
292 wait $CLI_PID
293 CLI_EXIT=$?
294
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200295 kill $DOG_PID >/dev/null 2>&1
296 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200297
298 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
299}
300
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200301# check if the given command uses dtls and sets global variable DTLS
302detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200303 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200304 DTLS=1
305 else
306 DTLS=0
307 fi
308}
309
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200310# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100311# Options: -s pattern pattern that must be present in server output
312# -c pattern pattern that must be present in client output
313# -S pattern pattern that must be absent in server output
314# -C pattern pattern that must be absent in client output
315run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100316 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200317 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100318
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100319 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
320 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200321 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100322 return
323 fi
324
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100325 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100326
Paul Bakkerb7584a52016-05-10 10:50:43 +0100327 # Do we only run numbered tests?
328 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
329 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
330 else
331 SKIP_NEXT="YES"
332 fi
333
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200334 # should we skip?
335 if [ "X$SKIP_NEXT" = "XYES" ]; then
336 SKIP_NEXT="NO"
337 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200338 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200339 return
340 fi
341
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200342 # does this test use a proxy?
343 if [ "X$1" = "X-p" ]; then
344 PXY_CMD="$2"
345 shift 2
346 else
347 PXY_CMD=""
348 fi
349
350 # get commands and client output
351 SRV_CMD="$1"
352 CLI_CMD="$2"
353 CLI_EXPECT="$3"
354 shift 3
355
356 # fix client port
357 if [ -n "$PXY_CMD" ]; then
358 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
359 else
360 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
361 fi
362
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200363 # update DTLS variable
364 detect_dtls "$SRV_CMD"
365
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100366 # prepend valgrind to our commands if active
367 if [ "$MEMCHECK" -gt 0 ]; then
368 if is_polar "$SRV_CMD"; then
369 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
370 fi
371 if is_polar "$CLI_CMD"; then
372 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
373 fi
374 fi
375
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200376 TIMES_LEFT=2
377 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200378 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200379
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200380 # run the commands
381 if [ -n "$PXY_CMD" ]; then
382 echo "$PXY_CMD" > $PXY_OUT
383 $PXY_CMD >> $PXY_OUT 2>&1 &
384 PXY_PID=$!
385 # assume proxy starts faster than server
386 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200387
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200388 check_osrv_dtls
389 echo "$SRV_CMD" > $SRV_OUT
390 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
391 SRV_PID=$!
392 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200393
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200394 echo "$CLI_CMD" > $CLI_OUT
395 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
396 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100397
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200398 # terminate the server (and the proxy)
399 kill $SRV_PID
400 wait $SRV_PID
401 if [ -n "$PXY_CMD" ]; then
402 kill $PXY_PID >/dev/null 2>&1
403 wait $PXY_PID
404 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100405
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200406 # retry only on timeouts
407 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
408 printf "RETRY "
409 else
410 TIMES_LEFT=0
411 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200412 done
413
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100414 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200415 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100416 # expected client exit to incorrectly succeed in case of catastrophic
417 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100418 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200419 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100420 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100421 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100422 return
423 fi
424 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100425 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200426 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100427 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100428 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100429 return
430 fi
431 fi
432
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100433 # check server exit code
434 if [ $? != 0 ]; then
435 fail "server fail"
436 return
437 fi
438
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100439 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100440 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
441 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100442 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200443 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100444 return
445 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100446
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100447 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200448 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100449 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100450 while [ $# -gt 0 ]
451 do
452 case $1 in
453 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100454 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100455 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100456 return
457 fi
458 ;;
459
460 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100461 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100462 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100463 return
464 fi
465 ;;
466
467 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100468 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100469 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100470 return
471 fi
472 ;;
473
474 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100475 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100476 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100477 return
478 fi
479 ;;
480
481 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200482 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100483 exit 1
484 esac
485 shift 2
486 done
487
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100488 # check valgrind's results
489 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200490 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100491 fail "Server has memory errors"
492 return
493 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200494 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100495 fail "Client has memory errors"
496 return
497 fi
498 fi
499
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100500 # if we're here, everything is ok
501 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100502 if [ "$PRESERVE_LOGS" -gt 0 ]; then
503 mv $SRV_OUT o-srv-${TESTS}.log
504 mv $CLI_OUT o-cli-${TESTS}.log
505 fi
506
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200507 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100508}
509
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100510cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200511 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200512 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
513 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
514 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
515 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100516 exit 1
517}
518
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100519#
520# MAIN
521#
522
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000523if cd $( dirname $0 ); then :; else
524 echo "cd $( dirname $0 ) failed" >&2
525 exit 1
526fi
527
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100528get_options "$@"
529
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100530# sanity checks, avoid an avalanche of errors
531if [ ! -x "$P_SRV" ]; then
532 echo "Command '$P_SRV' is not an executable file"
533 exit 1
534fi
535if [ ! -x "$P_CLI" ]; then
536 echo "Command '$P_CLI' is not an executable file"
537 exit 1
538fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200539if [ ! -x "$P_PXY" ]; then
540 echo "Command '$P_PXY' is not an executable file"
541 exit 1
542fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100543if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
544 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100545 exit 1
546fi
547
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200548# used by watchdog
549MAIN_PID="$$"
550
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200551# be more patient with valgrind
552if [ "$MEMCHECK" -gt 0 ]; then
553 START_DELAY=3
554 DOG_DELAY=30
555else
556 START_DELAY=1
557 DOG_DELAY=10
558fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200559CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200560
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200561# Pick a "unique" server port in the range 10000-19999, and a proxy port
562PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000563PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200564SRV_PORT="1$PORT_BASE"
565PXY_PORT="2$PORT_BASE"
566unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200567
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200568# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000569# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200570P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
571P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
572P_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 +0200573O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200574O_CLI="$O_CLI -connect localhost:+SRV_PORT"
575G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000576G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200577
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200578# Also pick a unique name for intermediate files
579SRV_OUT="srv_out.$$"
580CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200581PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200582SESSION="session.$$"
583
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200584SKIP_NEXT="NO"
585
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100586trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100587
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200588# Basic test
589
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200590# Checks that:
591# - things work with all ciphersuites active (used with config-full in all.sh)
592# - the expected (highest security) parameters are selected
593# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200594run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200595 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200596 "$P_CLI" \
597 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200598 -s "Protocol is TLSv1.2" \
599 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
600 -s "client hello v3, signature_algorithm ext: 6" \
601 -s "ECDHE curve: secp521r1" \
602 -S "error" \
603 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200604
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000605run_test "Default, DTLS" \
606 "$P_SRV dtls=1" \
607 "$P_CLI dtls=1" \
608 0 \
609 -s "Protocol is DTLSv1.2" \
610 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
611
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100612# Tests for rc4 option
613
614run_test "RC4: server disabled, client enabled" \
615 "$P_SRV" \
616 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
617 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100618 -s "SSL - The server has no ciphersuites in common"
619
620run_test "RC4: server half, client enabled" \
621 "$P_SRV arc4=1" \
622 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
623 1 \
624 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100625
626run_test "RC4: server enabled, client disabled" \
627 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
628 "$P_CLI" \
629 1 \
630 -s "SSL - The server has no ciphersuites in common"
631
632run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100633 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100634 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
635 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100636 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100637 -S "SSL - The server has no ciphersuites in common"
638
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100639# Tests for Truncated HMAC extension
640
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100641run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200642 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100643 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100644 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100645 -s "dumping 'computed mac' (20 bytes)" \
646 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100647
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100648run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200649 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100650 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
651 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100652 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100653 -s "dumping 'computed mac' (20 bytes)" \
654 -S "dumping 'computed mac' (10 bytes)"
655
656run_test "Truncated HMAC: client enabled, server default" \
657 "$P_SRV debug_level=4" \
658 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
659 trunc_hmac=1" \
660 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100661 -s "dumping 'computed mac' (20 bytes)" \
662 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100663
664run_test "Truncated HMAC: client enabled, server disabled" \
665 "$P_SRV debug_level=4 trunc_hmac=0" \
666 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
667 trunc_hmac=1" \
668 0 \
669 -s "dumping 'computed mac' (20 bytes)" \
670 -S "dumping 'computed mac' (10 bytes)"
671
672run_test "Truncated HMAC: client enabled, server enabled" \
673 "$P_SRV debug_level=4 trunc_hmac=1" \
674 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
675 trunc_hmac=1" \
676 0 \
677 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100678 -s "dumping 'computed mac' (10 bytes)"
679
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100680# Tests for Encrypt-then-MAC extension
681
682run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100683 "$P_SRV debug_level=3 \
684 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100685 "$P_CLI debug_level=3" \
686 0 \
687 -c "client hello, adding encrypt_then_mac extension" \
688 -s "found encrypt then mac extension" \
689 -s "server hello, adding encrypt then mac extension" \
690 -c "found encrypt_then_mac extension" \
691 -c "using encrypt then mac" \
692 -s "using encrypt then mac"
693
694run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100695 "$P_SRV debug_level=3 etm=0 \
696 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100697 "$P_CLI debug_level=3 etm=1" \
698 0 \
699 -c "client hello, adding encrypt_then_mac extension" \
700 -s "found encrypt then mac extension" \
701 -S "server hello, adding encrypt then mac extension" \
702 -C "found encrypt_then_mac extension" \
703 -C "using encrypt then mac" \
704 -S "using encrypt then mac"
705
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100706run_test "Encrypt then MAC: client enabled, aead cipher" \
707 "$P_SRV debug_level=3 etm=1 \
708 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
709 "$P_CLI debug_level=3 etm=1" \
710 0 \
711 -c "client hello, adding encrypt_then_mac extension" \
712 -s "found encrypt then mac extension" \
713 -S "server hello, adding encrypt then mac extension" \
714 -C "found encrypt_then_mac extension" \
715 -C "using encrypt then mac" \
716 -S "using encrypt then mac"
717
718run_test "Encrypt then MAC: client enabled, stream cipher" \
719 "$P_SRV debug_level=3 etm=1 \
720 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100721 "$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 +0100722 0 \
723 -c "client hello, adding encrypt_then_mac extension" \
724 -s "found encrypt then mac extension" \
725 -S "server hello, adding encrypt then mac extension" \
726 -C "found encrypt_then_mac extension" \
727 -C "using encrypt then mac" \
728 -S "using encrypt then mac"
729
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100730run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100731 "$P_SRV debug_level=3 etm=1 \
732 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100733 "$P_CLI debug_level=3 etm=0" \
734 0 \
735 -C "client hello, adding encrypt_then_mac extension" \
736 -S "found encrypt then mac extension" \
737 -S "server hello, adding encrypt then mac extension" \
738 -C "found encrypt_then_mac extension" \
739 -C "using encrypt then mac" \
740 -S "using encrypt then mac"
741
Janos Follathe2681a42016-03-07 15:57:05 +0000742requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100743run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100744 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100745 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100746 "$P_CLI debug_level=3 force_version=ssl3" \
747 0 \
748 -C "client hello, adding encrypt_then_mac extension" \
749 -S "found encrypt then mac extension" \
750 -S "server hello, adding encrypt then mac extension" \
751 -C "found encrypt_then_mac extension" \
752 -C "using encrypt then mac" \
753 -S "using encrypt then mac"
754
Janos Follathe2681a42016-03-07 15:57:05 +0000755requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100756run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100757 "$P_SRV debug_level=3 force_version=ssl3 \
758 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100759 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100760 0 \
761 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100762 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100763 -S "server hello, adding encrypt then mac extension" \
764 -C "found encrypt_then_mac extension" \
765 -C "using encrypt then mac" \
766 -S "using encrypt then mac"
767
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200768# Tests for Extended Master Secret extension
769
770run_test "Extended Master Secret: default" \
771 "$P_SRV debug_level=3" \
772 "$P_CLI debug_level=3" \
773 0 \
774 -c "client hello, adding extended_master_secret extension" \
775 -s "found extended master secret extension" \
776 -s "server hello, adding extended master secret extension" \
777 -c "found extended_master_secret extension" \
778 -c "using extended master secret" \
779 -s "using extended master secret"
780
781run_test "Extended Master Secret: client enabled, server disabled" \
782 "$P_SRV debug_level=3 extended_ms=0" \
783 "$P_CLI debug_level=3 extended_ms=1" \
784 0 \
785 -c "client hello, adding extended_master_secret extension" \
786 -s "found extended master secret extension" \
787 -S "server hello, adding extended master secret extension" \
788 -C "found extended_master_secret extension" \
789 -C "using extended master secret" \
790 -S "using extended master secret"
791
792run_test "Extended Master Secret: client disabled, server enabled" \
793 "$P_SRV debug_level=3 extended_ms=1" \
794 "$P_CLI debug_level=3 extended_ms=0" \
795 0 \
796 -C "client hello, adding extended_master_secret extension" \
797 -S "found extended master secret extension" \
798 -S "server hello, adding extended master secret extension" \
799 -C "found extended_master_secret extension" \
800 -C "using extended master secret" \
801 -S "using extended master secret"
802
Janos Follathe2681a42016-03-07 15:57:05 +0000803requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200804run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100805 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200806 "$P_CLI debug_level=3 force_version=ssl3" \
807 0 \
808 -C "client hello, adding extended_master_secret extension" \
809 -S "found extended master secret extension" \
810 -S "server hello, adding extended master secret extension" \
811 -C "found extended_master_secret extension" \
812 -C "using extended master secret" \
813 -S "using extended master secret"
814
Janos Follathe2681a42016-03-07 15:57:05 +0000815requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200816run_test "Extended Master Secret: client enabled, server SSLv3" \
817 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100818 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200819 0 \
820 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100821 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200822 -S "server hello, adding extended master secret extension" \
823 -C "found extended_master_secret extension" \
824 -C "using extended master secret" \
825 -S "using extended master secret"
826
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200827# Tests for FALLBACK_SCSV
828
829run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200830 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200831 "$P_CLI debug_level=3 force_version=tls1_1" \
832 0 \
833 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200834 -S "received FALLBACK_SCSV" \
835 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200836 -C "is a fatal alert message (msg 86)"
837
838run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200839 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200840 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
841 0 \
842 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200843 -S "received FALLBACK_SCSV" \
844 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200845 -C "is a fatal alert message (msg 86)"
846
847run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200848 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200849 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200850 1 \
851 -c "adding FALLBACK_SCSV" \
852 -s "received FALLBACK_SCSV" \
853 -s "inapropriate fallback" \
854 -c "is a fatal alert message (msg 86)"
855
856run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200857 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200858 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200859 0 \
860 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200861 -s "received FALLBACK_SCSV" \
862 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200863 -C "is a fatal alert message (msg 86)"
864
865requires_openssl_with_fallback_scsv
866run_test "Fallback SCSV: default, openssl server" \
867 "$O_SRV" \
868 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
869 0 \
870 -C "adding FALLBACK_SCSV" \
871 -C "is a fatal alert message (msg 86)"
872
873requires_openssl_with_fallback_scsv
874run_test "Fallback SCSV: enabled, openssl server" \
875 "$O_SRV" \
876 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
877 1 \
878 -c "adding FALLBACK_SCSV" \
879 -c "is a fatal alert message (msg 86)"
880
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200881requires_openssl_with_fallback_scsv
882run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200883 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200884 "$O_CLI -tls1_1" \
885 0 \
886 -S "received FALLBACK_SCSV" \
887 -S "inapropriate fallback"
888
889requires_openssl_with_fallback_scsv
890run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200891 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200892 "$O_CLI -tls1_1 -fallback_scsv" \
893 1 \
894 -s "received FALLBACK_SCSV" \
895 -s "inapropriate fallback"
896
897requires_openssl_with_fallback_scsv
898run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200899 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200900 "$O_CLI -fallback_scsv" \
901 0 \
902 -s "received FALLBACK_SCSV" \
903 -S "inapropriate fallback"
904
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100905# Tests for CBC 1/n-1 record splitting
906
907run_test "CBC Record splitting: TLS 1.2, no splitting" \
908 "$P_SRV" \
909 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
910 request_size=123 force_version=tls1_2" \
911 0 \
912 -s "Read from client: 123 bytes read" \
913 -S "Read from client: 1 bytes read" \
914 -S "122 bytes read"
915
916run_test "CBC Record splitting: TLS 1.1, no splitting" \
917 "$P_SRV" \
918 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
919 request_size=123 force_version=tls1_1" \
920 0 \
921 -s "Read from client: 123 bytes read" \
922 -S "Read from client: 1 bytes read" \
923 -S "122 bytes read"
924
925run_test "CBC Record splitting: TLS 1.0, splitting" \
926 "$P_SRV" \
927 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
928 request_size=123 force_version=tls1" \
929 0 \
930 -S "Read from client: 123 bytes read" \
931 -s "Read from client: 1 bytes read" \
932 -s "122 bytes read"
933
Janos Follathe2681a42016-03-07 15:57:05 +0000934requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100935run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100936 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100937 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
938 request_size=123 force_version=ssl3" \
939 0 \
940 -S "Read from client: 123 bytes read" \
941 -s "Read from client: 1 bytes read" \
942 -s "122 bytes read"
943
944run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100945 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100946 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
947 request_size=123 force_version=tls1" \
948 0 \
949 -s "Read from client: 123 bytes read" \
950 -S "Read from client: 1 bytes read" \
951 -S "122 bytes read"
952
953run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
954 "$P_SRV" \
955 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
956 request_size=123 force_version=tls1 recsplit=0" \
957 0 \
958 -s "Read from client: 123 bytes read" \
959 -S "Read from client: 1 bytes read" \
960 -S "122 bytes read"
961
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100962run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
963 "$P_SRV nbio=2" \
964 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
965 request_size=123 force_version=tls1" \
966 0 \
967 -S "Read from client: 123 bytes read" \
968 -s "Read from client: 1 bytes read" \
969 -s "122 bytes read"
970
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100971# Tests for Session Tickets
972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200973run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200974 "$P_SRV debug_level=3 tickets=1" \
975 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100976 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100977 -c "client hello, adding session ticket extension" \
978 -s "found session ticket extension" \
979 -s "server hello, adding session ticket extension" \
980 -c "found session_ticket extension" \
981 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100982 -S "session successfully restored from cache" \
983 -s "session successfully restored from ticket" \
984 -s "a session has been resumed" \
985 -c "a session has been resumed"
986
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200987run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200988 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
989 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100990 0 \
991 -c "client hello, adding session ticket extension" \
992 -s "found session ticket extension" \
993 -s "server hello, adding session ticket extension" \
994 -c "found session_ticket extension" \
995 -c "parse new session ticket" \
996 -S "session successfully restored from cache" \
997 -s "session successfully restored from ticket" \
998 -s "a session has been resumed" \
999 -c "a session has been resumed"
1000
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001001run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001002 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1003 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001004 0 \
1005 -c "client hello, adding session ticket extension" \
1006 -s "found session ticket extension" \
1007 -s "server hello, adding session ticket extension" \
1008 -c "found session_ticket extension" \
1009 -c "parse new session ticket" \
1010 -S "session successfully restored from cache" \
1011 -S "session successfully restored from ticket" \
1012 -S "a session has been resumed" \
1013 -C "a session has been resumed"
1014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001015run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001016 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001017 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001018 0 \
1019 -c "client hello, adding session ticket extension" \
1020 -c "found session_ticket extension" \
1021 -c "parse new session ticket" \
1022 -c "a session has been resumed"
1023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001024run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001025 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001026 "( $O_CLI -sess_out $SESSION; \
1027 $O_CLI -sess_in $SESSION; \
1028 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001029 0 \
1030 -s "found session ticket extension" \
1031 -s "server hello, adding session ticket extension" \
1032 -S "session successfully restored from cache" \
1033 -s "session successfully restored from ticket" \
1034 -s "a session has been resumed"
1035
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001036# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001038run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001039 "$P_SRV debug_level=3 tickets=0" \
1040 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001041 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001042 -c "client hello, adding session ticket extension" \
1043 -s "found session ticket extension" \
1044 -S "server hello, adding session ticket extension" \
1045 -C "found session_ticket extension" \
1046 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001047 -s "session successfully restored from cache" \
1048 -S "session successfully restored from ticket" \
1049 -s "a session has been resumed" \
1050 -c "a session has been resumed"
1051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001052run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001053 "$P_SRV debug_level=3 tickets=1" \
1054 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001055 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001056 -C "client hello, adding session ticket extension" \
1057 -S "found session ticket extension" \
1058 -S "server hello, adding session ticket extension" \
1059 -C "found session_ticket extension" \
1060 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001061 -s "session successfully restored from cache" \
1062 -S "session successfully restored from ticket" \
1063 -s "a session has been resumed" \
1064 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001066run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001067 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1068 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001069 0 \
1070 -S "session successfully restored from cache" \
1071 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001072 -S "a session has been resumed" \
1073 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001075run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001076 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1077 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001078 0 \
1079 -s "session successfully restored from cache" \
1080 -S "session successfully restored from ticket" \
1081 -s "a session has been resumed" \
1082 -c "a session has been resumed"
1083
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001084run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001085 "$P_SRV debug_level=3 tickets=0" \
1086 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001087 0 \
1088 -s "session successfully restored from cache" \
1089 -S "session successfully restored from ticket" \
1090 -s "a session has been resumed" \
1091 -c "a session has been resumed"
1092
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001093run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001094 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1095 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001096 0 \
1097 -S "session successfully restored from cache" \
1098 -S "session successfully restored from ticket" \
1099 -S "a session has been resumed" \
1100 -C "a session has been resumed"
1101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001102run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001103 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1104 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001105 0 \
1106 -s "session successfully restored from cache" \
1107 -S "session successfully restored from ticket" \
1108 -s "a session has been resumed" \
1109 -c "a session has been resumed"
1110
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001111run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001112 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001113 "( $O_CLI -sess_out $SESSION; \
1114 $O_CLI -sess_in $SESSION; \
1115 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001116 0 \
1117 -s "found session ticket extension" \
1118 -S "server hello, adding session ticket extension" \
1119 -s "session successfully restored from cache" \
1120 -S "session successfully restored from ticket" \
1121 -s "a session has been resumed"
1122
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001123run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001124 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001125 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001126 0 \
1127 -C "found session_ticket extension" \
1128 -C "parse new session ticket" \
1129 -c "a session has been resumed"
1130
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001131# Tests for Max Fragment Length extension
1132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001133run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001134 "$P_SRV debug_level=3" \
1135 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001136 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001137 -c "Maximum fragment length is 16384" \
1138 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001139 -C "client hello, adding max_fragment_length extension" \
1140 -S "found max fragment length extension" \
1141 -S "server hello, max_fragment_length extension" \
1142 -C "found max_fragment_length extension"
1143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001144run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001145 "$P_SRV debug_level=3" \
1146 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001147 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001148 -c "Maximum fragment length is 4096" \
1149 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001150 -c "client hello, adding max_fragment_length extension" \
1151 -s "found max fragment length extension" \
1152 -s "server hello, max_fragment_length extension" \
1153 -c "found max_fragment_length extension"
1154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001155run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001156 "$P_SRV debug_level=3 max_frag_len=4096" \
1157 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001158 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001159 -c "Maximum fragment length is 16384" \
1160 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001161 -C "client hello, adding max_fragment_length extension" \
1162 -S "found max fragment length extension" \
1163 -S "server hello, max_fragment_length extension" \
1164 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001165
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001166requires_gnutls
1167run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001168 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001169 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001170 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001171 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001172 -c "client hello, adding max_fragment_length extension" \
1173 -c "found max_fragment_length extension"
1174
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001175run_test "Max fragment length: client, message just fits" \
1176 "$P_SRV debug_level=3" \
1177 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1178 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001179 -c "Maximum fragment length is 2048" \
1180 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001181 -c "client hello, adding max_fragment_length extension" \
1182 -s "found max fragment length extension" \
1183 -s "server hello, max_fragment_length extension" \
1184 -c "found max_fragment_length extension" \
1185 -c "2048 bytes written in 1 fragments" \
1186 -s "2048 bytes read"
1187
1188run_test "Max fragment length: client, larger message" \
1189 "$P_SRV debug_level=3" \
1190 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1191 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001192 -c "Maximum fragment length is 2048" \
1193 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001194 -c "client hello, adding max_fragment_length extension" \
1195 -s "found max fragment length extension" \
1196 -s "server hello, max_fragment_length extension" \
1197 -c "found max_fragment_length extension" \
1198 -c "2345 bytes written in 2 fragments" \
1199 -s "2048 bytes read" \
1200 -s "297 bytes read"
1201
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001202run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001203 "$P_SRV debug_level=3 dtls=1" \
1204 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1205 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001206 -c "Maximum fragment length is 2048" \
1207 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001208 -c "client hello, adding max_fragment_length extension" \
1209 -s "found max fragment length extension" \
1210 -s "server hello, max_fragment_length extension" \
1211 -c "found max_fragment_length extension" \
1212 -c "fragment larger than.*maximum"
1213
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001214# Tests for renegotiation
1215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001216run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001217 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001218 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001219 0 \
1220 -C "client hello, adding renegotiation extension" \
1221 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1222 -S "found renegotiation extension" \
1223 -s "server hello, secure renegotiation extension" \
1224 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001225 -C "=> renegotiate" \
1226 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001227 -S "write hello request"
1228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001230 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001231 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001232 0 \
1233 -c "client hello, adding renegotiation extension" \
1234 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1235 -s "found renegotiation extension" \
1236 -s "server hello, secure renegotiation extension" \
1237 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001238 -c "=> renegotiate" \
1239 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001240 -S "write hello request"
1241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001242run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001243 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001244 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001245 0 \
1246 -c "client hello, adding renegotiation extension" \
1247 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1248 -s "found renegotiation extension" \
1249 -s "server hello, secure renegotiation extension" \
1250 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001251 -c "=> renegotiate" \
1252 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001253 -s "write hello request"
1254
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001255run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001256 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001258 0 \
1259 -c "client hello, adding renegotiation extension" \
1260 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1261 -s "found renegotiation extension" \
1262 -s "server hello, secure renegotiation extension" \
1263 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001264 -c "=> renegotiate" \
1265 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001266 -s "write hello request"
1267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001268run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001269 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001270 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001271 1 \
1272 -c "client hello, adding renegotiation extension" \
1273 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1274 -S "found renegotiation extension" \
1275 -s "server hello, secure renegotiation extension" \
1276 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001277 -c "=> renegotiate" \
1278 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001279 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001280 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001281 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001283run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001284 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001285 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001286 0 \
1287 -C "client hello, adding renegotiation extension" \
1288 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1289 -S "found renegotiation extension" \
1290 -s "server hello, secure renegotiation extension" \
1291 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001292 -C "=> renegotiate" \
1293 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001294 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001295 -S "SSL - An unexpected message was received from our peer" \
1296 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001297
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001298run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001299 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001300 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001301 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001302 0 \
1303 -C "client hello, adding renegotiation extension" \
1304 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1305 -S "found renegotiation extension" \
1306 -s "server hello, secure renegotiation extension" \
1307 -c "found renegotiation extension" \
1308 -C "=> renegotiate" \
1309 -S "=> renegotiate" \
1310 -s "write hello request" \
1311 -S "SSL - An unexpected message was received from our peer" \
1312 -S "failed"
1313
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001314# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001315run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001316 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001317 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001318 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001319 0 \
1320 -C "client hello, adding renegotiation extension" \
1321 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1322 -S "found renegotiation extension" \
1323 -s "server hello, secure renegotiation extension" \
1324 -c "found renegotiation extension" \
1325 -C "=> renegotiate" \
1326 -S "=> renegotiate" \
1327 -s "write hello request" \
1328 -S "SSL - An unexpected message was received from our peer" \
1329 -S "failed"
1330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001331run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001332 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001333 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001334 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001335 0 \
1336 -C "client hello, adding renegotiation extension" \
1337 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1338 -S "found renegotiation extension" \
1339 -s "server hello, secure renegotiation extension" \
1340 -c "found renegotiation extension" \
1341 -C "=> renegotiate" \
1342 -S "=> renegotiate" \
1343 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001344 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001348 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001349 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001350 0 \
1351 -c "client hello, adding renegotiation extension" \
1352 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1353 -s "found renegotiation extension" \
1354 -s "server hello, secure renegotiation extension" \
1355 -c "found renegotiation extension" \
1356 -c "=> renegotiate" \
1357 -s "=> renegotiate" \
1358 -s "write hello request" \
1359 -S "SSL - An unexpected message was received from our peer" \
1360 -S "failed"
1361
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001362run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001363 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001364 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1365 0 \
1366 -C "client hello, adding renegotiation extension" \
1367 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1368 -S "found renegotiation extension" \
1369 -s "server hello, secure renegotiation extension" \
1370 -c "found renegotiation extension" \
1371 -S "record counter limit reached: renegotiate" \
1372 -C "=> renegotiate" \
1373 -S "=> renegotiate" \
1374 -S "write hello request" \
1375 -S "SSL - An unexpected message was received from our peer" \
1376 -S "failed"
1377
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001378# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001379run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001380 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001381 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001382 0 \
1383 -c "client hello, adding renegotiation extension" \
1384 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1385 -s "found renegotiation extension" \
1386 -s "server hello, secure renegotiation extension" \
1387 -c "found renegotiation extension" \
1388 -s "record counter limit reached: renegotiate" \
1389 -c "=> renegotiate" \
1390 -s "=> renegotiate" \
1391 -s "write hello request" \
1392 -S "SSL - An unexpected message was received from our peer" \
1393 -S "failed"
1394
1395run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001396 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001397 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001398 0 \
1399 -c "client hello, adding renegotiation extension" \
1400 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1401 -s "found renegotiation extension" \
1402 -s "server hello, secure renegotiation extension" \
1403 -c "found renegotiation extension" \
1404 -s "record counter limit reached: renegotiate" \
1405 -c "=> renegotiate" \
1406 -s "=> renegotiate" \
1407 -s "write hello request" \
1408 -S "SSL - An unexpected message was received from our peer" \
1409 -S "failed"
1410
1411run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001412 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001413 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1414 0 \
1415 -C "client hello, adding renegotiation extension" \
1416 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1417 -S "found renegotiation extension" \
1418 -s "server hello, secure renegotiation extension" \
1419 -c "found renegotiation extension" \
1420 -S "record counter limit reached: renegotiate" \
1421 -C "=> renegotiate" \
1422 -S "=> renegotiate" \
1423 -S "write hello request" \
1424 -S "SSL - An unexpected message was received from our peer" \
1425 -S "failed"
1426
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001427run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001428 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001429 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001430 0 \
1431 -c "client hello, adding renegotiation extension" \
1432 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1433 -s "found renegotiation extension" \
1434 -s "server hello, secure renegotiation extension" \
1435 -c "found renegotiation extension" \
1436 -c "=> renegotiate" \
1437 -s "=> renegotiate" \
1438 -S "write hello request"
1439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001440run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001441 "$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 +02001442 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001443 0 \
1444 -c "client hello, adding renegotiation extension" \
1445 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1446 -s "found renegotiation extension" \
1447 -s "server hello, secure renegotiation extension" \
1448 -c "found renegotiation extension" \
1449 -c "=> renegotiate" \
1450 -s "=> renegotiate" \
1451 -s "write hello request"
1452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001453run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001454 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001455 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001456 0 \
1457 -c "client hello, adding renegotiation extension" \
1458 -c "found renegotiation extension" \
1459 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001460 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001461 -C "error" \
1462 -c "HTTP/1.0 200 [Oo][Kk]"
1463
Paul Bakker539d9722015-02-08 16:18:35 +01001464requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001465run_test "Renegotiation: gnutls server strict, client-initiated" \
1466 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001467 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001468 0 \
1469 -c "client hello, adding renegotiation extension" \
1470 -c "found renegotiation extension" \
1471 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001472 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001473 -C "error" \
1474 -c "HTTP/1.0 200 [Oo][Kk]"
1475
Paul Bakker539d9722015-02-08 16:18:35 +01001476requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001477run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1478 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1479 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1480 1 \
1481 -c "client hello, adding renegotiation extension" \
1482 -C "found renegotiation extension" \
1483 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001484 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001485 -c "error" \
1486 -C "HTTP/1.0 200 [Oo][Kk]"
1487
Paul Bakker539d9722015-02-08 16:18:35 +01001488requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001489run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1490 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1491 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1492 allow_legacy=0" \
1493 1 \
1494 -c "client hello, adding renegotiation extension" \
1495 -C "found renegotiation extension" \
1496 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001497 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001498 -c "error" \
1499 -C "HTTP/1.0 200 [Oo][Kk]"
1500
Paul Bakker539d9722015-02-08 16:18:35 +01001501requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001502run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1503 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1504 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1505 allow_legacy=1" \
1506 0 \
1507 -c "client hello, adding renegotiation extension" \
1508 -C "found renegotiation extension" \
1509 -c "=> renegotiate" \
1510 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001511 -C "error" \
1512 -c "HTTP/1.0 200 [Oo][Kk]"
1513
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001514run_test "Renegotiation: DTLS, client-initiated" \
1515 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1516 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1517 0 \
1518 -c "client hello, adding renegotiation extension" \
1519 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1520 -s "found renegotiation extension" \
1521 -s "server hello, secure renegotiation extension" \
1522 -c "found renegotiation extension" \
1523 -c "=> renegotiate" \
1524 -s "=> renegotiate" \
1525 -S "write hello request"
1526
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001527run_test "Renegotiation: DTLS, server-initiated" \
1528 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001529 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1530 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001531 0 \
1532 -c "client hello, adding renegotiation extension" \
1533 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1534 -s "found renegotiation extension" \
1535 -s "server hello, secure renegotiation extension" \
1536 -c "found renegotiation extension" \
1537 -c "=> renegotiate" \
1538 -s "=> renegotiate" \
1539 -s "write hello request"
1540
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001541requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001542run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1543 "$G_SRV -u --mtu 4096" \
1544 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1545 0 \
1546 -c "client hello, adding renegotiation extension" \
1547 -c "found renegotiation extension" \
1548 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001549 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001550 -C "error" \
1551 -s "Extra-header:"
1552
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001553# Test for the "secure renegotation" extension only (no actual renegotiation)
1554
Paul Bakker539d9722015-02-08 16:18:35 +01001555requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001556run_test "Renego ext: gnutls server strict, client default" \
1557 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1558 "$P_CLI debug_level=3" \
1559 0 \
1560 -c "found renegotiation extension" \
1561 -C "error" \
1562 -c "HTTP/1.0 200 [Oo][Kk]"
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 unsafe, client default" \
1566 "$G_SRV --priority=NORMAL:%DISABLE_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 break legacy" \
1575 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1576 "$P_CLI debug_level=3 allow_legacy=-1" \
1577 1 \
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 client strict, server default" \
1584 "$P_SRV debug_level=3" \
1585 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1586 0 \
1587 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1588 -s "server hello, secure renegotiation extension"
1589
Paul Bakker539d9722015-02-08 16:18:35 +01001590requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001591run_test "Renego ext: gnutls client unsafe, server default" \
1592 "$P_SRV debug_level=3" \
1593 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1594 0 \
1595 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1596 -S "server hello, secure renegotiation extension"
1597
Paul Bakker539d9722015-02-08 16:18:35 +01001598requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001599run_test "Renego ext: gnutls client unsafe, server break legacy" \
1600 "$P_SRV debug_level=3 allow_legacy=-1" \
1601 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1602 1 \
1603 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1604 -S "server hello, secure renegotiation extension"
1605
Janos Follath0b242342016-02-17 10:11:21 +00001606# Tests for silently dropping trailing extra bytes in .der certificates
1607
1608requires_gnutls
1609run_test "DER format: no trailing bytes" \
1610 "$P_SRV crt_file=data_files/server5-der0.crt \
1611 key_file=data_files/server5.key" \
1612 "$G_CLI " \
1613 0 \
1614 -c "Handshake was completed" \
1615
1616requires_gnutls
1617run_test "DER format: with a trailing zero byte" \
1618 "$P_SRV crt_file=data_files/server5-der1a.crt \
1619 key_file=data_files/server5.key" \
1620 "$G_CLI " \
1621 0 \
1622 -c "Handshake was completed" \
1623
1624requires_gnutls
1625run_test "DER format: with a trailing random byte" \
1626 "$P_SRV crt_file=data_files/server5-der1b.crt \
1627 key_file=data_files/server5.key" \
1628 "$G_CLI " \
1629 0 \
1630 -c "Handshake was completed" \
1631
1632requires_gnutls
1633run_test "DER format: with 2 trailing random bytes" \
1634 "$P_SRV crt_file=data_files/server5-der2.crt \
1635 key_file=data_files/server5.key" \
1636 "$G_CLI " \
1637 0 \
1638 -c "Handshake was completed" \
1639
1640requires_gnutls
1641run_test "DER format: with 4 trailing random bytes" \
1642 "$P_SRV crt_file=data_files/server5-der4.crt \
1643 key_file=data_files/server5.key" \
1644 "$G_CLI " \
1645 0 \
1646 -c "Handshake was completed" \
1647
1648requires_gnutls
1649run_test "DER format: with 8 trailing random bytes" \
1650 "$P_SRV crt_file=data_files/server5-der8.crt \
1651 key_file=data_files/server5.key" \
1652 "$G_CLI " \
1653 0 \
1654 -c "Handshake was completed" \
1655
1656requires_gnutls
1657run_test "DER format: with 9 trailing random bytes" \
1658 "$P_SRV crt_file=data_files/server5-der9.crt \
1659 key_file=data_files/server5.key" \
1660 "$G_CLI " \
1661 0 \
1662 -c "Handshake was completed" \
1663
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001664# Tests for auth_mode
1665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001666run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001667 "$P_SRV crt_file=data_files/server5-badsign.crt \
1668 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001669 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001670 1 \
1671 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001672 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001673 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001674 -c "X509 - Certificate verification failed"
1675
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001676run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001677 "$P_SRV crt_file=data_files/server5-badsign.crt \
1678 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001679 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001680 0 \
1681 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001682 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001683 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001684 -C "X509 - Certificate verification failed"
1685
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001686run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001687 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001688 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001689 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001690 0 \
1691 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001692 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001693 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001694 -C "X509 - Certificate verification failed"
1695
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001696run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001697 "$P_SRV debug_level=3 auth_mode=required" \
1698 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001699 key_file=data_files/server5.key" \
1700 1 \
1701 -S "skip write certificate request" \
1702 -C "skip parse certificate request" \
1703 -c "got a certificate request" \
1704 -C "skip write certificate" \
1705 -C "skip write certificate verify" \
1706 -S "skip parse certificate verify" \
1707 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001708 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001709 -s "! mbedtls_ssl_handshake returned" \
1710 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001711 -s "X509 - Certificate verification failed"
1712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001713run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001714 "$P_SRV debug_level=3 auth_mode=optional" \
1715 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001716 key_file=data_files/server5.key" \
1717 0 \
1718 -S "skip write certificate request" \
1719 -C "skip parse certificate request" \
1720 -c "got a certificate request" \
1721 -C "skip write certificate" \
1722 -C "skip write certificate verify" \
1723 -S "skip parse certificate verify" \
1724 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001725 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001726 -S "! mbedtls_ssl_handshake returned" \
1727 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001728 -S "X509 - Certificate verification failed"
1729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001730run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001731 "$P_SRV debug_level=3 auth_mode=none" \
1732 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001733 key_file=data_files/server5.key" \
1734 0 \
1735 -s "skip write certificate request" \
1736 -C "skip parse certificate request" \
1737 -c "got no certificate request" \
1738 -c "skip write certificate" \
1739 -c "skip write certificate verify" \
1740 -s "skip parse certificate verify" \
1741 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001742 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001743 -S "! mbedtls_ssl_handshake returned" \
1744 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001745 -S "X509 - Certificate verification failed"
1746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001747run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001748 "$P_SRV debug_level=3 auth_mode=optional" \
1749 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001750 0 \
1751 -S "skip write certificate request" \
1752 -C "skip parse certificate request" \
1753 -c "got a certificate request" \
1754 -C "skip write certificate$" \
1755 -C "got no certificate to send" \
1756 -S "SSLv3 client has no certificate" \
1757 -c "skip write certificate verify" \
1758 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001759 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001760 -S "! mbedtls_ssl_handshake returned" \
1761 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001762 -S "X509 - Certificate verification failed"
1763
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001764run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001765 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001766 "$O_CLI" \
1767 0 \
1768 -S "skip write certificate request" \
1769 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001770 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001771 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001772 -S "X509 - Certificate verification failed"
1773
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001774run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001775 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001776 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001777 0 \
1778 -C "skip parse certificate request" \
1779 -c "got a certificate request" \
1780 -C "skip write certificate$" \
1781 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001782 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001783
Janos Follathe2681a42016-03-07 15:57:05 +00001784requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001785run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001786 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001787 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001788 0 \
1789 -S "skip write certificate request" \
1790 -C "skip parse certificate request" \
1791 -c "got a certificate request" \
1792 -C "skip write certificate$" \
1793 -c "skip write certificate verify" \
1794 -c "got no certificate to send" \
1795 -s "SSLv3 client has no certificate" \
1796 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001797 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001798 -S "! mbedtls_ssl_handshake returned" \
1799 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001800 -S "X509 - Certificate verification failed"
1801
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001802# Tests for certificate selection based on SHA verson
1803
1804run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1805 "$P_SRV crt_file=data_files/server5.crt \
1806 key_file=data_files/server5.key \
1807 crt_file2=data_files/server5-sha1.crt \
1808 key_file2=data_files/server5.key" \
1809 "$P_CLI force_version=tls1_2" \
1810 0 \
1811 -c "signed using.*ECDSA with SHA256" \
1812 -C "signed using.*ECDSA with SHA1"
1813
1814run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1815 "$P_SRV crt_file=data_files/server5.crt \
1816 key_file=data_files/server5.key \
1817 crt_file2=data_files/server5-sha1.crt \
1818 key_file2=data_files/server5.key" \
1819 "$P_CLI force_version=tls1_1" \
1820 0 \
1821 -C "signed using.*ECDSA with SHA256" \
1822 -c "signed using.*ECDSA with SHA1"
1823
1824run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1825 "$P_SRV crt_file=data_files/server5.crt \
1826 key_file=data_files/server5.key \
1827 crt_file2=data_files/server5-sha1.crt \
1828 key_file2=data_files/server5.key" \
1829 "$P_CLI force_version=tls1" \
1830 0 \
1831 -C "signed using.*ECDSA with SHA256" \
1832 -c "signed using.*ECDSA with SHA1"
1833
1834run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1835 "$P_SRV crt_file=data_files/server5.crt \
1836 key_file=data_files/server5.key \
1837 crt_file2=data_files/server6.crt \
1838 key_file2=data_files/server6.key" \
1839 "$P_CLI force_version=tls1_1" \
1840 0 \
1841 -c "serial number.*09" \
1842 -c "signed using.*ECDSA with SHA256" \
1843 -C "signed using.*ECDSA with SHA1"
1844
1845run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1846 "$P_SRV crt_file=data_files/server6.crt \
1847 key_file=data_files/server6.key \
1848 crt_file2=data_files/server5.crt \
1849 key_file2=data_files/server5.key" \
1850 "$P_CLI force_version=tls1_1" \
1851 0 \
1852 -c "serial number.*0A" \
1853 -c "signed using.*ECDSA with SHA256" \
1854 -C "signed using.*ECDSA with SHA1"
1855
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001856# tests for SNI
1857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001858run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001859 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001860 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001861 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001862 0 \
1863 -S "parse ServerName extension" \
1864 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1865 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001866
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001867run_test "SNI: matching cert 1" \
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é-Gonnard4d6f1782015-06-19 14:40:39 +02001870 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 +02001871 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001872 0 \
1873 -s "parse ServerName extension" \
1874 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1875 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001877run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001878 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001879 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001880 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 +02001881 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001882 0 \
1883 -s "parse ServerName extension" \
1884 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1885 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001886
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001887run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001888 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001889 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001890 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 +02001891 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001892 1 \
1893 -s "parse ServerName extension" \
1894 -s "ssl_sni_wrapper() returned" \
1895 -s "mbedtls_ssl_handshake returned" \
1896 -c "mbedtls_ssl_handshake returned" \
1897 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001898
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001899run_test "SNI: client auth no override: optional" \
1900 "$P_SRV debug_level=3 auth_mode=optional \
1901 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1902 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1903 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001904 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001905 -S "skip write certificate request" \
1906 -C "skip parse certificate request" \
1907 -c "got a certificate request" \
1908 -C "skip write certificate" \
1909 -C "skip write certificate verify" \
1910 -S "skip parse certificate verify"
1911
1912run_test "SNI: client auth override: none -> optional" \
1913 "$P_SRV debug_level=3 auth_mode=none \
1914 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1915 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1916 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001917 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001918 -S "skip write certificate request" \
1919 -C "skip parse certificate request" \
1920 -c "got a certificate request" \
1921 -C "skip write certificate" \
1922 -C "skip write certificate verify" \
1923 -S "skip parse certificate verify"
1924
1925run_test "SNI: client auth override: optional -> none" \
1926 "$P_SRV debug_level=3 auth_mode=optional \
1927 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1928 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1929 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001930 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001931 -s "skip write certificate request" \
1932 -C "skip parse certificate request" \
1933 -c "got no certificate request" \
1934 -c "skip write certificate" \
1935 -c "skip write certificate verify" \
1936 -s "skip parse certificate verify"
1937
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001938run_test "SNI: CA no override" \
1939 "$P_SRV debug_level=3 auth_mode=optional \
1940 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1941 ca_file=data_files/test-ca.crt \
1942 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1943 "$P_CLI debug_level=3 server_name=localhost \
1944 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1945 1 \
1946 -S "skip write certificate request" \
1947 -C "skip parse certificate request" \
1948 -c "got a certificate request" \
1949 -C "skip write certificate" \
1950 -C "skip write certificate verify" \
1951 -S "skip parse certificate verify" \
1952 -s "x509_verify_cert() returned" \
1953 -s "! The certificate is not correctly signed by the trusted CA" \
1954 -S "The certificate has been revoked (is on a CRL)"
1955
1956run_test "SNI: CA override" \
1957 "$P_SRV debug_level=3 auth_mode=optional \
1958 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1959 ca_file=data_files/test-ca.crt \
1960 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1961 "$P_CLI debug_level=3 server_name=localhost \
1962 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1963 0 \
1964 -S "skip write certificate request" \
1965 -C "skip parse certificate request" \
1966 -c "got a certificate request" \
1967 -C "skip write certificate" \
1968 -C "skip write certificate verify" \
1969 -S "skip parse certificate verify" \
1970 -S "x509_verify_cert() returned" \
1971 -S "! The certificate is not correctly signed by the trusted CA" \
1972 -S "The certificate has been revoked (is on a CRL)"
1973
1974run_test "SNI: CA override with CRL" \
1975 "$P_SRV debug_level=3 auth_mode=optional \
1976 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1977 ca_file=data_files/test-ca.crt \
1978 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1979 "$P_CLI debug_level=3 server_name=localhost \
1980 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1981 1 \
1982 -S "skip write certificate request" \
1983 -C "skip parse certificate request" \
1984 -c "got a certificate request" \
1985 -C "skip write certificate" \
1986 -C "skip write certificate verify" \
1987 -S "skip parse certificate verify" \
1988 -s "x509_verify_cert() returned" \
1989 -S "! The certificate is not correctly signed by the trusted CA" \
1990 -s "The certificate has been revoked (is on a CRL)"
1991
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001992# Tests for non-blocking I/O: exercise a variety of handshake flows
1993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001994run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001995 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1996 "$P_CLI nbio=2 tickets=0" \
1997 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001998 -S "mbedtls_ssl_handshake returned" \
1999 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002000 -c "Read from server: .* bytes read"
2001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002002run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002003 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2004 "$P_CLI nbio=2 tickets=0" \
2005 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002006 -S "mbedtls_ssl_handshake returned" \
2007 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002008 -c "Read from server: .* bytes read"
2009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002010run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002011 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2012 "$P_CLI nbio=2 tickets=1" \
2013 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002014 -S "mbedtls_ssl_handshake returned" \
2015 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002016 -c "Read from server: .* bytes read"
2017
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002018run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002019 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2020 "$P_CLI nbio=2 tickets=1" \
2021 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002022 -S "mbedtls_ssl_handshake returned" \
2023 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002024 -c "Read from server: .* bytes read"
2025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002026run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002027 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2028 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2029 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002030 -S "mbedtls_ssl_handshake returned" \
2031 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002032 -c "Read from server: .* bytes read"
2033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002034run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002035 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2036 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2037 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002038 -S "mbedtls_ssl_handshake returned" \
2039 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002040 -c "Read from server: .* bytes read"
2041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002042run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002043 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2044 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2045 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002046 -S "mbedtls_ssl_handshake returned" \
2047 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002048 -c "Read from server: .* bytes read"
2049
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002050# Tests for version negotiation
2051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002052run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002053 "$P_SRV" \
2054 "$P_CLI" \
2055 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002056 -S "mbedtls_ssl_handshake returned" \
2057 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002058 -s "Protocol is TLSv1.2" \
2059 -c "Protocol is TLSv1.2"
2060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002061run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002062 "$P_SRV" \
2063 "$P_CLI max_version=tls1_1" \
2064 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002065 -S "mbedtls_ssl_handshake returned" \
2066 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002067 -s "Protocol is TLSv1.1" \
2068 -c "Protocol is TLSv1.1"
2069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002070run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002071 "$P_SRV max_version=tls1_1" \
2072 "$P_CLI" \
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: cli+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 max_version=tls1_1" \
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 max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002089 "$P_SRV min_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 min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002098 "$P_SRV max_version=tls1_1" \
2099 "$P_CLI min_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.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002107 "$P_SRV max_version=tls1_1" \
2108 "$P_CLI min_version=tls1_2" \
2109 1 \
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 -c "SSL - Handshake protocol not within min/max boundaries"
2113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002114run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002115 "$P_SRV min_version=tls1_2" \
2116 "$P_CLI max_version=tls1_1" \
2117 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002118 -s "mbedtls_ssl_handshake returned" \
2119 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002120 -s "SSL - Handshake protocol not within min/max boundaries"
2121
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002122# Tests for ALPN extension
2123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002124run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002125 "$P_SRV debug_level=3" \
2126 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002127 0 \
2128 -C "client hello, adding alpn extension" \
2129 -S "found alpn extension" \
2130 -C "got an alert message, type: \\[2:120]" \
2131 -S "server hello, adding alpn extension" \
2132 -C "found alpn extension " \
2133 -C "Application Layer Protocol is" \
2134 -S "Application Layer Protocol is"
2135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002136run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002137 "$P_SRV debug_level=3" \
2138 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002139 0 \
2140 -c "client hello, adding alpn extension" \
2141 -s "found alpn extension" \
2142 -C "got an alert message, type: \\[2:120]" \
2143 -S "server hello, adding alpn extension" \
2144 -C "found alpn extension " \
2145 -c "Application Layer Protocol is (none)" \
2146 -S "Application Layer Protocol is"
2147
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002148run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002149 "$P_SRV debug_level=3 alpn=abc,1234" \
2150 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002151 0 \
2152 -C "client hello, adding alpn extension" \
2153 -S "found alpn extension" \
2154 -C "got an alert message, type: \\[2:120]" \
2155 -S "server hello, adding alpn extension" \
2156 -C "found alpn extension " \
2157 -C "Application Layer Protocol is" \
2158 -s "Application Layer Protocol is (none)"
2159
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002160run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002161 "$P_SRV debug_level=3 alpn=abc,1234" \
2162 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002163 0 \
2164 -c "client hello, adding alpn extension" \
2165 -s "found alpn extension" \
2166 -C "got an alert message, type: \\[2:120]" \
2167 -s "server hello, adding alpn extension" \
2168 -c "found alpn extension" \
2169 -c "Application Layer Protocol is abc" \
2170 -s "Application Layer Protocol is abc"
2171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002172run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002173 "$P_SRV debug_level=3 alpn=abc,1234" \
2174 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002175 0 \
2176 -c "client hello, adding alpn extension" \
2177 -s "found alpn extension" \
2178 -C "got an alert message, type: \\[2:120]" \
2179 -s "server hello, adding alpn extension" \
2180 -c "found alpn extension" \
2181 -c "Application Layer Protocol is abc" \
2182 -s "Application Layer Protocol is abc"
2183
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002184run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002185 "$P_SRV debug_level=3 alpn=abc,1234" \
2186 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002187 0 \
2188 -c "client hello, adding alpn extension" \
2189 -s "found alpn extension" \
2190 -C "got an alert message, type: \\[2:120]" \
2191 -s "server hello, adding alpn extension" \
2192 -c "found alpn extension" \
2193 -c "Application Layer Protocol is 1234" \
2194 -s "Application Layer Protocol is 1234"
2195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002196run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002197 "$P_SRV debug_level=3 alpn=abc,123" \
2198 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002199 1 \
2200 -c "client hello, adding alpn extension" \
2201 -s "found alpn extension" \
2202 -c "got an alert message, type: \\[2:120]" \
2203 -S "server hello, adding alpn extension" \
2204 -C "found alpn extension" \
2205 -C "Application Layer Protocol is 1234" \
2206 -S "Application Layer Protocol is 1234"
2207
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002208
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002209# Tests for keyUsage in leaf certificates, part 1:
2210# server-side certificate/suite selection
2211
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002212run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002213 "$P_SRV key_file=data_files/server2.key \
2214 crt_file=data_files/server2.ku-ds.crt" \
2215 "$P_CLI" \
2216 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002217 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002218
2219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002220run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002221 "$P_SRV key_file=data_files/server2.key \
2222 crt_file=data_files/server2.ku-ke.crt" \
2223 "$P_CLI" \
2224 0 \
2225 -c "Ciphersuite is TLS-RSA-WITH-"
2226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002227run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002228 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002229 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002230 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002231 1 \
2232 -C "Ciphersuite is "
2233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002234run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002235 "$P_SRV key_file=data_files/server5.key \
2236 crt_file=data_files/server5.ku-ds.crt" \
2237 "$P_CLI" \
2238 0 \
2239 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2240
2241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002242run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002243 "$P_SRV key_file=data_files/server5.key \
2244 crt_file=data_files/server5.ku-ka.crt" \
2245 "$P_CLI" \
2246 0 \
2247 -c "Ciphersuite is TLS-ECDH-"
2248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002249run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002250 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002251 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002252 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002253 1 \
2254 -C "Ciphersuite is "
2255
2256# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002257# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002259run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002260 "$O_SRV -key data_files/server2.key \
2261 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002262 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002263 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2264 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002265 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002266 -C "Processing of the Certificate handshake message failed" \
2267 -c "Ciphersuite is TLS-"
2268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002269run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002270 "$O_SRV -key data_files/server2.key \
2271 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002272 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002273 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2274 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002275 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002276 -C "Processing of the Certificate handshake message failed" \
2277 -c "Ciphersuite is TLS-"
2278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002279run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002280 "$O_SRV -key data_files/server2.key \
2281 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002282 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002283 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2284 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002285 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002286 -C "Processing of the Certificate handshake message failed" \
2287 -c "Ciphersuite is TLS-"
2288
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002289run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002290 "$O_SRV -key data_files/server2.key \
2291 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002292 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002293 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2294 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002295 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002296 -c "Processing of the Certificate handshake message failed" \
2297 -C "Ciphersuite is TLS-"
2298
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002299run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2300 "$O_SRV -key data_files/server2.key \
2301 -cert data_files/server2.ku-ke.crt" \
2302 "$P_CLI debug_level=1 auth_mode=optional \
2303 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2304 0 \
2305 -c "bad certificate (usage extensions)" \
2306 -C "Processing of the Certificate handshake message failed" \
2307 -c "Ciphersuite is TLS-" \
2308 -c "! Usage does not match the keyUsage extension"
2309
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002310run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002311 "$O_SRV -key data_files/server2.key \
2312 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002313 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002314 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2315 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002316 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002317 -C "Processing of the Certificate handshake message failed" \
2318 -c "Ciphersuite is TLS-"
2319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002320run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002321 "$O_SRV -key data_files/server2.key \
2322 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002323 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002324 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2325 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002326 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002327 -c "Processing of the Certificate handshake message failed" \
2328 -C "Ciphersuite is TLS-"
2329
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002330run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2331 "$O_SRV -key data_files/server2.key \
2332 -cert data_files/server2.ku-ds.crt" \
2333 "$P_CLI debug_level=1 auth_mode=optional \
2334 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2335 0 \
2336 -c "bad certificate (usage extensions)" \
2337 -C "Processing of the Certificate handshake message failed" \
2338 -c "Ciphersuite is TLS-" \
2339 -c "! Usage does not match the keyUsage extension"
2340
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002341# Tests for keyUsage in leaf certificates, part 3:
2342# server-side checking of client cert
2343
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002344run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002345 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002346 "$O_CLI -key data_files/server2.key \
2347 -cert data_files/server2.ku-ds.crt" \
2348 0 \
2349 -S "bad certificate (usage extensions)" \
2350 -S "Processing of the Certificate handshake message failed"
2351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002352run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002353 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002354 "$O_CLI -key data_files/server2.key \
2355 -cert data_files/server2.ku-ke.crt" \
2356 0 \
2357 -s "bad certificate (usage extensions)" \
2358 -S "Processing of the Certificate handshake message failed"
2359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002360run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002361 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002362 "$O_CLI -key data_files/server2.key \
2363 -cert data_files/server2.ku-ke.crt" \
2364 1 \
2365 -s "bad certificate (usage extensions)" \
2366 -s "Processing of the Certificate handshake message failed"
2367
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002368run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002369 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002370 "$O_CLI -key data_files/server5.key \
2371 -cert data_files/server5.ku-ds.crt" \
2372 0 \
2373 -S "bad certificate (usage extensions)" \
2374 -S "Processing of the Certificate handshake message failed"
2375
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002376run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002377 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002378 "$O_CLI -key data_files/server5.key \
2379 -cert data_files/server5.ku-ka.crt" \
2380 0 \
2381 -s "bad certificate (usage extensions)" \
2382 -S "Processing of the Certificate handshake message failed"
2383
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002384# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002386run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002387 "$P_SRV key_file=data_files/server5.key \
2388 crt_file=data_files/server5.eku-srv.crt" \
2389 "$P_CLI" \
2390 0
2391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002392run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002393 "$P_SRV key_file=data_files/server5.key \
2394 crt_file=data_files/server5.eku-srv.crt" \
2395 "$P_CLI" \
2396 0
2397
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002398run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002399 "$P_SRV key_file=data_files/server5.key \
2400 crt_file=data_files/server5.eku-cs_any.crt" \
2401 "$P_CLI" \
2402 0
2403
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002404run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002405 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002406 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002407 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002408 1
2409
2410# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2411
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002412run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002413 "$O_SRV -key data_files/server5.key \
2414 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002415 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002416 0 \
2417 -C "bad certificate (usage extensions)" \
2418 -C "Processing of the Certificate handshake message failed" \
2419 -c "Ciphersuite is TLS-"
2420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002421run_test "extKeyUsage cli: serverAuth,clientAuth -> 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_cli.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: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002431 "$O_SRV -key data_files/server5.key \
2432 -cert data_files/server5.eku-cs_any.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 -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002440 "$O_SRV -key data_files/server5.key \
2441 -cert data_files/server5.eku-cs.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 1 \
2444 -c "bad certificate (usage extensions)" \
2445 -c "Processing of the Certificate handshake message failed" \
2446 -C "Ciphersuite is TLS-"
2447
2448# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2449
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002450run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002451 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002452 "$O_CLI -key data_files/server5.key \
2453 -cert data_files/server5.eku-cli.crt" \
2454 0 \
2455 -S "bad certificate (usage extensions)" \
2456 -S "Processing of the Certificate handshake message failed"
2457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002458run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002459 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002460 "$O_CLI -key data_files/server5.key \
2461 -cert data_files/server5.eku-srv_cli.crt" \
2462 0 \
2463 -S "bad certificate (usage extensions)" \
2464 -S "Processing of the Certificate handshake message failed"
2465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002466run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002467 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002468 "$O_CLI -key data_files/server5.key \
2469 -cert data_files/server5.eku-cs_any.crt" \
2470 0 \
2471 -S "bad certificate (usage extensions)" \
2472 -S "Processing of the Certificate handshake message failed"
2473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002474run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002475 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002476 "$O_CLI -key data_files/server5.key \
2477 -cert data_files/server5.eku-cs.crt" \
2478 0 \
2479 -s "bad certificate (usage extensions)" \
2480 -S "Processing of the Certificate handshake message failed"
2481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002482run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002483 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002484 "$O_CLI -key data_files/server5.key \
2485 -cert data_files/server5.eku-cs.crt" \
2486 1 \
2487 -s "bad certificate (usage extensions)" \
2488 -s "Processing of the Certificate handshake message failed"
2489
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002490# Tests for DHM parameters loading
2491
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002492run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002493 "$P_SRV" \
2494 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2495 debug_level=3" \
2496 0 \
2497 -c "value of 'DHM: P ' (2048 bits)" \
2498 -c "value of 'DHM: G ' (2048 bits)"
2499
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002500run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002501 "$P_SRV dhm_file=data_files/dhparams.pem" \
2502 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2503 debug_level=3" \
2504 0 \
2505 -c "value of 'DHM: P ' (1024 bits)" \
2506 -c "value of 'DHM: G ' (2 bits)"
2507
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002508# Tests for DHM client-side size checking
2509
2510run_test "DHM size: server default, client default, OK" \
2511 "$P_SRV" \
2512 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2513 debug_level=1" \
2514 0 \
2515 -C "DHM prime too short:"
2516
2517run_test "DHM size: server default, client 2048, OK" \
2518 "$P_SRV" \
2519 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2520 debug_level=1 dhmlen=2048" \
2521 0 \
2522 -C "DHM prime too short:"
2523
2524run_test "DHM size: server 1024, client default, OK" \
2525 "$P_SRV dhm_file=data_files/dhparams.pem" \
2526 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2527 debug_level=1" \
2528 0 \
2529 -C "DHM prime too short:"
2530
2531run_test "DHM size: server 1000, client default, rejected" \
2532 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2533 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2534 debug_level=1" \
2535 1 \
2536 -c "DHM prime too short:"
2537
2538run_test "DHM size: server default, client 2049, rejected" \
2539 "$P_SRV" \
2540 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2541 debug_level=1 dhmlen=2049" \
2542 1 \
2543 -c "DHM prime too short:"
2544
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002545# Tests for PSK callback
2546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002547run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002548 "$P_SRV psk=abc123 psk_identity=foo" \
2549 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2550 psk_identity=foo psk=abc123" \
2551 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002552 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002553 -S "SSL - Unknown identity received" \
2554 -S "SSL - Verification of the message MAC failed"
2555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002556run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002557 "$P_SRV" \
2558 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2559 psk_identity=foo psk=abc123" \
2560 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002561 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +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: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002566 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
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: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002575 "$P_SRV psk_list=abc,dead,def,beef" \
2576 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2577 psk_identity=abc psk=dead" \
2578 0 \
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: second 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=def psk=beef" \
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: no match" \
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=ghi psk=beef" \
2596 1 \
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: wrong key" \
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=abc 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"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002609
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002610# Tests for EC J-PAKE
2611
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002612requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002613run_test "ECJPAKE: client not configured" \
2614 "$P_SRV debug_level=3" \
2615 "$P_CLI debug_level=3" \
2616 0 \
2617 -C "add ciphersuite: c0ff" \
2618 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002619 -S "found ecjpake kkpp extension" \
2620 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002621 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002622 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002623 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002624 -S "None of the common ciphersuites is usable"
2625
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002626requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002627run_test "ECJPAKE: server not configured" \
2628 "$P_SRV debug_level=3" \
2629 "$P_CLI debug_level=3 ecjpake_pw=bla \
2630 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2631 1 \
2632 -c "add ciphersuite: c0ff" \
2633 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002634 -s "found ecjpake kkpp extension" \
2635 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002636 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002637 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002638 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002639 -s "None of the common ciphersuites is usable"
2640
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002641requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002642run_test "ECJPAKE: working, TLS" \
2643 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2644 "$P_CLI debug_level=3 ecjpake_pw=bla \
2645 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002646 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002647 -c "add ciphersuite: c0ff" \
2648 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002649 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002650 -s "found ecjpake kkpp extension" \
2651 -S "skip ecjpake kkpp extension" \
2652 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002653 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002654 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002655 -S "None of the common ciphersuites is usable" \
2656 -S "SSL - Verification of the message MAC failed"
2657
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002658requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002659run_test "ECJPAKE: password mismatch, TLS" \
2660 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2661 "$P_CLI debug_level=3 ecjpake_pw=bad \
2662 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2663 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002664 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002665 -s "SSL - Verification of the message MAC failed"
2666
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002667requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002668run_test "ECJPAKE: working, DTLS" \
2669 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2670 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2671 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2672 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002673 -c "re-using cached ecjpake parameters" \
2674 -S "SSL - Verification of the message MAC failed"
2675
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002676requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002677run_test "ECJPAKE: working, DTLS, no cookie" \
2678 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2679 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2680 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2681 0 \
2682 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002683 -S "SSL - Verification of the message MAC failed"
2684
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002685requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002686run_test "ECJPAKE: password mismatch, DTLS" \
2687 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2688 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2689 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2690 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002691 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002692 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002693
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002694# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002695requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002696run_test "ECJPAKE: working, DTLS, nolog" \
2697 "$P_SRV dtls=1 ecjpake_pw=bla" \
2698 "$P_CLI dtls=1 ecjpake_pw=bla \
2699 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2700 0
2701
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002702# Tests for ciphersuites per version
2703
Janos Follathe2681a42016-03-07 15:57:05 +00002704requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002705run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002706 "$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 +02002707 "$P_CLI force_version=ssl3" \
2708 0 \
2709 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002711run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002712 "$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 +01002713 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002714 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002715 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002717run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002718 "$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 +02002719 "$P_CLI force_version=tls1_1" \
2720 0 \
2721 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002723run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002724 "$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 +02002725 "$P_CLI force_version=tls1_2" \
2726 0 \
2727 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2728
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002729# Test for ClientHello without extensions
2730
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002731requires_gnutls
2732run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002733 "$P_SRV debug_level=3" \
2734 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2735 0 \
2736 -s "dumping 'client hello extensions' (0 bytes)"
2737
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002738# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002739
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002740run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002741 "$P_SRV" \
2742 "$P_CLI request_size=100" \
2743 0 \
2744 -s "Read from client: 100 bytes read$"
2745
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002746run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002747 "$P_SRV" \
2748 "$P_CLI request_size=500" \
2749 0 \
2750 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002751
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002752# Tests for small packets
2753
Janos Follathe2681a42016-03-07 15:57:05 +00002754requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002755run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002756 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002757 "$P_CLI request_size=1 force_version=ssl3 \
2758 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2759 0 \
2760 -s "Read from client: 1 bytes read"
2761
Janos Follathe2681a42016-03-07 15:57:05 +00002762requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002763run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002764 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002765 "$P_CLI request_size=1 force_version=ssl3 \
2766 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2767 0 \
2768 -s "Read from client: 1 bytes read"
2769
2770run_test "Small packet TLS 1.0 BlockCipher" \
2771 "$P_SRV" \
2772 "$P_CLI request_size=1 force_version=tls1 \
2773 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2774 0 \
2775 -s "Read from client: 1 bytes read"
2776
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002777run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2778 "$P_SRV" \
2779 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2780 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2781 0 \
2782 -s "Read from client: 1 bytes read"
2783
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002784run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2785 "$P_SRV" \
2786 "$P_CLI request_size=1 force_version=tls1 \
2787 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2788 trunc_hmac=1" \
2789 0 \
2790 -s "Read from client: 1 bytes read"
2791
2792run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002793 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002794 "$P_CLI request_size=1 force_version=tls1 \
2795 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2796 trunc_hmac=1" \
2797 0 \
2798 -s "Read from client: 1 bytes read"
2799
2800run_test "Small packet TLS 1.1 BlockCipher" \
2801 "$P_SRV" \
2802 "$P_CLI request_size=1 force_version=tls1_1 \
2803 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2804 0 \
2805 -s "Read from client: 1 bytes read"
2806
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002807run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2808 "$P_SRV" \
2809 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2810 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2811 0 \
2812 -s "Read from client: 1 bytes read"
2813
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002814run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002815 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002816 "$P_CLI request_size=1 force_version=tls1_1 \
2817 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2818 0 \
2819 -s "Read from client: 1 bytes read"
2820
2821run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2822 "$P_SRV" \
2823 "$P_CLI request_size=1 force_version=tls1_1 \
2824 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2825 trunc_hmac=1" \
2826 0 \
2827 -s "Read from client: 1 bytes read"
2828
2829run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002830 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002831 "$P_CLI request_size=1 force_version=tls1_1 \
2832 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2833 trunc_hmac=1" \
2834 0 \
2835 -s "Read from client: 1 bytes read"
2836
2837run_test "Small packet TLS 1.2 BlockCipher" \
2838 "$P_SRV" \
2839 "$P_CLI request_size=1 force_version=tls1_2 \
2840 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2841 0 \
2842 -s "Read from client: 1 bytes read"
2843
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002844run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2845 "$P_SRV" \
2846 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2847 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2848 0 \
2849 -s "Read from client: 1 bytes read"
2850
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002851run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2852 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002853 "$P_CLI request_size=1 force_version=tls1_2 \
2854 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002855 0 \
2856 -s "Read from client: 1 bytes read"
2857
2858run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2859 "$P_SRV" \
2860 "$P_CLI request_size=1 force_version=tls1_2 \
2861 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2862 trunc_hmac=1" \
2863 0 \
2864 -s "Read from client: 1 bytes read"
2865
2866run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002867 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002868 "$P_CLI request_size=1 force_version=tls1_2 \
2869 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2870 0 \
2871 -s "Read from client: 1 bytes read"
2872
2873run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002874 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002875 "$P_CLI request_size=1 force_version=tls1_2 \
2876 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2877 trunc_hmac=1" \
2878 0 \
2879 -s "Read from client: 1 bytes read"
2880
2881run_test "Small packet TLS 1.2 AEAD" \
2882 "$P_SRV" \
2883 "$P_CLI request_size=1 force_version=tls1_2 \
2884 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2885 0 \
2886 -s "Read from client: 1 bytes read"
2887
2888run_test "Small packet TLS 1.2 AEAD shorter tag" \
2889 "$P_SRV" \
2890 "$P_CLI request_size=1 force_version=tls1_2 \
2891 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2892 0 \
2893 -s "Read from client: 1 bytes read"
2894
Janos Follath00efff72016-05-06 13:48:23 +01002895# A test for extensions in SSLv3
2896
2897requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2898run_test "SSLv3 with extensions, server side" \
2899 "$P_SRV min_version=ssl3 debug_level=3" \
2900 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2901 0 \
2902 -S "dumping 'client hello extensions'" \
2903 -S "server hello, total extension length:"
2904
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002905# Test for large packets
2906
Janos Follathe2681a42016-03-07 15:57:05 +00002907requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002908run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002909 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002910 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002911 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2912 0 \
2913 -s "Read from client: 16384 bytes read"
2914
Janos Follathe2681a42016-03-07 15:57:05 +00002915requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002916run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002917 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002918 "$P_CLI request_size=16384 force_version=ssl3 \
2919 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2920 0 \
2921 -s "Read from client: 16384 bytes read"
2922
2923run_test "Large packet TLS 1.0 BlockCipher" \
2924 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002925 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002926 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2927 0 \
2928 -s "Read from client: 16384 bytes read"
2929
2930run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2931 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002932 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002933 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2934 trunc_hmac=1" \
2935 0 \
2936 -s "Read from client: 16384 bytes read"
2937
2938run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002939 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002940 "$P_CLI request_size=16384 force_version=tls1 \
2941 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2942 trunc_hmac=1" \
2943 0 \
2944 -s "Read from client: 16384 bytes read"
2945
2946run_test "Large packet TLS 1.1 BlockCipher" \
2947 "$P_SRV" \
2948 "$P_CLI request_size=16384 force_version=tls1_1 \
2949 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2950 0 \
2951 -s "Read from client: 16384 bytes read"
2952
2953run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002954 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002955 "$P_CLI request_size=16384 force_version=tls1_1 \
2956 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2957 0 \
2958 -s "Read from client: 16384 bytes read"
2959
2960run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2961 "$P_SRV" \
2962 "$P_CLI request_size=16384 force_version=tls1_1 \
2963 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2964 trunc_hmac=1" \
2965 0 \
2966 -s "Read from client: 16384 bytes read"
2967
2968run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002969 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002970 "$P_CLI request_size=16384 force_version=tls1_1 \
2971 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2972 trunc_hmac=1" \
2973 0 \
2974 -s "Read from client: 16384 bytes read"
2975
2976run_test "Large packet TLS 1.2 BlockCipher" \
2977 "$P_SRV" \
2978 "$P_CLI request_size=16384 force_version=tls1_2 \
2979 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2980 0 \
2981 -s "Read from client: 16384 bytes read"
2982
2983run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2984 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002985 "$P_CLI request_size=16384 force_version=tls1_2 \
2986 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002987 0 \
2988 -s "Read from client: 16384 bytes read"
2989
2990run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2991 "$P_SRV" \
2992 "$P_CLI request_size=16384 force_version=tls1_2 \
2993 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2994 trunc_hmac=1" \
2995 0 \
2996 -s "Read from client: 16384 bytes read"
2997
2998run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002999 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003000 "$P_CLI request_size=16384 force_version=tls1_2 \
3001 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3002 0 \
3003 -s "Read from client: 16384 bytes read"
3004
3005run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003006 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003007 "$P_CLI request_size=16384 force_version=tls1_2 \
3008 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3009 trunc_hmac=1" \
3010 0 \
3011 -s "Read from client: 16384 bytes read"
3012
3013run_test "Large packet TLS 1.2 AEAD" \
3014 "$P_SRV" \
3015 "$P_CLI request_size=16384 force_version=tls1_2 \
3016 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3017 0 \
3018 -s "Read from client: 16384 bytes read"
3019
3020run_test "Large packet TLS 1.2 AEAD shorter tag" \
3021 "$P_SRV" \
3022 "$P_CLI request_size=16384 force_version=tls1_2 \
3023 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3024 0 \
3025 -s "Read from client: 16384 bytes read"
3026
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003027# Tests for DTLS HelloVerifyRequest
3028
3029run_test "DTLS cookie: enabled" \
3030 "$P_SRV dtls=1 debug_level=2" \
3031 "$P_CLI dtls=1 debug_level=2" \
3032 0 \
3033 -s "cookie verification failed" \
3034 -s "cookie verification passed" \
3035 -S "cookie verification skipped" \
3036 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003037 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003038 -S "SSL - The requested feature is not available"
3039
3040run_test "DTLS cookie: disabled" \
3041 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3042 "$P_CLI dtls=1 debug_level=2" \
3043 0 \
3044 -S "cookie verification failed" \
3045 -S "cookie verification passed" \
3046 -s "cookie verification skipped" \
3047 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003048 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003049 -S "SSL - The requested feature is not available"
3050
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003051run_test "DTLS cookie: default (failing)" \
3052 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3053 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3054 1 \
3055 -s "cookie verification failed" \
3056 -S "cookie verification passed" \
3057 -S "cookie verification skipped" \
3058 -C "received hello verify request" \
3059 -S "hello verification requested" \
3060 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003061
3062requires_ipv6
3063run_test "DTLS cookie: enabled, IPv6" \
3064 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3065 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3066 0 \
3067 -s "cookie verification failed" \
3068 -s "cookie verification passed" \
3069 -S "cookie verification skipped" \
3070 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003071 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003072 -S "SSL - The requested feature is not available"
3073
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003074run_test "DTLS cookie: enabled, nbio" \
3075 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3076 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3077 0 \
3078 -s "cookie verification failed" \
3079 -s "cookie verification passed" \
3080 -S "cookie verification skipped" \
3081 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003082 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003083 -S "SSL - The requested feature is not available"
3084
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003085# Tests for client reconnecting from the same port with DTLS
3086
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003087not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003088run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003089 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3090 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003091 0 \
3092 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003093 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003094 -S "Client initiated reconnection from same port"
3095
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003096not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003097run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003098 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3099 "$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 +02003100 0 \
3101 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003102 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003103 -s "Client initiated reconnection from same port"
3104
Paul Bakker362689d2016-05-13 10:33:25 +01003105not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3106run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003107 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3108 "$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 +02003109 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003110 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003111 -s "Client initiated reconnection from same port"
3112
Paul Bakker362689d2016-05-13 10:33:25 +01003113only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3114run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3115 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3116 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3117 0 \
3118 -S "The operation timed out" \
3119 -s "Client initiated reconnection from same port"
3120
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003121run_test "DTLS client reconnect from same port: no cookies" \
3122 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003123 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3124 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003125 -s "The operation timed out" \
3126 -S "Client initiated reconnection from same port"
3127
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003128# Tests for various cases of client authentication with DTLS
3129# (focused on handshake flows and message parsing)
3130
3131run_test "DTLS client auth: required" \
3132 "$P_SRV dtls=1 auth_mode=required" \
3133 "$P_CLI dtls=1" \
3134 0 \
3135 -s "Verifying peer X.509 certificate... ok"
3136
3137run_test "DTLS client auth: optional, client has no cert" \
3138 "$P_SRV dtls=1 auth_mode=optional" \
3139 "$P_CLI dtls=1 crt_file=none key_file=none" \
3140 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003141 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003142
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003143run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003144 "$P_SRV dtls=1 auth_mode=none" \
3145 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3146 0 \
3147 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003148 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003149
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003150run_test "DTLS wrong PSK: badmac alert" \
3151 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3152 "$P_CLI dtls=1 psk=abc124" \
3153 1 \
3154 -s "SSL - Verification of the message MAC failed" \
3155 -c "SSL - A fatal alert message was received from our peer"
3156
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003157# Tests for receiving fragmented handshake messages with DTLS
3158
3159requires_gnutls
3160run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3161 "$G_SRV -u --mtu 2048 -a" \
3162 "$P_CLI dtls=1 debug_level=2" \
3163 0 \
3164 -C "found fragmented DTLS handshake message" \
3165 -C "error"
3166
3167requires_gnutls
3168run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3169 "$G_SRV -u --mtu 512" \
3170 "$P_CLI dtls=1 debug_level=2" \
3171 0 \
3172 -c "found fragmented DTLS handshake message" \
3173 -C "error"
3174
3175requires_gnutls
3176run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3177 "$G_SRV -u --mtu 128" \
3178 "$P_CLI dtls=1 debug_level=2" \
3179 0 \
3180 -c "found fragmented DTLS handshake message" \
3181 -C "error"
3182
3183requires_gnutls
3184run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3185 "$G_SRV -u --mtu 128" \
3186 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3187 0 \
3188 -c "found fragmented DTLS handshake message" \
3189 -C "error"
3190
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003191requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003192run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3193 "$G_SRV -u --mtu 256" \
3194 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3195 0 \
3196 -c "found fragmented DTLS handshake message" \
3197 -c "client hello, adding renegotiation extension" \
3198 -c "found renegotiation extension" \
3199 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003200 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003201 -C "error" \
3202 -s "Extra-header:"
3203
3204requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003205run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3206 "$G_SRV -u --mtu 256" \
3207 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3208 0 \
3209 -c "found fragmented DTLS handshake message" \
3210 -c "client hello, adding renegotiation extension" \
3211 -c "found renegotiation extension" \
3212 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003213 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003214 -C "error" \
3215 -s "Extra-header:"
3216
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003217run_test "DTLS reassembly: no fragmentation (openssl server)" \
3218 "$O_SRV -dtls1 -mtu 2048" \
3219 "$P_CLI dtls=1 debug_level=2" \
3220 0 \
3221 -C "found fragmented DTLS handshake message" \
3222 -C "error"
3223
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003224run_test "DTLS reassembly: some fragmentation (openssl server)" \
3225 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003226 "$P_CLI dtls=1 debug_level=2" \
3227 0 \
3228 -c "found fragmented DTLS handshake message" \
3229 -C "error"
3230
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003231run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003232 "$O_SRV -dtls1 -mtu 256" \
3233 "$P_CLI dtls=1 debug_level=2" \
3234 0 \
3235 -c "found fragmented DTLS handshake message" \
3236 -C "error"
3237
3238run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3239 "$O_SRV -dtls1 -mtu 256" \
3240 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3241 0 \
3242 -c "found fragmented DTLS handshake message" \
3243 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003244
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003245# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003246
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003247not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003248run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003249 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003250 "$P_SRV dtls=1 debug_level=2" \
3251 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003252 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003253 -C "replayed record" \
3254 -S "replayed record" \
3255 -C "record from another epoch" \
3256 -S "record from another epoch" \
3257 -C "discarding invalid record" \
3258 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003259 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003260 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003261 -c "HTTP/1.0 200 OK"
3262
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003263not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003264run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003265 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003266 "$P_SRV dtls=1 debug_level=2" \
3267 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003268 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003269 -c "replayed record" \
3270 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003271 -c "discarding invalid record" \
3272 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003273 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003274 -s "Extra-header:" \
3275 -c "HTTP/1.0 200 OK"
3276
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003277run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3278 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003279 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3280 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003281 0 \
3282 -c "replayed record" \
3283 -S "replayed record" \
3284 -c "discarding invalid record" \
3285 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003286 -c "resend" \
3287 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003288 -s "Extra-header:" \
3289 -c "HTTP/1.0 200 OK"
3290
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003291run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003292 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003293 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003294 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003295 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003296 -c "discarding invalid record (mac)" \
3297 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003298 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003299 -c "HTTP/1.0 200 OK" \
3300 -S "too many records with bad MAC" \
3301 -S "Verification of the message MAC failed"
3302
3303run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3304 -p "$P_PXY bad_ad=1" \
3305 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3306 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3307 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003308 -C "discarding invalid record (mac)" \
3309 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003310 -S "Extra-header:" \
3311 -C "HTTP/1.0 200 OK" \
3312 -s "too many records with bad MAC" \
3313 -s "Verification of the message MAC failed"
3314
3315run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3316 -p "$P_PXY bad_ad=1" \
3317 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3318 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3319 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003320 -c "discarding invalid record (mac)" \
3321 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003322 -s "Extra-header:" \
3323 -c "HTTP/1.0 200 OK" \
3324 -S "too many records with bad MAC" \
3325 -S "Verification of the message MAC failed"
3326
3327run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3328 -p "$P_PXY bad_ad=1" \
3329 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3330 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3331 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003332 -c "discarding invalid record (mac)" \
3333 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003334 -s "Extra-header:" \
3335 -c "HTTP/1.0 200 OK" \
3336 -s "too many records with bad MAC" \
3337 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003338
3339run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003340 -p "$P_PXY delay_ccs=1" \
3341 "$P_SRV dtls=1 debug_level=1" \
3342 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003343 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003344 -c "record from another epoch" \
3345 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003346 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003347 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003348 -s "Extra-header:" \
3349 -c "HTTP/1.0 200 OK"
3350
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003351# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003352
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003353needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003354run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003355 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003356 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3357 psk=abc123" \
3358 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003359 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3360 0 \
3361 -s "Extra-header:" \
3362 -c "HTTP/1.0 200 OK"
3363
3364needs_more_time 2
3365run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3366 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003367 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3368 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003369 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3370 0 \
3371 -s "Extra-header:" \
3372 -c "HTTP/1.0 200 OK"
3373
3374needs_more_time 2
3375run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3376 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003377 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3378 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003379 0 \
3380 -s "Extra-header:" \
3381 -c "HTTP/1.0 200 OK"
3382
3383needs_more_time 2
3384run_test "DTLS proxy: 3d, FS, client auth" \
3385 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003386 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3387 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003388 0 \
3389 -s "Extra-header:" \
3390 -c "HTTP/1.0 200 OK"
3391
3392needs_more_time 2
3393run_test "DTLS proxy: 3d, FS, ticket" \
3394 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003395 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3396 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003397 0 \
3398 -s "Extra-header:" \
3399 -c "HTTP/1.0 200 OK"
3400
3401needs_more_time 2
3402run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3403 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003404 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3405 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003406 0 \
3407 -s "Extra-header:" \
3408 -c "HTTP/1.0 200 OK"
3409
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003410needs_more_time 2
3411run_test "DTLS proxy: 3d, max handshake, nbio" \
3412 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003413 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3414 auth_mode=required" \
3415 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003416 0 \
3417 -s "Extra-header:" \
3418 -c "HTTP/1.0 200 OK"
3419
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003420needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003421run_test "DTLS proxy: 3d, min handshake, resumption" \
3422 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3423 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3424 psk=abc123 debug_level=3" \
3425 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3426 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3427 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3428 0 \
3429 -s "a session has been resumed" \
3430 -c "a session has been resumed" \
3431 -s "Extra-header:" \
3432 -c "HTTP/1.0 200 OK"
3433
3434needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003435run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3436 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3437 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3438 psk=abc123 debug_level=3 nbio=2" \
3439 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3440 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3441 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3442 0 \
3443 -s "a session has been resumed" \
3444 -c "a session has been resumed" \
3445 -s "Extra-header:" \
3446 -c "HTTP/1.0 200 OK"
3447
3448needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003449run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003450 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003451 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3452 psk=abc123 renegotiation=1 debug_level=2" \
3453 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3454 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003455 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3456 0 \
3457 -c "=> renegotiate" \
3458 -s "=> renegotiate" \
3459 -s "Extra-header:" \
3460 -c "HTTP/1.0 200 OK"
3461
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003462needs_more_time 4
3463run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3464 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003465 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3466 psk=abc123 renegotiation=1 debug_level=2" \
3467 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3468 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003469 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3470 0 \
3471 -c "=> renegotiate" \
3472 -s "=> renegotiate" \
3473 -s "Extra-header:" \
3474 -c "HTTP/1.0 200 OK"
3475
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003476needs_more_time 4
3477run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003478 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003479 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003480 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003481 debug_level=2" \
3482 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003483 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003484 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3485 0 \
3486 -c "=> renegotiate" \
3487 -s "=> renegotiate" \
3488 -s "Extra-header:" \
3489 -c "HTTP/1.0 200 OK"
3490
3491needs_more_time 4
3492run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003493 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003494 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003495 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003496 debug_level=2 nbio=2" \
3497 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003498 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003499 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3500 0 \
3501 -c "=> renegotiate" \
3502 -s "=> renegotiate" \
3503 -s "Extra-header:" \
3504 -c "HTTP/1.0 200 OK"
3505
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003506needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003507not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003508run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003509 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3510 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003511 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003512 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003513 -c "HTTP/1.0 200 OK"
3514
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003515needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003516not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003517run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3518 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3519 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003520 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003521 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003522 -c "HTTP/1.0 200 OK"
3523
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003524needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003525not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003526run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3527 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3528 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003529 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003530 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003531 -c "HTTP/1.0 200 OK"
3532
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003533requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003534needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003535not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003536run_test "DTLS proxy: 3d, gnutls server" \
3537 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3538 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003539 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003540 0 \
3541 -s "Extra-header:" \
3542 -c "Extra-header:"
3543
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003544requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003545needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003546not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003547run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3548 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3549 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003550 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003551 0 \
3552 -s "Extra-header:" \
3553 -c "Extra-header:"
3554
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003555requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003556needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003557not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003558run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3559 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3560 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003561 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003562 0 \
3563 -s "Extra-header:" \
3564 -c "Extra-header:"
3565
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003566# Final report
3567
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003568echo "------------------------------------------------------------------------"
3569
3570if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003571 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003572else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003573 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003574fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003575PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003576echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003577
3578exit $FAILS