blob: 78ca1cac7b9d74f7b4383d14b8baf9e1037c0df6 [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
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200150# multiply the client timeout delay by the given factor for the next test
151needs_more_time() {
152 CLI_DELAY_FACTOR=$1
153}
154
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100155# print_name <name>
156print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100157 TESTS=$(( $TESTS + 1 ))
158 LINE=""
159
160 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
161 LINE="$TESTS "
162 fi
163
164 LINE="$LINE$1"
165 printf "$LINE "
166 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100167 for i in `seq 1 $LEN`; do printf '.'; done
168 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100169
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100170}
171
172# fail <message>
173fail() {
174 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100175 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100176
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200177 mv $SRV_OUT o-srv-${TESTS}.log
178 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200179 if [ -n "$PXY_CMD" ]; then
180 mv $PXY_OUT o-pxy-${TESTS}.log
181 fi
182 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100183
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200184 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
185 echo " ! server output:"
186 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200187 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200188 echo " ! client output:"
189 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200190 if [ -n "$PXY_CMD" ]; then
191 echo " ! ========================================================"
192 echo " ! proxy output:"
193 cat o-pxy-${TESTS}.log
194 fi
195 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200196 fi
197
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200198 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100199}
200
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100201# is_polar <cmd_line>
202is_polar() {
203 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
204}
205
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200206# openssl s_server doesn't have -www with DTLS
207check_osrv_dtls() {
208 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
209 NEEDS_INPUT=1
210 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
211 else
212 NEEDS_INPUT=0
213 fi
214}
215
216# provide input to commands that need it
217provide_input() {
218 if [ $NEEDS_INPUT -eq 0 ]; then
219 return
220 fi
221
222 while true; do
223 echo "HTTP/1.0 200 OK"
224 sleep 1
225 done
226}
227
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100228# has_mem_err <log_file_name>
229has_mem_err() {
230 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
231 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
232 then
233 return 1 # false: does not have errors
234 else
235 return 0 # true: has errors
236 fi
237}
238
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200239# wait for server to start: two versions depending on lsof availability
240wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200241 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200242 START_TIME=$( date +%s )
243 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200244
245 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200246 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200247 while [ $DONE -eq 0 ]; do
248 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
249 then
250 DONE=1
251 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
252 echo "SERVERSTART TIMEOUT"
253 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
254 DONE=1
255 fi
256 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200257 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200258 while [ $DONE -eq 0 ]; do
259 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
260 then
261 DONE=1
262 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
263 echo "SERVERSTART TIMEOUT"
264 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
265 DONE=1
266 fi
267 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200268 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200269 else
270 sleep "$START_DELAY"
271 fi
272}
273
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200274# wait for client to terminate and set CLI_EXIT
275# must be called right after starting the client
276wait_client_done() {
277 CLI_PID=$!
278
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200279 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
280 CLI_DELAY_FACTOR=1
281
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200282 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200283 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200284
285 wait $CLI_PID
286 CLI_EXIT=$?
287
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200288 kill $DOG_PID >/dev/null 2>&1
289 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200290
291 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
292}
293
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200294# check if the given command uses dtls and sets global variable DTLS
295detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200296 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200297 DTLS=1
298 else
299 DTLS=0
300 fi
301}
302
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200303# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100304# Options: -s pattern pattern that must be present in server output
305# -c pattern pattern that must be present in client output
306# -S pattern pattern that must be absent in server output
307# -C pattern pattern that must be absent in client output
308run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100309 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200310 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100311
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100312 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
313 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200314 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100315 return
316 fi
317
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100318 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100319
Paul Bakkerb7584a52016-05-10 10:50:43 +0100320 # Do we only run numbered tests?
321 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
322 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
323 else
324 SKIP_NEXT="YES"
325 fi
326
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200327 # should we skip?
328 if [ "X$SKIP_NEXT" = "XYES" ]; then
329 SKIP_NEXT="NO"
330 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200331 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200332 return
333 fi
334
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200335 # does this test use a proxy?
336 if [ "X$1" = "X-p" ]; then
337 PXY_CMD="$2"
338 shift 2
339 else
340 PXY_CMD=""
341 fi
342
343 # get commands and client output
344 SRV_CMD="$1"
345 CLI_CMD="$2"
346 CLI_EXPECT="$3"
347 shift 3
348
349 # fix client port
350 if [ -n "$PXY_CMD" ]; then
351 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
352 else
353 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
354 fi
355
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200356 # update DTLS variable
357 detect_dtls "$SRV_CMD"
358
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100359 # prepend valgrind to our commands if active
360 if [ "$MEMCHECK" -gt 0 ]; then
361 if is_polar "$SRV_CMD"; then
362 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
363 fi
364 if is_polar "$CLI_CMD"; then
365 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
366 fi
367 fi
368
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200369 TIMES_LEFT=2
370 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200371 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200372
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200373 # run the commands
374 if [ -n "$PXY_CMD" ]; then
375 echo "$PXY_CMD" > $PXY_OUT
376 $PXY_CMD >> $PXY_OUT 2>&1 &
377 PXY_PID=$!
378 # assume proxy starts faster than server
379 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200380
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200381 check_osrv_dtls
382 echo "$SRV_CMD" > $SRV_OUT
383 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
384 SRV_PID=$!
385 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200386
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200387 echo "$CLI_CMD" > $CLI_OUT
388 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
389 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100390
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200391 # terminate the server (and the proxy)
392 kill $SRV_PID
393 wait $SRV_PID
394 if [ -n "$PXY_CMD" ]; then
395 kill $PXY_PID >/dev/null 2>&1
396 wait $PXY_PID
397 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100398
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200399 # retry only on timeouts
400 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
401 printf "RETRY "
402 else
403 TIMES_LEFT=0
404 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200405 done
406
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100407 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200408 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100409 # expected client exit to incorrectly succeed in case of catastrophic
410 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100411 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200412 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100413 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100414 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100415 return
416 fi
417 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100418 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200419 if grep "Performing the SSL/TLS handshake" $CLI_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
425
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100426 # check server exit code
427 if [ $? != 0 ]; then
428 fail "server fail"
429 return
430 fi
431
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100432 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100433 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
434 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100435 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200436 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100437 return
438 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100439
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100440 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200441 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100442 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100443 while [ $# -gt 0 ]
444 do
445 case $1 in
446 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100447 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 +0100448 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100449 return
450 fi
451 ;;
452
453 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100454 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 +0100455 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100456 return
457 fi
458 ;;
459
460 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100461 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 +0100462 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100463 return
464 fi
465 ;;
466
467 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100468 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 +0100469 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100470 return
471 fi
472 ;;
473
474 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200475 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100476 exit 1
477 esac
478 shift 2
479 done
480
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100481 # check valgrind's results
482 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200483 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100484 fail "Server has memory errors"
485 return
486 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200487 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100488 fail "Client has memory errors"
489 return
490 fi
491 fi
492
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100493 # if we're here, everything is ok
494 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100495 if [ "$PRESERVE_LOGS" -gt 0 ]; then
496 mv $SRV_OUT o-srv-${TESTS}.log
497 mv $CLI_OUT o-cli-${TESTS}.log
498 fi
499
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200500 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100501}
502
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100503cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200504 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200505 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
506 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
507 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
508 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100509 exit 1
510}
511
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100512#
513# MAIN
514#
515
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000516if cd $( dirname $0 ); then :; else
517 echo "cd $( dirname $0 ) failed" >&2
518 exit 1
519fi
520
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100521get_options "$@"
522
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100523# sanity checks, avoid an avalanche of errors
524if [ ! -x "$P_SRV" ]; then
525 echo "Command '$P_SRV' is not an executable file"
526 exit 1
527fi
528if [ ! -x "$P_CLI" ]; then
529 echo "Command '$P_CLI' is not an executable file"
530 exit 1
531fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200532if [ ! -x "$P_PXY" ]; then
533 echo "Command '$P_PXY' is not an executable file"
534 exit 1
535fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100536if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
537 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100538 exit 1
539fi
540
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200541# used by watchdog
542MAIN_PID="$$"
543
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200544# be more patient with valgrind
545if [ "$MEMCHECK" -gt 0 ]; then
546 START_DELAY=3
547 DOG_DELAY=30
548else
549 START_DELAY=1
550 DOG_DELAY=10
551fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200552CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200553
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200554# Pick a "unique" server port in the range 10000-19999, and a proxy port
555PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000556PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200557SRV_PORT="1$PORT_BASE"
558PXY_PORT="2$PORT_BASE"
559unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200560
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200561# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000562# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200563P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
564P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
565P_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 +0200566O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200567O_CLI="$O_CLI -connect localhost:+SRV_PORT"
568G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000569G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200570
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200571# Also pick a unique name for intermediate files
572SRV_OUT="srv_out.$$"
573CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200574PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200575SESSION="session.$$"
576
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200577SKIP_NEXT="NO"
578
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100579trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100580
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200581# Basic test
582
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200583# Checks that:
584# - things work with all ciphersuites active (used with config-full in all.sh)
585# - the expected (highest security) parameters are selected
586# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200587run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200588 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200589 "$P_CLI" \
590 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200591 -s "Protocol is TLSv1.2" \
592 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
593 -s "client hello v3, signature_algorithm ext: 6" \
594 -s "ECDHE curve: secp521r1" \
595 -S "error" \
596 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200597
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000598run_test "Default, DTLS" \
599 "$P_SRV dtls=1" \
600 "$P_CLI dtls=1" \
601 0 \
602 -s "Protocol is DTLSv1.2" \
603 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
604
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100605# Tests for rc4 option
606
607run_test "RC4: server disabled, client enabled" \
608 "$P_SRV" \
609 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
610 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100611 -s "SSL - The server has no ciphersuites in common"
612
613run_test "RC4: server half, client enabled" \
614 "$P_SRV arc4=1" \
615 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
616 1 \
617 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100618
619run_test "RC4: server enabled, client disabled" \
620 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
621 "$P_CLI" \
622 1 \
623 -s "SSL - The server has no ciphersuites in common"
624
625run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100626 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100627 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
628 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100629 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100630 -S "SSL - The server has no ciphersuites in common"
631
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100632# Tests for Truncated HMAC extension
633
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100634run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200635 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100636 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100637 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100638 -s "dumping 'computed mac' (20 bytes)" \
639 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100640
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100641run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200642 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100643 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
644 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100645 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100646 -s "dumping 'computed mac' (20 bytes)" \
647 -S "dumping 'computed mac' (10 bytes)"
648
649run_test "Truncated HMAC: client enabled, server default" \
650 "$P_SRV debug_level=4" \
651 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
652 trunc_hmac=1" \
653 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100654 -s "dumping 'computed mac' (20 bytes)" \
655 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100656
657run_test "Truncated HMAC: client enabled, server disabled" \
658 "$P_SRV debug_level=4 trunc_hmac=0" \
659 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
660 trunc_hmac=1" \
661 0 \
662 -s "dumping 'computed mac' (20 bytes)" \
663 -S "dumping 'computed mac' (10 bytes)"
664
665run_test "Truncated HMAC: client enabled, server enabled" \
666 "$P_SRV debug_level=4 trunc_hmac=1" \
667 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
668 trunc_hmac=1" \
669 0 \
670 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100671 -s "dumping 'computed mac' (10 bytes)"
672
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100673# Tests for Encrypt-then-MAC extension
674
675run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100676 "$P_SRV debug_level=3 \
677 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100678 "$P_CLI debug_level=3" \
679 0 \
680 -c "client hello, adding encrypt_then_mac extension" \
681 -s "found encrypt then mac extension" \
682 -s "server hello, adding encrypt then mac extension" \
683 -c "found encrypt_then_mac extension" \
684 -c "using encrypt then mac" \
685 -s "using encrypt then mac"
686
687run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100688 "$P_SRV debug_level=3 etm=0 \
689 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100690 "$P_CLI debug_level=3 etm=1" \
691 0 \
692 -c "client hello, adding encrypt_then_mac extension" \
693 -s "found encrypt then mac extension" \
694 -S "server hello, adding encrypt then mac extension" \
695 -C "found encrypt_then_mac extension" \
696 -C "using encrypt then mac" \
697 -S "using encrypt then mac"
698
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100699run_test "Encrypt then MAC: client enabled, aead cipher" \
700 "$P_SRV debug_level=3 etm=1 \
701 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
702 "$P_CLI debug_level=3 etm=1" \
703 0 \
704 -c "client hello, adding encrypt_then_mac extension" \
705 -s "found encrypt then mac extension" \
706 -S "server hello, adding encrypt then mac extension" \
707 -C "found encrypt_then_mac extension" \
708 -C "using encrypt then mac" \
709 -S "using encrypt then mac"
710
711run_test "Encrypt then MAC: client enabled, stream cipher" \
712 "$P_SRV debug_level=3 etm=1 \
713 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100714 "$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 +0100715 0 \
716 -c "client hello, adding encrypt_then_mac extension" \
717 -s "found encrypt then mac extension" \
718 -S "server hello, adding encrypt then mac extension" \
719 -C "found encrypt_then_mac extension" \
720 -C "using encrypt then mac" \
721 -S "using encrypt then mac"
722
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100723run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100724 "$P_SRV debug_level=3 etm=1 \
725 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100726 "$P_CLI debug_level=3 etm=0" \
727 0 \
728 -C "client hello, adding encrypt_then_mac extension" \
729 -S "found encrypt then mac extension" \
730 -S "server hello, adding encrypt then mac extension" \
731 -C "found encrypt_then_mac extension" \
732 -C "using encrypt then mac" \
733 -S "using encrypt then mac"
734
Janos Follathe2681a42016-03-07 15:57:05 +0000735requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100736run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100737 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100738 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100739 "$P_CLI debug_level=3 force_version=ssl3" \
740 0 \
741 -C "client hello, adding encrypt_then_mac extension" \
742 -S "found encrypt then mac extension" \
743 -S "server hello, adding encrypt then mac extension" \
744 -C "found encrypt_then_mac extension" \
745 -C "using encrypt then mac" \
746 -S "using encrypt then mac"
747
Janos Follathe2681a42016-03-07 15:57:05 +0000748requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100749run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100750 "$P_SRV debug_level=3 force_version=ssl3 \
751 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100752 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100753 0 \
754 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100755 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100756 -S "server hello, adding encrypt then mac extension" \
757 -C "found encrypt_then_mac extension" \
758 -C "using encrypt then mac" \
759 -S "using encrypt then mac"
760
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200761# Tests for Extended Master Secret extension
762
763run_test "Extended Master Secret: default" \
764 "$P_SRV debug_level=3" \
765 "$P_CLI debug_level=3" \
766 0 \
767 -c "client hello, adding extended_master_secret extension" \
768 -s "found extended master secret extension" \
769 -s "server hello, adding extended master secret extension" \
770 -c "found extended_master_secret extension" \
771 -c "using extended master secret" \
772 -s "using extended master secret"
773
774run_test "Extended Master Secret: client enabled, server disabled" \
775 "$P_SRV debug_level=3 extended_ms=0" \
776 "$P_CLI debug_level=3 extended_ms=1" \
777 0 \
778 -c "client hello, adding extended_master_secret extension" \
779 -s "found extended master secret extension" \
780 -S "server hello, adding extended master secret extension" \
781 -C "found extended_master_secret extension" \
782 -C "using extended master secret" \
783 -S "using extended master secret"
784
785run_test "Extended Master Secret: client disabled, server enabled" \
786 "$P_SRV debug_level=3 extended_ms=1" \
787 "$P_CLI debug_level=3 extended_ms=0" \
788 0 \
789 -C "client hello, adding extended_master_secret extension" \
790 -S "found extended master secret extension" \
791 -S "server hello, adding extended master secret extension" \
792 -C "found extended_master_secret extension" \
793 -C "using extended master secret" \
794 -S "using extended master secret"
795
Janos Follathe2681a42016-03-07 15:57:05 +0000796requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200797run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100798 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200799 "$P_CLI debug_level=3 force_version=ssl3" \
800 0 \
801 -C "client hello, adding extended_master_secret extension" \
802 -S "found extended master secret extension" \
803 -S "server hello, adding extended master secret extension" \
804 -C "found extended_master_secret extension" \
805 -C "using extended master secret" \
806 -S "using extended master secret"
807
Janos Follathe2681a42016-03-07 15:57:05 +0000808requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200809run_test "Extended Master Secret: client enabled, server SSLv3" \
810 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100811 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200812 0 \
813 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100814 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200815 -S "server hello, adding extended master secret extension" \
816 -C "found extended_master_secret extension" \
817 -C "using extended master secret" \
818 -S "using extended master secret"
819
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200820# Tests for FALLBACK_SCSV
821
822run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200823 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200824 "$P_CLI debug_level=3 force_version=tls1_1" \
825 0 \
826 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200827 -S "received FALLBACK_SCSV" \
828 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200829 -C "is a fatal alert message (msg 86)"
830
831run_test "Fallback SCSV: explicitly disabled" \
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 fallback=0" \
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: enabled" \
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=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200843 1 \
844 -c "adding FALLBACK_SCSV" \
845 -s "received FALLBACK_SCSV" \
846 -s "inapropriate fallback" \
847 -c "is a fatal alert message (msg 86)"
848
849run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200850 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200851 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200852 0 \
853 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200854 -s "received FALLBACK_SCSV" \
855 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200856 -C "is a fatal alert message (msg 86)"
857
858requires_openssl_with_fallback_scsv
859run_test "Fallback SCSV: default, openssl server" \
860 "$O_SRV" \
861 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
862 0 \
863 -C "adding FALLBACK_SCSV" \
864 -C "is a fatal alert message (msg 86)"
865
866requires_openssl_with_fallback_scsv
867run_test "Fallback SCSV: enabled, openssl server" \
868 "$O_SRV" \
869 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
870 1 \
871 -c "adding FALLBACK_SCSV" \
872 -c "is a fatal alert message (msg 86)"
873
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200874requires_openssl_with_fallback_scsv
875run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200876 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200877 "$O_CLI -tls1_1" \
878 0 \
879 -S "received FALLBACK_SCSV" \
880 -S "inapropriate fallback"
881
882requires_openssl_with_fallback_scsv
883run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200884 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200885 "$O_CLI -tls1_1 -fallback_scsv" \
886 1 \
887 -s "received FALLBACK_SCSV" \
888 -s "inapropriate fallback"
889
890requires_openssl_with_fallback_scsv
891run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200892 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200893 "$O_CLI -fallback_scsv" \
894 0 \
895 -s "received FALLBACK_SCSV" \
896 -S "inapropriate fallback"
897
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100898# Tests for CBC 1/n-1 record splitting
899
900run_test "CBC Record splitting: TLS 1.2, no splitting" \
901 "$P_SRV" \
902 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
903 request_size=123 force_version=tls1_2" \
904 0 \
905 -s "Read from client: 123 bytes read" \
906 -S "Read from client: 1 bytes read" \
907 -S "122 bytes read"
908
909run_test "CBC Record splitting: TLS 1.1, no splitting" \
910 "$P_SRV" \
911 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
912 request_size=123 force_version=tls1_1" \
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.0, splitting" \
919 "$P_SRV" \
920 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
921 request_size=123 force_version=tls1" \
922 0 \
923 -S "Read from client: 123 bytes read" \
924 -s "Read from client: 1 bytes read" \
925 -s "122 bytes read"
926
Janos Follathe2681a42016-03-07 15:57:05 +0000927requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100928run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100929 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100930 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
931 request_size=123 force_version=ssl3" \
932 0 \
933 -S "Read from client: 123 bytes read" \
934 -s "Read from client: 1 bytes read" \
935 -s "122 bytes read"
936
937run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100938 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100939 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
940 request_size=123 force_version=tls1" \
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, splitting disabled" \
947 "$P_SRV" \
948 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
949 request_size=123 force_version=tls1 recsplit=0" \
950 0 \
951 -s "Read from client: 123 bytes read" \
952 -S "Read from client: 1 bytes read" \
953 -S "122 bytes read"
954
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100955run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
956 "$P_SRV nbio=2" \
957 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
958 request_size=123 force_version=tls1" \
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é-Gonnard780d6712014-02-20 17:19:59 +0100964# Tests for Session Tickets
965
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200966run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200967 "$P_SRV debug_level=3 tickets=1" \
968 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100969 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100970 -c "client hello, adding session ticket extension" \
971 -s "found session ticket extension" \
972 -s "server hello, adding session ticket extension" \
973 -c "found session_ticket extension" \
974 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100975 -S "session successfully restored from cache" \
976 -s "session successfully restored from ticket" \
977 -s "a session has been resumed" \
978 -c "a session has been resumed"
979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200980run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200981 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
982 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100983 0 \
984 -c "client hello, adding session ticket extension" \
985 -s "found session ticket extension" \
986 -s "server hello, adding session ticket extension" \
987 -c "found session_ticket extension" \
988 -c "parse new session ticket" \
989 -S "session successfully restored from cache" \
990 -s "session successfully restored from ticket" \
991 -s "a session has been resumed" \
992 -c "a session has been resumed"
993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200994run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200995 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
996 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100997 0 \
998 -c "client hello, adding session ticket extension" \
999 -s "found session ticket extension" \
1000 -s "server hello, adding session ticket extension" \
1001 -c "found session_ticket extension" \
1002 -c "parse new session ticket" \
1003 -S "session successfully restored from cache" \
1004 -S "session successfully restored from ticket" \
1005 -S "a session has been resumed" \
1006 -C "a session has been resumed"
1007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001008run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001009 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001010 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001011 0 \
1012 -c "client hello, adding session ticket extension" \
1013 -c "found session_ticket extension" \
1014 -c "parse new session ticket" \
1015 -c "a session has been resumed"
1016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001017run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001018 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001019 "( $O_CLI -sess_out $SESSION; \
1020 $O_CLI -sess_in $SESSION; \
1021 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001022 0 \
1023 -s "found session ticket extension" \
1024 -s "server hello, adding session ticket extension" \
1025 -S "session successfully restored from cache" \
1026 -s "session successfully restored from ticket" \
1027 -s "a session has been resumed"
1028
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001029# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001031run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001032 "$P_SRV debug_level=3 tickets=0" \
1033 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001034 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001035 -c "client hello, adding session ticket extension" \
1036 -s "found session ticket extension" \
1037 -S "server hello, adding session ticket extension" \
1038 -C "found session_ticket extension" \
1039 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001040 -s "session successfully restored from cache" \
1041 -S "session successfully restored from ticket" \
1042 -s "a session has been resumed" \
1043 -c "a session has been resumed"
1044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001045run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001046 "$P_SRV debug_level=3 tickets=1" \
1047 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001048 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001049 -C "client hello, adding session ticket extension" \
1050 -S "found session ticket extension" \
1051 -S "server hello, adding session ticket extension" \
1052 -C "found session_ticket extension" \
1053 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001054 -s "session successfully restored from cache" \
1055 -S "session successfully restored from ticket" \
1056 -s "a session has been resumed" \
1057 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001059run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001060 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1061 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001062 0 \
1063 -S "session successfully restored from cache" \
1064 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001065 -S "a session has been resumed" \
1066 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001068run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001069 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1070 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001071 0 \
1072 -s "session successfully restored from cache" \
1073 -S "session successfully restored from ticket" \
1074 -s "a session has been resumed" \
1075 -c "a session has been resumed"
1076
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001077run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001078 "$P_SRV debug_level=3 tickets=0" \
1079 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
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é-Gonnard8e03c712014-08-30 21:42:40 +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 cache_timeout=1" \
1088 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
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: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001096 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1097 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +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: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001105 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001106 "( $O_CLI -sess_out $SESSION; \
1107 $O_CLI -sess_in $SESSION; \
1108 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001109 0 \
1110 -s "found session ticket extension" \
1111 -S "server hello, adding session ticket extension" \
1112 -s "session successfully restored from cache" \
1113 -S "session successfully restored from ticket" \
1114 -s "a session has been resumed"
1115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001116run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001117 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001118 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001119 0 \
1120 -C "found session_ticket extension" \
1121 -C "parse new session ticket" \
1122 -c "a session has been resumed"
1123
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001124# Tests for Max Fragment Length extension
1125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001126run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001127 "$P_SRV debug_level=3" \
1128 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001129 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001130 -c "Maximum fragment length is 16384" \
1131 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001132 -C "client hello, adding max_fragment_length extension" \
1133 -S "found max fragment length extension" \
1134 -S "server hello, max_fragment_length extension" \
1135 -C "found max_fragment_length extension"
1136
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001137run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001138 "$P_SRV debug_level=3" \
1139 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001140 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001141 -c "Maximum fragment length is 4096" \
1142 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001143 -c "client hello, adding max_fragment_length extension" \
1144 -s "found max fragment length extension" \
1145 -s "server hello, max_fragment_length extension" \
1146 -c "found max_fragment_length extension"
1147
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001148run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001149 "$P_SRV debug_level=3 max_frag_len=4096" \
1150 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001151 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001152 -c "Maximum fragment length is 16384" \
1153 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001154 -C "client hello, adding max_fragment_length extension" \
1155 -S "found max fragment length extension" \
1156 -S "server hello, max_fragment_length extension" \
1157 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001158
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001159requires_gnutls
1160run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001161 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001162 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001163 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001164 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001165 -c "client hello, adding max_fragment_length extension" \
1166 -c "found max_fragment_length extension"
1167
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001168run_test "Max fragment length: client, message just fits" \
1169 "$P_SRV debug_level=3" \
1170 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1171 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001172 -c "Maximum fragment length is 2048" \
1173 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001174 -c "client hello, adding max_fragment_length extension" \
1175 -s "found max fragment length extension" \
1176 -s "server hello, max_fragment_length extension" \
1177 -c "found max_fragment_length extension" \
1178 -c "2048 bytes written in 1 fragments" \
1179 -s "2048 bytes read"
1180
1181run_test "Max fragment length: client, larger message" \
1182 "$P_SRV debug_level=3" \
1183 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1184 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001185 -c "Maximum fragment length is 2048" \
1186 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001187 -c "client hello, adding max_fragment_length extension" \
1188 -s "found max fragment length extension" \
1189 -s "server hello, max_fragment_length extension" \
1190 -c "found max_fragment_length extension" \
1191 -c "2345 bytes written in 2 fragments" \
1192 -s "2048 bytes read" \
1193 -s "297 bytes read"
1194
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001195run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001196 "$P_SRV debug_level=3 dtls=1" \
1197 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1198 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001199 -c "Maximum fragment length is 2048" \
1200 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001201 -c "client hello, adding max_fragment_length extension" \
1202 -s "found max fragment length extension" \
1203 -s "server hello, max_fragment_length extension" \
1204 -c "found max_fragment_length extension" \
1205 -c "fragment larger than.*maximum"
1206
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001207# Tests for renegotiation
1208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001209run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001210 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001211 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001212 0 \
1213 -C "client hello, adding renegotiation extension" \
1214 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1215 -S "found renegotiation extension" \
1216 -s "server hello, secure renegotiation extension" \
1217 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001218 -C "=> renegotiate" \
1219 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001220 -S "write hello request"
1221
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001222run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001223 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001224 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001225 0 \
1226 -c "client hello, adding renegotiation extension" \
1227 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1228 -s "found renegotiation extension" \
1229 -s "server hello, secure renegotiation extension" \
1230 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001231 -c "=> renegotiate" \
1232 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001233 -S "write hello request"
1234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001235run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001236 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001237 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001238 0 \
1239 -c "client hello, adding renegotiation extension" \
1240 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1241 -s "found renegotiation extension" \
1242 -s "server hello, secure renegotiation extension" \
1243 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001244 -c "=> renegotiate" \
1245 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001246 -s "write hello request"
1247
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001248run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001249 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001250 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001251 0 \
1252 -c "client hello, adding renegotiation extension" \
1253 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1254 -s "found renegotiation extension" \
1255 -s "server hello, secure renegotiation extension" \
1256 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001257 -c "=> renegotiate" \
1258 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001259 -s "write hello request"
1260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001261run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001262 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001263 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001264 1 \
1265 -c "client hello, adding renegotiation extension" \
1266 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1267 -S "found renegotiation extension" \
1268 -s "server hello, secure renegotiation extension" \
1269 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001270 -c "=> renegotiate" \
1271 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001272 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001273 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001274 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001276run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001277 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001278 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001279 0 \
1280 -C "client hello, adding renegotiation extension" \
1281 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1282 -S "found renegotiation extension" \
1283 -s "server hello, secure renegotiation extension" \
1284 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001285 -C "=> renegotiate" \
1286 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001287 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001288 -S "SSL - An unexpected message was received from our peer" \
1289 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001291run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001292 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001293 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001294 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001295 0 \
1296 -C "client hello, adding renegotiation extension" \
1297 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1298 -S "found renegotiation extension" \
1299 -s "server hello, secure renegotiation extension" \
1300 -c "found renegotiation extension" \
1301 -C "=> renegotiate" \
1302 -S "=> renegotiate" \
1303 -s "write hello request" \
1304 -S "SSL - An unexpected message was received from our peer" \
1305 -S "failed"
1306
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001307# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001308run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001309 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001310 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001311 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001312 0 \
1313 -C "client hello, adding renegotiation extension" \
1314 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1315 -S "found renegotiation extension" \
1316 -s "server hello, secure renegotiation extension" \
1317 -c "found renegotiation extension" \
1318 -C "=> renegotiate" \
1319 -S "=> renegotiate" \
1320 -s "write hello request" \
1321 -S "SSL - An unexpected message was received from our peer" \
1322 -S "failed"
1323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001324run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001325 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001326 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001327 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001328 0 \
1329 -C "client hello, adding renegotiation extension" \
1330 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1331 -S "found renegotiation extension" \
1332 -s "server hello, secure renegotiation extension" \
1333 -c "found renegotiation extension" \
1334 -C "=> renegotiate" \
1335 -S "=> renegotiate" \
1336 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001337 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001339run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001340 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001341 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001342 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001343 0 \
1344 -c "client hello, adding renegotiation extension" \
1345 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1346 -s "found renegotiation extension" \
1347 -s "server hello, secure renegotiation extension" \
1348 -c "found renegotiation extension" \
1349 -c "=> renegotiate" \
1350 -s "=> renegotiate" \
1351 -s "write hello request" \
1352 -S "SSL - An unexpected message was received from our peer" \
1353 -S "failed"
1354
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001355run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001356 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001357 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1358 0 \
1359 -C "client hello, adding renegotiation extension" \
1360 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1361 -S "found renegotiation extension" \
1362 -s "server hello, secure renegotiation extension" \
1363 -c "found renegotiation extension" \
1364 -S "record counter limit reached: renegotiate" \
1365 -C "=> renegotiate" \
1366 -S "=> renegotiate" \
1367 -S "write hello request" \
1368 -S "SSL - An unexpected message was received from our peer" \
1369 -S "failed"
1370
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001371# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001372run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001373 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001374 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001375 0 \
1376 -c "client hello, adding renegotiation extension" \
1377 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1378 -s "found renegotiation extension" \
1379 -s "server hello, secure renegotiation extension" \
1380 -c "found renegotiation extension" \
1381 -s "record counter limit reached: renegotiate" \
1382 -c "=> renegotiate" \
1383 -s "=> renegotiate" \
1384 -s "write hello request" \
1385 -S "SSL - An unexpected message was received from our peer" \
1386 -S "failed"
1387
1388run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001389 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001390 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001391 0 \
1392 -c "client hello, adding renegotiation extension" \
1393 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1394 -s "found renegotiation extension" \
1395 -s "server hello, secure renegotiation extension" \
1396 -c "found renegotiation extension" \
1397 -s "record counter limit reached: renegotiate" \
1398 -c "=> renegotiate" \
1399 -s "=> renegotiate" \
1400 -s "write hello request" \
1401 -S "SSL - An unexpected message was received from our peer" \
1402 -S "failed"
1403
1404run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001405 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001406 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1407 0 \
1408 -C "client hello, adding renegotiation extension" \
1409 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1410 -S "found renegotiation extension" \
1411 -s "server hello, secure renegotiation extension" \
1412 -c "found renegotiation extension" \
1413 -S "record counter limit reached: renegotiate" \
1414 -C "=> renegotiate" \
1415 -S "=> renegotiate" \
1416 -S "write hello request" \
1417 -S "SSL - An unexpected message was received from our peer" \
1418 -S "failed"
1419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001420run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001421 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001422 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001423 0 \
1424 -c "client hello, adding renegotiation extension" \
1425 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1426 -s "found renegotiation extension" \
1427 -s "server hello, secure renegotiation extension" \
1428 -c "found renegotiation extension" \
1429 -c "=> renegotiate" \
1430 -s "=> renegotiate" \
1431 -S "write hello request"
1432
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001433run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001434 "$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 +02001435 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001436 0 \
1437 -c "client hello, adding renegotiation extension" \
1438 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1439 -s "found renegotiation extension" \
1440 -s "server hello, secure renegotiation extension" \
1441 -c "found renegotiation extension" \
1442 -c "=> renegotiate" \
1443 -s "=> renegotiate" \
1444 -s "write hello request"
1445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001446run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001447 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001448 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001449 0 \
1450 -c "client hello, adding renegotiation extension" \
1451 -c "found renegotiation extension" \
1452 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001453 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001454 -C "error" \
1455 -c "HTTP/1.0 200 [Oo][Kk]"
1456
Paul Bakker539d9722015-02-08 16:18:35 +01001457requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001458run_test "Renegotiation: gnutls server strict, client-initiated" \
1459 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001460 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001461 0 \
1462 -c "client hello, adding renegotiation extension" \
1463 -c "found renegotiation extension" \
1464 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001465 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001466 -C "error" \
1467 -c "HTTP/1.0 200 [Oo][Kk]"
1468
Paul Bakker539d9722015-02-08 16:18:35 +01001469requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001470run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1471 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1472 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1473 1 \
1474 -c "client hello, adding renegotiation extension" \
1475 -C "found renegotiation extension" \
1476 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001477 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001478 -c "error" \
1479 -C "HTTP/1.0 200 [Oo][Kk]"
1480
Paul Bakker539d9722015-02-08 16:18:35 +01001481requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001482run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1483 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1484 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1485 allow_legacy=0" \
1486 1 \
1487 -c "client hello, adding renegotiation extension" \
1488 -C "found renegotiation extension" \
1489 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001490 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001491 -c "error" \
1492 -C "HTTP/1.0 200 [Oo][Kk]"
1493
Paul Bakker539d9722015-02-08 16:18:35 +01001494requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001495run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1496 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1497 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1498 allow_legacy=1" \
1499 0 \
1500 -c "client hello, adding renegotiation extension" \
1501 -C "found renegotiation extension" \
1502 -c "=> renegotiate" \
1503 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001504 -C "error" \
1505 -c "HTTP/1.0 200 [Oo][Kk]"
1506
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001507run_test "Renegotiation: DTLS, client-initiated" \
1508 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1509 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1510 0 \
1511 -c "client hello, adding renegotiation extension" \
1512 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1513 -s "found renegotiation extension" \
1514 -s "server hello, secure renegotiation extension" \
1515 -c "found renegotiation extension" \
1516 -c "=> renegotiate" \
1517 -s "=> renegotiate" \
1518 -S "write hello request"
1519
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001520run_test "Renegotiation: DTLS, server-initiated" \
1521 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001522 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1523 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001524 0 \
1525 -c "client hello, adding renegotiation extension" \
1526 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1527 -s "found renegotiation extension" \
1528 -s "server hello, secure renegotiation extension" \
1529 -c "found renegotiation extension" \
1530 -c "=> renegotiate" \
1531 -s "=> renegotiate" \
1532 -s "write hello request"
1533
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001534requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001535run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1536 "$G_SRV -u --mtu 4096" \
1537 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1538 0 \
1539 -c "client hello, adding renegotiation extension" \
1540 -c "found renegotiation extension" \
1541 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001542 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001543 -C "error" \
1544 -s "Extra-header:"
1545
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001546# Test for the "secure renegotation" extension only (no actual renegotiation)
1547
Paul Bakker539d9722015-02-08 16:18:35 +01001548requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001549run_test "Renego ext: gnutls server strict, client default" \
1550 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1551 "$P_CLI debug_level=3" \
1552 0 \
1553 -c "found renegotiation extension" \
1554 -C "error" \
1555 -c "HTTP/1.0 200 [Oo][Kk]"
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 unsafe, client default" \
1559 "$G_SRV --priority=NORMAL:%DISABLE_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 break legacy" \
1568 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1569 "$P_CLI debug_level=3 allow_legacy=-1" \
1570 1 \
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 client strict, server default" \
1577 "$P_SRV debug_level=3" \
1578 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1579 0 \
1580 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1581 -s "server hello, secure renegotiation extension"
1582
Paul Bakker539d9722015-02-08 16:18:35 +01001583requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001584run_test "Renego ext: gnutls client unsafe, server default" \
1585 "$P_SRV debug_level=3" \
1586 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1587 0 \
1588 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1589 -S "server hello, secure renegotiation extension"
1590
Paul Bakker539d9722015-02-08 16:18:35 +01001591requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001592run_test "Renego ext: gnutls client unsafe, server break legacy" \
1593 "$P_SRV debug_level=3 allow_legacy=-1" \
1594 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1595 1 \
1596 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1597 -S "server hello, secure renegotiation extension"
1598
Janos Follath0b242342016-02-17 10:11:21 +00001599# Tests for silently dropping trailing extra bytes in .der certificates
1600
1601requires_gnutls
1602run_test "DER format: no trailing bytes" \
1603 "$P_SRV crt_file=data_files/server5-der0.crt \
1604 key_file=data_files/server5.key" \
1605 "$G_CLI " \
1606 0 \
1607 -c "Handshake was completed" \
1608
1609requires_gnutls
1610run_test "DER format: with a trailing zero byte" \
1611 "$P_SRV crt_file=data_files/server5-der1a.crt \
1612 key_file=data_files/server5.key" \
1613 "$G_CLI " \
1614 0 \
1615 -c "Handshake was completed" \
1616
1617requires_gnutls
1618run_test "DER format: with a trailing random byte" \
1619 "$P_SRV crt_file=data_files/server5-der1b.crt \
1620 key_file=data_files/server5.key" \
1621 "$G_CLI " \
1622 0 \
1623 -c "Handshake was completed" \
1624
1625requires_gnutls
1626run_test "DER format: with 2 trailing random bytes" \
1627 "$P_SRV crt_file=data_files/server5-der2.crt \
1628 key_file=data_files/server5.key" \
1629 "$G_CLI " \
1630 0 \
1631 -c "Handshake was completed" \
1632
1633requires_gnutls
1634run_test "DER format: with 4 trailing random bytes" \
1635 "$P_SRV crt_file=data_files/server5-der4.crt \
1636 key_file=data_files/server5.key" \
1637 "$G_CLI " \
1638 0 \
1639 -c "Handshake was completed" \
1640
1641requires_gnutls
1642run_test "DER format: with 8 trailing random bytes" \
1643 "$P_SRV crt_file=data_files/server5-der8.crt \
1644 key_file=data_files/server5.key" \
1645 "$G_CLI " \
1646 0 \
1647 -c "Handshake was completed" \
1648
1649requires_gnutls
1650run_test "DER format: with 9 trailing random bytes" \
1651 "$P_SRV crt_file=data_files/server5-der9.crt \
1652 key_file=data_files/server5.key" \
1653 "$G_CLI " \
1654 0 \
1655 -c "Handshake was completed" \
1656
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001657# Tests for auth_mode
1658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001659run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001660 "$P_SRV crt_file=data_files/server5-badsign.crt \
1661 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001662 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001663 1 \
1664 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001665 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001666 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001667 -c "X509 - Certificate verification failed"
1668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001669run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001670 "$P_SRV crt_file=data_files/server5-badsign.crt \
1671 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001672 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001673 0 \
1674 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001675 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001676 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001677 -C "X509 - Certificate verification failed"
1678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001679run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001680 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001681 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001682 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001683 0 \
1684 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001685 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001686 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001687 -C "X509 - Certificate verification failed"
1688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001689run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001690 "$P_SRV debug_level=3 auth_mode=required" \
1691 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001692 key_file=data_files/server5.key" \
1693 1 \
1694 -S "skip write certificate request" \
1695 -C "skip parse certificate request" \
1696 -c "got a certificate request" \
1697 -C "skip write certificate" \
1698 -C "skip write certificate verify" \
1699 -S "skip parse certificate verify" \
1700 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001701 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001702 -s "! mbedtls_ssl_handshake returned" \
1703 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001704 -s "X509 - Certificate verification failed"
1705
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001706run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001707 "$P_SRV debug_level=3 auth_mode=optional" \
1708 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001709 key_file=data_files/server5.key" \
1710 0 \
1711 -S "skip write certificate request" \
1712 -C "skip parse certificate request" \
1713 -c "got a certificate request" \
1714 -C "skip write certificate" \
1715 -C "skip write certificate verify" \
1716 -S "skip parse certificate verify" \
1717 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001718 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001719 -S "! mbedtls_ssl_handshake returned" \
1720 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001721 -S "X509 - Certificate verification failed"
1722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001723run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001724 "$P_SRV debug_level=3 auth_mode=none" \
1725 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001726 key_file=data_files/server5.key" \
1727 0 \
1728 -s "skip write certificate request" \
1729 -C "skip parse certificate request" \
1730 -c "got no certificate request" \
1731 -c "skip write certificate" \
1732 -c "skip write certificate verify" \
1733 -s "skip parse certificate verify" \
1734 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001735 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001736 -S "! mbedtls_ssl_handshake returned" \
1737 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001738 -S "X509 - Certificate verification failed"
1739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001740run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001741 "$P_SRV debug_level=3 auth_mode=optional" \
1742 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001743 0 \
1744 -S "skip write certificate request" \
1745 -C "skip parse certificate request" \
1746 -c "got a certificate request" \
1747 -C "skip write certificate$" \
1748 -C "got no certificate to send" \
1749 -S "SSLv3 client has no certificate" \
1750 -c "skip write certificate verify" \
1751 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001752 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001753 -S "! mbedtls_ssl_handshake returned" \
1754 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001755 -S "X509 - Certificate verification failed"
1756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001757run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001758 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001759 "$O_CLI" \
1760 0 \
1761 -S "skip write certificate request" \
1762 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001763 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001764 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001765 -S "X509 - Certificate verification failed"
1766
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001767run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001768 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001769 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001770 0 \
1771 -C "skip parse certificate request" \
1772 -c "got a certificate request" \
1773 -C "skip write certificate$" \
1774 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001775 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001776
Janos Follathe2681a42016-03-07 15:57:05 +00001777requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001778run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001779 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001780 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001781 0 \
1782 -S "skip write certificate request" \
1783 -C "skip parse certificate request" \
1784 -c "got a certificate request" \
1785 -C "skip write certificate$" \
1786 -c "skip write certificate verify" \
1787 -c "got no certificate to send" \
1788 -s "SSLv3 client has no certificate" \
1789 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001790 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001791 -S "! mbedtls_ssl_handshake returned" \
1792 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001793 -S "X509 - Certificate verification failed"
1794
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001795# Tests for certificate selection based on SHA verson
1796
1797run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1798 "$P_SRV crt_file=data_files/server5.crt \
1799 key_file=data_files/server5.key \
1800 crt_file2=data_files/server5-sha1.crt \
1801 key_file2=data_files/server5.key" \
1802 "$P_CLI force_version=tls1_2" \
1803 0 \
1804 -c "signed using.*ECDSA with SHA256" \
1805 -C "signed using.*ECDSA with SHA1"
1806
1807run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1808 "$P_SRV crt_file=data_files/server5.crt \
1809 key_file=data_files/server5.key \
1810 crt_file2=data_files/server5-sha1.crt \
1811 key_file2=data_files/server5.key" \
1812 "$P_CLI force_version=tls1_1" \
1813 0 \
1814 -C "signed using.*ECDSA with SHA256" \
1815 -c "signed using.*ECDSA with SHA1"
1816
1817run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1818 "$P_SRV crt_file=data_files/server5.crt \
1819 key_file=data_files/server5.key \
1820 crt_file2=data_files/server5-sha1.crt \
1821 key_file2=data_files/server5.key" \
1822 "$P_CLI force_version=tls1" \
1823 0 \
1824 -C "signed using.*ECDSA with SHA256" \
1825 -c "signed using.*ECDSA with SHA1"
1826
1827run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1828 "$P_SRV crt_file=data_files/server5.crt \
1829 key_file=data_files/server5.key \
1830 crt_file2=data_files/server6.crt \
1831 key_file2=data_files/server6.key" \
1832 "$P_CLI force_version=tls1_1" \
1833 0 \
1834 -c "serial number.*09" \
1835 -c "signed using.*ECDSA with SHA256" \
1836 -C "signed using.*ECDSA with SHA1"
1837
1838run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1839 "$P_SRV crt_file=data_files/server6.crt \
1840 key_file=data_files/server6.key \
1841 crt_file2=data_files/server5.crt \
1842 key_file2=data_files/server5.key" \
1843 "$P_CLI force_version=tls1_1" \
1844 0 \
1845 -c "serial number.*0A" \
1846 -c "signed using.*ECDSA with SHA256" \
1847 -C "signed using.*ECDSA with SHA1"
1848
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001849# tests for SNI
1850
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001851run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001852 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001853 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001854 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001855 0 \
1856 -S "parse ServerName extension" \
1857 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1858 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001860run_test "SNI: matching cert 1" \
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é-Gonnard4d6f1782015-06-19 14:40:39 +02001863 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 +02001864 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001865 0 \
1866 -s "parse ServerName extension" \
1867 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1868 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001870run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001871 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001872 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001873 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 +02001874 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001875 0 \
1876 -s "parse ServerName extension" \
1877 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1878 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001880run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001881 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001882 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001883 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 +02001884 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001885 1 \
1886 -s "parse ServerName extension" \
1887 -s "ssl_sni_wrapper() returned" \
1888 -s "mbedtls_ssl_handshake returned" \
1889 -c "mbedtls_ssl_handshake returned" \
1890 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001891
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001892run_test "SNI: client auth no override: optional" \
1893 "$P_SRV debug_level=3 auth_mode=optional \
1894 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1895 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1896 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001897 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001898 -S "skip write certificate request" \
1899 -C "skip parse certificate request" \
1900 -c "got a certificate request" \
1901 -C "skip write certificate" \
1902 -C "skip write certificate verify" \
1903 -S "skip parse certificate verify"
1904
1905run_test "SNI: client auth override: none -> optional" \
1906 "$P_SRV debug_level=3 auth_mode=none \
1907 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1908 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1909 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001910 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001911 -S "skip write certificate request" \
1912 -C "skip parse certificate request" \
1913 -c "got a certificate request" \
1914 -C "skip write certificate" \
1915 -C "skip write certificate verify" \
1916 -S "skip parse certificate verify"
1917
1918run_test "SNI: client auth override: optional -> none" \
1919 "$P_SRV debug_level=3 auth_mode=optional \
1920 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1921 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1922 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001923 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001924 -s "skip write certificate request" \
1925 -C "skip parse certificate request" \
1926 -c "got no certificate request" \
1927 -c "skip write certificate" \
1928 -c "skip write certificate verify" \
1929 -s "skip parse certificate verify"
1930
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001931run_test "SNI: CA no override" \
1932 "$P_SRV debug_level=3 auth_mode=optional \
1933 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1934 ca_file=data_files/test-ca.crt \
1935 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1936 "$P_CLI debug_level=3 server_name=localhost \
1937 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1938 1 \
1939 -S "skip write certificate request" \
1940 -C "skip parse certificate request" \
1941 -c "got a certificate request" \
1942 -C "skip write certificate" \
1943 -C "skip write certificate verify" \
1944 -S "skip parse certificate verify" \
1945 -s "x509_verify_cert() returned" \
1946 -s "! The certificate is not correctly signed by the trusted CA" \
1947 -S "The certificate has been revoked (is on a CRL)"
1948
1949run_test "SNI: CA override" \
1950 "$P_SRV debug_level=3 auth_mode=optional \
1951 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1952 ca_file=data_files/test-ca.crt \
1953 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1954 "$P_CLI debug_level=3 server_name=localhost \
1955 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1956 0 \
1957 -S "skip write certificate request" \
1958 -C "skip parse certificate request" \
1959 -c "got a certificate request" \
1960 -C "skip write certificate" \
1961 -C "skip write certificate verify" \
1962 -S "skip parse certificate verify" \
1963 -S "x509_verify_cert() returned" \
1964 -S "! The certificate is not correctly signed by the trusted CA" \
1965 -S "The certificate has been revoked (is on a CRL)"
1966
1967run_test "SNI: CA override with CRL" \
1968 "$P_SRV debug_level=3 auth_mode=optional \
1969 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1970 ca_file=data_files/test-ca.crt \
1971 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1972 "$P_CLI debug_level=3 server_name=localhost \
1973 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1974 1 \
1975 -S "skip write certificate request" \
1976 -C "skip parse certificate request" \
1977 -c "got a certificate request" \
1978 -C "skip write certificate" \
1979 -C "skip write certificate verify" \
1980 -S "skip parse certificate verify" \
1981 -s "x509_verify_cert() returned" \
1982 -S "! The certificate is not correctly signed by the trusted CA" \
1983 -s "The certificate has been revoked (is on a CRL)"
1984
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001985# Tests for non-blocking I/O: exercise a variety of handshake flows
1986
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001987run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001988 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1989 "$P_CLI nbio=2 tickets=0" \
1990 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001991 -S "mbedtls_ssl_handshake returned" \
1992 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001993 -c "Read from server: .* bytes read"
1994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001995run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001996 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1997 "$P_CLI nbio=2 tickets=0" \
1998 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001999 -S "mbedtls_ssl_handshake returned" \
2000 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002001 -c "Read from server: .* bytes read"
2002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002003run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002004 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2005 "$P_CLI nbio=2 tickets=1" \
2006 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002007 -S "mbedtls_ssl_handshake returned" \
2008 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002009 -c "Read from server: .* bytes read"
2010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002011run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002012 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2013 "$P_CLI nbio=2 tickets=1" \
2014 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002015 -S "mbedtls_ssl_handshake returned" \
2016 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002017 -c "Read from server: .* bytes read"
2018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002019run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002020 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2021 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2022 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002023 -S "mbedtls_ssl_handshake returned" \
2024 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002025 -c "Read from server: .* bytes read"
2026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002027run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002028 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2029 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2030 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002031 -S "mbedtls_ssl_handshake returned" \
2032 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002033 -c "Read from server: .* bytes read"
2034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002035run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002036 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2037 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2038 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002039 -S "mbedtls_ssl_handshake returned" \
2040 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002041 -c "Read from server: .* bytes read"
2042
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002043# Tests for version negotiation
2044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002045run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002046 "$P_SRV" \
2047 "$P_CLI" \
2048 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002049 -S "mbedtls_ssl_handshake returned" \
2050 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002051 -s "Protocol is TLSv1.2" \
2052 -c "Protocol is TLSv1.2"
2053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002054run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002055 "$P_SRV" \
2056 "$P_CLI max_version=tls1_1" \
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.1" \
2061 -c "Protocol is TLSv1.1"
2062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002063run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002064 "$P_SRV max_version=tls1_1" \
2065 "$P_CLI" \
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: cli+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 max_version=tls1_1" \
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 max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002082 "$P_SRV min_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 min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002091 "$P_SRV max_version=tls1_1" \
2092 "$P_CLI min_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.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002100 "$P_SRV max_version=tls1_1" \
2101 "$P_CLI min_version=tls1_2" \
2102 1 \
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 -c "SSL - Handshake protocol not within min/max boundaries"
2106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002107run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002108 "$P_SRV min_version=tls1_2" \
2109 "$P_CLI max_version=tls1_1" \
2110 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002111 -s "mbedtls_ssl_handshake returned" \
2112 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002113 -s "SSL - Handshake protocol not within min/max boundaries"
2114
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002115# Tests for ALPN extension
2116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002117run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002118 "$P_SRV debug_level=3" \
2119 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002120 0 \
2121 -C "client hello, adding alpn extension" \
2122 -S "found alpn extension" \
2123 -C "got an alert message, type: \\[2:120]" \
2124 -S "server hello, adding alpn extension" \
2125 -C "found alpn extension " \
2126 -C "Application Layer Protocol is" \
2127 -S "Application Layer Protocol is"
2128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002129run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002130 "$P_SRV debug_level=3" \
2131 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002132 0 \
2133 -c "client hello, adding alpn extension" \
2134 -s "found alpn extension" \
2135 -C "got an alert message, type: \\[2:120]" \
2136 -S "server hello, adding alpn extension" \
2137 -C "found alpn extension " \
2138 -c "Application Layer Protocol is (none)" \
2139 -S "Application Layer Protocol is"
2140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002141run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002142 "$P_SRV debug_level=3 alpn=abc,1234" \
2143 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002144 0 \
2145 -C "client hello, adding alpn extension" \
2146 -S "found alpn extension" \
2147 -C "got an alert message, type: \\[2:120]" \
2148 -S "server hello, adding alpn extension" \
2149 -C "found alpn extension " \
2150 -C "Application Layer Protocol is" \
2151 -s "Application Layer Protocol is (none)"
2152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002153run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002154 "$P_SRV debug_level=3 alpn=abc,1234" \
2155 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002156 0 \
2157 -c "client hello, adding alpn extension" \
2158 -s "found alpn extension" \
2159 -C "got an alert message, type: \\[2:120]" \
2160 -s "server hello, adding alpn extension" \
2161 -c "found alpn extension" \
2162 -c "Application Layer Protocol is abc" \
2163 -s "Application Layer Protocol is abc"
2164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002165run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002166 "$P_SRV debug_level=3 alpn=abc,1234" \
2167 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002168 0 \
2169 -c "client hello, adding alpn extension" \
2170 -s "found alpn extension" \
2171 -C "got an alert message, type: \\[2:120]" \
2172 -s "server hello, adding alpn extension" \
2173 -c "found alpn extension" \
2174 -c "Application Layer Protocol is abc" \
2175 -s "Application Layer Protocol is abc"
2176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002177run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002178 "$P_SRV debug_level=3 alpn=abc,1234" \
2179 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002180 0 \
2181 -c "client hello, adding alpn extension" \
2182 -s "found alpn extension" \
2183 -C "got an alert message, type: \\[2:120]" \
2184 -s "server hello, adding alpn extension" \
2185 -c "found alpn extension" \
2186 -c "Application Layer Protocol is 1234" \
2187 -s "Application Layer Protocol is 1234"
2188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002189run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002190 "$P_SRV debug_level=3 alpn=abc,123" \
2191 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002192 1 \
2193 -c "client hello, adding alpn extension" \
2194 -s "found alpn extension" \
2195 -c "got an alert message, type: \\[2:120]" \
2196 -S "server hello, adding alpn extension" \
2197 -C "found alpn extension" \
2198 -C "Application Layer Protocol is 1234" \
2199 -S "Application Layer Protocol is 1234"
2200
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002201
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002202# Tests for keyUsage in leaf certificates, part 1:
2203# server-side certificate/suite selection
2204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002205run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002206 "$P_SRV key_file=data_files/server2.key \
2207 crt_file=data_files/server2.ku-ds.crt" \
2208 "$P_CLI" \
2209 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002210 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002211
2212
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002213run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002214 "$P_SRV key_file=data_files/server2.key \
2215 crt_file=data_files/server2.ku-ke.crt" \
2216 "$P_CLI" \
2217 0 \
2218 -c "Ciphersuite is TLS-RSA-WITH-"
2219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002220run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002221 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002222 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002223 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002224 1 \
2225 -C "Ciphersuite is "
2226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002227run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002228 "$P_SRV key_file=data_files/server5.key \
2229 crt_file=data_files/server5.ku-ds.crt" \
2230 "$P_CLI" \
2231 0 \
2232 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2233
2234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002235run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002236 "$P_SRV key_file=data_files/server5.key \
2237 crt_file=data_files/server5.ku-ka.crt" \
2238 "$P_CLI" \
2239 0 \
2240 -c "Ciphersuite is TLS-ECDH-"
2241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002242run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002243 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002244 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002245 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002246 1 \
2247 -C "Ciphersuite is "
2248
2249# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002250# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002252run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002253 "$O_SRV -key data_files/server2.key \
2254 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002255 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002256 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2257 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002258 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002259 -C "Processing of the Certificate handshake message failed" \
2260 -c "Ciphersuite is TLS-"
2261
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002262run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002263 "$O_SRV -key data_files/server2.key \
2264 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002265 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002266 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2267 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002268 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002269 -C "Processing of the Certificate handshake message failed" \
2270 -c "Ciphersuite is TLS-"
2271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002272run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002273 "$O_SRV -key data_files/server2.key \
2274 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002275 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002276 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2277 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002278 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002279 -C "Processing of the Certificate handshake message failed" \
2280 -c "Ciphersuite is TLS-"
2281
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002282run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002283 "$O_SRV -key data_files/server2.key \
2284 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002285 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002286 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2287 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002288 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002289 -c "Processing of the Certificate handshake message failed" \
2290 -C "Ciphersuite is TLS-"
2291
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002292run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2293 "$O_SRV -key data_files/server2.key \
2294 -cert data_files/server2.ku-ke.crt" \
2295 "$P_CLI debug_level=1 auth_mode=optional \
2296 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2297 0 \
2298 -c "bad certificate (usage extensions)" \
2299 -C "Processing of the Certificate handshake message failed" \
2300 -c "Ciphersuite is TLS-" \
2301 -c "! Usage does not match the keyUsage extension"
2302
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002303run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002304 "$O_SRV -key data_files/server2.key \
2305 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002306 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002307 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2308 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002309 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002310 -C "Processing of the Certificate handshake message failed" \
2311 -c "Ciphersuite is TLS-"
2312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002313run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002314 "$O_SRV -key data_files/server2.key \
2315 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002316 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002317 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2318 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002319 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002320 -c "Processing of the Certificate handshake message failed" \
2321 -C "Ciphersuite is TLS-"
2322
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002323run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2324 "$O_SRV -key data_files/server2.key \
2325 -cert data_files/server2.ku-ds.crt" \
2326 "$P_CLI debug_level=1 auth_mode=optional \
2327 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2328 0 \
2329 -c "bad certificate (usage extensions)" \
2330 -C "Processing of the Certificate handshake message failed" \
2331 -c "Ciphersuite is TLS-" \
2332 -c "! Usage does not match the keyUsage extension"
2333
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002334# Tests for keyUsage in leaf certificates, part 3:
2335# server-side checking of client cert
2336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002337run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002338 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002339 "$O_CLI -key data_files/server2.key \
2340 -cert data_files/server2.ku-ds.crt" \
2341 0 \
2342 -S "bad certificate (usage extensions)" \
2343 -S "Processing of the Certificate handshake message failed"
2344
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002345run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002346 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002347 "$O_CLI -key data_files/server2.key \
2348 -cert data_files/server2.ku-ke.crt" \
2349 0 \
2350 -s "bad certificate (usage extensions)" \
2351 -S "Processing of the Certificate handshake message failed"
2352
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002353run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002354 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002355 "$O_CLI -key data_files/server2.key \
2356 -cert data_files/server2.ku-ke.crt" \
2357 1 \
2358 -s "bad certificate (usage extensions)" \
2359 -s "Processing of the Certificate handshake message failed"
2360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002361run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002362 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002363 "$O_CLI -key data_files/server5.key \
2364 -cert data_files/server5.ku-ds.crt" \
2365 0 \
2366 -S "bad certificate (usage extensions)" \
2367 -S "Processing of the Certificate handshake message failed"
2368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002369run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002370 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002371 "$O_CLI -key data_files/server5.key \
2372 -cert data_files/server5.ku-ka.crt" \
2373 0 \
2374 -s "bad certificate (usage extensions)" \
2375 -S "Processing of the Certificate handshake message failed"
2376
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002377# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002379run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002380 "$P_SRV key_file=data_files/server5.key \
2381 crt_file=data_files/server5.eku-srv.crt" \
2382 "$P_CLI" \
2383 0
2384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002385run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002386 "$P_SRV key_file=data_files/server5.key \
2387 crt_file=data_files/server5.eku-srv.crt" \
2388 "$P_CLI" \
2389 0
2390
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002391run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002392 "$P_SRV key_file=data_files/server5.key \
2393 crt_file=data_files/server5.eku-cs_any.crt" \
2394 "$P_CLI" \
2395 0
2396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002397run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002398 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002399 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002400 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002401 1
2402
2403# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002405run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002406 "$O_SRV -key data_files/server5.key \
2407 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002408 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002409 0 \
2410 -C "bad certificate (usage extensions)" \
2411 -C "Processing of the Certificate handshake message failed" \
2412 -c "Ciphersuite is TLS-"
2413
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002414run_test "extKeyUsage cli: serverAuth,clientAuth -> 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_cli.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: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002424 "$O_SRV -key data_files/server5.key \
2425 -cert data_files/server5.eku-cs_any.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 -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002433 "$O_SRV -key data_files/server5.key \
2434 -cert data_files/server5.eku-cs.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 1 \
2437 -c "bad certificate (usage extensions)" \
2438 -c "Processing of the Certificate handshake message failed" \
2439 -C "Ciphersuite is TLS-"
2440
2441# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2442
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002443run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002444 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002445 "$O_CLI -key data_files/server5.key \
2446 -cert data_files/server5.eku-cli.crt" \
2447 0 \
2448 -S "bad certificate (usage extensions)" \
2449 -S "Processing of the Certificate handshake message failed"
2450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002451run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002452 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002453 "$O_CLI -key data_files/server5.key \
2454 -cert data_files/server5.eku-srv_cli.crt" \
2455 0 \
2456 -S "bad certificate (usage extensions)" \
2457 -S "Processing of the Certificate handshake message failed"
2458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002459run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002460 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002461 "$O_CLI -key data_files/server5.key \
2462 -cert data_files/server5.eku-cs_any.crt" \
2463 0 \
2464 -S "bad certificate (usage extensions)" \
2465 -S "Processing of the Certificate handshake message failed"
2466
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002467run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002468 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002469 "$O_CLI -key data_files/server5.key \
2470 -cert data_files/server5.eku-cs.crt" \
2471 0 \
2472 -s "bad certificate (usage extensions)" \
2473 -S "Processing of the Certificate handshake message failed"
2474
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002475run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002476 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002477 "$O_CLI -key data_files/server5.key \
2478 -cert data_files/server5.eku-cs.crt" \
2479 1 \
2480 -s "bad certificate (usage extensions)" \
2481 -s "Processing of the Certificate handshake message failed"
2482
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002483# Tests for DHM parameters loading
2484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002485run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002486 "$P_SRV" \
2487 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2488 debug_level=3" \
2489 0 \
2490 -c "value of 'DHM: P ' (2048 bits)" \
2491 -c "value of 'DHM: G ' (2048 bits)"
2492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002493run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002494 "$P_SRV dhm_file=data_files/dhparams.pem" \
2495 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2496 debug_level=3" \
2497 0 \
2498 -c "value of 'DHM: P ' (1024 bits)" \
2499 -c "value of 'DHM: G ' (2 bits)"
2500
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002501# Tests for DHM client-side size checking
2502
2503run_test "DHM size: server default, client default, OK" \
2504 "$P_SRV" \
2505 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2506 debug_level=1" \
2507 0 \
2508 -C "DHM prime too short:"
2509
2510run_test "DHM size: server default, client 2048, OK" \
2511 "$P_SRV" \
2512 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2513 debug_level=1 dhmlen=2048" \
2514 0 \
2515 -C "DHM prime too short:"
2516
2517run_test "DHM size: server 1024, client default, OK" \
2518 "$P_SRV dhm_file=data_files/dhparams.pem" \
2519 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2520 debug_level=1" \
2521 0 \
2522 -C "DHM prime too short:"
2523
2524run_test "DHM size: server 1000, client default, rejected" \
2525 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2526 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2527 debug_level=1" \
2528 1 \
2529 -c "DHM prime too short:"
2530
2531run_test "DHM size: server default, client 2049, rejected" \
2532 "$P_SRV" \
2533 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2534 debug_level=1 dhmlen=2049" \
2535 1 \
2536 -c "DHM prime too short:"
2537
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002538# Tests for PSK callback
2539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002540run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002541 "$P_SRV psk=abc123 psk_identity=foo" \
2542 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2543 psk_identity=foo psk=abc123" \
2544 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002545 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002546 -S "SSL - Unknown identity received" \
2547 -S "SSL - Verification of the message MAC failed"
2548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002549run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002550 "$P_SRV" \
2551 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2552 psk_identity=foo psk=abc123" \
2553 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002554 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +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: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002559 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
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: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002568 "$P_SRV psk_list=abc,dead,def,beef" \
2569 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2570 psk_identity=abc psk=dead" \
2571 0 \
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: second 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=def psk=beef" \
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: no match" \
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=ghi psk=beef" \
2589 1 \
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: wrong key" \
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=abc 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"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002602
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002603# Tests for EC J-PAKE
2604
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002605requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002606run_test "ECJPAKE: client not configured" \
2607 "$P_SRV debug_level=3" \
2608 "$P_CLI debug_level=3" \
2609 0 \
2610 -C "add ciphersuite: c0ff" \
2611 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002612 -S "found ecjpake kkpp extension" \
2613 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002614 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002615 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002616 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002617 -S "None of the common ciphersuites is usable"
2618
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002619requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002620run_test "ECJPAKE: server not configured" \
2621 "$P_SRV debug_level=3" \
2622 "$P_CLI debug_level=3 ecjpake_pw=bla \
2623 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2624 1 \
2625 -c "add ciphersuite: c0ff" \
2626 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002627 -s "found ecjpake kkpp extension" \
2628 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002629 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002630 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002631 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002632 -s "None of the common ciphersuites is usable"
2633
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002634requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002635run_test "ECJPAKE: working, TLS" \
2636 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2637 "$P_CLI debug_level=3 ecjpake_pw=bla \
2638 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002639 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002640 -c "add ciphersuite: c0ff" \
2641 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002642 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002643 -s "found ecjpake kkpp extension" \
2644 -S "skip ecjpake kkpp extension" \
2645 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002646 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002647 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002648 -S "None of the common ciphersuites is usable" \
2649 -S "SSL - Verification of the message MAC failed"
2650
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002651requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002652run_test "ECJPAKE: password mismatch, TLS" \
2653 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2654 "$P_CLI debug_level=3 ecjpake_pw=bad \
2655 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2656 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002657 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002658 -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: working, DTLS" \
2662 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2663 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2664 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2665 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002666 -c "re-using cached ecjpake parameters" \
2667 -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é-Gonnardd0d8cb32015-09-17 14:16:30 +02002670run_test "ECJPAKE: working, DTLS, no cookie" \
2671 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2672 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2673 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2674 0 \
2675 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002676 -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é-Gonnard921f2d02015-09-16 22:52:18 +02002679run_test "ECJPAKE: password mismatch, DTLS" \
2680 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2681 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2682 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2683 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002684 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002685 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002686
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002687# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002688requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002689run_test "ECJPAKE: working, DTLS, nolog" \
2690 "$P_SRV dtls=1 ecjpake_pw=bla" \
2691 "$P_CLI dtls=1 ecjpake_pw=bla \
2692 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2693 0
2694
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002695# Tests for ciphersuites per version
2696
Janos Follathe2681a42016-03-07 15:57:05 +00002697requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002698run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002699 "$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 +02002700 "$P_CLI force_version=ssl3" \
2701 0 \
2702 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2703
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002704run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002705 "$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 +01002706 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002707 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002708 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002709
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002710run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002711 "$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 +02002712 "$P_CLI force_version=tls1_1" \
2713 0 \
2714 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002716run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002717 "$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 +02002718 "$P_CLI force_version=tls1_2" \
2719 0 \
2720 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2721
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002722# Test for ClientHello without extensions
2723
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002724requires_gnutls
2725run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002726 "$P_SRV debug_level=3" \
2727 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2728 0 \
2729 -s "dumping 'client hello extensions' (0 bytes)"
2730
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002731# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002732
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002733run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002734 "$P_SRV" \
2735 "$P_CLI request_size=100" \
2736 0 \
2737 -s "Read from client: 100 bytes read$"
2738
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002739run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002740 "$P_SRV" \
2741 "$P_CLI request_size=500" \
2742 0 \
2743 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002744
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002745# Tests for small packets
2746
Janos Follathe2681a42016-03-07 15:57:05 +00002747requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002748run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002749 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002750 "$P_CLI request_size=1 force_version=ssl3 \
2751 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2752 0 \
2753 -s "Read from client: 1 bytes read"
2754
Janos Follathe2681a42016-03-07 15:57:05 +00002755requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002756run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002757 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002758 "$P_CLI request_size=1 force_version=ssl3 \
2759 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2760 0 \
2761 -s "Read from client: 1 bytes read"
2762
2763run_test "Small packet TLS 1.0 BlockCipher" \
2764 "$P_SRV" \
2765 "$P_CLI request_size=1 force_version=tls1 \
2766 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2767 0 \
2768 -s "Read from client: 1 bytes read"
2769
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002770run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2771 "$P_SRV" \
2772 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2773 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2774 0 \
2775 -s "Read from client: 1 bytes read"
2776
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002777run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2778 "$P_SRV" \
2779 "$P_CLI request_size=1 force_version=tls1 \
2780 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2781 trunc_hmac=1" \
2782 0 \
2783 -s "Read from client: 1 bytes read"
2784
2785run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002786 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002787 "$P_CLI request_size=1 force_version=tls1 \
2788 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2789 trunc_hmac=1" \
2790 0 \
2791 -s "Read from client: 1 bytes read"
2792
2793run_test "Small packet TLS 1.1 BlockCipher" \
2794 "$P_SRV" \
2795 "$P_CLI request_size=1 force_version=tls1_1 \
2796 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2797 0 \
2798 -s "Read from client: 1 bytes read"
2799
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002800run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2801 "$P_SRV" \
2802 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2803 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2804 0 \
2805 -s "Read from client: 1 bytes read"
2806
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002807run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002808 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002809 "$P_CLI request_size=1 force_version=tls1_1 \
2810 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2811 0 \
2812 -s "Read from client: 1 bytes read"
2813
2814run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2815 "$P_SRV" \
2816 "$P_CLI request_size=1 force_version=tls1_1 \
2817 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2818 trunc_hmac=1" \
2819 0 \
2820 -s "Read from client: 1 bytes read"
2821
2822run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002823 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002824 "$P_CLI request_size=1 force_version=tls1_1 \
2825 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2826 trunc_hmac=1" \
2827 0 \
2828 -s "Read from client: 1 bytes read"
2829
2830run_test "Small packet TLS 1.2 BlockCipher" \
2831 "$P_SRV" \
2832 "$P_CLI request_size=1 force_version=tls1_2 \
2833 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2834 0 \
2835 -s "Read from client: 1 bytes read"
2836
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002837run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2838 "$P_SRV" \
2839 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2840 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2841 0 \
2842 -s "Read from client: 1 bytes read"
2843
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002844run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2845 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002846 "$P_CLI request_size=1 force_version=tls1_2 \
2847 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002848 0 \
2849 -s "Read from client: 1 bytes read"
2850
2851run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2852 "$P_SRV" \
2853 "$P_CLI request_size=1 force_version=tls1_2 \
2854 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2855 trunc_hmac=1" \
2856 0 \
2857 -s "Read from client: 1 bytes read"
2858
2859run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002860 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002861 "$P_CLI request_size=1 force_version=tls1_2 \
2862 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2863 0 \
2864 -s "Read from client: 1 bytes read"
2865
2866run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002867 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002868 "$P_CLI request_size=1 force_version=tls1_2 \
2869 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2870 trunc_hmac=1" \
2871 0 \
2872 -s "Read from client: 1 bytes read"
2873
2874run_test "Small packet TLS 1.2 AEAD" \
2875 "$P_SRV" \
2876 "$P_CLI request_size=1 force_version=tls1_2 \
2877 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2878 0 \
2879 -s "Read from client: 1 bytes read"
2880
2881run_test "Small packet TLS 1.2 AEAD shorter tag" \
2882 "$P_SRV" \
2883 "$P_CLI request_size=1 force_version=tls1_2 \
2884 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2885 0 \
2886 -s "Read from client: 1 bytes read"
2887
Janos Follath00efff72016-05-06 13:48:23 +01002888# A test for extensions in SSLv3
2889
2890requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2891run_test "SSLv3 with extensions, server side" \
2892 "$P_SRV min_version=ssl3 debug_level=3" \
2893 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2894 0 \
2895 -S "dumping 'client hello extensions'" \
2896 -S "server hello, total extension length:"
2897
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002898# Test for large packets
2899
Janos Follathe2681a42016-03-07 15:57:05 +00002900requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002901run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002902 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002903 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002904 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2905 0 \
2906 -s "Read from client: 16384 bytes read"
2907
Janos Follathe2681a42016-03-07 15:57:05 +00002908requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002909run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002910 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002911 "$P_CLI request_size=16384 force_version=ssl3 \
2912 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2913 0 \
2914 -s "Read from client: 16384 bytes read"
2915
2916run_test "Large packet TLS 1.0 BlockCipher" \
2917 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002918 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002919 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2920 0 \
2921 -s "Read from client: 16384 bytes read"
2922
2923run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2924 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002925 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002926 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2927 trunc_hmac=1" \
2928 0 \
2929 -s "Read from client: 16384 bytes read"
2930
2931run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002932 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002933 "$P_CLI request_size=16384 force_version=tls1 \
2934 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2935 trunc_hmac=1" \
2936 0 \
2937 -s "Read from client: 16384 bytes read"
2938
2939run_test "Large packet TLS 1.1 BlockCipher" \
2940 "$P_SRV" \
2941 "$P_CLI request_size=16384 force_version=tls1_1 \
2942 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2943 0 \
2944 -s "Read from client: 16384 bytes read"
2945
2946run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002947 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002948 "$P_CLI request_size=16384 force_version=tls1_1 \
2949 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2950 0 \
2951 -s "Read from client: 16384 bytes read"
2952
2953run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2954 "$P_SRV" \
2955 "$P_CLI request_size=16384 force_version=tls1_1 \
2956 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2957 trunc_hmac=1" \
2958 0 \
2959 -s "Read from client: 16384 bytes read"
2960
2961run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002962 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002963 "$P_CLI request_size=16384 force_version=tls1_1 \
2964 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2965 trunc_hmac=1" \
2966 0 \
2967 -s "Read from client: 16384 bytes read"
2968
2969run_test "Large packet TLS 1.2 BlockCipher" \
2970 "$P_SRV" \
2971 "$P_CLI request_size=16384 force_version=tls1_2 \
2972 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2973 0 \
2974 -s "Read from client: 16384 bytes read"
2975
2976run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2977 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002978 "$P_CLI request_size=16384 force_version=tls1_2 \
2979 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002980 0 \
2981 -s "Read from client: 16384 bytes read"
2982
2983run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2984 "$P_SRV" \
2985 "$P_CLI request_size=16384 force_version=tls1_2 \
2986 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2987 trunc_hmac=1" \
2988 0 \
2989 -s "Read from client: 16384 bytes read"
2990
2991run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002992 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002993 "$P_CLI request_size=16384 force_version=tls1_2 \
2994 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2995 0 \
2996 -s "Read from client: 16384 bytes read"
2997
2998run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002999 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003000 "$P_CLI request_size=16384 force_version=tls1_2 \
3001 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3002 trunc_hmac=1" \
3003 0 \
3004 -s "Read from client: 16384 bytes read"
3005
3006run_test "Large packet TLS 1.2 AEAD" \
3007 "$P_SRV" \
3008 "$P_CLI request_size=16384 force_version=tls1_2 \
3009 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3010 0 \
3011 -s "Read from client: 16384 bytes read"
3012
3013run_test "Large packet TLS 1.2 AEAD shorter tag" \
3014 "$P_SRV" \
3015 "$P_CLI request_size=16384 force_version=tls1_2 \
3016 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3017 0 \
3018 -s "Read from client: 16384 bytes read"
3019
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003020# Tests for DTLS HelloVerifyRequest
3021
3022run_test "DTLS cookie: enabled" \
3023 "$P_SRV dtls=1 debug_level=2" \
3024 "$P_CLI dtls=1 debug_level=2" \
3025 0 \
3026 -s "cookie verification failed" \
3027 -s "cookie verification passed" \
3028 -S "cookie verification skipped" \
3029 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003030 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003031 -S "SSL - The requested feature is not available"
3032
3033run_test "DTLS cookie: disabled" \
3034 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3035 "$P_CLI dtls=1 debug_level=2" \
3036 0 \
3037 -S "cookie verification failed" \
3038 -S "cookie verification passed" \
3039 -s "cookie verification skipped" \
3040 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003041 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003042 -S "SSL - The requested feature is not available"
3043
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003044run_test "DTLS cookie: default (failing)" \
3045 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3046 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3047 1 \
3048 -s "cookie verification failed" \
3049 -S "cookie verification passed" \
3050 -S "cookie verification skipped" \
3051 -C "received hello verify request" \
3052 -S "hello verification requested" \
3053 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003054
3055requires_ipv6
3056run_test "DTLS cookie: enabled, IPv6" \
3057 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3058 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3059 0 \
3060 -s "cookie verification failed" \
3061 -s "cookie verification passed" \
3062 -S "cookie verification skipped" \
3063 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003064 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003065 -S "SSL - The requested feature is not available"
3066
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003067run_test "DTLS cookie: enabled, nbio" \
3068 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3069 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3070 0 \
3071 -s "cookie verification failed" \
3072 -s "cookie verification passed" \
3073 -S "cookie verification skipped" \
3074 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003075 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003076 -S "SSL - The requested feature is not available"
3077
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003078# Tests for client reconnecting from the same port with DTLS
3079
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003080not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003081run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003082 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3083 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003084 0 \
3085 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003086 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003087 -S "Client initiated reconnection from same port"
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: reconnect" \
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 reconnect_hard=1" \
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
3098run_test "DTLS client reconnect from same port: reconnect, nbio" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003099 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3100 "$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 +02003101 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003102 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003103 -s "Client initiated reconnection from same port"
3104
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003105run_test "DTLS client reconnect from same port: no cookies" \
3106 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003107 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3108 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003109 -s "The operation timed out" \
3110 -S "Client initiated reconnection from same port"
3111
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003112# Tests for various cases of client authentication with DTLS
3113# (focused on handshake flows and message parsing)
3114
3115run_test "DTLS client auth: required" \
3116 "$P_SRV dtls=1 auth_mode=required" \
3117 "$P_CLI dtls=1" \
3118 0 \
3119 -s "Verifying peer X.509 certificate... ok"
3120
3121run_test "DTLS client auth: optional, client has no cert" \
3122 "$P_SRV dtls=1 auth_mode=optional" \
3123 "$P_CLI dtls=1 crt_file=none key_file=none" \
3124 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003125 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003126
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003127run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003128 "$P_SRV dtls=1 auth_mode=none" \
3129 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3130 0 \
3131 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003132 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003133
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003134run_test "DTLS wrong PSK: badmac alert" \
3135 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3136 "$P_CLI dtls=1 psk=abc124" \
3137 1 \
3138 -s "SSL - Verification of the message MAC failed" \
3139 -c "SSL - A fatal alert message was received from our peer"
3140
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003141# Tests for receiving fragmented handshake messages with DTLS
3142
3143requires_gnutls
3144run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3145 "$G_SRV -u --mtu 2048 -a" \
3146 "$P_CLI dtls=1 debug_level=2" \
3147 0 \
3148 -C "found fragmented DTLS handshake message" \
3149 -C "error"
3150
3151requires_gnutls
3152run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3153 "$G_SRV -u --mtu 512" \
3154 "$P_CLI dtls=1 debug_level=2" \
3155 0 \
3156 -c "found fragmented DTLS handshake message" \
3157 -C "error"
3158
3159requires_gnutls
3160run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3161 "$G_SRV -u --mtu 128" \
3162 "$P_CLI dtls=1 debug_level=2" \
3163 0 \
3164 -c "found fragmented DTLS handshake message" \
3165 -C "error"
3166
3167requires_gnutls
3168run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3169 "$G_SRV -u --mtu 128" \
3170 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3171 0 \
3172 -c "found fragmented DTLS handshake message" \
3173 -C "error"
3174
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003175requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003176run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3177 "$G_SRV -u --mtu 256" \
3178 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3179 0 \
3180 -c "found fragmented DTLS handshake message" \
3181 -c "client hello, adding renegotiation extension" \
3182 -c "found renegotiation extension" \
3183 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003184 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003185 -C "error" \
3186 -s "Extra-header:"
3187
3188requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003189run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3190 "$G_SRV -u --mtu 256" \
3191 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3192 0 \
3193 -c "found fragmented DTLS handshake message" \
3194 -c "client hello, adding renegotiation extension" \
3195 -c "found renegotiation extension" \
3196 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003197 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003198 -C "error" \
3199 -s "Extra-header:"
3200
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003201run_test "DTLS reassembly: no fragmentation (openssl server)" \
3202 "$O_SRV -dtls1 -mtu 2048" \
3203 "$P_CLI dtls=1 debug_level=2" \
3204 0 \
3205 -C "found fragmented DTLS handshake message" \
3206 -C "error"
3207
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003208run_test "DTLS reassembly: some fragmentation (openssl server)" \
3209 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003210 "$P_CLI dtls=1 debug_level=2" \
3211 0 \
3212 -c "found fragmented DTLS handshake message" \
3213 -C "error"
3214
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003215run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003216 "$O_SRV -dtls1 -mtu 256" \
3217 "$P_CLI dtls=1 debug_level=2" \
3218 0 \
3219 -c "found fragmented DTLS handshake message" \
3220 -C "error"
3221
3222run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3223 "$O_SRV -dtls1 -mtu 256" \
3224 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3225 0 \
3226 -c "found fragmented DTLS handshake message" \
3227 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003228
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003229# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003230
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003231not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003232run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003233 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003234 "$P_SRV dtls=1 debug_level=2" \
3235 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003236 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003237 -C "replayed record" \
3238 -S "replayed record" \
3239 -C "record from another epoch" \
3240 -S "record from another epoch" \
3241 -C "discarding invalid record" \
3242 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003243 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003244 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003245 -c "HTTP/1.0 200 OK"
3246
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003247not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003248run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003249 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003250 "$P_SRV dtls=1 debug_level=2" \
3251 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003252 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003253 -c "replayed record" \
3254 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003255 -c "discarding invalid record" \
3256 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003257 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003258 -s "Extra-header:" \
3259 -c "HTTP/1.0 200 OK"
3260
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003261run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3262 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003263 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3264 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003265 0 \
3266 -c "replayed record" \
3267 -S "replayed record" \
3268 -c "discarding invalid record" \
3269 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003270 -c "resend" \
3271 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003272 -s "Extra-header:" \
3273 -c "HTTP/1.0 200 OK"
3274
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003275run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003276 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003277 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003278 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003279 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003280 -c "discarding invalid record (mac)" \
3281 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003282 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003283 -c "HTTP/1.0 200 OK" \
3284 -S "too many records with bad MAC" \
3285 -S "Verification of the message MAC failed"
3286
3287run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3288 -p "$P_PXY bad_ad=1" \
3289 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3290 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3291 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003292 -C "discarding invalid record (mac)" \
3293 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003294 -S "Extra-header:" \
3295 -C "HTTP/1.0 200 OK" \
3296 -s "too many records with bad MAC" \
3297 -s "Verification of the message MAC failed"
3298
3299run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3300 -p "$P_PXY bad_ad=1" \
3301 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3302 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3303 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003304 -c "discarding invalid record (mac)" \
3305 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003306 -s "Extra-header:" \
3307 -c "HTTP/1.0 200 OK" \
3308 -S "too many records with bad MAC" \
3309 -S "Verification of the message MAC failed"
3310
3311run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3312 -p "$P_PXY bad_ad=1" \
3313 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3314 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3315 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003316 -c "discarding invalid record (mac)" \
3317 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003318 -s "Extra-header:" \
3319 -c "HTTP/1.0 200 OK" \
3320 -s "too many records with bad MAC" \
3321 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003322
3323run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003324 -p "$P_PXY delay_ccs=1" \
3325 "$P_SRV dtls=1 debug_level=1" \
3326 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003327 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003328 -c "record from another epoch" \
3329 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003330 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003331 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003332 -s "Extra-header:" \
3333 -c "HTTP/1.0 200 OK"
3334
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003335# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003336
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003337needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003338run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003339 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003340 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3341 psk=abc123" \
3342 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003343 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3344 0 \
3345 -s "Extra-header:" \
3346 -c "HTTP/1.0 200 OK"
3347
3348needs_more_time 2
3349run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3350 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003351 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3352 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003353 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3354 0 \
3355 -s "Extra-header:" \
3356 -c "HTTP/1.0 200 OK"
3357
3358needs_more_time 2
3359run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3360 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003361 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3362 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003363 0 \
3364 -s "Extra-header:" \
3365 -c "HTTP/1.0 200 OK"
3366
3367needs_more_time 2
3368run_test "DTLS proxy: 3d, FS, client auth" \
3369 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003370 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3371 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003372 0 \
3373 -s "Extra-header:" \
3374 -c "HTTP/1.0 200 OK"
3375
3376needs_more_time 2
3377run_test "DTLS proxy: 3d, FS, ticket" \
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=1 auth_mode=none" \
3380 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
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, max handshake (FS, ticket + 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=1 auth_mode=required" \
3389 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003390 0 \
3391 -s "Extra-header:" \
3392 -c "HTTP/1.0 200 OK"
3393
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003394needs_more_time 2
3395run_test "DTLS proxy: 3d, max handshake, nbio" \
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 nbio=2 tickets=1 \
3398 auth_mode=required" \
3399 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003400 0 \
3401 -s "Extra-header:" \
3402 -c "HTTP/1.0 200 OK"
3403
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003404needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003405run_test "DTLS proxy: 3d, min handshake, resumption" \
3406 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3407 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3408 psk=abc123 debug_level=3" \
3409 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3410 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3411 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3412 0 \
3413 -s "a session has been resumed" \
3414 -c "a session has been resumed" \
3415 -s "Extra-header:" \
3416 -c "HTTP/1.0 200 OK"
3417
3418needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003419run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3420 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3421 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3422 psk=abc123 debug_level=3 nbio=2" \
3423 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3424 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3425 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3426 0 \
3427 -s "a session has been resumed" \
3428 -c "a session has been resumed" \
3429 -s "Extra-header:" \
3430 -c "HTTP/1.0 200 OK"
3431
3432needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003433run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003434 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003435 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3436 psk=abc123 renegotiation=1 debug_level=2" \
3437 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3438 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003439 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3440 0 \
3441 -c "=> renegotiate" \
3442 -s "=> renegotiate" \
3443 -s "Extra-header:" \
3444 -c "HTTP/1.0 200 OK"
3445
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003446needs_more_time 4
3447run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3448 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003449 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3450 psk=abc123 renegotiation=1 debug_level=2" \
3451 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3452 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003453 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3454 0 \
3455 -c "=> renegotiate" \
3456 -s "=> renegotiate" \
3457 -s "Extra-header:" \
3458 -c "HTTP/1.0 200 OK"
3459
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003460needs_more_time 4
3461run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003462 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003463 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003464 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003465 debug_level=2" \
3466 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003467 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003468 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3469 0 \
3470 -c "=> renegotiate" \
3471 -s "=> renegotiate" \
3472 -s "Extra-header:" \
3473 -c "HTTP/1.0 200 OK"
3474
3475needs_more_time 4
3476run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003477 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003478 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003479 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003480 debug_level=2 nbio=2" \
3481 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003482 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003483 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3484 0 \
3485 -c "=> renegotiate" \
3486 -s "=> renegotiate" \
3487 -s "Extra-header:" \
3488 -c "HTTP/1.0 200 OK"
3489
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003490needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003491not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003492run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003493 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3494 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003495 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003496 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003497 -c "HTTP/1.0 200 OK"
3498
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003499needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003500not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003501run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3502 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3503 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003504 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003505 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003506 -c "HTTP/1.0 200 OK"
3507
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003508needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003509not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003510run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3511 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3512 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003513 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003514 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003515 -c "HTTP/1.0 200 OK"
3516
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003517requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003518needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003519not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003520run_test "DTLS proxy: 3d, gnutls server" \
3521 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3522 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003523 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003524 0 \
3525 -s "Extra-header:" \
3526 -c "Extra-header:"
3527
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003528requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003529needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003530not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003531run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3532 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3533 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003534 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003535 0 \
3536 -s "Extra-header:" \
3537 -c "Extra-header:"
3538
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003539requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003540needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003541not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003542run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3543 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3544 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003545 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003546 0 \
3547 -s "Extra-header:" \
3548 -c "Extra-header:"
3549
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003550# Final report
3551
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003552echo "------------------------------------------------------------------------"
3553
3554if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003555 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003556else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003557 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003558fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003559PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003560echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003561
3562exit $FAILS