blob: 0d5222673779fa67232ff1f4357aeacf9795b7c8 [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
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100442 while [ $# -gt 0 ]
443 do
444 case $1 in
445 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200446 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100447 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100448 return
449 fi
450 ;;
451
452 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200453 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100454 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100455 return
456 fi
457 ;;
458
459 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200460 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100461 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100462 return
463 fi
464 ;;
465
466 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200467 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100468 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100469 return
470 fi
471 ;;
472
473 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200474 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100475 exit 1
476 esac
477 shift 2
478 done
479
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100480 # check valgrind's results
481 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200482 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100483 fail "Server has memory errors"
484 return
485 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200486 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100487 fail "Client has memory errors"
488 return
489 fi
490 fi
491
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100492 # if we're here, everything is ok
493 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100494 if [ "$PRESERVE_LOGS" -gt 0 ]; then
495 mv $SRV_OUT o-srv-${TESTS}.log
496 mv $CLI_OUT o-cli-${TESTS}.log
497 fi
498
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200499 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100500}
501
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100502cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200503 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200504 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
505 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
506 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
507 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100508 exit 1
509}
510
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100511#
512# MAIN
513#
514
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000515if cd $( dirname $0 ); then :; else
516 echo "cd $( dirname $0 ) failed" >&2
517 exit 1
518fi
519
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100520get_options "$@"
521
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100522# sanity checks, avoid an avalanche of errors
523if [ ! -x "$P_SRV" ]; then
524 echo "Command '$P_SRV' is not an executable file"
525 exit 1
526fi
527if [ ! -x "$P_CLI" ]; then
528 echo "Command '$P_CLI' is not an executable file"
529 exit 1
530fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200531if [ ! -x "$P_PXY" ]; then
532 echo "Command '$P_PXY' is not an executable file"
533 exit 1
534fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100535if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
536 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100537 exit 1
538fi
539
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200540# used by watchdog
541MAIN_PID="$$"
542
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200543# be more patient with valgrind
544if [ "$MEMCHECK" -gt 0 ]; then
545 START_DELAY=3
546 DOG_DELAY=30
547else
548 START_DELAY=1
549 DOG_DELAY=10
550fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200551CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200552
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200553# Pick a "unique" server port in the range 10000-19999, and a proxy port
554PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000555PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200556SRV_PORT="1$PORT_BASE"
557PXY_PORT="2$PORT_BASE"
558unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200559
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200560# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000561# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200562P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
563P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
564P_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 +0200565O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200566O_CLI="$O_CLI -connect localhost:+SRV_PORT"
567G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000568G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200569
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200570# Also pick a unique name for intermediate files
571SRV_OUT="srv_out.$$"
572CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200573PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200574SESSION="session.$$"
575
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200576SKIP_NEXT="NO"
577
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100578trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100579
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200580# Basic test
581
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200582# Checks that:
583# - things work with all ciphersuites active (used with config-full in all.sh)
584# - the expected (highest security) parameters are selected
585# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200586run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200587 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200588 "$P_CLI" \
589 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200590 -s "Protocol is TLSv1.2" \
591 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
592 -s "client hello v3, signature_algorithm ext: 6" \
593 -s "ECDHE curve: secp521r1" \
594 -S "error" \
595 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200596
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000597run_test "Default, DTLS" \
598 "$P_SRV dtls=1" \
599 "$P_CLI dtls=1" \
600 0 \
601 -s "Protocol is DTLSv1.2" \
602 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
603
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100604# Tests for rc4 option
605
606run_test "RC4: server disabled, client enabled" \
607 "$P_SRV" \
608 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
609 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100610 -s "SSL - The server has no ciphersuites in common"
611
612run_test "RC4: server half, client enabled" \
613 "$P_SRV arc4=1" \
614 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
615 1 \
616 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100617
618run_test "RC4: server enabled, client disabled" \
619 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
620 "$P_CLI" \
621 1 \
622 -s "SSL - The server has no ciphersuites in common"
623
624run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100625 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100626 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
627 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100628 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100629 -S "SSL - The server has no ciphersuites in common"
630
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100631# Tests for Truncated HMAC extension
632
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100633run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200634 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100635 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100636 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100637 -s "dumping 'computed mac' (20 bytes)" \
638 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100639
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100640run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200641 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100642 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
643 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100644 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100645 -s "dumping 'computed mac' (20 bytes)" \
646 -S "dumping 'computed mac' (10 bytes)"
647
648run_test "Truncated HMAC: client enabled, server default" \
649 "$P_SRV debug_level=4" \
650 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
651 trunc_hmac=1" \
652 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100653 -s "dumping 'computed mac' (20 bytes)" \
654 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100655
656run_test "Truncated HMAC: client enabled, server disabled" \
657 "$P_SRV debug_level=4 trunc_hmac=0" \
658 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
659 trunc_hmac=1" \
660 0 \
661 -s "dumping 'computed mac' (20 bytes)" \
662 -S "dumping 'computed mac' (10 bytes)"
663
664run_test "Truncated HMAC: client enabled, server enabled" \
665 "$P_SRV debug_level=4 trunc_hmac=1" \
666 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
667 trunc_hmac=1" \
668 0 \
669 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100670 -s "dumping 'computed mac' (10 bytes)"
671
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100672# Tests for Encrypt-then-MAC extension
673
674run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100675 "$P_SRV debug_level=3 \
676 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100677 "$P_CLI debug_level=3" \
678 0 \
679 -c "client hello, adding encrypt_then_mac extension" \
680 -s "found encrypt then mac extension" \
681 -s "server hello, adding encrypt then mac extension" \
682 -c "found encrypt_then_mac extension" \
683 -c "using encrypt then mac" \
684 -s "using encrypt then mac"
685
686run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100687 "$P_SRV debug_level=3 etm=0 \
688 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100689 "$P_CLI debug_level=3 etm=1" \
690 0 \
691 -c "client hello, adding encrypt_then_mac extension" \
692 -s "found encrypt then mac extension" \
693 -S "server hello, adding encrypt then mac extension" \
694 -C "found encrypt_then_mac extension" \
695 -C "using encrypt then mac" \
696 -S "using encrypt then mac"
697
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100698run_test "Encrypt then MAC: client enabled, aead cipher" \
699 "$P_SRV debug_level=3 etm=1 \
700 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
701 "$P_CLI debug_level=3 etm=1" \
702 0 \
703 -c "client hello, adding encrypt_then_mac extension" \
704 -s "found encrypt then mac extension" \
705 -S "server hello, adding encrypt then mac extension" \
706 -C "found encrypt_then_mac extension" \
707 -C "using encrypt then mac" \
708 -S "using encrypt then mac"
709
710run_test "Encrypt then MAC: client enabled, stream cipher" \
711 "$P_SRV debug_level=3 etm=1 \
712 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100713 "$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 +0100714 0 \
715 -c "client hello, adding encrypt_then_mac extension" \
716 -s "found encrypt then mac extension" \
717 -S "server hello, adding encrypt then mac extension" \
718 -C "found encrypt_then_mac extension" \
719 -C "using encrypt then mac" \
720 -S "using encrypt then mac"
721
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100722run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100723 "$P_SRV debug_level=3 etm=1 \
724 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100725 "$P_CLI debug_level=3 etm=0" \
726 0 \
727 -C "client hello, adding encrypt_then_mac extension" \
728 -S "found encrypt then mac extension" \
729 -S "server hello, adding encrypt then mac extension" \
730 -C "found encrypt_then_mac extension" \
731 -C "using encrypt then mac" \
732 -S "using encrypt then mac"
733
Janos Follathe2681a42016-03-07 15:57:05 +0000734requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100735run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100736 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100737 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100738 "$P_CLI debug_level=3 force_version=ssl3" \
739 0 \
740 -C "client hello, adding encrypt_then_mac extension" \
741 -S "found encrypt then mac extension" \
742 -S "server hello, adding encrypt then mac extension" \
743 -C "found encrypt_then_mac extension" \
744 -C "using encrypt then mac" \
745 -S "using encrypt then mac"
746
Janos Follathe2681a42016-03-07 15:57:05 +0000747requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100748run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100749 "$P_SRV debug_level=3 force_version=ssl3 \
750 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100751 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100752 0 \
753 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100754 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100755 -S "server hello, adding encrypt then mac extension" \
756 -C "found encrypt_then_mac extension" \
757 -C "using encrypt then mac" \
758 -S "using encrypt then mac"
759
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200760# Tests for Extended Master Secret extension
761
762run_test "Extended Master Secret: default" \
763 "$P_SRV debug_level=3" \
764 "$P_CLI debug_level=3" \
765 0 \
766 -c "client hello, adding extended_master_secret extension" \
767 -s "found extended master secret extension" \
768 -s "server hello, adding extended master secret extension" \
769 -c "found extended_master_secret extension" \
770 -c "using extended master secret" \
771 -s "using extended master secret"
772
773run_test "Extended Master Secret: client enabled, server disabled" \
774 "$P_SRV debug_level=3 extended_ms=0" \
775 "$P_CLI debug_level=3 extended_ms=1" \
776 0 \
777 -c "client hello, adding extended_master_secret extension" \
778 -s "found extended master secret extension" \
779 -S "server hello, adding extended master secret extension" \
780 -C "found extended_master_secret extension" \
781 -C "using extended master secret" \
782 -S "using extended master secret"
783
784run_test "Extended Master Secret: client disabled, server enabled" \
785 "$P_SRV debug_level=3 extended_ms=1" \
786 "$P_CLI debug_level=3 extended_ms=0" \
787 0 \
788 -C "client hello, adding extended_master_secret extension" \
789 -S "found extended master secret extension" \
790 -S "server hello, adding extended master secret extension" \
791 -C "found extended_master_secret extension" \
792 -C "using extended master secret" \
793 -S "using extended master secret"
794
Janos Follathe2681a42016-03-07 15:57:05 +0000795requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200796run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100797 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200798 "$P_CLI debug_level=3 force_version=ssl3" \
799 0 \
800 -C "client hello, adding extended_master_secret extension" \
801 -S "found extended master secret extension" \
802 -S "server hello, adding extended master secret extension" \
803 -C "found extended_master_secret extension" \
804 -C "using extended master secret" \
805 -S "using extended master secret"
806
Janos Follathe2681a42016-03-07 15:57:05 +0000807requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200808run_test "Extended Master Secret: client enabled, server SSLv3" \
809 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100810 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200811 0 \
812 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100813 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200814 -S "server hello, adding extended master secret extension" \
815 -C "found extended_master_secret extension" \
816 -C "using extended master secret" \
817 -S "using extended master secret"
818
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200819# Tests for FALLBACK_SCSV
820
821run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200822 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200823 "$P_CLI debug_level=3 force_version=tls1_1" \
824 0 \
825 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200826 -S "received FALLBACK_SCSV" \
827 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200828 -C "is a fatal alert message (msg 86)"
829
830run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200831 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200832 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
833 0 \
834 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200835 -S "received FALLBACK_SCSV" \
836 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200837 -C "is a fatal alert message (msg 86)"
838
839run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200840 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200841 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200842 1 \
843 -c "adding FALLBACK_SCSV" \
844 -s "received FALLBACK_SCSV" \
845 -s "inapropriate fallback" \
846 -c "is a fatal alert message (msg 86)"
847
848run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200849 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200850 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200851 0 \
852 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200853 -s "received FALLBACK_SCSV" \
854 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200855 -C "is a fatal alert message (msg 86)"
856
857requires_openssl_with_fallback_scsv
858run_test "Fallback SCSV: default, openssl server" \
859 "$O_SRV" \
860 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
861 0 \
862 -C "adding FALLBACK_SCSV" \
863 -C "is a fatal alert message (msg 86)"
864
865requires_openssl_with_fallback_scsv
866run_test "Fallback SCSV: enabled, openssl server" \
867 "$O_SRV" \
868 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
869 1 \
870 -c "adding FALLBACK_SCSV" \
871 -c "is a fatal alert message (msg 86)"
872
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200873requires_openssl_with_fallback_scsv
874run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200875 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200876 "$O_CLI -tls1_1" \
877 0 \
878 -S "received FALLBACK_SCSV" \
879 -S "inapropriate fallback"
880
881requires_openssl_with_fallback_scsv
882run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200883 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200884 "$O_CLI -tls1_1 -fallback_scsv" \
885 1 \
886 -s "received FALLBACK_SCSV" \
887 -s "inapropriate fallback"
888
889requires_openssl_with_fallback_scsv
890run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200891 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200892 "$O_CLI -fallback_scsv" \
893 0 \
894 -s "received FALLBACK_SCSV" \
895 -S "inapropriate fallback"
896
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100897# Tests for CBC 1/n-1 record splitting
898
899run_test "CBC Record splitting: TLS 1.2, no splitting" \
900 "$P_SRV" \
901 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
902 request_size=123 force_version=tls1_2" \
903 0 \
904 -s "Read from client: 123 bytes read" \
905 -S "Read from client: 1 bytes read" \
906 -S "122 bytes read"
907
908run_test "CBC Record splitting: TLS 1.1, no splitting" \
909 "$P_SRV" \
910 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
911 request_size=123 force_version=tls1_1" \
912 0 \
913 -s "Read from client: 123 bytes read" \
914 -S "Read from client: 1 bytes read" \
915 -S "122 bytes read"
916
917run_test "CBC Record splitting: TLS 1.0, splitting" \
918 "$P_SRV" \
919 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
920 request_size=123 force_version=tls1" \
921 0 \
922 -S "Read from client: 123 bytes read" \
923 -s "Read from client: 1 bytes read" \
924 -s "122 bytes read"
925
Janos Follathe2681a42016-03-07 15:57:05 +0000926requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100927run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100928 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100929 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
930 request_size=123 force_version=ssl3" \
931 0 \
932 -S "Read from client: 123 bytes read" \
933 -s "Read from client: 1 bytes read" \
934 -s "122 bytes read"
935
936run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100937 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100938 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
939 request_size=123 force_version=tls1" \
940 0 \
941 -s "Read from client: 123 bytes read" \
942 -S "Read from client: 1 bytes read" \
943 -S "122 bytes read"
944
945run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
946 "$P_SRV" \
947 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
948 request_size=123 force_version=tls1 recsplit=0" \
949 0 \
950 -s "Read from client: 123 bytes read" \
951 -S "Read from client: 1 bytes read" \
952 -S "122 bytes read"
953
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100954run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
955 "$P_SRV nbio=2" \
956 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
957 request_size=123 force_version=tls1" \
958 0 \
959 -S "Read from client: 123 bytes read" \
960 -s "Read from client: 1 bytes read" \
961 -s "122 bytes read"
962
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100963# Tests for Session Tickets
964
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200965run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200966 "$P_SRV debug_level=3 tickets=1" \
967 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100968 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100969 -c "client hello, adding session ticket extension" \
970 -s "found session ticket extension" \
971 -s "server hello, adding session ticket extension" \
972 -c "found session_ticket extension" \
973 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100974 -S "session successfully restored from cache" \
975 -s "session successfully restored from ticket" \
976 -s "a session has been resumed" \
977 -c "a session has been resumed"
978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200979run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200980 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
981 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100982 0 \
983 -c "client hello, adding session ticket extension" \
984 -s "found session ticket extension" \
985 -s "server hello, adding session ticket extension" \
986 -c "found session_ticket extension" \
987 -c "parse new session ticket" \
988 -S "session successfully restored from cache" \
989 -s "session successfully restored from ticket" \
990 -s "a session has been resumed" \
991 -c "a session has been resumed"
992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200993run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200994 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
995 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100996 0 \
997 -c "client hello, adding session ticket extension" \
998 -s "found session ticket extension" \
999 -s "server hello, adding session ticket extension" \
1000 -c "found session_ticket extension" \
1001 -c "parse new session ticket" \
1002 -S "session successfully restored from cache" \
1003 -S "session successfully restored from ticket" \
1004 -S "a session has been resumed" \
1005 -C "a session has been resumed"
1006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001007run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001008 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001009 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001010 0 \
1011 -c "client hello, adding session ticket extension" \
1012 -c "found session_ticket extension" \
1013 -c "parse new session ticket" \
1014 -c "a session has been resumed"
1015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001016run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001017 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001018 "( $O_CLI -sess_out $SESSION; \
1019 $O_CLI -sess_in $SESSION; \
1020 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001021 0 \
1022 -s "found session ticket extension" \
1023 -s "server hello, adding session ticket extension" \
1024 -S "session successfully restored from cache" \
1025 -s "session successfully restored from ticket" \
1026 -s "a session has been resumed"
1027
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001028# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001030run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001031 "$P_SRV debug_level=3 tickets=0" \
1032 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001033 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001034 -c "client hello, adding session ticket extension" \
1035 -s "found session ticket extension" \
1036 -S "server hello, adding session ticket extension" \
1037 -C "found session_ticket extension" \
1038 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001039 -s "session successfully restored from cache" \
1040 -S "session successfully restored from ticket" \
1041 -s "a session has been resumed" \
1042 -c "a session has been resumed"
1043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001044run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001045 "$P_SRV debug_level=3 tickets=1" \
1046 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001047 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001048 -C "client hello, adding session ticket extension" \
1049 -S "found session ticket extension" \
1050 -S "server hello, adding session ticket extension" \
1051 -C "found session_ticket extension" \
1052 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001053 -s "session successfully restored from cache" \
1054 -S "session successfully restored from ticket" \
1055 -s "a session has been resumed" \
1056 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001058run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001059 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1060 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001061 0 \
1062 -S "session successfully restored from cache" \
1063 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001064 -S "a session has been resumed" \
1065 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001067run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001068 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1069 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001070 0 \
1071 -s "session successfully restored from cache" \
1072 -S "session successfully restored from ticket" \
1073 -s "a session has been resumed" \
1074 -c "a session has been resumed"
1075
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001076run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001077 "$P_SRV debug_level=3 tickets=0" \
1078 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001079 0 \
1080 -s "session successfully restored from cache" \
1081 -S "session successfully restored from ticket" \
1082 -s "a session has been resumed" \
1083 -c "a session has been resumed"
1084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001085run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001086 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1087 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001088 0 \
1089 -S "session successfully restored from cache" \
1090 -S "session successfully restored from ticket" \
1091 -S "a session has been resumed" \
1092 -C "a session has been resumed"
1093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001094run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001095 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1096 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001097 0 \
1098 -s "session successfully restored from cache" \
1099 -S "session successfully restored from ticket" \
1100 -s "a session has been resumed" \
1101 -c "a session has been resumed"
1102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001103run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001104 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001105 "( $O_CLI -sess_out $SESSION; \
1106 $O_CLI -sess_in $SESSION; \
1107 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001108 0 \
1109 -s "found session ticket extension" \
1110 -S "server hello, adding session ticket extension" \
1111 -s "session successfully restored from cache" \
1112 -S "session successfully restored from ticket" \
1113 -s "a session has been resumed"
1114
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001115run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001116 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001117 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001118 0 \
1119 -C "found session_ticket extension" \
1120 -C "parse new session ticket" \
1121 -c "a session has been resumed"
1122
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001123# Tests for Max Fragment Length extension
1124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001125run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001126 "$P_SRV debug_level=3" \
1127 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001128 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001129 -c "Maximum fragment length is 16384" \
1130 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001131 -C "client hello, adding max_fragment_length extension" \
1132 -S "found max fragment length extension" \
1133 -S "server hello, max_fragment_length extension" \
1134 -C "found max_fragment_length extension"
1135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001136run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001137 "$P_SRV debug_level=3" \
1138 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001139 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001140 -c "Maximum fragment length is 4096" \
1141 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001142 -c "client hello, adding max_fragment_length extension" \
1143 -s "found max fragment length extension" \
1144 -s "server hello, max_fragment_length extension" \
1145 -c "found max_fragment_length extension"
1146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001147run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001148 "$P_SRV debug_level=3 max_frag_len=4096" \
1149 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001150 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001151 -c "Maximum fragment length is 16384" \
1152 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001153 -C "client hello, adding max_fragment_length extension" \
1154 -S "found max fragment length extension" \
1155 -S "server hello, max_fragment_length extension" \
1156 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001157
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001158requires_gnutls
1159run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001160 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001161 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001162 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001163 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001164 -c "client hello, adding max_fragment_length extension" \
1165 -c "found max_fragment_length extension"
1166
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001167run_test "Max fragment length: client, message just fits" \
1168 "$P_SRV debug_level=3" \
1169 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1170 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001171 -c "Maximum fragment length is 2048" \
1172 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001173 -c "client hello, adding max_fragment_length extension" \
1174 -s "found max fragment length extension" \
1175 -s "server hello, max_fragment_length extension" \
1176 -c "found max_fragment_length extension" \
1177 -c "2048 bytes written in 1 fragments" \
1178 -s "2048 bytes read"
1179
1180run_test "Max fragment length: client, larger message" \
1181 "$P_SRV debug_level=3" \
1182 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1183 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001184 -c "Maximum fragment length is 2048" \
1185 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001186 -c "client hello, adding max_fragment_length extension" \
1187 -s "found max fragment length extension" \
1188 -s "server hello, max_fragment_length extension" \
1189 -c "found max_fragment_length extension" \
1190 -c "2345 bytes written in 2 fragments" \
1191 -s "2048 bytes read" \
1192 -s "297 bytes read"
1193
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001194run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001195 "$P_SRV debug_level=3 dtls=1" \
1196 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1197 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001198 -c "Maximum fragment length is 2048" \
1199 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001200 -c "client hello, adding max_fragment_length extension" \
1201 -s "found max fragment length extension" \
1202 -s "server hello, max_fragment_length extension" \
1203 -c "found max_fragment_length extension" \
1204 -c "fragment larger than.*maximum"
1205
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001206# Tests for renegotiation
1207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001208run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001209 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001210 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001211 0 \
1212 -C "client hello, adding renegotiation extension" \
1213 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1214 -S "found renegotiation extension" \
1215 -s "server hello, secure renegotiation extension" \
1216 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001217 -C "=> renegotiate" \
1218 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001219 -S "write hello request"
1220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001221run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001222 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001223 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001224 0 \
1225 -c "client hello, adding renegotiation extension" \
1226 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1227 -s "found renegotiation extension" \
1228 -s "server hello, secure renegotiation extension" \
1229 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001230 -c "=> renegotiate" \
1231 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001232 -S "write hello request"
1233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001234run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001235 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001236 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001237 0 \
1238 -c "client hello, adding renegotiation extension" \
1239 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1240 -s "found renegotiation extension" \
1241 -s "server hello, secure renegotiation extension" \
1242 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001243 -c "=> renegotiate" \
1244 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001245 -s "write hello request"
1246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001247run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001248 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001249 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001250 0 \
1251 -c "client hello, adding renegotiation extension" \
1252 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1253 -s "found renegotiation extension" \
1254 -s "server hello, secure renegotiation extension" \
1255 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001256 -c "=> renegotiate" \
1257 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001258 -s "write hello request"
1259
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001260run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001261 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001262 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001263 1 \
1264 -c "client hello, adding renegotiation extension" \
1265 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1266 -S "found renegotiation extension" \
1267 -s "server hello, secure renegotiation extension" \
1268 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001269 -c "=> renegotiate" \
1270 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001271 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001272 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001273 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001275run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001276 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001277 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001278 0 \
1279 -C "client hello, adding renegotiation extension" \
1280 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1281 -S "found renegotiation extension" \
1282 -s "server hello, secure renegotiation extension" \
1283 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001284 -C "=> renegotiate" \
1285 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001286 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001287 -S "SSL - An unexpected message was received from our peer" \
1288 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001290run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001291 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001292 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001293 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001294 0 \
1295 -C "client hello, adding renegotiation extension" \
1296 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1297 -S "found renegotiation extension" \
1298 -s "server hello, secure renegotiation extension" \
1299 -c "found renegotiation extension" \
1300 -C "=> renegotiate" \
1301 -S "=> renegotiate" \
1302 -s "write hello request" \
1303 -S "SSL - An unexpected message was received from our peer" \
1304 -S "failed"
1305
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001306# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001307run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001308 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001309 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001310 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001311 0 \
1312 -C "client hello, adding renegotiation extension" \
1313 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1314 -S "found renegotiation extension" \
1315 -s "server hello, secure renegotiation extension" \
1316 -c "found renegotiation extension" \
1317 -C "=> renegotiate" \
1318 -S "=> renegotiate" \
1319 -s "write hello request" \
1320 -S "SSL - An unexpected message was received from our peer" \
1321 -S "failed"
1322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001323run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001324 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001325 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001326 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001327 0 \
1328 -C "client hello, adding renegotiation extension" \
1329 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1330 -S "found renegotiation extension" \
1331 -s "server hello, secure renegotiation extension" \
1332 -c "found renegotiation extension" \
1333 -C "=> renegotiate" \
1334 -S "=> renegotiate" \
1335 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001336 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001338run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001339 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001340 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001341 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001342 0 \
1343 -c "client hello, adding renegotiation extension" \
1344 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1345 -s "found renegotiation extension" \
1346 -s "server hello, secure renegotiation extension" \
1347 -c "found renegotiation extension" \
1348 -c "=> renegotiate" \
1349 -s "=> renegotiate" \
1350 -s "write hello request" \
1351 -S "SSL - An unexpected message was received from our peer" \
1352 -S "failed"
1353
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001354run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001355 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001356 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1357 0 \
1358 -C "client hello, adding renegotiation extension" \
1359 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1360 -S "found renegotiation extension" \
1361 -s "server hello, secure renegotiation extension" \
1362 -c "found renegotiation extension" \
1363 -S "record counter limit reached: renegotiate" \
1364 -C "=> renegotiate" \
1365 -S "=> renegotiate" \
1366 -S "write hello request" \
1367 -S "SSL - An unexpected message was received from our peer" \
1368 -S "failed"
1369
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001370# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001371run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001372 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001373 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001374 0 \
1375 -c "client hello, adding renegotiation extension" \
1376 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1377 -s "found renegotiation extension" \
1378 -s "server hello, secure renegotiation extension" \
1379 -c "found renegotiation extension" \
1380 -s "record counter limit reached: renegotiate" \
1381 -c "=> renegotiate" \
1382 -s "=> renegotiate" \
1383 -s "write hello request" \
1384 -S "SSL - An unexpected message was received from our peer" \
1385 -S "failed"
1386
1387run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001388 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001389 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001390 0 \
1391 -c "client hello, adding renegotiation extension" \
1392 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1393 -s "found renegotiation extension" \
1394 -s "server hello, secure renegotiation extension" \
1395 -c "found renegotiation extension" \
1396 -s "record counter limit reached: renegotiate" \
1397 -c "=> renegotiate" \
1398 -s "=> renegotiate" \
1399 -s "write hello request" \
1400 -S "SSL - An unexpected message was received from our peer" \
1401 -S "failed"
1402
1403run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001404 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001405 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1406 0 \
1407 -C "client hello, adding renegotiation extension" \
1408 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1409 -S "found renegotiation extension" \
1410 -s "server hello, secure renegotiation extension" \
1411 -c "found renegotiation extension" \
1412 -S "record counter limit reached: renegotiate" \
1413 -C "=> renegotiate" \
1414 -S "=> renegotiate" \
1415 -S "write hello request" \
1416 -S "SSL - An unexpected message was received from our peer" \
1417 -S "failed"
1418
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001419run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001420 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001421 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001422 0 \
1423 -c "client hello, adding renegotiation extension" \
1424 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1425 -s "found renegotiation extension" \
1426 -s "server hello, secure renegotiation extension" \
1427 -c "found renegotiation extension" \
1428 -c "=> renegotiate" \
1429 -s "=> renegotiate" \
1430 -S "write hello request"
1431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001432run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001433 "$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 +02001434 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001435 0 \
1436 -c "client hello, adding renegotiation extension" \
1437 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1438 -s "found renegotiation extension" \
1439 -s "server hello, secure renegotiation extension" \
1440 -c "found renegotiation extension" \
1441 -c "=> renegotiate" \
1442 -s "=> renegotiate" \
1443 -s "write hello request"
1444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001445run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001446 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001447 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001448 0 \
1449 -c "client hello, adding renegotiation extension" \
1450 -c "found renegotiation extension" \
1451 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001452 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001453 -C "error" \
1454 -c "HTTP/1.0 200 [Oo][Kk]"
1455
Paul Bakker539d9722015-02-08 16:18:35 +01001456requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001457run_test "Renegotiation: gnutls server strict, client-initiated" \
1458 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001459 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001460 0 \
1461 -c "client hello, adding renegotiation extension" \
1462 -c "found renegotiation extension" \
1463 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001464 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001465 -C "error" \
1466 -c "HTTP/1.0 200 [Oo][Kk]"
1467
Paul Bakker539d9722015-02-08 16:18:35 +01001468requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001469run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1470 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1471 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1472 1 \
1473 -c "client hello, adding renegotiation extension" \
1474 -C "found renegotiation extension" \
1475 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001476 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001477 -c "error" \
1478 -C "HTTP/1.0 200 [Oo][Kk]"
1479
Paul Bakker539d9722015-02-08 16:18:35 +01001480requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001481run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1482 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1483 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1484 allow_legacy=0" \
1485 1 \
1486 -c "client hello, adding renegotiation extension" \
1487 -C "found renegotiation extension" \
1488 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001489 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001490 -c "error" \
1491 -C "HTTP/1.0 200 [Oo][Kk]"
1492
Paul Bakker539d9722015-02-08 16:18:35 +01001493requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001494run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1495 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1496 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1497 allow_legacy=1" \
1498 0 \
1499 -c "client hello, adding renegotiation extension" \
1500 -C "found renegotiation extension" \
1501 -c "=> renegotiate" \
1502 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001503 -C "error" \
1504 -c "HTTP/1.0 200 [Oo][Kk]"
1505
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001506run_test "Renegotiation: DTLS, client-initiated" \
1507 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1508 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1509 0 \
1510 -c "client hello, adding renegotiation extension" \
1511 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1512 -s "found renegotiation extension" \
1513 -s "server hello, secure renegotiation extension" \
1514 -c "found renegotiation extension" \
1515 -c "=> renegotiate" \
1516 -s "=> renegotiate" \
1517 -S "write hello request"
1518
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001519run_test "Renegotiation: DTLS, server-initiated" \
1520 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001521 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1522 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001523 0 \
1524 -c "client hello, adding renegotiation extension" \
1525 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1526 -s "found renegotiation extension" \
1527 -s "server hello, secure renegotiation extension" \
1528 -c "found renegotiation extension" \
1529 -c "=> renegotiate" \
1530 -s "=> renegotiate" \
1531 -s "write hello request"
1532
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001533requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001534run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1535 "$G_SRV -u --mtu 4096" \
1536 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1537 0 \
1538 -c "client hello, adding renegotiation extension" \
1539 -c "found renegotiation extension" \
1540 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001541 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001542 -C "error" \
1543 -s "Extra-header:"
1544
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001545# Test for the "secure renegotation" extension only (no actual renegotiation)
1546
Paul Bakker539d9722015-02-08 16:18:35 +01001547requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001548run_test "Renego ext: gnutls server strict, client default" \
1549 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1550 "$P_CLI debug_level=3" \
1551 0 \
1552 -c "found renegotiation extension" \
1553 -C "error" \
1554 -c "HTTP/1.0 200 [Oo][Kk]"
1555
Paul Bakker539d9722015-02-08 16:18:35 +01001556requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001557run_test "Renego ext: gnutls server unsafe, client default" \
1558 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1559 "$P_CLI debug_level=3" \
1560 0 \
1561 -C "found renegotiation extension" \
1562 -C "error" \
1563 -c "HTTP/1.0 200 [Oo][Kk]"
1564
Paul Bakker539d9722015-02-08 16:18:35 +01001565requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001566run_test "Renego ext: gnutls server unsafe, client break legacy" \
1567 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1568 "$P_CLI debug_level=3 allow_legacy=-1" \
1569 1 \
1570 -C "found renegotiation extension" \
1571 -c "error" \
1572 -C "HTTP/1.0 200 [Oo][Kk]"
1573
Paul Bakker539d9722015-02-08 16:18:35 +01001574requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001575run_test "Renego ext: gnutls client strict, server default" \
1576 "$P_SRV debug_level=3" \
1577 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1578 0 \
1579 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1580 -s "server hello, secure renegotiation extension"
1581
Paul Bakker539d9722015-02-08 16:18:35 +01001582requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001583run_test "Renego ext: gnutls client unsafe, server default" \
1584 "$P_SRV debug_level=3" \
1585 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1586 0 \
1587 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1588 -S "server hello, secure renegotiation extension"
1589
Paul Bakker539d9722015-02-08 16:18:35 +01001590requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001591run_test "Renego ext: gnutls client unsafe, server break legacy" \
1592 "$P_SRV debug_level=3 allow_legacy=-1" \
1593 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1594 1 \
1595 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1596 -S "server hello, secure renegotiation extension"
1597
Janos Follath0b242342016-02-17 10:11:21 +00001598# Tests for silently dropping trailing extra bytes in .der certificates
1599
1600requires_gnutls
1601run_test "DER format: no trailing bytes" \
1602 "$P_SRV crt_file=data_files/server5-der0.crt \
1603 key_file=data_files/server5.key" \
1604 "$G_CLI " \
1605 0 \
1606 -c "Handshake was completed" \
1607
1608requires_gnutls
1609run_test "DER format: with a trailing zero byte" \
1610 "$P_SRV crt_file=data_files/server5-der1a.crt \
1611 key_file=data_files/server5.key" \
1612 "$G_CLI " \
1613 0 \
1614 -c "Handshake was completed" \
1615
1616requires_gnutls
1617run_test "DER format: with a trailing random byte" \
1618 "$P_SRV crt_file=data_files/server5-der1b.crt \
1619 key_file=data_files/server5.key" \
1620 "$G_CLI " \
1621 0 \
1622 -c "Handshake was completed" \
1623
1624requires_gnutls
1625run_test "DER format: with 2 trailing random bytes" \
1626 "$P_SRV crt_file=data_files/server5-der2.crt \
1627 key_file=data_files/server5.key" \
1628 "$G_CLI " \
1629 0 \
1630 -c "Handshake was completed" \
1631
1632requires_gnutls
1633run_test "DER format: with 4 trailing random bytes" \
1634 "$P_SRV crt_file=data_files/server5-der4.crt \
1635 key_file=data_files/server5.key" \
1636 "$G_CLI " \
1637 0 \
1638 -c "Handshake was completed" \
1639
1640requires_gnutls
1641run_test "DER format: with 8 trailing random bytes" \
1642 "$P_SRV crt_file=data_files/server5-der8.crt \
1643 key_file=data_files/server5.key" \
1644 "$G_CLI " \
1645 0 \
1646 -c "Handshake was completed" \
1647
1648requires_gnutls
1649run_test "DER format: with 9 trailing random bytes" \
1650 "$P_SRV crt_file=data_files/server5-der9.crt \
1651 key_file=data_files/server5.key" \
1652 "$G_CLI " \
1653 0 \
1654 -c "Handshake was completed" \
1655
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001656# Tests for auth_mode
1657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001658run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001659 "$P_SRV crt_file=data_files/server5-badsign.crt \
1660 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001661 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001662 1 \
1663 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001664 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001665 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001666 -c "X509 - Certificate verification failed"
1667
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001668run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001669 "$P_SRV crt_file=data_files/server5-badsign.crt \
1670 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001671 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001672 0 \
1673 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001674 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001675 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001676 -C "X509 - Certificate verification failed"
1677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001678run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001679 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001680 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001681 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001682 0 \
1683 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001684 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001685 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001686 -C "X509 - Certificate verification failed"
1687
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001688run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001689 "$P_SRV debug_level=3 auth_mode=required" \
1690 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001691 key_file=data_files/server5.key" \
1692 1 \
1693 -S "skip write certificate request" \
1694 -C "skip parse certificate request" \
1695 -c "got a certificate request" \
1696 -C "skip write certificate" \
1697 -C "skip write certificate verify" \
1698 -S "skip parse certificate verify" \
1699 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001700 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001701 -s "! mbedtls_ssl_handshake returned" \
1702 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001703 -s "X509 - Certificate verification failed"
1704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001705run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001706 "$P_SRV debug_level=3 auth_mode=optional" \
1707 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001708 key_file=data_files/server5.key" \
1709 0 \
1710 -S "skip write certificate request" \
1711 -C "skip parse certificate request" \
1712 -c "got a certificate request" \
1713 -C "skip write certificate" \
1714 -C "skip write certificate verify" \
1715 -S "skip parse certificate verify" \
1716 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001717 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001718 -S "! mbedtls_ssl_handshake returned" \
1719 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001720 -S "X509 - Certificate verification failed"
1721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001722run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001723 "$P_SRV debug_level=3 auth_mode=none" \
1724 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001725 key_file=data_files/server5.key" \
1726 0 \
1727 -s "skip write certificate request" \
1728 -C "skip parse certificate request" \
1729 -c "got no certificate request" \
1730 -c "skip write certificate" \
1731 -c "skip write certificate verify" \
1732 -s "skip parse certificate verify" \
1733 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001734 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001735 -S "! mbedtls_ssl_handshake returned" \
1736 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001737 -S "X509 - Certificate verification failed"
1738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001739run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001740 "$P_SRV debug_level=3 auth_mode=optional" \
1741 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001742 0 \
1743 -S "skip write certificate request" \
1744 -C "skip parse certificate request" \
1745 -c "got a certificate request" \
1746 -C "skip write certificate$" \
1747 -C "got no certificate to send" \
1748 -S "SSLv3 client has no certificate" \
1749 -c "skip write certificate verify" \
1750 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001751 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001752 -S "! mbedtls_ssl_handshake returned" \
1753 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001754 -S "X509 - Certificate verification failed"
1755
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001756run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001757 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001758 "$O_CLI" \
1759 0 \
1760 -S "skip write certificate request" \
1761 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001762 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001763 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001764 -S "X509 - Certificate verification failed"
1765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001766run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001767 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001768 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001769 0 \
1770 -C "skip parse certificate request" \
1771 -c "got a certificate request" \
1772 -C "skip write certificate$" \
1773 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001774 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001775
Janos Follathe2681a42016-03-07 15:57:05 +00001776requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001778 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001779 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001780 0 \
1781 -S "skip write certificate request" \
1782 -C "skip parse certificate request" \
1783 -c "got a certificate request" \
1784 -C "skip write certificate$" \
1785 -c "skip write certificate verify" \
1786 -c "got no certificate to send" \
1787 -s "SSLv3 client has no certificate" \
1788 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001789 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001790 -S "! mbedtls_ssl_handshake returned" \
1791 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001792 -S "X509 - Certificate verification failed"
1793
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001794# Tests for certificate selection based on SHA verson
1795
1796run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1797 "$P_SRV crt_file=data_files/server5.crt \
1798 key_file=data_files/server5.key \
1799 crt_file2=data_files/server5-sha1.crt \
1800 key_file2=data_files/server5.key" \
1801 "$P_CLI force_version=tls1_2" \
1802 0 \
1803 -c "signed using.*ECDSA with SHA256" \
1804 -C "signed using.*ECDSA with SHA1"
1805
1806run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1807 "$P_SRV crt_file=data_files/server5.crt \
1808 key_file=data_files/server5.key \
1809 crt_file2=data_files/server5-sha1.crt \
1810 key_file2=data_files/server5.key" \
1811 "$P_CLI force_version=tls1_1" \
1812 0 \
1813 -C "signed using.*ECDSA with SHA256" \
1814 -c "signed using.*ECDSA with SHA1"
1815
1816run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1817 "$P_SRV crt_file=data_files/server5.crt \
1818 key_file=data_files/server5.key \
1819 crt_file2=data_files/server5-sha1.crt \
1820 key_file2=data_files/server5.key" \
1821 "$P_CLI force_version=tls1" \
1822 0 \
1823 -C "signed using.*ECDSA with SHA256" \
1824 -c "signed using.*ECDSA with SHA1"
1825
1826run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1827 "$P_SRV crt_file=data_files/server5.crt \
1828 key_file=data_files/server5.key \
1829 crt_file2=data_files/server6.crt \
1830 key_file2=data_files/server6.key" \
1831 "$P_CLI force_version=tls1_1" \
1832 0 \
1833 -c "serial number.*09" \
1834 -c "signed using.*ECDSA with SHA256" \
1835 -C "signed using.*ECDSA with SHA1"
1836
1837run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1838 "$P_SRV crt_file=data_files/server6.crt \
1839 key_file=data_files/server6.key \
1840 crt_file2=data_files/server5.crt \
1841 key_file2=data_files/server5.key" \
1842 "$P_CLI force_version=tls1_1" \
1843 0 \
1844 -c "serial number.*0A" \
1845 -c "signed using.*ECDSA with SHA256" \
1846 -C "signed using.*ECDSA with SHA1"
1847
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001848# tests for SNI
1849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001850run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001851 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001852 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001853 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001854 0 \
1855 -S "parse ServerName extension" \
1856 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1857 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001859run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001860 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001861 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001862 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 +02001863 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001864 0 \
1865 -s "parse ServerName extension" \
1866 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1867 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001868
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001869run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001870 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001871 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001872 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001873 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001874 0 \
1875 -s "parse ServerName extension" \
1876 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1877 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001879run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001880 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001881 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001882 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001883 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001884 1 \
1885 -s "parse ServerName extension" \
1886 -s "ssl_sni_wrapper() returned" \
1887 -s "mbedtls_ssl_handshake returned" \
1888 -c "mbedtls_ssl_handshake returned" \
1889 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001890
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001891run_test "SNI: client auth no override: optional" \
1892 "$P_SRV debug_level=3 auth_mode=optional \
1893 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1894 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1895 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001896 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001897 -S "skip write certificate request" \
1898 -C "skip parse certificate request" \
1899 -c "got a certificate request" \
1900 -C "skip write certificate" \
1901 -C "skip write certificate verify" \
1902 -S "skip parse certificate verify"
1903
1904run_test "SNI: client auth override: none -> optional" \
1905 "$P_SRV debug_level=3 auth_mode=none \
1906 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1907 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1908 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001909 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001910 -S "skip write certificate request" \
1911 -C "skip parse certificate request" \
1912 -c "got a certificate request" \
1913 -C "skip write certificate" \
1914 -C "skip write certificate verify" \
1915 -S "skip parse certificate verify"
1916
1917run_test "SNI: client auth override: optional -> none" \
1918 "$P_SRV debug_level=3 auth_mode=optional \
1919 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1920 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1921 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001922 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001923 -s "skip write certificate request" \
1924 -C "skip parse certificate request" \
1925 -c "got no certificate request" \
1926 -c "skip write certificate" \
1927 -c "skip write certificate verify" \
1928 -s "skip parse certificate verify"
1929
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001930run_test "SNI: CA no override" \
1931 "$P_SRV debug_level=3 auth_mode=optional \
1932 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1933 ca_file=data_files/test-ca.crt \
1934 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1935 "$P_CLI debug_level=3 server_name=localhost \
1936 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1937 1 \
1938 -S "skip write certificate request" \
1939 -C "skip parse certificate request" \
1940 -c "got a certificate request" \
1941 -C "skip write certificate" \
1942 -C "skip write certificate verify" \
1943 -S "skip parse certificate verify" \
1944 -s "x509_verify_cert() returned" \
1945 -s "! The certificate is not correctly signed by the trusted CA" \
1946 -S "The certificate has been revoked (is on a CRL)"
1947
1948run_test "SNI: CA override" \
1949 "$P_SRV debug_level=3 auth_mode=optional \
1950 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1951 ca_file=data_files/test-ca.crt \
1952 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1953 "$P_CLI debug_level=3 server_name=localhost \
1954 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1955 0 \
1956 -S "skip write certificate request" \
1957 -C "skip parse certificate request" \
1958 -c "got a certificate request" \
1959 -C "skip write certificate" \
1960 -C "skip write certificate verify" \
1961 -S "skip parse certificate verify" \
1962 -S "x509_verify_cert() returned" \
1963 -S "! The certificate is not correctly signed by the trusted CA" \
1964 -S "The certificate has been revoked (is on a CRL)"
1965
1966run_test "SNI: CA override with CRL" \
1967 "$P_SRV debug_level=3 auth_mode=optional \
1968 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1969 ca_file=data_files/test-ca.crt \
1970 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1971 "$P_CLI debug_level=3 server_name=localhost \
1972 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1973 1 \
1974 -S "skip write certificate request" \
1975 -C "skip parse certificate request" \
1976 -c "got a certificate request" \
1977 -C "skip write certificate" \
1978 -C "skip write certificate verify" \
1979 -S "skip parse certificate verify" \
1980 -s "x509_verify_cert() returned" \
1981 -S "! The certificate is not correctly signed by the trusted CA" \
1982 -s "The certificate has been revoked (is on a CRL)"
1983
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001984# Tests for non-blocking I/O: exercise a variety of handshake flows
1985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001986run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001987 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1988 "$P_CLI nbio=2 tickets=0" \
1989 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001990 -S "mbedtls_ssl_handshake returned" \
1991 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001992 -c "Read from server: .* bytes read"
1993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001994run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001995 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1996 "$P_CLI nbio=2 tickets=0" \
1997 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001998 -S "mbedtls_ssl_handshake returned" \
1999 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002000 -c "Read from server: .* bytes read"
2001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002002run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002003 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2004 "$P_CLI nbio=2 tickets=1" \
2005 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002006 -S "mbedtls_ssl_handshake returned" \
2007 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002008 -c "Read from server: .* bytes read"
2009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002010run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002011 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2012 "$P_CLI nbio=2 tickets=1" \
2013 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002014 -S "mbedtls_ssl_handshake returned" \
2015 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002016 -c "Read from server: .* bytes read"
2017
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002018run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002019 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2020 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2021 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002022 -S "mbedtls_ssl_handshake returned" \
2023 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002024 -c "Read from server: .* bytes read"
2025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002026run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002027 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2028 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2029 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002030 -S "mbedtls_ssl_handshake returned" \
2031 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002032 -c "Read from server: .* bytes read"
2033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002034run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002035 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2036 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2037 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002038 -S "mbedtls_ssl_handshake returned" \
2039 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002040 -c "Read from server: .* bytes read"
2041
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002042# Tests for version negotiation
2043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002044run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002045 "$P_SRV" \
2046 "$P_CLI" \
2047 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002048 -S "mbedtls_ssl_handshake returned" \
2049 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002050 -s "Protocol is TLSv1.2" \
2051 -c "Protocol is TLSv1.2"
2052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002053run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002054 "$P_SRV" \
2055 "$P_CLI max_version=tls1_1" \
2056 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002057 -S "mbedtls_ssl_handshake returned" \
2058 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002059 -s "Protocol is TLSv1.1" \
2060 -c "Protocol is TLSv1.1"
2061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002062run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002063 "$P_SRV max_version=tls1_1" \
2064 "$P_CLI" \
2065 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002066 -S "mbedtls_ssl_handshake returned" \
2067 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002068 -s "Protocol is TLSv1.1" \
2069 -c "Protocol is TLSv1.1"
2070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002071run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002072 "$P_SRV max_version=tls1_1" \
2073 "$P_CLI max_version=tls1_1" \
2074 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002075 -S "mbedtls_ssl_handshake returned" \
2076 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002077 -s "Protocol is TLSv1.1" \
2078 -c "Protocol is TLSv1.1"
2079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002080run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002081 "$P_SRV min_version=tls1_1" \
2082 "$P_CLI max_version=tls1_1" \
2083 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002084 -S "mbedtls_ssl_handshake returned" \
2085 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002086 -s "Protocol is TLSv1.1" \
2087 -c "Protocol is TLSv1.1"
2088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002089run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002090 "$P_SRV max_version=tls1_1" \
2091 "$P_CLI min_version=tls1_1" \
2092 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002093 -S "mbedtls_ssl_handshake returned" \
2094 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002095 -s "Protocol is TLSv1.1" \
2096 -c "Protocol is TLSv1.1"
2097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002098run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002099 "$P_SRV max_version=tls1_1" \
2100 "$P_CLI min_version=tls1_2" \
2101 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002102 -s "mbedtls_ssl_handshake returned" \
2103 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002104 -c "SSL - Handshake protocol not within min/max boundaries"
2105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002106run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002107 "$P_SRV min_version=tls1_2" \
2108 "$P_CLI max_version=tls1_1" \
2109 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002110 -s "mbedtls_ssl_handshake returned" \
2111 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002112 -s "SSL - Handshake protocol not within min/max boundaries"
2113
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002114# Tests for ALPN extension
2115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002116run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002117 "$P_SRV debug_level=3" \
2118 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002119 0 \
2120 -C "client hello, adding alpn extension" \
2121 -S "found alpn extension" \
2122 -C "got an alert message, type: \\[2:120]" \
2123 -S "server hello, adding alpn extension" \
2124 -C "found alpn extension " \
2125 -C "Application Layer Protocol is" \
2126 -S "Application Layer Protocol is"
2127
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002128run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002129 "$P_SRV debug_level=3" \
2130 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002131 0 \
2132 -c "client hello, adding alpn extension" \
2133 -s "found alpn extension" \
2134 -C "got an alert message, type: \\[2:120]" \
2135 -S "server hello, adding alpn extension" \
2136 -C "found alpn extension " \
2137 -c "Application Layer Protocol is (none)" \
2138 -S "Application Layer Protocol is"
2139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002140run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002141 "$P_SRV debug_level=3 alpn=abc,1234" \
2142 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002143 0 \
2144 -C "client hello, adding alpn extension" \
2145 -S "found alpn extension" \
2146 -C "got an alert message, type: \\[2:120]" \
2147 -S "server hello, adding alpn extension" \
2148 -C "found alpn extension " \
2149 -C "Application Layer Protocol is" \
2150 -s "Application Layer Protocol is (none)"
2151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002152run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002153 "$P_SRV debug_level=3 alpn=abc,1234" \
2154 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002155 0 \
2156 -c "client hello, adding alpn extension" \
2157 -s "found alpn extension" \
2158 -C "got an alert message, type: \\[2:120]" \
2159 -s "server hello, adding alpn extension" \
2160 -c "found alpn extension" \
2161 -c "Application Layer Protocol is abc" \
2162 -s "Application Layer Protocol is abc"
2163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002164run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002165 "$P_SRV debug_level=3 alpn=abc,1234" \
2166 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002167 0 \
2168 -c "client hello, adding alpn extension" \
2169 -s "found alpn extension" \
2170 -C "got an alert message, type: \\[2:120]" \
2171 -s "server hello, adding alpn extension" \
2172 -c "found alpn extension" \
2173 -c "Application Layer Protocol is abc" \
2174 -s "Application Layer Protocol is abc"
2175
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002176run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002177 "$P_SRV debug_level=3 alpn=abc,1234" \
2178 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002179 0 \
2180 -c "client hello, adding alpn extension" \
2181 -s "found alpn extension" \
2182 -C "got an alert message, type: \\[2:120]" \
2183 -s "server hello, adding alpn extension" \
2184 -c "found alpn extension" \
2185 -c "Application Layer Protocol is 1234" \
2186 -s "Application Layer Protocol is 1234"
2187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002188run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002189 "$P_SRV debug_level=3 alpn=abc,123" \
2190 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002191 1 \
2192 -c "client hello, adding alpn extension" \
2193 -s "found alpn extension" \
2194 -c "got an alert message, type: \\[2:120]" \
2195 -S "server hello, adding alpn extension" \
2196 -C "found alpn extension" \
2197 -C "Application Layer Protocol is 1234" \
2198 -S "Application Layer Protocol is 1234"
2199
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002200
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002201# Tests for keyUsage in leaf certificates, part 1:
2202# server-side certificate/suite selection
2203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002204run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002205 "$P_SRV key_file=data_files/server2.key \
2206 crt_file=data_files/server2.ku-ds.crt" \
2207 "$P_CLI" \
2208 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002209 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002210
2211
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002212run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002213 "$P_SRV key_file=data_files/server2.key \
2214 crt_file=data_files/server2.ku-ke.crt" \
2215 "$P_CLI" \
2216 0 \
2217 -c "Ciphersuite is TLS-RSA-WITH-"
2218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002219run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002220 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002221 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002222 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002223 1 \
2224 -C "Ciphersuite is "
2225
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002226run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002227 "$P_SRV key_file=data_files/server5.key \
2228 crt_file=data_files/server5.ku-ds.crt" \
2229 "$P_CLI" \
2230 0 \
2231 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2232
2233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002234run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002235 "$P_SRV key_file=data_files/server5.key \
2236 crt_file=data_files/server5.ku-ka.crt" \
2237 "$P_CLI" \
2238 0 \
2239 -c "Ciphersuite is TLS-ECDH-"
2240
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002241run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002242 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002243 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002244 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002245 1 \
2246 -C "Ciphersuite is "
2247
2248# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002249# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002251run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002252 "$O_SRV -key data_files/server2.key \
2253 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002254 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002255 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2256 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002257 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002258 -C "Processing of the Certificate handshake message failed" \
2259 -c "Ciphersuite is TLS-"
2260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002261run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002262 "$O_SRV -key data_files/server2.key \
2263 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002264 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002265 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2266 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002267 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002268 -C "Processing of the Certificate handshake message failed" \
2269 -c "Ciphersuite is TLS-"
2270
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002271run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002272 "$O_SRV -key data_files/server2.key \
2273 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002274 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002275 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2276 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002277 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002278 -C "Processing of the Certificate handshake message failed" \
2279 -c "Ciphersuite is TLS-"
2280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002281run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002282 "$O_SRV -key data_files/server2.key \
2283 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002284 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002285 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2286 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002287 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002288 -c "Processing of the Certificate handshake message failed" \
2289 -C "Ciphersuite is TLS-"
2290
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002291run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2292 "$O_SRV -key data_files/server2.key \
2293 -cert data_files/server2.ku-ke.crt" \
2294 "$P_CLI debug_level=1 auth_mode=optional \
2295 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2296 0 \
2297 -c "bad certificate (usage extensions)" \
2298 -C "Processing of the Certificate handshake message failed" \
2299 -c "Ciphersuite is TLS-" \
2300 -c "! Usage does not match the keyUsage extension"
2301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002302run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002303 "$O_SRV -key data_files/server2.key \
2304 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002305 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002306 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2307 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002308 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002309 -C "Processing of the Certificate handshake message failed" \
2310 -c "Ciphersuite is TLS-"
2311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002312run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002313 "$O_SRV -key data_files/server2.key \
2314 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002315 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002316 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2317 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002318 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002319 -c "Processing of the Certificate handshake message failed" \
2320 -C "Ciphersuite is TLS-"
2321
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002322run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2323 "$O_SRV -key data_files/server2.key \
2324 -cert data_files/server2.ku-ds.crt" \
2325 "$P_CLI debug_level=1 auth_mode=optional \
2326 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2327 0 \
2328 -c "bad certificate (usage extensions)" \
2329 -C "Processing of the Certificate handshake message failed" \
2330 -c "Ciphersuite is TLS-" \
2331 -c "! Usage does not match the keyUsage extension"
2332
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002333# Tests for keyUsage in leaf certificates, part 3:
2334# server-side checking of client cert
2335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002336run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002337 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002338 "$O_CLI -key data_files/server2.key \
2339 -cert data_files/server2.ku-ds.crt" \
2340 0 \
2341 -S "bad certificate (usage extensions)" \
2342 -S "Processing of the Certificate handshake message failed"
2343
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002344run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002345 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002346 "$O_CLI -key data_files/server2.key \
2347 -cert data_files/server2.ku-ke.crt" \
2348 0 \
2349 -s "bad certificate (usage extensions)" \
2350 -S "Processing of the Certificate handshake message failed"
2351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002352run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002353 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002354 "$O_CLI -key data_files/server2.key \
2355 -cert data_files/server2.ku-ke.crt" \
2356 1 \
2357 -s "bad certificate (usage extensions)" \
2358 -s "Processing of the Certificate handshake message failed"
2359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002360run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002361 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002362 "$O_CLI -key data_files/server5.key \
2363 -cert data_files/server5.ku-ds.crt" \
2364 0 \
2365 -S "bad certificate (usage extensions)" \
2366 -S "Processing of the Certificate handshake message failed"
2367
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002368run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002369 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002370 "$O_CLI -key data_files/server5.key \
2371 -cert data_files/server5.ku-ka.crt" \
2372 0 \
2373 -s "bad certificate (usage extensions)" \
2374 -S "Processing of the Certificate handshake message failed"
2375
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002376# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002378run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002379 "$P_SRV key_file=data_files/server5.key \
2380 crt_file=data_files/server5.eku-srv.crt" \
2381 "$P_CLI" \
2382 0
2383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002384run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002385 "$P_SRV key_file=data_files/server5.key \
2386 crt_file=data_files/server5.eku-srv.crt" \
2387 "$P_CLI" \
2388 0
2389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002390run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002391 "$P_SRV key_file=data_files/server5.key \
2392 crt_file=data_files/server5.eku-cs_any.crt" \
2393 "$P_CLI" \
2394 0
2395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002396run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002397 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002398 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002399 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002400 1
2401
2402# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2403
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002404run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002405 "$O_SRV -key data_files/server5.key \
2406 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002407 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002408 0 \
2409 -C "bad certificate (usage extensions)" \
2410 -C "Processing of the Certificate handshake message failed" \
2411 -c "Ciphersuite is TLS-"
2412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002413run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002414 "$O_SRV -key data_files/server5.key \
2415 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002416 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002417 0 \
2418 -C "bad certificate (usage extensions)" \
2419 -C "Processing of the Certificate handshake message failed" \
2420 -c "Ciphersuite is TLS-"
2421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002422run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002423 "$O_SRV -key data_files/server5.key \
2424 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002425 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002426 0 \
2427 -C "bad certificate (usage extensions)" \
2428 -C "Processing of the Certificate handshake message failed" \
2429 -c "Ciphersuite is TLS-"
2430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002431run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002432 "$O_SRV -key data_files/server5.key \
2433 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002434 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002435 1 \
2436 -c "bad certificate (usage extensions)" \
2437 -c "Processing of the Certificate handshake message failed" \
2438 -C "Ciphersuite is TLS-"
2439
2440# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002442run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002443 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002444 "$O_CLI -key data_files/server5.key \
2445 -cert data_files/server5.eku-cli.crt" \
2446 0 \
2447 -S "bad certificate (usage extensions)" \
2448 -S "Processing of the Certificate handshake message failed"
2449
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002450run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002451 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002452 "$O_CLI -key data_files/server5.key \
2453 -cert data_files/server5.eku-srv_cli.crt" \
2454 0 \
2455 -S "bad certificate (usage extensions)" \
2456 -S "Processing of the Certificate handshake message failed"
2457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002458run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002459 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002460 "$O_CLI -key data_files/server5.key \
2461 -cert data_files/server5.eku-cs_any.crt" \
2462 0 \
2463 -S "bad certificate (usage extensions)" \
2464 -S "Processing of the Certificate handshake message failed"
2465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002466run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002467 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002468 "$O_CLI -key data_files/server5.key \
2469 -cert data_files/server5.eku-cs.crt" \
2470 0 \
2471 -s "bad certificate (usage extensions)" \
2472 -S "Processing of the Certificate handshake message failed"
2473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002474run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002475 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002476 "$O_CLI -key data_files/server5.key \
2477 -cert data_files/server5.eku-cs.crt" \
2478 1 \
2479 -s "bad certificate (usage extensions)" \
2480 -s "Processing of the Certificate handshake message failed"
2481
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002482# Tests for DHM parameters loading
2483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002484run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002485 "$P_SRV" \
2486 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2487 debug_level=3" \
2488 0 \
2489 -c "value of 'DHM: P ' (2048 bits)" \
2490 -c "value of 'DHM: G ' (2048 bits)"
2491
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002492run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002493 "$P_SRV dhm_file=data_files/dhparams.pem" \
2494 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2495 debug_level=3" \
2496 0 \
2497 -c "value of 'DHM: P ' (1024 bits)" \
2498 -c "value of 'DHM: G ' (2 bits)"
2499
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002500# Tests for DHM client-side size checking
2501
2502run_test "DHM size: server default, client default, OK" \
2503 "$P_SRV" \
2504 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2505 debug_level=1" \
2506 0 \
2507 -C "DHM prime too short:"
2508
2509run_test "DHM size: server default, client 2048, OK" \
2510 "$P_SRV" \
2511 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2512 debug_level=1 dhmlen=2048" \
2513 0 \
2514 -C "DHM prime too short:"
2515
2516run_test "DHM size: server 1024, client default, OK" \
2517 "$P_SRV dhm_file=data_files/dhparams.pem" \
2518 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2519 debug_level=1" \
2520 0 \
2521 -C "DHM prime too short:"
2522
2523run_test "DHM size: server 1000, client default, rejected" \
2524 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2525 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2526 debug_level=1" \
2527 1 \
2528 -c "DHM prime too short:"
2529
2530run_test "DHM size: server default, client 2049, rejected" \
2531 "$P_SRV" \
2532 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2533 debug_level=1 dhmlen=2049" \
2534 1 \
2535 -c "DHM prime too short:"
2536
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002537# Tests for PSK callback
2538
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002539run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002540 "$P_SRV psk=abc123 psk_identity=foo" \
2541 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2542 psk_identity=foo psk=abc123" \
2543 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002544 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002545 -S "SSL - Unknown identity received" \
2546 -S "SSL - Verification of the message MAC failed"
2547
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002548run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002549 "$P_SRV" \
2550 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2551 psk_identity=foo psk=abc123" \
2552 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002553 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002554 -S "SSL - Unknown identity received" \
2555 -S "SSL - Verification of the message MAC failed"
2556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002557run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002558 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2559 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2560 psk_identity=foo psk=abc123" \
2561 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002562 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002563 -s "SSL - Unknown identity received" \
2564 -S "SSL - Verification of the message MAC failed"
2565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002566run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002567 "$P_SRV psk_list=abc,dead,def,beef" \
2568 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2569 psk_identity=abc psk=dead" \
2570 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002571 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002572 -S "SSL - Unknown identity received" \
2573 -S "SSL - Verification of the message MAC failed"
2574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002576 "$P_SRV psk_list=abc,dead,def,beef" \
2577 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2578 psk_identity=def psk=beef" \
2579 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002580 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002581 -S "SSL - Unknown identity received" \
2582 -S "SSL - Verification of the message MAC failed"
2583
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002584run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002585 "$P_SRV psk_list=abc,dead,def,beef" \
2586 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2587 psk_identity=ghi psk=beef" \
2588 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002589 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002590 -s "SSL - Unknown identity received" \
2591 -S "SSL - Verification of the message MAC failed"
2592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002593run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002594 "$P_SRV psk_list=abc,dead,def,beef" \
2595 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2596 psk_identity=abc psk=beef" \
2597 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002598 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002599 -S "SSL - Unknown identity received" \
2600 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002601
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002602# Tests for EC J-PAKE
2603
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002604requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002605run_test "ECJPAKE: client not configured" \
2606 "$P_SRV debug_level=3" \
2607 "$P_CLI debug_level=3" \
2608 0 \
2609 -C "add ciphersuite: c0ff" \
2610 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002611 -S "found ecjpake kkpp extension" \
2612 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002613 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002614 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002615 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002616 -S "None of the common ciphersuites is usable"
2617
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002618requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002619run_test "ECJPAKE: server not configured" \
2620 "$P_SRV debug_level=3" \
2621 "$P_CLI debug_level=3 ecjpake_pw=bla \
2622 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2623 1 \
2624 -c "add ciphersuite: c0ff" \
2625 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002626 -s "found ecjpake kkpp extension" \
2627 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002628 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002629 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002630 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002631 -s "None of the common ciphersuites is usable"
2632
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002633requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002634run_test "ECJPAKE: working, TLS" \
2635 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2636 "$P_CLI debug_level=3 ecjpake_pw=bla \
2637 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002638 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002639 -c "add ciphersuite: c0ff" \
2640 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002641 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002642 -s "found ecjpake kkpp extension" \
2643 -S "skip ecjpake kkpp extension" \
2644 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002645 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002646 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002647 -S "None of the common ciphersuites is usable" \
2648 -S "SSL - Verification of the message MAC failed"
2649
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002650requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002651run_test "ECJPAKE: password mismatch, TLS" \
2652 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2653 "$P_CLI debug_level=3 ecjpake_pw=bad \
2654 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2655 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002656 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002657 -s "SSL - Verification of the message MAC failed"
2658
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002659requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002660run_test "ECJPAKE: working, DTLS" \
2661 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2662 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2663 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2664 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002665 -c "re-using cached ecjpake parameters" \
2666 -S "SSL - Verification of the message MAC failed"
2667
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002668requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002669run_test "ECJPAKE: working, DTLS, no cookie" \
2670 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2671 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2672 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2673 0 \
2674 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002675 -S "SSL - Verification of the message MAC failed"
2676
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002677requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002678run_test "ECJPAKE: password mismatch, DTLS" \
2679 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2680 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2681 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2682 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002683 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002684 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002685
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002686# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002687requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002688run_test "ECJPAKE: working, DTLS, nolog" \
2689 "$P_SRV dtls=1 ecjpake_pw=bla" \
2690 "$P_CLI dtls=1 ecjpake_pw=bla \
2691 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2692 0
2693
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002694# Tests for ciphersuites per version
2695
Janos Follathe2681a42016-03-07 15:57:05 +00002696requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002697run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002698 "$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 +02002699 "$P_CLI force_version=ssl3" \
2700 0 \
2701 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002703run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002704 "$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 +01002705 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002706 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002707 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002709run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002710 "$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 +02002711 "$P_CLI force_version=tls1_1" \
2712 0 \
2713 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002715run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002716 "$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 +02002717 "$P_CLI force_version=tls1_2" \
2718 0 \
2719 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2720
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002721# Test for ClientHello without extensions
2722
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002723requires_gnutls
2724run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002725 "$P_SRV debug_level=3" \
2726 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2727 0 \
2728 -s "dumping 'client hello extensions' (0 bytes)"
2729
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002730# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002731
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002732run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002733 "$P_SRV" \
2734 "$P_CLI request_size=100" \
2735 0 \
2736 -s "Read from client: 100 bytes read$"
2737
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002738run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002739 "$P_SRV" \
2740 "$P_CLI request_size=500" \
2741 0 \
2742 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002743
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002744# Tests for small packets
2745
Janos Follathe2681a42016-03-07 15:57:05 +00002746requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002747run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002748 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002749 "$P_CLI request_size=1 force_version=ssl3 \
2750 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2751 0 \
2752 -s "Read from client: 1 bytes read"
2753
Janos Follathe2681a42016-03-07 15:57:05 +00002754requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002755run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002756 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002757 "$P_CLI request_size=1 force_version=ssl3 \
2758 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2759 0 \
2760 -s "Read from client: 1 bytes read"
2761
2762run_test "Small packet TLS 1.0 BlockCipher" \
2763 "$P_SRV" \
2764 "$P_CLI request_size=1 force_version=tls1 \
2765 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2766 0 \
2767 -s "Read from client: 1 bytes read"
2768
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002769run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2770 "$P_SRV" \
2771 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2772 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2773 0 \
2774 -s "Read from client: 1 bytes read"
2775
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002776run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2777 "$P_SRV" \
2778 "$P_CLI request_size=1 force_version=tls1 \
2779 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2780 trunc_hmac=1" \
2781 0 \
2782 -s "Read from client: 1 bytes read"
2783
2784run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002785 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002786 "$P_CLI request_size=1 force_version=tls1 \
2787 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2788 trunc_hmac=1" \
2789 0 \
2790 -s "Read from client: 1 bytes read"
2791
2792run_test "Small packet TLS 1.1 BlockCipher" \
2793 "$P_SRV" \
2794 "$P_CLI request_size=1 force_version=tls1_1 \
2795 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2796 0 \
2797 -s "Read from client: 1 bytes read"
2798
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002799run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2800 "$P_SRV" \
2801 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2802 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2803 0 \
2804 -s "Read from client: 1 bytes read"
2805
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002806run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002807 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002808 "$P_CLI request_size=1 force_version=tls1_1 \
2809 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2810 0 \
2811 -s "Read from client: 1 bytes read"
2812
2813run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2814 "$P_SRV" \
2815 "$P_CLI request_size=1 force_version=tls1_1 \
2816 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2817 trunc_hmac=1" \
2818 0 \
2819 -s "Read from client: 1 bytes read"
2820
2821run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002822 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002823 "$P_CLI request_size=1 force_version=tls1_1 \
2824 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2825 trunc_hmac=1" \
2826 0 \
2827 -s "Read from client: 1 bytes read"
2828
2829run_test "Small packet TLS 1.2 BlockCipher" \
2830 "$P_SRV" \
2831 "$P_CLI request_size=1 force_version=tls1_2 \
2832 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2833 0 \
2834 -s "Read from client: 1 bytes read"
2835
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002836run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2837 "$P_SRV" \
2838 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2839 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2840 0 \
2841 -s "Read from client: 1 bytes read"
2842
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002843run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2844 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002845 "$P_CLI request_size=1 force_version=tls1_2 \
2846 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002847 0 \
2848 -s "Read from client: 1 bytes read"
2849
2850run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2851 "$P_SRV" \
2852 "$P_CLI request_size=1 force_version=tls1_2 \
2853 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2854 trunc_hmac=1" \
2855 0 \
2856 -s "Read from client: 1 bytes read"
2857
2858run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002859 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002860 "$P_CLI request_size=1 force_version=tls1_2 \
2861 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2862 0 \
2863 -s "Read from client: 1 bytes read"
2864
2865run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002866 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002867 "$P_CLI request_size=1 force_version=tls1_2 \
2868 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2869 trunc_hmac=1" \
2870 0 \
2871 -s "Read from client: 1 bytes read"
2872
2873run_test "Small packet TLS 1.2 AEAD" \
2874 "$P_SRV" \
2875 "$P_CLI request_size=1 force_version=tls1_2 \
2876 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2877 0 \
2878 -s "Read from client: 1 bytes read"
2879
2880run_test "Small packet TLS 1.2 AEAD shorter tag" \
2881 "$P_SRV" \
2882 "$P_CLI request_size=1 force_version=tls1_2 \
2883 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2884 0 \
2885 -s "Read from client: 1 bytes read"
2886
Janos Follath00efff72016-05-06 13:48:23 +01002887# A test for extensions in SSLv3
2888
2889requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2890run_test "SSLv3 with extensions, server side" \
2891 "$P_SRV min_version=ssl3 debug_level=3" \
2892 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2893 0 \
2894 -S "dumping 'client hello extensions'" \
2895 -S "server hello, total extension length:"
2896
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002897# Test for large packets
2898
Janos Follathe2681a42016-03-07 15:57:05 +00002899requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002900run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002901 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002902 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002903 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2904 0 \
2905 -s "Read from client: 16384 bytes read"
2906
Janos Follathe2681a42016-03-07 15:57:05 +00002907requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002908run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002909 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002910 "$P_CLI request_size=16384 force_version=ssl3 \
2911 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2912 0 \
2913 -s "Read from client: 16384 bytes read"
2914
2915run_test "Large packet TLS 1.0 BlockCipher" \
2916 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002917 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002918 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2919 0 \
2920 -s "Read from client: 16384 bytes read"
2921
2922run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2923 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002924 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002925 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2926 trunc_hmac=1" \
2927 0 \
2928 -s "Read from client: 16384 bytes read"
2929
2930run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002931 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002932 "$P_CLI request_size=16384 force_version=tls1 \
2933 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2934 trunc_hmac=1" \
2935 0 \
2936 -s "Read from client: 16384 bytes read"
2937
2938run_test "Large packet TLS 1.1 BlockCipher" \
2939 "$P_SRV" \
2940 "$P_CLI request_size=16384 force_version=tls1_1 \
2941 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2942 0 \
2943 -s "Read from client: 16384 bytes read"
2944
2945run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002946 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002947 "$P_CLI request_size=16384 force_version=tls1_1 \
2948 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2949 0 \
2950 -s "Read from client: 16384 bytes read"
2951
2952run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2953 "$P_SRV" \
2954 "$P_CLI request_size=16384 force_version=tls1_1 \
2955 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2956 trunc_hmac=1" \
2957 0 \
2958 -s "Read from client: 16384 bytes read"
2959
2960run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002961 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002962 "$P_CLI request_size=16384 force_version=tls1_1 \
2963 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2964 trunc_hmac=1" \
2965 0 \
2966 -s "Read from client: 16384 bytes read"
2967
2968run_test "Large packet TLS 1.2 BlockCipher" \
2969 "$P_SRV" \
2970 "$P_CLI request_size=16384 force_version=tls1_2 \
2971 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2972 0 \
2973 -s "Read from client: 16384 bytes read"
2974
2975run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2976 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002977 "$P_CLI request_size=16384 force_version=tls1_2 \
2978 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002979 0 \
2980 -s "Read from client: 16384 bytes read"
2981
2982run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2983 "$P_SRV" \
2984 "$P_CLI request_size=16384 force_version=tls1_2 \
2985 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2986 trunc_hmac=1" \
2987 0 \
2988 -s "Read from client: 16384 bytes read"
2989
2990run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002991 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002992 "$P_CLI request_size=16384 force_version=tls1_2 \
2993 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2994 0 \
2995 -s "Read from client: 16384 bytes read"
2996
2997run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002998 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002999 "$P_CLI request_size=16384 force_version=tls1_2 \
3000 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3001 trunc_hmac=1" \
3002 0 \
3003 -s "Read from client: 16384 bytes read"
3004
3005run_test "Large packet TLS 1.2 AEAD" \
3006 "$P_SRV" \
3007 "$P_CLI request_size=16384 force_version=tls1_2 \
3008 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3009 0 \
3010 -s "Read from client: 16384 bytes read"
3011
3012run_test "Large packet TLS 1.2 AEAD shorter tag" \
3013 "$P_SRV" \
3014 "$P_CLI request_size=16384 force_version=tls1_2 \
3015 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3016 0 \
3017 -s "Read from client: 16384 bytes read"
3018
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003019# Tests for DTLS HelloVerifyRequest
3020
3021run_test "DTLS cookie: enabled" \
3022 "$P_SRV dtls=1 debug_level=2" \
3023 "$P_CLI dtls=1 debug_level=2" \
3024 0 \
3025 -s "cookie verification failed" \
3026 -s "cookie verification passed" \
3027 -S "cookie verification skipped" \
3028 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003029 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003030 -S "SSL - The requested feature is not available"
3031
3032run_test "DTLS cookie: disabled" \
3033 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3034 "$P_CLI dtls=1 debug_level=2" \
3035 0 \
3036 -S "cookie verification failed" \
3037 -S "cookie verification passed" \
3038 -s "cookie verification skipped" \
3039 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003040 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003041 -S "SSL - The requested feature is not available"
3042
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003043run_test "DTLS cookie: default (failing)" \
3044 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3045 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3046 1 \
3047 -s "cookie verification failed" \
3048 -S "cookie verification passed" \
3049 -S "cookie verification skipped" \
3050 -C "received hello verify request" \
3051 -S "hello verification requested" \
3052 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003053
3054requires_ipv6
3055run_test "DTLS cookie: enabled, IPv6" \
3056 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3057 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3058 0 \
3059 -s "cookie verification failed" \
3060 -s "cookie verification passed" \
3061 -S "cookie verification skipped" \
3062 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003063 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003064 -S "SSL - The requested feature is not available"
3065
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003066run_test "DTLS cookie: enabled, nbio" \
3067 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3068 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3069 0 \
3070 -s "cookie verification failed" \
3071 -s "cookie verification passed" \
3072 -S "cookie verification skipped" \
3073 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003074 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003075 -S "SSL - The requested feature is not available"
3076
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003077# Tests for client reconnecting from the same port with DTLS
3078
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003079not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003080run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003081 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3082 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003083 0 \
3084 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003085 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003086 -S "Client initiated reconnection from same port"
3087
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003088not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003089run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003090 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3091 "$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 +02003092 0 \
3093 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003094 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003095 -s "Client initiated reconnection from same port"
3096
3097run_test "DTLS client reconnect from same port: reconnect, nbio" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003098 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3099 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003100 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003101 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003102 -s "Client initiated reconnection from same port"
3103
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003104run_test "DTLS client reconnect from same port: no cookies" \
3105 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003106 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3107 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003108 -s "The operation timed out" \
3109 -S "Client initiated reconnection from same port"
3110
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003111# Tests for various cases of client authentication with DTLS
3112# (focused on handshake flows and message parsing)
3113
3114run_test "DTLS client auth: required" \
3115 "$P_SRV dtls=1 auth_mode=required" \
3116 "$P_CLI dtls=1" \
3117 0 \
3118 -s "Verifying peer X.509 certificate... ok"
3119
3120run_test "DTLS client auth: optional, client has no cert" \
3121 "$P_SRV dtls=1 auth_mode=optional" \
3122 "$P_CLI dtls=1 crt_file=none key_file=none" \
3123 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003124 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003125
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003126run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003127 "$P_SRV dtls=1 auth_mode=none" \
3128 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3129 0 \
3130 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003131 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003132
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003133run_test "DTLS wrong PSK: badmac alert" \
3134 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3135 "$P_CLI dtls=1 psk=abc124" \
3136 1 \
3137 -s "SSL - Verification of the message MAC failed" \
3138 -c "SSL - A fatal alert message was received from our peer"
3139
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003140# Tests for receiving fragmented handshake messages with DTLS
3141
3142requires_gnutls
3143run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3144 "$G_SRV -u --mtu 2048 -a" \
3145 "$P_CLI dtls=1 debug_level=2" \
3146 0 \
3147 -C "found fragmented DTLS handshake message" \
3148 -C "error"
3149
3150requires_gnutls
3151run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3152 "$G_SRV -u --mtu 512" \
3153 "$P_CLI dtls=1 debug_level=2" \
3154 0 \
3155 -c "found fragmented DTLS handshake message" \
3156 -C "error"
3157
3158requires_gnutls
3159run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3160 "$G_SRV -u --mtu 128" \
3161 "$P_CLI dtls=1 debug_level=2" \
3162 0 \
3163 -c "found fragmented DTLS handshake message" \
3164 -C "error"
3165
3166requires_gnutls
3167run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3168 "$G_SRV -u --mtu 128" \
3169 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3170 0 \
3171 -c "found fragmented DTLS handshake message" \
3172 -C "error"
3173
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003174requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003175run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3176 "$G_SRV -u --mtu 256" \
3177 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3178 0 \
3179 -c "found fragmented DTLS handshake message" \
3180 -c "client hello, adding renegotiation extension" \
3181 -c "found renegotiation extension" \
3182 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003183 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003184 -C "error" \
3185 -s "Extra-header:"
3186
3187requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003188run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3189 "$G_SRV -u --mtu 256" \
3190 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3191 0 \
3192 -c "found fragmented DTLS handshake message" \
3193 -c "client hello, adding renegotiation extension" \
3194 -c "found renegotiation extension" \
3195 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003196 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003197 -C "error" \
3198 -s "Extra-header:"
3199
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003200run_test "DTLS reassembly: no fragmentation (openssl server)" \
3201 "$O_SRV -dtls1 -mtu 2048" \
3202 "$P_CLI dtls=1 debug_level=2" \
3203 0 \
3204 -C "found fragmented DTLS handshake message" \
3205 -C "error"
3206
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003207run_test "DTLS reassembly: some fragmentation (openssl server)" \
3208 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003209 "$P_CLI dtls=1 debug_level=2" \
3210 0 \
3211 -c "found fragmented DTLS handshake message" \
3212 -C "error"
3213
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003214run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003215 "$O_SRV -dtls1 -mtu 256" \
3216 "$P_CLI dtls=1 debug_level=2" \
3217 0 \
3218 -c "found fragmented DTLS handshake message" \
3219 -C "error"
3220
3221run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3222 "$O_SRV -dtls1 -mtu 256" \
3223 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3224 0 \
3225 -c "found fragmented DTLS handshake message" \
3226 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003227
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003228# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003229
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003230not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003231run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003232 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003233 "$P_SRV dtls=1 debug_level=2" \
3234 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003235 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003236 -C "replayed record" \
3237 -S "replayed record" \
3238 -C "record from another epoch" \
3239 -S "record from another epoch" \
3240 -C "discarding invalid record" \
3241 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003242 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003243 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003244 -c "HTTP/1.0 200 OK"
3245
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003246not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003247run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003248 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003249 "$P_SRV dtls=1 debug_level=2" \
3250 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003251 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003252 -c "replayed record" \
3253 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003254 -c "discarding invalid record" \
3255 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003256 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003257 -s "Extra-header:" \
3258 -c "HTTP/1.0 200 OK"
3259
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003260run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3261 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003262 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3263 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003264 0 \
3265 -c "replayed record" \
3266 -S "replayed record" \
3267 -c "discarding invalid record" \
3268 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003269 -c "resend" \
3270 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003271 -s "Extra-header:" \
3272 -c "HTTP/1.0 200 OK"
3273
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003274run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003275 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003276 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003277 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003278 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003279 -c "discarding invalid record (mac)" \
3280 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003281 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003282 -c "HTTP/1.0 200 OK" \
3283 -S "too many records with bad MAC" \
3284 -S "Verification of the message MAC failed"
3285
3286run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3287 -p "$P_PXY bad_ad=1" \
3288 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3289 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3290 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003291 -C "discarding invalid record (mac)" \
3292 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003293 -S "Extra-header:" \
3294 -C "HTTP/1.0 200 OK" \
3295 -s "too many records with bad MAC" \
3296 -s "Verification of the message MAC failed"
3297
3298run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3299 -p "$P_PXY bad_ad=1" \
3300 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3301 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3302 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003303 -c "discarding invalid record (mac)" \
3304 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003305 -s "Extra-header:" \
3306 -c "HTTP/1.0 200 OK" \
3307 -S "too many records with bad MAC" \
3308 -S "Verification of the message MAC failed"
3309
3310run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3311 -p "$P_PXY bad_ad=1" \
3312 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3313 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3314 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003315 -c "discarding invalid record (mac)" \
3316 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003317 -s "Extra-header:" \
3318 -c "HTTP/1.0 200 OK" \
3319 -s "too many records with bad MAC" \
3320 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003321
3322run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003323 -p "$P_PXY delay_ccs=1" \
3324 "$P_SRV dtls=1 debug_level=1" \
3325 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003326 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003327 -c "record from another epoch" \
3328 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003329 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003330 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003331 -s "Extra-header:" \
3332 -c "HTTP/1.0 200 OK"
3333
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003334# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003335
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003336needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003337run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003338 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003339 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3340 psk=abc123" \
3341 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003342 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3343 0 \
3344 -s "Extra-header:" \
3345 -c "HTTP/1.0 200 OK"
3346
3347needs_more_time 2
3348run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3349 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003350 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3351 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003352 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3353 0 \
3354 -s "Extra-header:" \
3355 -c "HTTP/1.0 200 OK"
3356
3357needs_more_time 2
3358run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3359 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003360 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3361 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003362 0 \
3363 -s "Extra-header:" \
3364 -c "HTTP/1.0 200 OK"
3365
3366needs_more_time 2
3367run_test "DTLS proxy: 3d, FS, client auth" \
3368 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003369 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3370 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003371 0 \
3372 -s "Extra-header:" \
3373 -c "HTTP/1.0 200 OK"
3374
3375needs_more_time 2
3376run_test "DTLS proxy: 3d, FS, ticket" \
3377 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003378 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3379 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003380 0 \
3381 -s "Extra-header:" \
3382 -c "HTTP/1.0 200 OK"
3383
3384needs_more_time 2
3385run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3386 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003387 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3388 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003389 0 \
3390 -s "Extra-header:" \
3391 -c "HTTP/1.0 200 OK"
3392
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003393needs_more_time 2
3394run_test "DTLS proxy: 3d, max handshake, nbio" \
3395 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003396 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3397 auth_mode=required" \
3398 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003399 0 \
3400 -s "Extra-header:" \
3401 -c "HTTP/1.0 200 OK"
3402
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003403needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003404run_test "DTLS proxy: 3d, min handshake, resumption" \
3405 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3406 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3407 psk=abc123 debug_level=3" \
3408 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3409 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3410 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3411 0 \
3412 -s "a session has been resumed" \
3413 -c "a session has been resumed" \
3414 -s "Extra-header:" \
3415 -c "HTTP/1.0 200 OK"
3416
3417needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003418run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3419 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3420 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3421 psk=abc123 debug_level=3 nbio=2" \
3422 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3423 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3424 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3425 0 \
3426 -s "a session has been resumed" \
3427 -c "a session has been resumed" \
3428 -s "Extra-header:" \
3429 -c "HTTP/1.0 200 OK"
3430
3431needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003432run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003433 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003434 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3435 psk=abc123 renegotiation=1 debug_level=2" \
3436 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3437 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003438 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3439 0 \
3440 -c "=> renegotiate" \
3441 -s "=> renegotiate" \
3442 -s "Extra-header:" \
3443 -c "HTTP/1.0 200 OK"
3444
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003445needs_more_time 4
3446run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3447 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003448 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3449 psk=abc123 renegotiation=1 debug_level=2" \
3450 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3451 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003452 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3453 0 \
3454 -c "=> renegotiate" \
3455 -s "=> renegotiate" \
3456 -s "Extra-header:" \
3457 -c "HTTP/1.0 200 OK"
3458
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003459needs_more_time 4
3460run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003461 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003462 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003463 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003464 debug_level=2" \
3465 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003466 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003467 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3468 0 \
3469 -c "=> renegotiate" \
3470 -s "=> renegotiate" \
3471 -s "Extra-header:" \
3472 -c "HTTP/1.0 200 OK"
3473
3474needs_more_time 4
3475run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003476 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003477 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003478 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003479 debug_level=2 nbio=2" \
3480 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003481 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003482 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3483 0 \
3484 -c "=> renegotiate" \
3485 -s "=> renegotiate" \
3486 -s "Extra-header:" \
3487 -c "HTTP/1.0 200 OK"
3488
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003489needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003490not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003491run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003492 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3493 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003494 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003495 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003496 -c "HTTP/1.0 200 OK"
3497
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003498needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003499not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003500run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3501 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3502 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003503 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003504 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003505 -c "HTTP/1.0 200 OK"
3506
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003507needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003508not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003509run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3510 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3511 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003512 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003513 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003514 -c "HTTP/1.0 200 OK"
3515
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003516requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003517needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003518not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003519run_test "DTLS proxy: 3d, gnutls server" \
3520 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3521 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003522 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003523 0 \
3524 -s "Extra-header:" \
3525 -c "Extra-header:"
3526
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003527requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003528needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003529not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003530run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3531 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3532 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003533 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003534 0 \
3535 -s "Extra-header:" \
3536 -c "Extra-header:"
3537
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003538requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003539needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003540not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003541run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3542 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3543 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003544 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003545 0 \
3546 -s "Extra-header:" \
3547 -c "Extra-header:"
3548
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003549# Final report
3550
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003551echo "------------------------------------------------------------------------"
3552
3553if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003554 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003555else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003556 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003557fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003558PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003559echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003560
3561exit $FAILS