blob: 50d457c4c7584bbd9070bbb662afa50cc6101945 [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
Simon Butchera410af52016-05-19 22:12:18 +0100614requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100615run_test "RC4: server disabled, client enabled" \
616 "$P_SRV" \
617 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
618 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100619 -s "SSL - The server has no ciphersuites in common"
620
Simon Butchera410af52016-05-19 22:12:18 +0100621requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100622run_test "RC4: server half, client enabled" \
623 "$P_SRV arc4=1" \
624 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
625 1 \
626 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100627
628run_test "RC4: server enabled, client disabled" \
629 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
630 "$P_CLI" \
631 1 \
632 -s "SSL - The server has no ciphersuites in common"
633
634run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100635 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100636 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
637 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100638 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100639 -S "SSL - The server has no ciphersuites in common"
640
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100641# Tests for Truncated HMAC extension
642
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100643run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200644 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100645 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100646 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100647 -s "dumping 'computed mac' (20 bytes)" \
648 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100649
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100650run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200651 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100652 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
653 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100654 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100655 -s "dumping 'computed mac' (20 bytes)" \
656 -S "dumping 'computed mac' (10 bytes)"
657
658run_test "Truncated HMAC: client enabled, server default" \
659 "$P_SRV debug_level=4" \
660 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
661 trunc_hmac=1" \
662 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100663 -s "dumping 'computed mac' (20 bytes)" \
664 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100665
666run_test "Truncated HMAC: client enabled, server disabled" \
667 "$P_SRV debug_level=4 trunc_hmac=0" \
668 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
669 trunc_hmac=1" \
670 0 \
671 -s "dumping 'computed mac' (20 bytes)" \
672 -S "dumping 'computed mac' (10 bytes)"
673
674run_test "Truncated HMAC: client enabled, server enabled" \
675 "$P_SRV debug_level=4 trunc_hmac=1" \
676 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
677 trunc_hmac=1" \
678 0 \
679 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100680 -s "dumping 'computed mac' (10 bytes)"
681
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100682# Tests for Encrypt-then-MAC extension
683
684run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100685 "$P_SRV debug_level=3 \
686 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100687 "$P_CLI debug_level=3" \
688 0 \
689 -c "client hello, adding encrypt_then_mac extension" \
690 -s "found encrypt then mac extension" \
691 -s "server hello, adding encrypt then mac extension" \
692 -c "found encrypt_then_mac extension" \
693 -c "using encrypt then mac" \
694 -s "using encrypt then mac"
695
696run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100697 "$P_SRV debug_level=3 etm=0 \
698 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100699 "$P_CLI debug_level=3 etm=1" \
700 0 \
701 -c "client hello, adding encrypt_then_mac extension" \
702 -s "found encrypt then mac extension" \
703 -S "server hello, adding encrypt then mac extension" \
704 -C "found encrypt_then_mac extension" \
705 -C "using encrypt then mac" \
706 -S "using encrypt then mac"
707
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100708run_test "Encrypt then MAC: client enabled, aead cipher" \
709 "$P_SRV debug_level=3 etm=1 \
710 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
711 "$P_CLI debug_level=3 etm=1" \
712 0 \
713 -c "client hello, adding encrypt_then_mac extension" \
714 -s "found encrypt then mac extension" \
715 -S "server hello, adding encrypt then mac extension" \
716 -C "found encrypt_then_mac extension" \
717 -C "using encrypt then mac" \
718 -S "using encrypt then mac"
719
720run_test "Encrypt then MAC: client enabled, stream cipher" \
721 "$P_SRV debug_level=3 etm=1 \
722 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100723 "$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 +0100724 0 \
725 -c "client hello, adding encrypt_then_mac extension" \
726 -s "found encrypt then mac extension" \
727 -S "server hello, adding encrypt then mac extension" \
728 -C "found encrypt_then_mac extension" \
729 -C "using encrypt then mac" \
730 -S "using encrypt then mac"
731
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100732run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100733 "$P_SRV debug_level=3 etm=1 \
734 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100735 "$P_CLI debug_level=3 etm=0" \
736 0 \
737 -C "client hello, adding encrypt_then_mac extension" \
738 -S "found encrypt then mac extension" \
739 -S "server hello, adding encrypt then mac extension" \
740 -C "found encrypt_then_mac extension" \
741 -C "using encrypt then mac" \
742 -S "using encrypt then mac"
743
Janos Follathe2681a42016-03-07 15:57:05 +0000744requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100745run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100746 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100747 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100748 "$P_CLI debug_level=3 force_version=ssl3" \
749 0 \
750 -C "client hello, adding encrypt_then_mac extension" \
751 -S "found encrypt then mac extension" \
752 -S "server hello, adding encrypt then mac extension" \
753 -C "found encrypt_then_mac extension" \
754 -C "using encrypt then mac" \
755 -S "using encrypt then mac"
756
Janos Follathe2681a42016-03-07 15:57:05 +0000757requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100758run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100759 "$P_SRV debug_level=3 force_version=ssl3 \
760 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100761 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100762 0 \
763 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100764 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100765 -S "server hello, adding encrypt then mac extension" \
766 -C "found encrypt_then_mac extension" \
767 -C "using encrypt then mac" \
768 -S "using encrypt then mac"
769
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200770# Tests for Extended Master Secret extension
771
772run_test "Extended Master Secret: default" \
773 "$P_SRV debug_level=3" \
774 "$P_CLI debug_level=3" \
775 0 \
776 -c "client hello, adding extended_master_secret extension" \
777 -s "found extended master secret extension" \
778 -s "server hello, adding extended master secret extension" \
779 -c "found extended_master_secret extension" \
780 -c "using extended master secret" \
781 -s "using extended master secret"
782
783run_test "Extended Master Secret: client enabled, server disabled" \
784 "$P_SRV debug_level=3 extended_ms=0" \
785 "$P_CLI debug_level=3 extended_ms=1" \
786 0 \
787 -c "client hello, adding extended_master_secret extension" \
788 -s "found extended master secret extension" \
789 -S "server hello, adding extended master secret extension" \
790 -C "found extended_master_secret extension" \
791 -C "using extended master secret" \
792 -S "using extended master secret"
793
794run_test "Extended Master Secret: client disabled, server enabled" \
795 "$P_SRV debug_level=3 extended_ms=1" \
796 "$P_CLI debug_level=3 extended_ms=0" \
797 0 \
798 -C "client hello, adding extended_master_secret extension" \
799 -S "found extended master secret extension" \
800 -S "server hello, adding extended master secret extension" \
801 -C "found extended_master_secret extension" \
802 -C "using extended master secret" \
803 -S "using extended master secret"
804
Janos Follathe2681a42016-03-07 15:57:05 +0000805requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200806run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100807 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200808 "$P_CLI debug_level=3 force_version=ssl3" \
809 0 \
810 -C "client hello, adding extended_master_secret extension" \
811 -S "found extended master secret extension" \
812 -S "server hello, adding extended master secret extension" \
813 -C "found extended_master_secret extension" \
814 -C "using extended master secret" \
815 -S "using extended master secret"
816
Janos Follathe2681a42016-03-07 15:57:05 +0000817requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200818run_test "Extended Master Secret: client enabled, server SSLv3" \
819 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100820 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200821 0 \
822 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100823 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200824 -S "server hello, adding extended master secret extension" \
825 -C "found extended_master_secret extension" \
826 -C "using extended master secret" \
827 -S "using extended master secret"
828
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200829# Tests for FALLBACK_SCSV
830
831run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200832 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200833 "$P_CLI debug_level=3 force_version=tls1_1" \
834 0 \
835 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200836 -S "received FALLBACK_SCSV" \
837 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200838 -C "is a fatal alert message (msg 86)"
839
840run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200841 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200842 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
843 0 \
844 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200845 -S "received FALLBACK_SCSV" \
846 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200847 -C "is a fatal alert message (msg 86)"
848
849run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200850 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200851 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200852 1 \
853 -c "adding FALLBACK_SCSV" \
854 -s "received FALLBACK_SCSV" \
855 -s "inapropriate fallback" \
856 -c "is a fatal alert message (msg 86)"
857
858run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200859 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200860 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200861 0 \
862 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200863 -s "received FALLBACK_SCSV" \
864 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200865 -C "is a fatal alert message (msg 86)"
866
867requires_openssl_with_fallback_scsv
868run_test "Fallback SCSV: default, openssl server" \
869 "$O_SRV" \
870 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
871 0 \
872 -C "adding FALLBACK_SCSV" \
873 -C "is a fatal alert message (msg 86)"
874
875requires_openssl_with_fallback_scsv
876run_test "Fallback SCSV: enabled, openssl server" \
877 "$O_SRV" \
878 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
879 1 \
880 -c "adding FALLBACK_SCSV" \
881 -c "is a fatal alert message (msg 86)"
882
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200883requires_openssl_with_fallback_scsv
884run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200885 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200886 "$O_CLI -tls1_1" \
887 0 \
888 -S "received FALLBACK_SCSV" \
889 -S "inapropriate fallback"
890
891requires_openssl_with_fallback_scsv
892run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200893 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200894 "$O_CLI -tls1_1 -fallback_scsv" \
895 1 \
896 -s "received FALLBACK_SCSV" \
897 -s "inapropriate fallback"
898
899requires_openssl_with_fallback_scsv
900run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200901 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200902 "$O_CLI -fallback_scsv" \
903 0 \
904 -s "received FALLBACK_SCSV" \
905 -S "inapropriate fallback"
906
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100907# Tests for CBC 1/n-1 record splitting
908
909run_test "CBC Record splitting: TLS 1.2, no splitting" \
910 "$P_SRV" \
911 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
912 request_size=123 force_version=tls1_2" \
913 0 \
914 -s "Read from client: 123 bytes read" \
915 -S "Read from client: 1 bytes read" \
916 -S "122 bytes read"
917
918run_test "CBC Record splitting: TLS 1.1, no splitting" \
919 "$P_SRV" \
920 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
921 request_size=123 force_version=tls1_1" \
922 0 \
923 -s "Read from client: 123 bytes read" \
924 -S "Read from client: 1 bytes read" \
925 -S "122 bytes read"
926
927run_test "CBC Record splitting: TLS 1.0, splitting" \
928 "$P_SRV" \
929 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
930 request_size=123 force_version=tls1" \
931 0 \
932 -S "Read from client: 123 bytes read" \
933 -s "Read from client: 1 bytes read" \
934 -s "122 bytes read"
935
Janos Follathe2681a42016-03-07 15:57:05 +0000936requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100937run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100938 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100939 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
940 request_size=123 force_version=ssl3" \
941 0 \
942 -S "Read from client: 123 bytes read" \
943 -s "Read from client: 1 bytes read" \
944 -s "122 bytes read"
945
946run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100947 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100948 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
949 request_size=123 force_version=tls1" \
950 0 \
951 -s "Read from client: 123 bytes read" \
952 -S "Read from client: 1 bytes read" \
953 -S "122 bytes read"
954
955run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
956 "$P_SRV" \
957 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
958 request_size=123 force_version=tls1 recsplit=0" \
959 0 \
960 -s "Read from client: 123 bytes read" \
961 -S "Read from client: 1 bytes read" \
962 -S "122 bytes read"
963
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100964run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
965 "$P_SRV nbio=2" \
966 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
967 request_size=123 force_version=tls1" \
968 0 \
969 -S "Read from client: 123 bytes read" \
970 -s "Read from client: 1 bytes read" \
971 -s "122 bytes read"
972
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100973# Tests for Session Tickets
974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200975run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200976 "$P_SRV debug_level=3 tickets=1" \
977 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100978 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100979 -c "client hello, adding session ticket extension" \
980 -s "found session ticket extension" \
981 -s "server hello, adding session ticket extension" \
982 -c "found session_ticket extension" \
983 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100984 -S "session successfully restored from cache" \
985 -s "session successfully restored from ticket" \
986 -s "a session has been resumed" \
987 -c "a session has been resumed"
988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200989run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200990 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
991 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100992 0 \
993 -c "client hello, adding session ticket extension" \
994 -s "found session ticket extension" \
995 -s "server hello, adding session ticket extension" \
996 -c "found session_ticket extension" \
997 -c "parse new session ticket" \
998 -S "session successfully restored from cache" \
999 -s "session successfully restored from ticket" \
1000 -s "a session has been resumed" \
1001 -c "a session has been resumed"
1002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001003run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001004 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1005 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001006 0 \
1007 -c "client hello, adding session ticket extension" \
1008 -s "found session ticket extension" \
1009 -s "server hello, adding session ticket extension" \
1010 -c "found session_ticket extension" \
1011 -c "parse new session ticket" \
1012 -S "session successfully restored from cache" \
1013 -S "session successfully restored from ticket" \
1014 -S "a session has been resumed" \
1015 -C "a session has been resumed"
1016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001017run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001018 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001019 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001020 0 \
1021 -c "client hello, adding session ticket extension" \
1022 -c "found session_ticket extension" \
1023 -c "parse new session ticket" \
1024 -c "a session has been resumed"
1025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001026run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001027 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001028 "( $O_CLI -sess_out $SESSION; \
1029 $O_CLI -sess_in $SESSION; \
1030 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001031 0 \
1032 -s "found session ticket extension" \
1033 -s "server hello, adding session ticket extension" \
1034 -S "session successfully restored from cache" \
1035 -s "session successfully restored from ticket" \
1036 -s "a session has been resumed"
1037
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001038# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001040run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001041 "$P_SRV debug_level=3 tickets=0" \
1042 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001043 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001044 -c "client hello, adding session ticket extension" \
1045 -s "found session ticket extension" \
1046 -S "server hello, adding session ticket extension" \
1047 -C "found session_ticket extension" \
1048 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001049 -s "session successfully restored from cache" \
1050 -S "session successfully restored from ticket" \
1051 -s "a session has been resumed" \
1052 -c "a session has been resumed"
1053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001054run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001055 "$P_SRV debug_level=3 tickets=1" \
1056 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001057 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001058 -C "client hello, adding session ticket extension" \
1059 -S "found session ticket extension" \
1060 -S "server hello, adding session ticket extension" \
1061 -C "found session_ticket extension" \
1062 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001063 -s "session successfully restored from cache" \
1064 -S "session successfully restored from ticket" \
1065 -s "a session has been resumed" \
1066 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001068run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001069 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1070 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001071 0 \
1072 -S "session successfully restored from cache" \
1073 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001074 -S "a session has been resumed" \
1075 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001077run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001078 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1079 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001080 0 \
1081 -s "session successfully restored from cache" \
1082 -S "session successfully restored from ticket" \
1083 -s "a session has been resumed" \
1084 -c "a session has been resumed"
1085
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001086run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001087 "$P_SRV debug_level=3 tickets=0" \
1088 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001089 0 \
1090 -s "session successfully restored from cache" \
1091 -S "session successfully restored from ticket" \
1092 -s "a session has been resumed" \
1093 -c "a session has been resumed"
1094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001095run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001096 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1097 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001098 0 \
1099 -S "session successfully restored from cache" \
1100 -S "session successfully restored from ticket" \
1101 -S "a session has been resumed" \
1102 -C "a session has been resumed"
1103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001104run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001105 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1106 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001107 0 \
1108 -s "session successfully restored from cache" \
1109 -S "session successfully restored from ticket" \
1110 -s "a session has been resumed" \
1111 -c "a session has been resumed"
1112
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001113run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001114 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001115 "( $O_CLI -sess_out $SESSION; \
1116 $O_CLI -sess_in $SESSION; \
1117 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001118 0 \
1119 -s "found session ticket extension" \
1120 -S "server hello, adding session ticket extension" \
1121 -s "session successfully restored from cache" \
1122 -S "session successfully restored from ticket" \
1123 -s "a session has been resumed"
1124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001125run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001126 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001127 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001128 0 \
1129 -C "found session_ticket extension" \
1130 -C "parse new session ticket" \
1131 -c "a session has been resumed"
1132
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001133# Tests for Max Fragment Length extension
1134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001135run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001136 "$P_SRV debug_level=3" \
1137 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001138 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001139 -c "Maximum fragment length is 16384" \
1140 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001141 -C "client hello, adding max_fragment_length extension" \
1142 -S "found max fragment length extension" \
1143 -S "server hello, max_fragment_length extension" \
1144 -C "found max_fragment_length extension"
1145
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001146run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001147 "$P_SRV debug_level=3" \
1148 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001149 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001150 -c "Maximum fragment length is 4096" \
1151 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001152 -c "client hello, adding max_fragment_length extension" \
1153 -s "found max fragment length extension" \
1154 -s "server hello, max_fragment_length extension" \
1155 -c "found max_fragment_length extension"
1156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001157run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001158 "$P_SRV debug_level=3 max_frag_len=4096" \
1159 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001160 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001161 -c "Maximum fragment length is 16384" \
1162 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001163 -C "client hello, adding max_fragment_length extension" \
1164 -S "found max fragment length extension" \
1165 -S "server hello, max_fragment_length extension" \
1166 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001168requires_gnutls
1169run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001170 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001171 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001172 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001173 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001174 -c "client hello, adding max_fragment_length extension" \
1175 -c "found max_fragment_length extension"
1176
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001177run_test "Max fragment length: client, message just fits" \
1178 "$P_SRV debug_level=3" \
1179 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1180 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001181 -c "Maximum fragment length is 2048" \
1182 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001183 -c "client hello, adding max_fragment_length extension" \
1184 -s "found max fragment length extension" \
1185 -s "server hello, max_fragment_length extension" \
1186 -c "found max_fragment_length extension" \
1187 -c "2048 bytes written in 1 fragments" \
1188 -s "2048 bytes read"
1189
1190run_test "Max fragment length: client, larger message" \
1191 "$P_SRV debug_level=3" \
1192 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1193 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001194 -c "Maximum fragment length is 2048" \
1195 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001196 -c "client hello, adding max_fragment_length extension" \
1197 -s "found max fragment length extension" \
1198 -s "server hello, max_fragment_length extension" \
1199 -c "found max_fragment_length extension" \
1200 -c "2345 bytes written in 2 fragments" \
1201 -s "2048 bytes read" \
1202 -s "297 bytes read"
1203
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001204run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001205 "$P_SRV debug_level=3 dtls=1" \
1206 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1207 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001208 -c "Maximum fragment length is 2048" \
1209 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001210 -c "client hello, adding max_fragment_length extension" \
1211 -s "found max fragment length extension" \
1212 -s "server hello, max_fragment_length extension" \
1213 -c "found max_fragment_length extension" \
1214 -c "fragment larger than.*maximum"
1215
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001216# Tests for renegotiation
1217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001218run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001219 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001220 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001221 0 \
1222 -C "client hello, adding renegotiation extension" \
1223 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1224 -S "found renegotiation extension" \
1225 -s "server hello, secure renegotiation extension" \
1226 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001227 -C "=> renegotiate" \
1228 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001229 -S "write hello request"
1230
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001231run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001232 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001233 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001234 0 \
1235 -c "client hello, adding renegotiation extension" \
1236 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1237 -s "found renegotiation extension" \
1238 -s "server hello, secure renegotiation extension" \
1239 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001240 -c "=> renegotiate" \
1241 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001242 -S "write hello request"
1243
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001244run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001245 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001246 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001247 0 \
1248 -c "client hello, adding renegotiation extension" \
1249 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1250 -s "found renegotiation extension" \
1251 -s "server hello, secure renegotiation extension" \
1252 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001253 -c "=> renegotiate" \
1254 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001255 -s "write hello request"
1256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001257run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001258 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001259 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001260 0 \
1261 -c "client hello, adding renegotiation extension" \
1262 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1263 -s "found renegotiation extension" \
1264 -s "server hello, secure renegotiation extension" \
1265 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001266 -c "=> renegotiate" \
1267 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001268 -s "write hello request"
1269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001270run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001271 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001272 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001273 1 \
1274 -c "client hello, adding renegotiation extension" \
1275 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1276 -S "found renegotiation extension" \
1277 -s "server hello, secure renegotiation extension" \
1278 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001279 -c "=> renegotiate" \
1280 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001281 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001282 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001283 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001285run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001286 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001287 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001288 0 \
1289 -C "client hello, adding renegotiation extension" \
1290 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1291 -S "found renegotiation extension" \
1292 -s "server hello, secure renegotiation extension" \
1293 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001294 -C "=> renegotiate" \
1295 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001296 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001297 -S "SSL - An unexpected message was received from our peer" \
1298 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001300run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001301 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001302 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001303 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001304 0 \
1305 -C "client hello, adding renegotiation extension" \
1306 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1307 -S "found renegotiation extension" \
1308 -s "server hello, secure renegotiation extension" \
1309 -c "found renegotiation extension" \
1310 -C "=> renegotiate" \
1311 -S "=> renegotiate" \
1312 -s "write hello request" \
1313 -S "SSL - An unexpected message was received from our peer" \
1314 -S "failed"
1315
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001316# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001317run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001318 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001319 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001320 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001321 0 \
1322 -C "client hello, adding renegotiation extension" \
1323 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1324 -S "found renegotiation extension" \
1325 -s "server hello, secure renegotiation extension" \
1326 -c "found renegotiation extension" \
1327 -C "=> renegotiate" \
1328 -S "=> renegotiate" \
1329 -s "write hello request" \
1330 -S "SSL - An unexpected message was received from our peer" \
1331 -S "failed"
1332
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001333run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001334 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001335 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001336 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001337 0 \
1338 -C "client hello, adding renegotiation extension" \
1339 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1340 -S "found renegotiation extension" \
1341 -s "server hello, secure renegotiation extension" \
1342 -c "found renegotiation extension" \
1343 -C "=> renegotiate" \
1344 -S "=> renegotiate" \
1345 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001346 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001348run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001349 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001350 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001351 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001352 0 \
1353 -c "client hello, adding renegotiation extension" \
1354 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1355 -s "found renegotiation extension" \
1356 -s "server hello, secure renegotiation extension" \
1357 -c "found renegotiation extension" \
1358 -c "=> renegotiate" \
1359 -s "=> renegotiate" \
1360 -s "write hello request" \
1361 -S "SSL - An unexpected message was received from our peer" \
1362 -S "failed"
1363
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001364run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001365 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001366 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1367 0 \
1368 -C "client hello, adding renegotiation extension" \
1369 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1370 -S "found renegotiation extension" \
1371 -s "server hello, secure renegotiation extension" \
1372 -c "found renegotiation extension" \
1373 -S "record counter limit reached: renegotiate" \
1374 -C "=> renegotiate" \
1375 -S "=> renegotiate" \
1376 -S "write hello request" \
1377 -S "SSL - An unexpected message was received from our peer" \
1378 -S "failed"
1379
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001380# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001381run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001382 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001383 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001384 0 \
1385 -c "client hello, adding renegotiation extension" \
1386 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1387 -s "found renegotiation extension" \
1388 -s "server hello, secure renegotiation extension" \
1389 -c "found renegotiation extension" \
1390 -s "record counter limit reached: renegotiate" \
1391 -c "=> renegotiate" \
1392 -s "=> renegotiate" \
1393 -s "write hello request" \
1394 -S "SSL - An unexpected message was received from our peer" \
1395 -S "failed"
1396
1397run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001398 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001399 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001400 0 \
1401 -c "client hello, adding renegotiation extension" \
1402 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1403 -s "found renegotiation extension" \
1404 -s "server hello, secure renegotiation extension" \
1405 -c "found renegotiation extension" \
1406 -s "record counter limit reached: renegotiate" \
1407 -c "=> renegotiate" \
1408 -s "=> renegotiate" \
1409 -s "write hello request" \
1410 -S "SSL - An unexpected message was received from our peer" \
1411 -S "failed"
1412
1413run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001414 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001415 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1416 0 \
1417 -C "client hello, adding renegotiation extension" \
1418 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1419 -S "found renegotiation extension" \
1420 -s "server hello, secure renegotiation extension" \
1421 -c "found renegotiation extension" \
1422 -S "record counter limit reached: renegotiate" \
1423 -C "=> renegotiate" \
1424 -S "=> renegotiate" \
1425 -S "write hello request" \
1426 -S "SSL - An unexpected message was received from our peer" \
1427 -S "failed"
1428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001429run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001430 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001431 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001432 0 \
1433 -c "client hello, adding renegotiation extension" \
1434 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1435 -s "found renegotiation extension" \
1436 -s "server hello, secure renegotiation extension" \
1437 -c "found renegotiation extension" \
1438 -c "=> renegotiate" \
1439 -s "=> renegotiate" \
1440 -S "write hello request"
1441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001442run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001443 "$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 +02001444 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001445 0 \
1446 -c "client hello, adding renegotiation extension" \
1447 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1448 -s "found renegotiation extension" \
1449 -s "server hello, secure renegotiation extension" \
1450 -c "found renegotiation extension" \
1451 -c "=> renegotiate" \
1452 -s "=> renegotiate" \
1453 -s "write hello request"
1454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001455run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001456 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001457 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001458 0 \
1459 -c "client hello, adding renegotiation extension" \
1460 -c "found renegotiation extension" \
1461 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001462 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001463 -C "error" \
1464 -c "HTTP/1.0 200 [Oo][Kk]"
1465
Paul Bakker539d9722015-02-08 16:18:35 +01001466requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001467run_test "Renegotiation: gnutls server strict, client-initiated" \
1468 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001469 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001470 0 \
1471 -c "client hello, adding renegotiation extension" \
1472 -c "found renegotiation extension" \
1473 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001474 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001475 -C "error" \
1476 -c "HTTP/1.0 200 [Oo][Kk]"
1477
Paul Bakker539d9722015-02-08 16:18:35 +01001478requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001479run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1480 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1481 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1482 1 \
1483 -c "client hello, adding renegotiation extension" \
1484 -C "found renegotiation extension" \
1485 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001486 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001487 -c "error" \
1488 -C "HTTP/1.0 200 [Oo][Kk]"
1489
Paul Bakker539d9722015-02-08 16:18:35 +01001490requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001491run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1492 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1493 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1494 allow_legacy=0" \
1495 1 \
1496 -c "client hello, adding renegotiation extension" \
1497 -C "found renegotiation extension" \
1498 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001499 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001500 -c "error" \
1501 -C "HTTP/1.0 200 [Oo][Kk]"
1502
Paul Bakker539d9722015-02-08 16:18:35 +01001503requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001504run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1505 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1506 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1507 allow_legacy=1" \
1508 0 \
1509 -c "client hello, adding renegotiation extension" \
1510 -C "found renegotiation extension" \
1511 -c "=> renegotiate" \
1512 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001513 -C "error" \
1514 -c "HTTP/1.0 200 [Oo][Kk]"
1515
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001516run_test "Renegotiation: DTLS, client-initiated" \
1517 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1518 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1519 0 \
1520 -c "client hello, adding renegotiation extension" \
1521 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1522 -s "found renegotiation extension" \
1523 -s "server hello, secure renegotiation extension" \
1524 -c "found renegotiation extension" \
1525 -c "=> renegotiate" \
1526 -s "=> renegotiate" \
1527 -S "write hello request"
1528
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001529run_test "Renegotiation: DTLS, server-initiated" \
1530 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001531 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1532 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001533 0 \
1534 -c "client hello, adding renegotiation extension" \
1535 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1536 -s "found renegotiation extension" \
1537 -s "server hello, secure renegotiation extension" \
1538 -c "found renegotiation extension" \
1539 -c "=> renegotiate" \
1540 -s "=> renegotiate" \
1541 -s "write hello request"
1542
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001543requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001544run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1545 "$G_SRV -u --mtu 4096" \
1546 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1547 0 \
1548 -c "client hello, adding renegotiation extension" \
1549 -c "found renegotiation extension" \
1550 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001551 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001552 -C "error" \
1553 -s "Extra-header:"
1554
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001555# Test for the "secure renegotation" extension only (no actual renegotiation)
1556
Paul Bakker539d9722015-02-08 16:18:35 +01001557requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001558run_test "Renego ext: gnutls server strict, client default" \
1559 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1560 "$P_CLI debug_level=3" \
1561 0 \
1562 -c "found renegotiation extension" \
1563 -C "error" \
1564 -c "HTTP/1.0 200 [Oo][Kk]"
1565
Paul Bakker539d9722015-02-08 16:18:35 +01001566requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001567run_test "Renego ext: gnutls server unsafe, client default" \
1568 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1569 "$P_CLI debug_level=3" \
1570 0 \
1571 -C "found renegotiation extension" \
1572 -C "error" \
1573 -c "HTTP/1.0 200 [Oo][Kk]"
1574
Paul Bakker539d9722015-02-08 16:18:35 +01001575requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001576run_test "Renego ext: gnutls server unsafe, client break legacy" \
1577 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1578 "$P_CLI debug_level=3 allow_legacy=-1" \
1579 1 \
1580 -C "found renegotiation extension" \
1581 -c "error" \
1582 -C "HTTP/1.0 200 [Oo][Kk]"
1583
Paul Bakker539d9722015-02-08 16:18:35 +01001584requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001585run_test "Renego ext: gnutls client strict, server default" \
1586 "$P_SRV debug_level=3" \
1587 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1588 0 \
1589 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1590 -s "server hello, secure renegotiation extension"
1591
Paul Bakker539d9722015-02-08 16:18:35 +01001592requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001593run_test "Renego ext: gnutls client unsafe, server default" \
1594 "$P_SRV debug_level=3" \
1595 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1596 0 \
1597 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1598 -S "server hello, secure renegotiation extension"
1599
Paul Bakker539d9722015-02-08 16:18:35 +01001600requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001601run_test "Renego ext: gnutls client unsafe, server break legacy" \
1602 "$P_SRV debug_level=3 allow_legacy=-1" \
1603 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1604 1 \
1605 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1606 -S "server hello, secure renegotiation extension"
1607
Janos Follath0b242342016-02-17 10:11:21 +00001608# Tests for silently dropping trailing extra bytes in .der certificates
1609
1610requires_gnutls
1611run_test "DER format: no trailing bytes" \
1612 "$P_SRV crt_file=data_files/server5-der0.crt \
1613 key_file=data_files/server5.key" \
1614 "$G_CLI " \
1615 0 \
1616 -c "Handshake was completed" \
1617
1618requires_gnutls
1619run_test "DER format: with a trailing zero byte" \
1620 "$P_SRV crt_file=data_files/server5-der1a.crt \
1621 key_file=data_files/server5.key" \
1622 "$G_CLI " \
1623 0 \
1624 -c "Handshake was completed" \
1625
1626requires_gnutls
1627run_test "DER format: with a trailing random byte" \
1628 "$P_SRV crt_file=data_files/server5-der1b.crt \
1629 key_file=data_files/server5.key" \
1630 "$G_CLI " \
1631 0 \
1632 -c "Handshake was completed" \
1633
1634requires_gnutls
1635run_test "DER format: with 2 trailing random bytes" \
1636 "$P_SRV crt_file=data_files/server5-der2.crt \
1637 key_file=data_files/server5.key" \
1638 "$G_CLI " \
1639 0 \
1640 -c "Handshake was completed" \
1641
1642requires_gnutls
1643run_test "DER format: with 4 trailing random bytes" \
1644 "$P_SRV crt_file=data_files/server5-der4.crt \
1645 key_file=data_files/server5.key" \
1646 "$G_CLI " \
1647 0 \
1648 -c "Handshake was completed" \
1649
1650requires_gnutls
1651run_test "DER format: with 8 trailing random bytes" \
1652 "$P_SRV crt_file=data_files/server5-der8.crt \
1653 key_file=data_files/server5.key" \
1654 "$G_CLI " \
1655 0 \
1656 -c "Handshake was completed" \
1657
1658requires_gnutls
1659run_test "DER format: with 9 trailing random bytes" \
1660 "$P_SRV crt_file=data_files/server5-der9.crt \
1661 key_file=data_files/server5.key" \
1662 "$G_CLI " \
1663 0 \
1664 -c "Handshake was completed" \
1665
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001666# Tests for auth_mode
1667
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001668run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001669 "$P_SRV crt_file=data_files/server5-badsign.crt \
1670 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001671 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001672 1 \
1673 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001674 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001675 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001676 -c "X509 - Certificate verification failed"
1677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001678run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001679 "$P_SRV crt_file=data_files/server5-badsign.crt \
1680 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001681 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001682 0 \
1683 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001684 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001685 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001686 -C "X509 - Certificate verification failed"
1687
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001688run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001689 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001690 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001691 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001692 0 \
1693 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001694 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001695 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001696 -C "X509 - Certificate verification failed"
1697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001698run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001699 "$P_SRV debug_level=3 auth_mode=required" \
1700 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001701 key_file=data_files/server5.key" \
1702 1 \
1703 -S "skip write certificate request" \
1704 -C "skip parse certificate request" \
1705 -c "got a certificate request" \
1706 -C "skip write certificate" \
1707 -C "skip write certificate verify" \
1708 -S "skip parse certificate verify" \
1709 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001710 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001711 -s "! mbedtls_ssl_handshake returned" \
1712 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001713 -s "X509 - Certificate verification failed"
1714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001715run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001716 "$P_SRV debug_level=3 auth_mode=optional" \
1717 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001718 key_file=data_files/server5.key" \
1719 0 \
1720 -S "skip write certificate request" \
1721 -C "skip parse certificate request" \
1722 -c "got a certificate request" \
1723 -C "skip write certificate" \
1724 -C "skip write certificate verify" \
1725 -S "skip parse certificate verify" \
1726 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001727 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001728 -S "! mbedtls_ssl_handshake returned" \
1729 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001730 -S "X509 - Certificate verification failed"
1731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001732run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001733 "$P_SRV debug_level=3 auth_mode=none" \
1734 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001735 key_file=data_files/server5.key" \
1736 0 \
1737 -s "skip write certificate request" \
1738 -C "skip parse certificate request" \
1739 -c "got no certificate request" \
1740 -c "skip write certificate" \
1741 -c "skip write certificate verify" \
1742 -s "skip parse certificate verify" \
1743 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001744 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001745 -S "! mbedtls_ssl_handshake returned" \
1746 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001747 -S "X509 - Certificate verification failed"
1748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001749run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001750 "$P_SRV debug_level=3 auth_mode=optional" \
1751 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001752 0 \
1753 -S "skip write certificate request" \
1754 -C "skip parse certificate request" \
1755 -c "got a certificate request" \
1756 -C "skip write certificate$" \
1757 -C "got no certificate to send" \
1758 -S "SSLv3 client has no certificate" \
1759 -c "skip write certificate verify" \
1760 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001761 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001762 -S "! mbedtls_ssl_handshake returned" \
1763 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001764 -S "X509 - Certificate verification failed"
1765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001766run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001767 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001768 "$O_CLI" \
1769 0 \
1770 -S "skip write certificate request" \
1771 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001772 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001773 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001774 -S "X509 - Certificate verification failed"
1775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001776run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001777 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001778 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001779 0 \
1780 -C "skip parse certificate request" \
1781 -c "got a certificate request" \
1782 -C "skip write certificate$" \
1783 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001784 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001785
Janos Follathe2681a42016-03-07 15:57:05 +00001786requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001787run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001788 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001789 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001790 0 \
1791 -S "skip write certificate request" \
1792 -C "skip parse certificate request" \
1793 -c "got a certificate request" \
1794 -C "skip write certificate$" \
1795 -c "skip write certificate verify" \
1796 -c "got no certificate to send" \
1797 -s "SSLv3 client has no certificate" \
1798 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001799 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001800 -S "! mbedtls_ssl_handshake returned" \
1801 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001802 -S "X509 - Certificate verification failed"
1803
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001804# Tests for certificate selection based on SHA verson
1805
1806run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1807 "$P_SRV crt_file=data_files/server5.crt \
1808 key_file=data_files/server5.key \
1809 crt_file2=data_files/server5-sha1.crt \
1810 key_file2=data_files/server5.key" \
1811 "$P_CLI force_version=tls1_2" \
1812 0 \
1813 -c "signed using.*ECDSA with SHA256" \
1814 -C "signed using.*ECDSA with SHA1"
1815
1816run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1817 "$P_SRV crt_file=data_files/server5.crt \
1818 key_file=data_files/server5.key \
1819 crt_file2=data_files/server5-sha1.crt \
1820 key_file2=data_files/server5.key" \
1821 "$P_CLI force_version=tls1_1" \
1822 0 \
1823 -C "signed using.*ECDSA with SHA256" \
1824 -c "signed using.*ECDSA with SHA1"
1825
1826run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1827 "$P_SRV crt_file=data_files/server5.crt \
1828 key_file=data_files/server5.key \
1829 crt_file2=data_files/server5-sha1.crt \
1830 key_file2=data_files/server5.key" \
1831 "$P_CLI force_version=tls1" \
1832 0 \
1833 -C "signed using.*ECDSA with SHA256" \
1834 -c "signed using.*ECDSA with SHA1"
1835
1836run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1837 "$P_SRV crt_file=data_files/server5.crt \
1838 key_file=data_files/server5.key \
1839 crt_file2=data_files/server6.crt \
1840 key_file2=data_files/server6.key" \
1841 "$P_CLI force_version=tls1_1" \
1842 0 \
1843 -c "serial number.*09" \
1844 -c "signed using.*ECDSA with SHA256" \
1845 -C "signed using.*ECDSA with SHA1"
1846
1847run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1848 "$P_SRV crt_file=data_files/server6.crt \
1849 key_file=data_files/server6.key \
1850 crt_file2=data_files/server5.crt \
1851 key_file2=data_files/server5.key" \
1852 "$P_CLI force_version=tls1_1" \
1853 0 \
1854 -c "serial number.*0A" \
1855 -c "signed using.*ECDSA with SHA256" \
1856 -C "signed using.*ECDSA with SHA1"
1857
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001858# tests for SNI
1859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001860run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001861 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001862 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001863 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001864 0 \
1865 -S "parse ServerName extension" \
1866 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1867 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001868
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001869run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001870 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001871 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001872 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 +02001873 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001874 0 \
1875 -s "parse ServerName extension" \
1876 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1877 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001879run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001880 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001881 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001882 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 +02001883 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001884 0 \
1885 -s "parse ServerName extension" \
1886 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1887 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001889run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001890 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001891 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001892 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 +02001893 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001894 1 \
1895 -s "parse ServerName extension" \
1896 -s "ssl_sni_wrapper() returned" \
1897 -s "mbedtls_ssl_handshake returned" \
1898 -c "mbedtls_ssl_handshake returned" \
1899 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001900
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001901run_test "SNI: client auth no override: optional" \
1902 "$P_SRV debug_level=3 auth_mode=optional \
1903 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1904 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1905 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001906 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001907 -S "skip write certificate request" \
1908 -C "skip parse certificate request" \
1909 -c "got a certificate request" \
1910 -C "skip write certificate" \
1911 -C "skip write certificate verify" \
1912 -S "skip parse certificate verify"
1913
1914run_test "SNI: client auth override: none -> optional" \
1915 "$P_SRV debug_level=3 auth_mode=none \
1916 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1917 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1918 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001919 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001920 -S "skip write certificate request" \
1921 -C "skip parse certificate request" \
1922 -c "got a certificate request" \
1923 -C "skip write certificate" \
1924 -C "skip write certificate verify" \
1925 -S "skip parse certificate verify"
1926
1927run_test "SNI: client auth override: optional -> none" \
1928 "$P_SRV debug_level=3 auth_mode=optional \
1929 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1930 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1931 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001932 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001933 -s "skip write certificate request" \
1934 -C "skip parse certificate request" \
1935 -c "got no certificate request" \
1936 -c "skip write certificate" \
1937 -c "skip write certificate verify" \
1938 -s "skip parse certificate verify"
1939
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001940run_test "SNI: CA no override" \
1941 "$P_SRV debug_level=3 auth_mode=optional \
1942 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1943 ca_file=data_files/test-ca.crt \
1944 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1945 "$P_CLI debug_level=3 server_name=localhost \
1946 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1947 1 \
1948 -S "skip write certificate request" \
1949 -C "skip parse certificate request" \
1950 -c "got a certificate request" \
1951 -C "skip write certificate" \
1952 -C "skip write certificate verify" \
1953 -S "skip parse certificate verify" \
1954 -s "x509_verify_cert() returned" \
1955 -s "! The certificate is not correctly signed by the trusted CA" \
1956 -S "The certificate has been revoked (is on a CRL)"
1957
1958run_test "SNI: CA override" \
1959 "$P_SRV debug_level=3 auth_mode=optional \
1960 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1961 ca_file=data_files/test-ca.crt \
1962 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1963 "$P_CLI debug_level=3 server_name=localhost \
1964 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1965 0 \
1966 -S "skip write certificate request" \
1967 -C "skip parse certificate request" \
1968 -c "got a certificate request" \
1969 -C "skip write certificate" \
1970 -C "skip write certificate verify" \
1971 -S "skip parse certificate verify" \
1972 -S "x509_verify_cert() returned" \
1973 -S "! The certificate is not correctly signed by the trusted CA" \
1974 -S "The certificate has been revoked (is on a CRL)"
1975
1976run_test "SNI: CA override with CRL" \
1977 "$P_SRV debug_level=3 auth_mode=optional \
1978 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1979 ca_file=data_files/test-ca.crt \
1980 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1981 "$P_CLI debug_level=3 server_name=localhost \
1982 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1983 1 \
1984 -S "skip write certificate request" \
1985 -C "skip parse certificate request" \
1986 -c "got a certificate request" \
1987 -C "skip write certificate" \
1988 -C "skip write certificate verify" \
1989 -S "skip parse certificate verify" \
1990 -s "x509_verify_cert() returned" \
1991 -S "! The certificate is not correctly signed by the trusted CA" \
1992 -s "The certificate has been revoked (is on a CRL)"
1993
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001994# Tests for non-blocking I/O: exercise a variety of handshake flows
1995
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001996run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001997 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1998 "$P_CLI nbio=2 tickets=0" \
1999 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002000 -S "mbedtls_ssl_handshake returned" \
2001 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002002 -c "Read from server: .* bytes read"
2003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002004run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002005 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2006 "$P_CLI nbio=2 tickets=0" \
2007 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002008 -S "mbedtls_ssl_handshake returned" \
2009 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002010 -c "Read from server: .* bytes read"
2011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002012run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002013 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2014 "$P_CLI nbio=2 tickets=1" \
2015 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002016 -S "mbedtls_ssl_handshake returned" \
2017 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002018 -c "Read from server: .* bytes read"
2019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002020run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002021 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2022 "$P_CLI nbio=2 tickets=1" \
2023 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002024 -S "mbedtls_ssl_handshake returned" \
2025 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002026 -c "Read from server: .* bytes read"
2027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002028run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002029 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2030 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2031 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002032 -S "mbedtls_ssl_handshake returned" \
2033 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002034 -c "Read from server: .* bytes read"
2035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002036run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002037 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2038 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2039 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002040 -S "mbedtls_ssl_handshake returned" \
2041 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002042 -c "Read from server: .* bytes read"
2043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002044run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002045 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2046 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2047 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002048 -S "mbedtls_ssl_handshake returned" \
2049 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002050 -c "Read from server: .* bytes read"
2051
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002052# Tests for version negotiation
2053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002054run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002055 "$P_SRV" \
2056 "$P_CLI" \
2057 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002058 -S "mbedtls_ssl_handshake returned" \
2059 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002060 -s "Protocol is TLSv1.2" \
2061 -c "Protocol is TLSv1.2"
2062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002063run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002064 "$P_SRV" \
2065 "$P_CLI max_version=tls1_1" \
2066 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002067 -S "mbedtls_ssl_handshake returned" \
2068 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002069 -s "Protocol is TLSv1.1" \
2070 -c "Protocol is TLSv1.1"
2071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002072run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002073 "$P_SRV max_version=tls1_1" \
2074 "$P_CLI" \
2075 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002076 -S "mbedtls_ssl_handshake returned" \
2077 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002078 -s "Protocol is TLSv1.1" \
2079 -c "Protocol is TLSv1.1"
2080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002081run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002082 "$P_SRV max_version=tls1_1" \
2083 "$P_CLI max_version=tls1_1" \
2084 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002085 -S "mbedtls_ssl_handshake returned" \
2086 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002087 -s "Protocol is TLSv1.1" \
2088 -c "Protocol is TLSv1.1"
2089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002090run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002091 "$P_SRV min_version=tls1_1" \
2092 "$P_CLI max_version=tls1_1" \
2093 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002094 -S "mbedtls_ssl_handshake returned" \
2095 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002096 -s "Protocol is TLSv1.1" \
2097 -c "Protocol is TLSv1.1"
2098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002099run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002100 "$P_SRV max_version=tls1_1" \
2101 "$P_CLI min_version=tls1_1" \
2102 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002103 -S "mbedtls_ssl_handshake returned" \
2104 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002105 -s "Protocol is TLSv1.1" \
2106 -c "Protocol is TLSv1.1"
2107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002108run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002109 "$P_SRV max_version=tls1_1" \
2110 "$P_CLI min_version=tls1_2" \
2111 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002112 -s "mbedtls_ssl_handshake returned" \
2113 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002114 -c "SSL - Handshake protocol not within min/max boundaries"
2115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002116run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002117 "$P_SRV min_version=tls1_2" \
2118 "$P_CLI max_version=tls1_1" \
2119 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002120 -s "mbedtls_ssl_handshake returned" \
2121 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002122 -s "SSL - Handshake protocol not within min/max boundaries"
2123
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002124# Tests for ALPN extension
2125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002126run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002127 "$P_SRV debug_level=3" \
2128 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002129 0 \
2130 -C "client hello, adding alpn extension" \
2131 -S "found alpn extension" \
2132 -C "got an alert message, type: \\[2:120]" \
2133 -S "server hello, adding alpn extension" \
2134 -C "found alpn extension " \
2135 -C "Application Layer Protocol is" \
2136 -S "Application Layer Protocol is"
2137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002138run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002139 "$P_SRV debug_level=3" \
2140 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002141 0 \
2142 -c "client hello, adding alpn extension" \
2143 -s "found alpn extension" \
2144 -C "got an alert message, type: \\[2:120]" \
2145 -S "server hello, adding alpn extension" \
2146 -C "found alpn extension " \
2147 -c "Application Layer Protocol is (none)" \
2148 -S "Application Layer Protocol is"
2149
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002150run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002151 "$P_SRV debug_level=3 alpn=abc,1234" \
2152 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002153 0 \
2154 -C "client hello, adding alpn extension" \
2155 -S "found alpn extension" \
2156 -C "got an alert message, type: \\[2:120]" \
2157 -S "server hello, adding alpn extension" \
2158 -C "found alpn extension " \
2159 -C "Application Layer Protocol is" \
2160 -s "Application Layer Protocol is (none)"
2161
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002162run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002163 "$P_SRV debug_level=3 alpn=abc,1234" \
2164 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002165 0 \
2166 -c "client hello, adding alpn extension" \
2167 -s "found alpn extension" \
2168 -C "got an alert message, type: \\[2:120]" \
2169 -s "server hello, adding alpn extension" \
2170 -c "found alpn extension" \
2171 -c "Application Layer Protocol is abc" \
2172 -s "Application Layer Protocol is abc"
2173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002174run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002175 "$P_SRV debug_level=3 alpn=abc,1234" \
2176 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002177 0 \
2178 -c "client hello, adding alpn extension" \
2179 -s "found alpn extension" \
2180 -C "got an alert message, type: \\[2:120]" \
2181 -s "server hello, adding alpn extension" \
2182 -c "found alpn extension" \
2183 -c "Application Layer Protocol is abc" \
2184 -s "Application Layer Protocol is abc"
2185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002186run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002187 "$P_SRV debug_level=3 alpn=abc,1234" \
2188 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002189 0 \
2190 -c "client hello, adding alpn extension" \
2191 -s "found alpn extension" \
2192 -C "got an alert message, type: \\[2:120]" \
2193 -s "server hello, adding alpn extension" \
2194 -c "found alpn extension" \
2195 -c "Application Layer Protocol is 1234" \
2196 -s "Application Layer Protocol is 1234"
2197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002198run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002199 "$P_SRV debug_level=3 alpn=abc,123" \
2200 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002201 1 \
2202 -c "client hello, adding alpn extension" \
2203 -s "found alpn extension" \
2204 -c "got an alert message, type: \\[2:120]" \
2205 -S "server hello, adding alpn extension" \
2206 -C "found alpn extension" \
2207 -C "Application Layer Protocol is 1234" \
2208 -S "Application Layer Protocol is 1234"
2209
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002210
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002211# Tests for keyUsage in leaf certificates, part 1:
2212# server-side certificate/suite selection
2213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002214run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002215 "$P_SRV key_file=data_files/server2.key \
2216 crt_file=data_files/server2.ku-ds.crt" \
2217 "$P_CLI" \
2218 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002219 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002220
2221
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002222run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002223 "$P_SRV key_file=data_files/server2.key \
2224 crt_file=data_files/server2.ku-ke.crt" \
2225 "$P_CLI" \
2226 0 \
2227 -c "Ciphersuite is TLS-RSA-WITH-"
2228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002229run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002230 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002231 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002232 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002233 1 \
2234 -C "Ciphersuite is "
2235
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002236run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002237 "$P_SRV key_file=data_files/server5.key \
2238 crt_file=data_files/server5.ku-ds.crt" \
2239 "$P_CLI" \
2240 0 \
2241 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2242
2243
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002244run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002245 "$P_SRV key_file=data_files/server5.key \
2246 crt_file=data_files/server5.ku-ka.crt" \
2247 "$P_CLI" \
2248 0 \
2249 -c "Ciphersuite is TLS-ECDH-"
2250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002251run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002252 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002253 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002254 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002255 1 \
2256 -C "Ciphersuite is "
2257
2258# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002259# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002261run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002262 "$O_SRV -key data_files/server2.key \
2263 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002264 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002265 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2266 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002267 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002268 -C "Processing of the Certificate handshake message failed" \
2269 -c "Ciphersuite is TLS-"
2270
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002271run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002272 "$O_SRV -key data_files/server2.key \
2273 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002274 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002275 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2276 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002277 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002278 -C "Processing of the Certificate handshake message failed" \
2279 -c "Ciphersuite is TLS-"
2280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002281run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002282 "$O_SRV -key data_files/server2.key \
2283 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002284 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002285 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2286 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002287 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002288 -C "Processing of the Certificate handshake message failed" \
2289 -c "Ciphersuite is TLS-"
2290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002291run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002292 "$O_SRV -key data_files/server2.key \
2293 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002294 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002295 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2296 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002297 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002298 -c "Processing of the Certificate handshake message failed" \
2299 -C "Ciphersuite is TLS-"
2300
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002301run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2302 "$O_SRV -key data_files/server2.key \
2303 -cert data_files/server2.ku-ke.crt" \
2304 "$P_CLI debug_level=1 auth_mode=optional \
2305 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2306 0 \
2307 -c "bad certificate (usage extensions)" \
2308 -C "Processing of the Certificate handshake message failed" \
2309 -c "Ciphersuite is TLS-" \
2310 -c "! Usage does not match the keyUsage extension"
2311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002312run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002313 "$O_SRV -key data_files/server2.key \
2314 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002315 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002316 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2317 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002318 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002319 -C "Processing of the Certificate handshake message failed" \
2320 -c "Ciphersuite is TLS-"
2321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002322run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002323 "$O_SRV -key data_files/server2.key \
2324 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002325 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002326 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2327 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002328 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002329 -c "Processing of the Certificate handshake message failed" \
2330 -C "Ciphersuite is TLS-"
2331
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002332run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2333 "$O_SRV -key data_files/server2.key \
2334 -cert data_files/server2.ku-ds.crt" \
2335 "$P_CLI debug_level=1 auth_mode=optional \
2336 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2337 0 \
2338 -c "bad certificate (usage extensions)" \
2339 -C "Processing of the Certificate handshake message failed" \
2340 -c "Ciphersuite is TLS-" \
2341 -c "! Usage does not match the keyUsage extension"
2342
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002343# Tests for keyUsage in leaf certificates, part 3:
2344# server-side checking of client cert
2345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002346run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002347 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002348 "$O_CLI -key data_files/server2.key \
2349 -cert data_files/server2.ku-ds.crt" \
2350 0 \
2351 -S "bad certificate (usage extensions)" \
2352 -S "Processing of the Certificate handshake message failed"
2353
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002354run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002355 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002356 "$O_CLI -key data_files/server2.key \
2357 -cert data_files/server2.ku-ke.crt" \
2358 0 \
2359 -s "bad certificate (usage extensions)" \
2360 -S "Processing of the Certificate handshake message failed"
2361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002362run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002363 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002364 "$O_CLI -key data_files/server2.key \
2365 -cert data_files/server2.ku-ke.crt" \
2366 1 \
2367 -s "bad certificate (usage extensions)" \
2368 -s "Processing of the Certificate handshake message failed"
2369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002370run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002371 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002372 "$O_CLI -key data_files/server5.key \
2373 -cert data_files/server5.ku-ds.crt" \
2374 0 \
2375 -S "bad certificate (usage extensions)" \
2376 -S "Processing of the Certificate handshake message failed"
2377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002378run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002379 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002380 "$O_CLI -key data_files/server5.key \
2381 -cert data_files/server5.ku-ka.crt" \
2382 0 \
2383 -s "bad certificate (usage extensions)" \
2384 -S "Processing of the Certificate handshake message failed"
2385
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002386# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002388run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002389 "$P_SRV key_file=data_files/server5.key \
2390 crt_file=data_files/server5.eku-srv.crt" \
2391 "$P_CLI" \
2392 0
2393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002394run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002395 "$P_SRV key_file=data_files/server5.key \
2396 crt_file=data_files/server5.eku-srv.crt" \
2397 "$P_CLI" \
2398 0
2399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002400run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002401 "$P_SRV key_file=data_files/server5.key \
2402 crt_file=data_files/server5.eku-cs_any.crt" \
2403 "$P_CLI" \
2404 0
2405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002406run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002407 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002408 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002409 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002410 1
2411
2412# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2413
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002414run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002415 "$O_SRV -key data_files/server5.key \
2416 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002417 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002418 0 \
2419 -C "bad certificate (usage extensions)" \
2420 -C "Processing of the Certificate handshake message failed" \
2421 -c "Ciphersuite is TLS-"
2422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002423run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002424 "$O_SRV -key data_files/server5.key \
2425 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002426 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002427 0 \
2428 -C "bad certificate (usage extensions)" \
2429 -C "Processing of the Certificate handshake message failed" \
2430 -c "Ciphersuite is TLS-"
2431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002432run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002433 "$O_SRV -key data_files/server5.key \
2434 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002435 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002436 0 \
2437 -C "bad certificate (usage extensions)" \
2438 -C "Processing of the Certificate handshake message failed" \
2439 -c "Ciphersuite is TLS-"
2440
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002441run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002442 "$O_SRV -key data_files/server5.key \
2443 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002444 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002445 1 \
2446 -c "bad certificate (usage extensions)" \
2447 -c "Processing of the Certificate handshake message failed" \
2448 -C "Ciphersuite is TLS-"
2449
2450# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2451
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002452run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002453 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002454 "$O_CLI -key data_files/server5.key \
2455 -cert data_files/server5.eku-cli.crt" \
2456 0 \
2457 -S "bad certificate (usage extensions)" \
2458 -S "Processing of the Certificate handshake message failed"
2459
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002460run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002461 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002462 "$O_CLI -key data_files/server5.key \
2463 -cert data_files/server5.eku-srv_cli.crt" \
2464 0 \
2465 -S "bad certificate (usage extensions)" \
2466 -S "Processing of the Certificate handshake message failed"
2467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002468run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002469 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002470 "$O_CLI -key data_files/server5.key \
2471 -cert data_files/server5.eku-cs_any.crt" \
2472 0 \
2473 -S "bad certificate (usage extensions)" \
2474 -S "Processing of the Certificate handshake message failed"
2475
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002476run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002477 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002478 "$O_CLI -key data_files/server5.key \
2479 -cert data_files/server5.eku-cs.crt" \
2480 0 \
2481 -s "bad certificate (usage extensions)" \
2482 -S "Processing of the Certificate handshake message failed"
2483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002484run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002485 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002486 "$O_CLI -key data_files/server5.key \
2487 -cert data_files/server5.eku-cs.crt" \
2488 1 \
2489 -s "bad certificate (usage extensions)" \
2490 -s "Processing of the Certificate handshake message failed"
2491
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002492# Tests for DHM parameters loading
2493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002494run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002495 "$P_SRV" \
2496 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2497 debug_level=3" \
2498 0 \
2499 -c "value of 'DHM: P ' (2048 bits)" \
2500 -c "value of 'DHM: G ' (2048 bits)"
2501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002502run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002503 "$P_SRV dhm_file=data_files/dhparams.pem" \
2504 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2505 debug_level=3" \
2506 0 \
2507 -c "value of 'DHM: P ' (1024 bits)" \
2508 -c "value of 'DHM: G ' (2 bits)"
2509
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002510# Tests for DHM client-side size checking
2511
2512run_test "DHM size: server default, client default, OK" \
2513 "$P_SRV" \
2514 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2515 debug_level=1" \
2516 0 \
2517 -C "DHM prime too short:"
2518
2519run_test "DHM size: server default, client 2048, OK" \
2520 "$P_SRV" \
2521 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2522 debug_level=1 dhmlen=2048" \
2523 0 \
2524 -C "DHM prime too short:"
2525
2526run_test "DHM size: server 1024, client default, OK" \
2527 "$P_SRV dhm_file=data_files/dhparams.pem" \
2528 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2529 debug_level=1" \
2530 0 \
2531 -C "DHM prime too short:"
2532
2533run_test "DHM size: server 1000, client default, rejected" \
2534 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2535 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2536 debug_level=1" \
2537 1 \
2538 -c "DHM prime too short:"
2539
2540run_test "DHM size: server default, client 2049, rejected" \
2541 "$P_SRV" \
2542 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2543 debug_level=1 dhmlen=2049" \
2544 1 \
2545 -c "DHM prime too short:"
2546
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002547# Tests for PSK callback
2548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002549run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002550 "$P_SRV psk=abc123 psk_identity=foo" \
2551 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2552 psk_identity=foo psk=abc123" \
2553 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002554 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002555 -S "SSL - Unknown identity received" \
2556 -S "SSL - Verification of the message MAC failed"
2557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002558run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002559 "$P_SRV" \
2560 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2561 psk_identity=foo psk=abc123" \
2562 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002563 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002564 -S "SSL - Unknown identity received" \
2565 -S "SSL - Verification of the message MAC failed"
2566
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002567run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002568 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2569 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2570 psk_identity=foo psk=abc123" \
2571 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002572 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002573 -s "SSL - Unknown identity received" \
2574 -S "SSL - Verification of the message MAC failed"
2575
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002576run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002577 "$P_SRV psk_list=abc,dead,def,beef" \
2578 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2579 psk_identity=abc psk=dead" \
2580 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002581 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002582 -S "SSL - Unknown identity received" \
2583 -S "SSL - Verification of the message MAC failed"
2584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002585run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002586 "$P_SRV psk_list=abc,dead,def,beef" \
2587 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2588 psk_identity=def psk=beef" \
2589 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002590 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002591 -S "SSL - Unknown identity received" \
2592 -S "SSL - Verification of the message MAC failed"
2593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002594run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002595 "$P_SRV psk_list=abc,dead,def,beef" \
2596 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2597 psk_identity=ghi psk=beef" \
2598 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002599 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002600 -s "SSL - Unknown identity received" \
2601 -S "SSL - Verification of the message MAC failed"
2602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002603run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002604 "$P_SRV psk_list=abc,dead,def,beef" \
2605 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2606 psk_identity=abc psk=beef" \
2607 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002608 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002609 -S "SSL - Unknown identity received" \
2610 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002611
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002612# Tests for EC J-PAKE
2613
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002614requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002615run_test "ECJPAKE: client not configured" \
2616 "$P_SRV debug_level=3" \
2617 "$P_CLI debug_level=3" \
2618 0 \
2619 -C "add ciphersuite: c0ff" \
2620 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002621 -S "found ecjpake kkpp extension" \
2622 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002623 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002624 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002625 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002626 -S "None of the common ciphersuites is usable"
2627
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002628requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002629run_test "ECJPAKE: server not configured" \
2630 "$P_SRV debug_level=3" \
2631 "$P_CLI debug_level=3 ecjpake_pw=bla \
2632 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2633 1 \
2634 -c "add ciphersuite: c0ff" \
2635 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002636 -s "found ecjpake kkpp extension" \
2637 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002638 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002639 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002640 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002641 -s "None of the common ciphersuites is usable"
2642
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002643requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002644run_test "ECJPAKE: working, TLS" \
2645 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2646 "$P_CLI debug_level=3 ecjpake_pw=bla \
2647 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002648 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002649 -c "add ciphersuite: c0ff" \
2650 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002651 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002652 -s "found ecjpake kkpp extension" \
2653 -S "skip ecjpake kkpp extension" \
2654 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002655 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002656 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002657 -S "None of the common ciphersuites is usable" \
2658 -S "SSL - Verification of the message MAC failed"
2659
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002660requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002661run_test "ECJPAKE: password mismatch, TLS" \
2662 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2663 "$P_CLI debug_level=3 ecjpake_pw=bad \
2664 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2665 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002666 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002667 -s "SSL - Verification of the message MAC failed"
2668
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002669requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002670run_test "ECJPAKE: working, DTLS" \
2671 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2672 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2673 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2674 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002675 -c "re-using cached ecjpake parameters" \
2676 -S "SSL - Verification of the message MAC failed"
2677
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002678requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002679run_test "ECJPAKE: working, DTLS, no cookie" \
2680 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2681 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2682 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2683 0 \
2684 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002685 -S "SSL - Verification of the message MAC failed"
2686
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002687requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002688run_test "ECJPAKE: password mismatch, DTLS" \
2689 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2690 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2691 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2692 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002693 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002694 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002695
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002696# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002697requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002698run_test "ECJPAKE: working, DTLS, nolog" \
2699 "$P_SRV dtls=1 ecjpake_pw=bla" \
2700 "$P_CLI dtls=1 ecjpake_pw=bla \
2701 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2702 0
2703
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002704# Tests for ciphersuites per version
2705
Janos Follathe2681a42016-03-07 15:57:05 +00002706requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002707run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002708 "$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 +02002709 "$P_CLI force_version=ssl3" \
2710 0 \
2711 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002713run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002714 "$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 +01002715 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002716 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002717 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002718
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002719run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002720 "$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 +02002721 "$P_CLI force_version=tls1_1" \
2722 0 \
2723 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002725run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002726 "$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 +02002727 "$P_CLI force_version=tls1_2" \
2728 0 \
2729 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2730
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002731# Test for ClientHello without extensions
2732
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002733requires_gnutls
2734run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002735 "$P_SRV debug_level=3" \
2736 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2737 0 \
2738 -s "dumping 'client hello extensions' (0 bytes)"
2739
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002740# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002741
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002742run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002743 "$P_SRV" \
2744 "$P_CLI request_size=100" \
2745 0 \
2746 -s "Read from client: 100 bytes read$"
2747
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002748run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002749 "$P_SRV" \
2750 "$P_CLI request_size=500" \
2751 0 \
2752 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002753
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002754# Tests for small packets
2755
Janos Follathe2681a42016-03-07 15:57:05 +00002756requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002757run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002758 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002759 "$P_CLI request_size=1 force_version=ssl3 \
2760 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2761 0 \
2762 -s "Read from client: 1 bytes read"
2763
Janos Follathe2681a42016-03-07 15:57:05 +00002764requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002765run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002766 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002767 "$P_CLI request_size=1 force_version=ssl3 \
2768 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2769 0 \
2770 -s "Read from client: 1 bytes read"
2771
2772run_test "Small packet TLS 1.0 BlockCipher" \
2773 "$P_SRV" \
2774 "$P_CLI request_size=1 force_version=tls1 \
2775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2776 0 \
2777 -s "Read from client: 1 bytes read"
2778
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002779run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2780 "$P_SRV" \
2781 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2782 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2783 0 \
2784 -s "Read from client: 1 bytes read"
2785
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002786run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2787 "$P_SRV" \
2788 "$P_CLI request_size=1 force_version=tls1 \
2789 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2790 trunc_hmac=1" \
2791 0 \
2792 -s "Read from client: 1 bytes read"
2793
2794run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002795 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002796 "$P_CLI request_size=1 force_version=tls1 \
2797 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2798 trunc_hmac=1" \
2799 0 \
2800 -s "Read from client: 1 bytes read"
2801
2802run_test "Small packet TLS 1.1 BlockCipher" \
2803 "$P_SRV" \
2804 "$P_CLI request_size=1 force_version=tls1_1 \
2805 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2806 0 \
2807 -s "Read from client: 1 bytes read"
2808
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002809run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2810 "$P_SRV" \
2811 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2812 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2813 0 \
2814 -s "Read from client: 1 bytes read"
2815
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002816run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002817 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002818 "$P_CLI request_size=1 force_version=tls1_1 \
2819 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2820 0 \
2821 -s "Read from client: 1 bytes read"
2822
2823run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2824 "$P_SRV" \
2825 "$P_CLI request_size=1 force_version=tls1_1 \
2826 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2827 trunc_hmac=1" \
2828 0 \
2829 -s "Read from client: 1 bytes read"
2830
2831run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002832 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002833 "$P_CLI request_size=1 force_version=tls1_1 \
2834 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2835 trunc_hmac=1" \
2836 0 \
2837 -s "Read from client: 1 bytes read"
2838
2839run_test "Small packet TLS 1.2 BlockCipher" \
2840 "$P_SRV" \
2841 "$P_CLI request_size=1 force_version=tls1_2 \
2842 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2843 0 \
2844 -s "Read from client: 1 bytes read"
2845
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002846run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2847 "$P_SRV" \
2848 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2849 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2850 0 \
2851 -s "Read from client: 1 bytes read"
2852
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002853run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2854 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002855 "$P_CLI request_size=1 force_version=tls1_2 \
2856 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002857 0 \
2858 -s "Read from client: 1 bytes read"
2859
2860run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2861 "$P_SRV" \
2862 "$P_CLI request_size=1 force_version=tls1_2 \
2863 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2864 trunc_hmac=1" \
2865 0 \
2866 -s "Read from client: 1 bytes read"
2867
2868run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002869 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002870 "$P_CLI request_size=1 force_version=tls1_2 \
2871 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2872 0 \
2873 -s "Read from client: 1 bytes read"
2874
2875run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002876 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002877 "$P_CLI request_size=1 force_version=tls1_2 \
2878 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2879 trunc_hmac=1" \
2880 0 \
2881 -s "Read from client: 1 bytes read"
2882
2883run_test "Small packet TLS 1.2 AEAD" \
2884 "$P_SRV" \
2885 "$P_CLI request_size=1 force_version=tls1_2 \
2886 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2887 0 \
2888 -s "Read from client: 1 bytes read"
2889
2890run_test "Small packet TLS 1.2 AEAD shorter tag" \
2891 "$P_SRV" \
2892 "$P_CLI request_size=1 force_version=tls1_2 \
2893 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2894 0 \
2895 -s "Read from client: 1 bytes read"
2896
Janos Follath00efff72016-05-06 13:48:23 +01002897# A test for extensions in SSLv3
2898
2899requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2900run_test "SSLv3 with extensions, server side" \
2901 "$P_SRV min_version=ssl3 debug_level=3" \
2902 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2903 0 \
2904 -S "dumping 'client hello extensions'" \
2905 -S "server hello, total extension length:"
2906
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002907# Test for large packets
2908
Janos Follathe2681a42016-03-07 15:57:05 +00002909requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002910run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002911 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002912 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002913 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2914 0 \
2915 -s "Read from client: 16384 bytes read"
2916
Janos Follathe2681a42016-03-07 15:57:05 +00002917requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002918run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002919 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002920 "$P_CLI request_size=16384 force_version=ssl3 \
2921 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2922 0 \
2923 -s "Read from client: 16384 bytes read"
2924
2925run_test "Large packet TLS 1.0 BlockCipher" \
2926 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002927 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002928 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2929 0 \
2930 -s "Read from client: 16384 bytes read"
2931
2932run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2933 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002934 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002935 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2936 trunc_hmac=1" \
2937 0 \
2938 -s "Read from client: 16384 bytes read"
2939
2940run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002941 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002942 "$P_CLI request_size=16384 force_version=tls1 \
2943 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2944 trunc_hmac=1" \
2945 0 \
2946 -s "Read from client: 16384 bytes read"
2947
2948run_test "Large packet TLS 1.1 BlockCipher" \
2949 "$P_SRV" \
2950 "$P_CLI request_size=16384 force_version=tls1_1 \
2951 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2952 0 \
2953 -s "Read from client: 16384 bytes read"
2954
2955run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002956 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002957 "$P_CLI request_size=16384 force_version=tls1_1 \
2958 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2959 0 \
2960 -s "Read from client: 16384 bytes read"
2961
2962run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2963 "$P_SRV" \
2964 "$P_CLI request_size=16384 force_version=tls1_1 \
2965 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2966 trunc_hmac=1" \
2967 0 \
2968 -s "Read from client: 16384 bytes read"
2969
2970run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002971 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002972 "$P_CLI request_size=16384 force_version=tls1_1 \
2973 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2974 trunc_hmac=1" \
2975 0 \
2976 -s "Read from client: 16384 bytes read"
2977
2978run_test "Large packet TLS 1.2 BlockCipher" \
2979 "$P_SRV" \
2980 "$P_CLI request_size=16384 force_version=tls1_2 \
2981 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2982 0 \
2983 -s "Read from client: 16384 bytes read"
2984
2985run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2986 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002987 "$P_CLI request_size=16384 force_version=tls1_2 \
2988 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002989 0 \
2990 -s "Read from client: 16384 bytes read"
2991
2992run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2993 "$P_SRV" \
2994 "$P_CLI request_size=16384 force_version=tls1_2 \
2995 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2996 trunc_hmac=1" \
2997 0 \
2998 -s "Read from client: 16384 bytes read"
2999
3000run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003001 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003002 "$P_CLI request_size=16384 force_version=tls1_2 \
3003 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3004 0 \
3005 -s "Read from client: 16384 bytes read"
3006
3007run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003008 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003009 "$P_CLI request_size=16384 force_version=tls1_2 \
3010 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3011 trunc_hmac=1" \
3012 0 \
3013 -s "Read from client: 16384 bytes read"
3014
3015run_test "Large packet TLS 1.2 AEAD" \
3016 "$P_SRV" \
3017 "$P_CLI request_size=16384 force_version=tls1_2 \
3018 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3019 0 \
3020 -s "Read from client: 16384 bytes read"
3021
3022run_test "Large packet TLS 1.2 AEAD shorter tag" \
3023 "$P_SRV" \
3024 "$P_CLI request_size=16384 force_version=tls1_2 \
3025 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3026 0 \
3027 -s "Read from client: 16384 bytes read"
3028
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003029# Tests for DTLS HelloVerifyRequest
3030
3031run_test "DTLS cookie: enabled" \
3032 "$P_SRV dtls=1 debug_level=2" \
3033 "$P_CLI dtls=1 debug_level=2" \
3034 0 \
3035 -s "cookie verification failed" \
3036 -s "cookie verification passed" \
3037 -S "cookie verification skipped" \
3038 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003039 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003040 -S "SSL - The requested feature is not available"
3041
3042run_test "DTLS cookie: disabled" \
3043 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3044 "$P_CLI dtls=1 debug_level=2" \
3045 0 \
3046 -S "cookie verification failed" \
3047 -S "cookie verification passed" \
3048 -s "cookie verification skipped" \
3049 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003050 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003051 -S "SSL - The requested feature is not available"
3052
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003053run_test "DTLS cookie: default (failing)" \
3054 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3055 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3056 1 \
3057 -s "cookie verification failed" \
3058 -S "cookie verification passed" \
3059 -S "cookie verification skipped" \
3060 -C "received hello verify request" \
3061 -S "hello verification requested" \
3062 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003063
3064requires_ipv6
3065run_test "DTLS cookie: enabled, IPv6" \
3066 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3067 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3068 0 \
3069 -s "cookie verification failed" \
3070 -s "cookie verification passed" \
3071 -S "cookie verification skipped" \
3072 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003073 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003074 -S "SSL - The requested feature is not available"
3075
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003076run_test "DTLS cookie: enabled, nbio" \
3077 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3078 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3079 0 \
3080 -s "cookie verification failed" \
3081 -s "cookie verification passed" \
3082 -S "cookie verification skipped" \
3083 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003084 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003085 -S "SSL - The requested feature is not available"
3086
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003087# Tests for client reconnecting from the same port with DTLS
3088
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003089not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003090run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003091 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3092 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003093 0 \
3094 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003095 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003096 -S "Client initiated reconnection from same port"
3097
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003098not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003099run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003100 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3101 "$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 +02003102 0 \
3103 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003104 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003105 -s "Client initiated reconnection from same port"
3106
Paul Bakker362689d2016-05-13 10:33:25 +01003107not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3108run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003109 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3110 "$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 +02003111 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003112 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003113 -s "Client initiated reconnection from same port"
3114
Paul Bakker362689d2016-05-13 10:33:25 +01003115only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3116run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3117 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3118 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3119 0 \
3120 -S "The operation timed out" \
3121 -s "Client initiated reconnection from same port"
3122
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003123run_test "DTLS client reconnect from same port: no cookies" \
3124 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003125 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3126 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003127 -s "The operation timed out" \
3128 -S "Client initiated reconnection from same port"
3129
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003130# Tests for various cases of client authentication with DTLS
3131# (focused on handshake flows and message parsing)
3132
3133run_test "DTLS client auth: required" \
3134 "$P_SRV dtls=1 auth_mode=required" \
3135 "$P_CLI dtls=1" \
3136 0 \
3137 -s "Verifying peer X.509 certificate... ok"
3138
3139run_test "DTLS client auth: optional, client has no cert" \
3140 "$P_SRV dtls=1 auth_mode=optional" \
3141 "$P_CLI dtls=1 crt_file=none key_file=none" \
3142 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003143 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003144
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003145run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003146 "$P_SRV dtls=1 auth_mode=none" \
3147 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3148 0 \
3149 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003150 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003151
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003152run_test "DTLS wrong PSK: badmac alert" \
3153 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3154 "$P_CLI dtls=1 psk=abc124" \
3155 1 \
3156 -s "SSL - Verification of the message MAC failed" \
3157 -c "SSL - A fatal alert message was received from our peer"
3158
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003159# Tests for receiving fragmented handshake messages with DTLS
3160
3161requires_gnutls
3162run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3163 "$G_SRV -u --mtu 2048 -a" \
3164 "$P_CLI dtls=1 debug_level=2" \
3165 0 \
3166 -C "found fragmented DTLS handshake message" \
3167 -C "error"
3168
3169requires_gnutls
3170run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3171 "$G_SRV -u --mtu 512" \
3172 "$P_CLI dtls=1 debug_level=2" \
3173 0 \
3174 -c "found fragmented DTLS handshake message" \
3175 -C "error"
3176
3177requires_gnutls
3178run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3179 "$G_SRV -u --mtu 128" \
3180 "$P_CLI dtls=1 debug_level=2" \
3181 0 \
3182 -c "found fragmented DTLS handshake message" \
3183 -C "error"
3184
3185requires_gnutls
3186run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3187 "$G_SRV -u --mtu 128" \
3188 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3189 0 \
3190 -c "found fragmented DTLS handshake message" \
3191 -C "error"
3192
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003193requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003194run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3195 "$G_SRV -u --mtu 256" \
3196 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3197 0 \
3198 -c "found fragmented DTLS handshake message" \
3199 -c "client hello, adding renegotiation extension" \
3200 -c "found renegotiation extension" \
3201 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003202 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003203 -C "error" \
3204 -s "Extra-header:"
3205
3206requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003207run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3208 "$G_SRV -u --mtu 256" \
3209 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3210 0 \
3211 -c "found fragmented DTLS handshake message" \
3212 -c "client hello, adding renegotiation extension" \
3213 -c "found renegotiation extension" \
3214 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003215 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003216 -C "error" \
3217 -s "Extra-header:"
3218
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003219run_test "DTLS reassembly: no fragmentation (openssl server)" \
3220 "$O_SRV -dtls1 -mtu 2048" \
3221 "$P_CLI dtls=1 debug_level=2" \
3222 0 \
3223 -C "found fragmented DTLS handshake message" \
3224 -C "error"
3225
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003226run_test "DTLS reassembly: some fragmentation (openssl server)" \
3227 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003228 "$P_CLI dtls=1 debug_level=2" \
3229 0 \
3230 -c "found fragmented DTLS handshake message" \
3231 -C "error"
3232
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003233run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003234 "$O_SRV -dtls1 -mtu 256" \
3235 "$P_CLI dtls=1 debug_level=2" \
3236 0 \
3237 -c "found fragmented DTLS handshake message" \
3238 -C "error"
3239
3240run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3241 "$O_SRV -dtls1 -mtu 256" \
3242 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3243 0 \
3244 -c "found fragmented DTLS handshake message" \
3245 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003246
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003247# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003248
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003249not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003250run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003251 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003252 "$P_SRV dtls=1 debug_level=2" \
3253 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003254 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003255 -C "replayed record" \
3256 -S "replayed record" \
3257 -C "record from another epoch" \
3258 -S "record from another epoch" \
3259 -C "discarding invalid record" \
3260 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003261 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003262 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003263 -c "HTTP/1.0 200 OK"
3264
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003265not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003266run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003267 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003268 "$P_SRV dtls=1 debug_level=2" \
3269 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003270 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003271 -c "replayed record" \
3272 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003273 -c "discarding invalid record" \
3274 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003275 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003276 -s "Extra-header:" \
3277 -c "HTTP/1.0 200 OK"
3278
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003279run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3280 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003281 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3282 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003283 0 \
3284 -c "replayed record" \
3285 -S "replayed record" \
3286 -c "discarding invalid record" \
3287 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003288 -c "resend" \
3289 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003290 -s "Extra-header:" \
3291 -c "HTTP/1.0 200 OK"
3292
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003293run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003294 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003295 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003296 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003297 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003298 -c "discarding invalid record (mac)" \
3299 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003300 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003301 -c "HTTP/1.0 200 OK" \
3302 -S "too many records with bad MAC" \
3303 -S "Verification of the message MAC failed"
3304
3305run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3306 -p "$P_PXY bad_ad=1" \
3307 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3308 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3309 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003310 -C "discarding invalid record (mac)" \
3311 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003312 -S "Extra-header:" \
3313 -C "HTTP/1.0 200 OK" \
3314 -s "too many records with bad MAC" \
3315 -s "Verification of the message MAC failed"
3316
3317run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3318 -p "$P_PXY bad_ad=1" \
3319 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3320 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3321 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003322 -c "discarding invalid record (mac)" \
3323 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003324 -s "Extra-header:" \
3325 -c "HTTP/1.0 200 OK" \
3326 -S "too many records with bad MAC" \
3327 -S "Verification of the message MAC failed"
3328
3329run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3330 -p "$P_PXY bad_ad=1" \
3331 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3332 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3333 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003334 -c "discarding invalid record (mac)" \
3335 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003336 -s "Extra-header:" \
3337 -c "HTTP/1.0 200 OK" \
3338 -s "too many records with bad MAC" \
3339 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003340
3341run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003342 -p "$P_PXY delay_ccs=1" \
3343 "$P_SRV dtls=1 debug_level=1" \
3344 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003345 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003346 -c "record from another epoch" \
3347 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003348 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003349 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003350 -s "Extra-header:" \
3351 -c "HTTP/1.0 200 OK"
3352
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003353# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003354
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003355needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003356run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003357 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003358 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3359 psk=abc123" \
3360 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003361 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3362 0 \
3363 -s "Extra-header:" \
3364 -c "HTTP/1.0 200 OK"
3365
3366needs_more_time 2
3367run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3368 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003369 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3370 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003371 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3372 0 \
3373 -s "Extra-header:" \
3374 -c "HTTP/1.0 200 OK"
3375
3376needs_more_time 2
3377run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3378 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003379 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3380 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003381 0 \
3382 -s "Extra-header:" \
3383 -c "HTTP/1.0 200 OK"
3384
3385needs_more_time 2
3386run_test "DTLS proxy: 3d, FS, client auth" \
3387 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003388 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3389 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003390 0 \
3391 -s "Extra-header:" \
3392 -c "HTTP/1.0 200 OK"
3393
3394needs_more_time 2
3395run_test "DTLS proxy: 3d, FS, ticket" \
3396 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003397 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3398 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003399 0 \
3400 -s "Extra-header:" \
3401 -c "HTTP/1.0 200 OK"
3402
3403needs_more_time 2
3404run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3405 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003406 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3407 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003408 0 \
3409 -s "Extra-header:" \
3410 -c "HTTP/1.0 200 OK"
3411
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003412needs_more_time 2
3413run_test "DTLS proxy: 3d, max handshake, nbio" \
3414 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003415 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3416 auth_mode=required" \
3417 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003418 0 \
3419 -s "Extra-header:" \
3420 -c "HTTP/1.0 200 OK"
3421
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003422needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003423run_test "DTLS proxy: 3d, min handshake, resumption" \
3424 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3425 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3426 psk=abc123 debug_level=3" \
3427 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3428 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3429 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3430 0 \
3431 -s "a session has been resumed" \
3432 -c "a session has been resumed" \
3433 -s "Extra-header:" \
3434 -c "HTTP/1.0 200 OK"
3435
3436needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003437run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3438 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3439 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3440 psk=abc123 debug_level=3 nbio=2" \
3441 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3442 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3443 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3444 0 \
3445 -s "a session has been resumed" \
3446 -c "a session has been resumed" \
3447 -s "Extra-header:" \
3448 -c "HTTP/1.0 200 OK"
3449
3450needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003451run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003452 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003453 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3454 psk=abc123 renegotiation=1 debug_level=2" \
3455 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3456 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003457 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3458 0 \
3459 -c "=> renegotiate" \
3460 -s "=> renegotiate" \
3461 -s "Extra-header:" \
3462 -c "HTTP/1.0 200 OK"
3463
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003464needs_more_time 4
3465run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3466 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003467 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3468 psk=abc123 renegotiation=1 debug_level=2" \
3469 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3470 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003471 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3472 0 \
3473 -c "=> renegotiate" \
3474 -s "=> renegotiate" \
3475 -s "Extra-header:" \
3476 -c "HTTP/1.0 200 OK"
3477
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003478needs_more_time 4
3479run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003480 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003481 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003482 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003483 debug_level=2" \
3484 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003485 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003486 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3487 0 \
3488 -c "=> renegotiate" \
3489 -s "=> renegotiate" \
3490 -s "Extra-header:" \
3491 -c "HTTP/1.0 200 OK"
3492
3493needs_more_time 4
3494run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003495 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003496 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003497 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003498 debug_level=2 nbio=2" \
3499 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003500 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003501 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3502 0 \
3503 -c "=> renegotiate" \
3504 -s "=> renegotiate" \
3505 -s "Extra-header:" \
3506 -c "HTTP/1.0 200 OK"
3507
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003508needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003509not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003510run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003511 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3512 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003513 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003514 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003515 -c "HTTP/1.0 200 OK"
3516
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003517needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003518not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003519run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3520 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3521 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003522 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003523 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003524 -c "HTTP/1.0 200 OK"
3525
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003526needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003527not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003528run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3529 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3530 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003531 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003532 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003533 -c "HTTP/1.0 200 OK"
3534
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003535requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003536needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003537not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003538run_test "DTLS proxy: 3d, gnutls server" \
3539 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3540 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003541 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003542 0 \
3543 -s "Extra-header:" \
3544 -c "Extra-header:"
3545
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003546requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003547needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003548not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003549run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3550 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3551 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003552 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003553 0 \
3554 -s "Extra-header:" \
3555 -c "Extra-header:"
3556
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003557requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003558needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003559not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003560run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3561 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3562 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003563 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003564 0 \
3565 -s "Extra-header:" \
3566 -c "Extra-header:"
3567
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003568# Final report
3569
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003570echo "------------------------------------------------------------------------"
3571
3572if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003573 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003574else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003575 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003576fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003577PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003578echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003579
3580exit $FAILS